From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- libs/vkd3d-shader/spirv.c | 28 +++++++++++++++++++----- libs/vkd3d-shader/vkd3d_shader_private.h | 2 +- 2 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index c8e0c379897a..53aa74a6434d 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -3761,6 +3761,9 @@ static void vkd3d_dxbc_compiler_emit_shader_phase_input(struct vkd3d_dxbc_compil case VKD3DSPR_JOININSTID: val_id = phase->instance_id; break; + case VKD3DSPR_OUTCONTROLPOINT: + /* See vkd3d_dxbc_compiler_leave_shader_phase(). */ + return; default: FIXME("Unhandled shader phase input register %#x.\n", reg->type); return; @@ -5227,8 +5230,8 @@ static void vkd3d_dxbc_compiler_leave_shader_phase(struct vkd3d_dxbc_compiler *c { const struct vkd3d_shader_signature *signature = compiler->output_signature; struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; + struct vkd3d_symbol reg_symbol, *symbol; struct vkd3d_shader_register reg; - struct vkd3d_symbol reg_symbol; struct rb_entry *entry; unsigned int i;
@@ -5244,26 +5247,39 @@ static void vkd3d_dxbc_compiler_leave_shader_phase(struct vkd3d_dxbc_compiler *c compiler->temp_count = 0;
/* - * Output regsiters have a different purpose in the control point phase and - * in fork/join phases. We have to remove all output registers' symbols - * when leaving the control point phase. + * vocp inputs in fork and join shader phases are outputs of the control + * point phase. Reinsert symbols for vocp registers while leaving the + * control point phase. */ if (is_control_point_phase(phase)) { memset(®, 0, sizeof(reg)); - reg.type = VKD3DSPR_OUTPUT; reg.idx[1].offset = ~0u;
for (i = 0; i < signature->element_count; ++i) { const struct vkd3d_shader_signature_element *e = &signature->elements[i];
+ reg.type = VKD3DSPR_OUTPUT; reg.idx[0].offset = e->register_index; vkd3d_symbol_make_register(®_symbol, ®); if ((entry = rb_get(&compiler->symbol_table, ®_symbol))) { rb_remove(&compiler->symbol_table, entry); - vkd3d_symbol_free(entry, NULL); + + symbol = RB_ENTRY_VALUE(entry, struct vkd3d_symbol, entry); + + reg.type = VKD3DSPR_OUTCONTROLPOINT; + reg.idx[1].offset = reg.idx[0].offset; + reg.idx[0].offset = compiler->output_control_point_count; + vkd3d_symbol_make_register(symbol, ®); + symbol->info.reg.is_aggregate = false; + + if (rb_put(&compiler->symbol_table, symbol, entry) == -1) + { + ERR("Failed to insert vocp symbol entry (%s).\n", debug_vkd3d_symbol(symbol)); + vkd3d_symbol_free(entry, NULL); + } } } } diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index 7ffcdd9c5e77..a6860969c068 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -765,7 +765,7 @@ static inline bool vkd3d_shader_instruction_has_texel_offset(const struct vkd3d_
static inline bool vkd3d_shader_register_is_input(const struct vkd3d_shader_register *reg) { - return reg->type == VKD3DSPR_INPUT || reg->type == VKD3DSPR_INCONTROLPOINT; + return reg->type == VKD3DSPR_INPUT || reg->type == VKD3DSPR_INCONTROLPOINT || reg->type == VKD3DSPR_OUTCONTROLPOINT; }
static inline bool vkd3d_shader_register_is_output(const struct vkd3d_shader_register *reg)