ac/nir: fix shared atomic operations.
authorDave Airlie <airlied@redhat.com>
Wed, 28 Feb 2018 23:38:19 +0000 (09:38 +1000)
committerDave Airlie <airlied@redhat.com>
Thu, 1 Mar 2018 00:06:06 +0000 (10:06 +1000)
The nir->llvm conversion was using the wrong srcs.

Fixes:
tests/spec/arb_compute_shader/execution/shared-atomics.shader_test

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/amd/common/ac_nir_to_llvm.c

index 3c5be7e203641863b7147d827a47f6ece6e6d933..afe17a8f11d5d43d0f414a6c389106bd6f617ecc 100644 (file)
@@ -3991,10 +3991,10 @@ visit_store_shared(struct ac_nir_context *ctx,
 
 static LLVMValueRef visit_var_atomic(struct ac_nir_context *ctx,
                                     const nir_intrinsic_instr *instr,
-                                    LLVMValueRef ptr)
+                                    LLVMValueRef ptr, int src_idx)
 {
        LLVMValueRef result;
-       LLVMValueRef src = get_src(ctx, instr->src[0]);
+       LLVMValueRef src = get_src(ctx, instr->src[src_idx]);
 
        if (instr->intrinsic == nir_intrinsic_var_atomic_comp_swap ||
            instr->intrinsic == nir_intrinsic_shared_atomic_comp_swap) {
@@ -4574,8 +4574,8 @@ static void visit_intrinsic(struct ac_nir_context *ctx,
        case nir_intrinsic_shared_atomic_xor:
        case nir_intrinsic_shared_atomic_exchange:
        case nir_intrinsic_shared_atomic_comp_swap: {
-               LLVMValueRef ptr = get_memory_ptr(ctx, instr->src[1]);
-               result = visit_var_atomic(ctx, instr, ptr);
+               LLVMValueRef ptr = get_memory_ptr(ctx, instr->src[0]);
+               result = visit_var_atomic(ctx, instr, ptr, 1);
                break;
        }
        case nir_intrinsic_var_atomic_add:
@@ -4589,7 +4589,7 @@ static void visit_intrinsic(struct ac_nir_context *ctx,
        case nir_intrinsic_var_atomic_exchange:
        case nir_intrinsic_var_atomic_comp_swap: {
                LLVMValueRef ptr = build_gep_for_deref(ctx, instr->variables[0]);
-               result = visit_var_atomic(ctx, instr, ptr);
+               result = visit_var_atomic(ctx, instr, ptr, 0);
                break;
        }
        case nir_intrinsic_interp_var_at_centroid: