diff options
author | Jason Ekstrand <[email protected]> | 2014-10-16 09:56:14 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-01-15 07:18:59 -0800 |
commit | 6e46c98ec1f4344d5c4794423e773d3cc591ebbb (patch) | |
tree | 0626262b16bfadf440301a1ef33b70c199f22ca7 /src | |
parent | 95fbd6e1eed58f1f87aaa425bb5312a92db29d21 (diff) |
nir/lower_atomics: Multiply array offsets by ATOMIC_COUNTER_SIZE
Reviewed-by: Connor Abbott <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/glsl/nir/nir_lower_atomics.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/glsl/nir/nir_lower_atomics.c b/src/glsl/nir/nir_lower_atomics.c index 06b14fc0b71..c2387cd8109 100644 --- a/src/glsl/nir/nir_lower_atomics.c +++ b/src/glsl/nir/nir_lower_atomics.c @@ -87,11 +87,27 @@ lower_instr(nir_intrinsic_instr *instr, nir_function_impl *impl) offset_const->value.u[0] += deref_array->base_offset; if (deref_array->has_indirect) { + nir_load_const_instr *atomic_counter_size = + nir_load_const_instr_create(mem_ctx); + atomic_counter_size->num_components = 1; + atomic_counter_size->value.u[0] = ATOMIC_COUNTER_SIZE; + atomic_counter_size->dest.reg.reg = nir_local_reg_create(impl); + atomic_counter_size->dest.reg.reg->num_components = 1; + nir_instr_insert_before(&instr->instr, &atomic_counter_size->instr); + + nir_alu_instr *mul = nir_alu_instr_create(mem_ctx, nir_op_imul); + mul->dest.dest.reg.reg = nir_local_reg_create(impl); + mul->dest.dest.reg.reg->num_components = 1; + mul->dest.write_mask = 0x1; + mul->src[0].src = nir_src_copy(deref_array->indirect, mem_ctx); + mul->src[1].src.reg.reg = atomic_counter_size->dest.reg.reg; + nir_instr_insert_before(&instr->instr, &mul->instr); + nir_alu_instr *add = nir_alu_instr_create(mem_ctx, nir_op_iadd); add->dest.dest.reg.reg = nir_local_reg_create(impl); add->dest.dest.reg.reg->num_components = 1; add->dest.write_mask = 0x1; - add->src[0].src = nir_src_copy(deref_array->indirect, mem_ctx); + add->src[0].src.reg.reg = mul->dest.dest.reg.reg; add->src[1].src.reg.reg = offset_const->dest.reg.reg; nir_instr_insert_before(&instr->instr, &add->instr); |