vkd3d-shader/ir: Lower monolithic switches to selection ladders.

PHI nodes must be fixed up after this pass, because the block references
might have become broken. For simplicitly this is not handled yet.

The goal for this pass is to make the CFG structurizer simpler, because
only conditional and unconditional branches must be supported.
Eventually this limitation might be lifted if there is advantage in
doing so.
This commit is contained in:
Giovanni Mascellani
2024-01-03 16:18:50 +01:00
committed by Alexandre Julliard
parent b97edee03d
commit 378109051c
Notes: Alexandre Julliard 2024-01-29 22:50:16 +01:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Conor McCarthy (@cmccarthy)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/598
3 changed files with 153 additions and 3 deletions

View File

@@ -7830,8 +7830,9 @@ static void spirv_compiler_emit_branch(struct spirv_compiler *compiler,
}
condition_id = spirv_compiler_emit_load_src(compiler, &src[0], VKD3DSP_WRITEMASK_0);
condition_id = spirv_compiler_emit_int_to_bool(compiler,
VKD3D_SHADER_CONDITIONAL_OP_NZ, src[0].reg.data_type, 1, condition_id);
if (src[0].reg.data_type != VKD3D_DATA_BOOL)
condition_id = spirv_compiler_emit_int_to_bool(compiler,
VKD3D_SHADER_CONDITIONAL_OP_NZ, src[0].reg.data_type, 1, condition_id);
/* Emit the merge immediately before the branch instruction. */
if (instruction->src_count >= 4)
spirv_compiler_emit_merge(compiler, src[3].reg.idx[0].offset,