aco: don't use p_as_uniform for vgpr sampler/image indices
authorRhys Perry <pendingchaos02@gmail.com>
Sat, 21 Sep 2019 14:33:44 +0000 (15:33 +0100)
committerRhys Perry <pendingchaos02@gmail.com>
Fri, 11 Oct 2019 14:26:58 +0000 (14:26 +0000)
p_as_uniform can get CSE'd, which can be incorrect and break some
dEQP-VK.descriptor_indexing.* tests.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
src/amd/compiler/aco_instruction_selection.cpp

index f521492bc7857740dab03f6b9de7c3779facf482..bdb7e2a549e4b7470209d3fd8b3210536ddf54b9 100644 (file)
@@ -3439,7 +3439,9 @@ Temp get_sampler_desc(isel_context *ctx, nir_deref_instr *deref_instr,
          if (const_value) {
             constant_index += array_size * const_value->u32;
          } else {
-            Temp indirect = bld.as_uniform(get_ssa_temp(ctx, deref_instr->arr.index.ssa));
+            Temp indirect = get_ssa_temp(ctx, deref_instr->arr.index.ssa);
+            if (indirect.type() == RegType::vgpr)
+               indirect = bld.vop1(aco_opcode::v_readfirstlane_b32, bld.def(s1), indirect);
 
             if (array_size != 1)
                indirect = bld.sop2(aco_opcode::s_mul_i32, bld.def(s1), Operand(array_size), indirect);