Fixes invalid SPIR-V in case there is an unconditional break right before the loop ends.
From: Philip Rebohle philip.rebohle@tu-dortmund.de Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- libs/vkd3d-shader/spirv.c | 4 +++- tests/d3d12.c | 6 ------ 2 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 9499159c..7d479184 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -7615,6 +7615,7 @@ static int vkd3d_dxbc_compiler_emit_control_flow_instruction(struct vkd3d_dxbc_c cf_info->u.loop.continue_block_id = continue_block_id; cf_info->u.loop.merge_block_id = merge_block_id; cf_info->current_block = VKD3D_BLOCK_LOOP; + cf_info->inside_block = true;
vkd3d_spirv_build_op_name(builder, loop_header_block_id, "loop%u_header", compiler->loop_id); vkd3d_spirv_build_op_name(builder, loop_body_block_id, "loop%u_body", compiler->loop_id); @@ -7627,7 +7628,8 @@ static int vkd3d_dxbc_compiler_emit_control_flow_instruction(struct vkd3d_dxbc_c assert(compiler->control_flow_depth); assert(cf_info->current_block == VKD3D_BLOCK_LOOP);
- vkd3d_spirv_build_op_branch(builder, cf_info->u.loop.continue_block_id); + if (cf_info->inside_block) + vkd3d_spirv_build_op_branch(builder, cf_info->u.loop.continue_block_id);
vkd3d_spirv_build_op_label(builder, cf_info->u.loop.continue_block_id); vkd3d_spirv_build_op_branch(builder, cf_info->u.loop.header_block_id); diff --git a/tests/d3d12.c b/tests/d3d12.c index 20eeac9d..8dbced41 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -10391,12 +10391,6 @@ static void test_shader_instructions(void) continue; }
- if (tests[i].ps == &ps_loop_end_break && !vkd3d_test_platform_is_windows()) - { - skip("Skipping shader '%s' test (would generate invalid SPIR-V).\n", tests[i].ps->name); - continue; - } - if (current_ps != tests[i].ps) { if (context.pipeline_state)