Module: Mesa
Branch: master
Commit: b00a023f1e16a280730650952134ce9b72382987
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b00a023f1e16a280730650952134ce9b72382987

Author: Samuel Pitoiset <[email protected]>
Date:   Wed Sep 30 13:52:19 2020 +0200

ac/nir: fix nir_intrinsic_shared_atomic_fadd

This was completely broken.

Fixes dEQP-VK.glsl.atomic_operations.add_float32_compute_shared.

Signed-off-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6936>

---

 src/amd/llvm/ac_llvm_helper.cpp | 5 +++++
 src/amd/llvm/ac_nir_to_llvm.c   | 9 +++++++++
 2 files changed, 14 insertions(+)

diff --git a/src/amd/llvm/ac_llvm_helper.cpp b/src/amd/llvm/ac_llvm_helper.cpp
index 5f04813704f..ebeafaea553 100644
--- a/src/amd/llvm/ac_llvm_helper.cpp
+++ b/src/amd/llvm/ac_llvm_helper.cpp
@@ -309,6 +309,11 @@ LLVMValueRef ac_build_atomic_rmw(struct ac_llvm_context 
*ctx, LLVMAtomicRMWBinOp
    case LLVMAtomicRMWBinOpUMin:
       binop = llvm::AtomicRMWInst::UMin;
       break;
+#if LLVM_VERSION_MAJOR >= 10
+   case LLVMAtomicRMWBinOpFAdd:
+      binop = llvm::AtomicRMWInst::FAdd;
+      break;
+#endif
    default:
       unreachable("invalid LLVMAtomicRMWBinOp");
       break;
diff --git a/src/amd/llvm/ac_nir_to_llvm.c b/src/amd/llvm/ac_nir_to_llvm.c
index 1beea68e876..a3543c4ae06 100644
--- a/src/amd/llvm/ac_nir_to_llvm.c
+++ b/src/amd/llvm/ac_nir_to_llvm.c
@@ -3364,11 +3364,20 @@ static LLVMValueRef visit_var_atomic(struct 
ac_nir_context *ctx, const nir_intri
       if (instr->intrinsic == nir_intrinsic_shared_atomic_fadd ||
           instr->intrinsic == nir_intrinsic_deref_atomic_fadd) {
          val = ac_to_float(&ctx->ac, src);
+
+         LLVMTypeRef ptr_type =
+            LLVMPointerType(LLVMTypeOf(val), 
LLVMGetPointerAddressSpace(LLVMTypeOf(ptr)));
+         ptr = LLVMBuildBitCast(ctx->ac.builder, ptr, ptr_type, "");
       } else {
          val = ac_to_integer(&ctx->ac, src);
       }
 
       result = ac_build_atomic_rmw(&ctx->ac, op, ptr, val, sync_scope);
+
+      if (instr->intrinsic == nir_intrinsic_shared_atomic_fadd ||
+          instr->intrinsic == nir_intrinsic_deref_atomic_fadd) {
+         result = ac_to_integer(&ctx->ac, result);
+      }
    }
 
    if (ctx->ac.postponed_kill)

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to