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

Author: Rhys Perry <[email protected]>
Date:   Thu Jul 30 11:50:44 2020 +0100

ac/nir: fix coherent global loads/stores

Signed-off-by: Rhys Perry <[email protected]>
Reviewed-by: Daniel Schürmann <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6063>

---

 src/amd/llvm/ac_nir_to_llvm.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/amd/llvm/ac_nir_to_llvm.c b/src/amd/llvm/ac_nir_to_llvm.c
index 8c316e417e9..1b0bdffdb45 100644
--- a/src/amd/llvm/ac_nir_to_llvm.c
+++ b/src/amd/llvm/ac_nir_to_llvm.c
@@ -2418,6 +2418,9 @@ static LLVMValueRef visit_load_var(struct ac_nir_context 
*ctx,
                                LLVMValueRef offset = LLVMConstInt(ctx->ac.i32, 
i * stride / natural_stride, 0);
                                values[i] = LLVMBuildLoad(ctx->ac.builder,
                                                          
ac_build_gep_ptr(&ctx->ac, address, offset), "");
+
+                               if (nir_intrinsic_access(instr) & 
(ACCESS_COHERENT | ACCESS_VOLATILE))
+                                       LLVMSetOrdering(values[i], 
LLVMAtomicOrderingMonotonic);
                        }
                        return ac_build_gather_values(&ctx->ac, values, 
instr->dest.ssa.num_components);
                } else {
@@ -2425,6 +2428,9 @@ static LLVMValueRef visit_load_var(struct ac_nir_context 
*ctx,
                                                                
LLVMGetPointerAddressSpace(LLVMTypeOf(address)));
                        address = LLVMBuildBitCast(ctx->ac.builder, address, 
ptr_type , "");
                        LLVMValueRef val = LLVMBuildLoad(ctx->ac.builder, 
address, "");
+
+                       if (nir_intrinsic_access(instr) & (ACCESS_COHERENT | 
ACCESS_VOLATILE))
+                               LLVMSetOrdering(val, 
LLVMAtomicOrderingMonotonic);
                        return val;
                }
        }
@@ -2580,7 +2586,10 @@ visit_store_var(struct ac_nir_context *ctx,
 
                        val = LLVMBuildBitCast(ctx->ac.builder, val,
                                               
LLVMGetElementType(LLVMTypeOf(address)), "");
-                       LLVMBuildStore(ctx->ac.builder, val, address);
+                       LLVMValueRef store = LLVMBuildStore(ctx->ac.builder, 
val, address);
+
+                       if (nir_intrinsic_access(instr) & (ACCESS_COHERENT | 
ACCESS_VOLATILE))
+                               LLVMSetOrdering(store, 
LLVMAtomicOrderingMonotonic);
                } else {
                        LLVMTypeRef val_type = LLVMTypeOf(val);
                        if (LLVMGetTypeKind(LLVMTypeOf(val)) == 
LLVMVectorTypeKind)
@@ -2600,7 +2609,10 @@ visit_store_var(struct ac_nir_context *ctx,
                                                                        chan);
                                src = LLVMBuildBitCast(ctx->ac.builder, src,
                                                       
LLVMGetElementType(LLVMTypeOf(ptr)), "");
-                               LLVMBuildStore(ctx->ac.builder, src, ptr);
+                               LLVMValueRef store = 
LLVMBuildStore(ctx->ac.builder, src, ptr);
+
+                               if (nir_intrinsic_access(instr) & 
(ACCESS_COHERENT | ACCESS_VOLATILE))
+                                       LLVMSetOrdering(store, 
LLVMAtomicOrderingMonotonic);
                        }
                }
                break;

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

Reply via email to