aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler/spirv/vtn_cfg.c
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2016-09-15 21:12:34 -0700
committerJason Ekstrand <[email protected]>2016-10-03 16:17:12 -0700
commit6ffbfc760da14fc710a05438b9fd9eff034128da (patch)
treed0d2f0d3f98c7a3a13e53e67d38426b2a520732b /src/compiler/spirv/vtn_cfg.c
parent7697b4b98b155c818811709becdb408772371538 (diff)
nir/spirv/cfg: Use a nop intrinsic for tagging the ends of blocks
Previously, we were saving off the last nir_block in a vtn_block before moving on so that we could find the nir_block again when it came time to handle phi sources. Unfortunately, NIR's control flow modification code is inconsistent when it comes to how it splits blocks so the block pointer we saved off may point to a block somewhere else in the shader by the time we get around to handling phi sources. In order to get around this, we insert a nop instruction and use that as the logical end of our block. Since the control flow manipulation code respects instructions, the nop will keeps its place like any other instruction and we can easily find the end of our block when we need it. This fixes a bug triggered by a couple of vkQuake shaders. Signed-off-by: Jason Ekstrand <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97233 Cc: "12.0" <[email protected]> Tested-by: Dave Airlie <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/compiler/spirv/vtn_cfg.c')
-rw-r--r--src/compiler/spirv/vtn_cfg.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/compiler/spirv/vtn_cfg.c b/src/compiler/spirv/vtn_cfg.c
index 1c8c4f8e108..62b9056990e 100644
--- a/src/compiler/spirv/vtn_cfg.c
+++ b/src/compiler/spirv/vtn_cfg.c
@@ -531,7 +531,7 @@ vtn_handle_phi_second_pass(struct vtn_builder *b, SpvOp opcode,
struct vtn_block *pred =
vtn_value(b, w[i + 1], vtn_value_type_block)->block;
- b->nb.cursor = nir_after_block_before_jump(pred->end_block);
+ b->nb.cursor = nir_after_instr(&pred->end_nop->instr);
vtn_local_store(b, src, nir_deref_var_create(b, phi_var));
}
@@ -589,7 +589,9 @@ vtn_emit_cf_list(struct vtn_builder *b, struct list_head *cf_list,
vtn_foreach_instruction(b, block_start, block_end, handler);
- block->end_block = nir_cursor_current_block(b->nb.cursor);
+ block->end_nop = nir_intrinsic_instr_create(b->nb.shader,
+ nir_intrinsic_nop);
+ nir_builder_instr_insert(&b->nb, &block->end_nop->instr);
if ((*block->branch & SpvOpCodeMask) == SpvOpReturnValue) {
struct vtn_ssa_value *src = vtn_ssa_value(b, block->branch[1]);