Skip to content
Snippets Groups Projects

vkd3d-shader/ir: Flatten structured control flow instructions.

Merged Conor McCarthy requested to merge cmccarthy/vkd3d:norm_cf into master
4 files
+ 731
433
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -44,6 +44,7 @@ static const char * const shader_opcode_names[] =
[VKD3DSIH_BEM ] = "bem",
[VKD3DSIH_BFI ] = "bfi",
[VKD3DSIH_BFREV ] = "bfrev",
[VKD3DSIH_BRANCH ] = "branch",
[VKD3DSIH_BREAK ] = "break",
[VKD3DSIH_BREAKC ] = "breakc",
[VKD3DSIH_BREAKP ] = "breakp",
@@ -1516,6 +1517,7 @@ static void shader_dump_instruction_flags(struct vkd3d_d3d_asm_compiler *compile
switch (ins->handler_idx)
{
case VKD3DSIH_BRANCH:
case VKD3DSIH_BREAKP:
case VKD3DSIH_CONTINUEP:
case VKD3DSIH_DISCARD:
@@ -1610,6 +1612,27 @@ static void shader_dump_instruction(struct vkd3d_d3d_asm_compiler *compiler,
switch (ins->handler_idx)
{
case VKD3DSIH_BRANCH:
{
const struct vkd3d_shader_branch *branch = &ins->declaration.branch;
if (ins->src_count)
{
shader_dump_instruction_flags(compiler, ins);
vkd3d_string_buffer_printf(buffer, " ");
shader_dump_src_param(compiler, ins->src);
vkd3d_string_buffer_printf(buffer, " ? l%u : l%u", branch->true_id, branch->false_id);
}
else
{
vkd3d_string_buffer_printf(buffer, " l%u", branch->true_id);
}
if (branch->merge_block_id)
vkd3d_string_buffer_printf(buffer, ", merge l%u", branch->merge_block_id);
if (branch->continue_block_id)
vkd3d_string_buffer_printf(buffer, ", continue l%u", branch->continue_block_id);
break;
}
case VKD3DSIH_DCL:
case VKD3DSIH_DCL_UAV_TYPED:
vkd3d_string_buffer_printf(buffer, "%s", compiler->colours.opcode);
@@ -1825,6 +1848,18 @@ static void shader_dump_instruction(struct vkd3d_d3d_asm_compiler *compiler,
shader_print_bool_literal(compiler, " = ", ins->src[0].reg.u.immconst_uint[0], "");
break;
case VKD3DSIH_SWITCH:
if (ins->declaration.switch_.case_count)
{
const struct vkd3d_shader_switch *switch_ = &ins->declaration.switch_;
vkd3d_string_buffer_printf(buffer, " ");
shader_dump_src_param(compiler, ins->src);
for (i = 0; i < switch_->case_count; ++i)
vkd3d_string_buffer_printf(buffer, ", %u: l%u", switch_->cases[i].value, switch_->cases[i].block_id);
vkd3d_string_buffer_printf(buffer, ", default: l%u", switch_->default_id);
break;
}
/* fall through */
default:
shader_dump_instruction_flags(compiler, ins);
@@ -1972,9 +2007,11 @@ enum vkd3d_result vkd3d_dxbc_binary_to_text(const struct vkd3d_shader_instructio
case VKD3DSIH_ELSE:
case VKD3DSIH_IF:
case VKD3DSIH_LOOP:
case VKD3DSIH_SWITCH:
++indent;
break;
case VKD3DSIH_SWITCH:
indent += !ins->declaration.switch_.case_count;
break;
default:
break;
Loading