From: Marek Olšák <[email protected]>

---
 src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c 
b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
index c5b94b9..9519e0d 100644
--- a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
+++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
@@ -410,27 +410,45 @@ static unsigned get_store_intr_attribs(bool 
writeonly_memory)
 }
 
 static void load_emit_buffer(struct si_shader_context *ctx,
                             struct lp_build_emit_data *emit_data,
                             bool readonly_memory)
 {
        const struct tgsi_full_instruction *inst = emit_data->inst;
        uint writemask = inst->Dst[0].Register.WriteMask;
        uint count = util_last_bit(writemask);
        LLVMValueRef *args = emit_data->args;
+       bool coherent = (inst->Memory.Qualifier &
+                        (TGSI_MEMORY_COHERENT | TGSI_MEMORY_VOLATILE)) != 0;
 
+       /* Force the use of VMEM for shader buffer loads, because LLVM doesn't
+        * select SMEM for SI.load.const with a non-constant offset, and
+        * constant offsets practically don't exist with shader buffers.
+        *
+        * Also, SI.load.const doesn't use inst_offset when it's lowered
+        * to VMEM, so we just end up with more VALU instructions in the end
+        * and no benefit.
+        *
+        * TODO: Remove this line once LLVM can select SMEM with a non-constant
+        *       offset, and can derive inst_offset when VMEM is selected.
+        *       After that, si_memory_barrier should invalidate sL1 for shader
+        *       buffers.
+        */
+       coherent = true;
+
+       assert(LLVMConstIntGetZExtValue(args[1]) == 0); /* vindex */
        emit_data->output[emit_data->chan] =
-               ac_build_buffer_load(&ctx->ac, args[0], count, args[1],
+               ac_build_buffer_load(&ctx->ac, args[0], count, NULL,
                                     args[2], NULL, 0,
                                     LLVMConstIntGetZExtValue(args[3]),
                                     LLVMConstIntGetZExtValue(args[4]),
-                                    readonly_memory, true);
+                                    readonly_memory, coherent);
 }
 
 static LLVMValueRef get_memory_ptr(struct si_shader_context *ctx,
                                    const struct tgsi_full_instruction *inst,
                                    LLVMTypeRef type, int arg)
 {
        struct gallivm_state *gallivm = &ctx->gallivm;
        LLVMBuilderRef builder = gallivm->builder;
        LLVMValueRef offset, ptr;
        int addr_space;
-- 
2.7.4

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

Reply via email to