summaryrefslogtreecommitdiffstats
path: root/src/intel
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2016-05-14 14:53:11 -0700
committerJason Ekstrand <[email protected]>2016-05-19 21:18:59 -0700
commit23090b51e042790974aa848bbe2760f659dba925 (patch)
tree620b24f94b5843c80a348b268a2133f5ad52e9de /src/intel
parentc29ffea6d161b14e1c6d1d1af7727425b323a3b5 (diff)
anv/apply_dynamic_offsets: Use rewrite_src instead of a regular assignment
Originally we removed the instruction, changed the source, and then re-inserted it. This works, but nir_instr_rewrite_src is a bit more obviously correct.
Diffstat (limited to 'src/intel')
-rw-r--r--src/intel/vulkan/anv_nir_apply_dynamic_offsets.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/intel/vulkan/anv_nir_apply_dynamic_offsets.c b/src/intel/vulkan/anv_nir_apply_dynamic_offsets.c
index 6a289539206..84fed0af535 100644
--- a/src/intel/vulkan/anv_nir_apply_dynamic_offsets.c
+++ b/src/intel/vulkan/anv_nir_apply_dynamic_offsets.c
@@ -81,18 +81,19 @@ apply_dynamic_offsets_block(nir_block *block, nir_builder *b,
nir_builder_instr_insert(b, &offset_load->instr);
nir_src *offset_src = nir_get_io_offset_src(intrin);
- nir_ssa_def *new_offset = nir_iadd(b, offset_src->ssa,
- &offset_load->dest.ssa);
+ nir_ssa_def *old_offset = nir_ssa_for_src(b, *offset_src, 1);
+ nir_ssa_def *new_offset = nir_iadd(b, old_offset, &offset_load->dest.ssa);
+ nir_instr_rewrite_src(&intrin->instr, offset_src,
+ nir_src_for_ssa(new_offset));
/* In order to avoid out-of-bounds access, we predicate */
nir_ssa_def *pred = nir_uge(b, nir_channel(b, &offset_load->dest.ssa, 1),
- offset_src->ssa);
+ old_offset);
nir_if *if_stmt = nir_if_create(b->shader);
if_stmt->condition = nir_src_for_ssa(pred);
nir_cf_node_insert(b->cursor, &if_stmt->cf_node);
nir_instr_remove(&intrin->instr);
- *offset_src = nir_src_for_ssa(new_offset);
nir_instr_insert_after_cf_list(&if_stmt->then_list, &intrin->instr);
if (intrin->intrinsic != nir_intrinsic_store_ssbo) {