Giovanni Mascellani (@giomasce) commented about libs/vkd3d-shader/dxil.c:
+{
- struct vkd3d_shader_instruction *ins;
- ins = sm6_parser_add_instruction(sm6, VKD3DSIH_BRANCH);
- ins->declaration.branch.true_id = block_idx;
+}
+static enum vkd3d_result sm6_function_emit_blocks(const struct sm6_function *function, struct sm6_parser *sm6) +{
- unsigned int i;
- for (i = 0; i < function->block_count; ++i)
- {
const struct sm6_block *block = function->blocks[i];
if (!sm6_parser_require_space(sm6, block->instruction_count + !i + 3))
I'm not sure I understand the computation here. I guess `!i` is got the branch instruction, then there is the label, but where the remaining 2 comes from?
Also, why do you need to emit a branch? Aren't block already supposed to be terminated?