From: Nicolai Hähnle <nicolai.haeh...@amd.com>

---
 src/gallium/drivers/radeonsi/si_shader.c          | 16 ++++++++++++++++
 src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c | 15 ++++-----------
 2 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index 6d0598b..678a926 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -1750,20 +1750,35 @@ static LLVMValueRef load_ubo(struct ac_shader_abi *abi, 
LLVMValueRef index)
        struct si_shader_context *ctx = si_shader_context_from_abi(abi);
        LLVMValueRef ptr = LLVMGetParam(ctx->main_fn, 
ctx->param_const_and_shader_buffers);
 
        index = si_llvm_bound_index(ctx, index, ctx->num_const_buffers);
        index = LLVMBuildAdd(ctx->gallivm.builder, index,
                             LLVMConstInt(ctx->i32, SI_NUM_SHADER_BUFFERS, 0), 
"");
 
        return ac_build_indexed_load_const(&ctx->ac, ptr, index);
 }
 
+static LLVMValueRef
+load_ssbo(struct ac_shader_abi *abi, LLVMValueRef index, bool write)
+{
+       struct si_shader_context *ctx = si_shader_context_from_abi(abi);
+       LLVMValueRef rsrc_ptr = LLVMGetParam(ctx->main_fn,
+                                            
ctx->param_const_and_shader_buffers);
+
+       index = si_llvm_bound_index(ctx, index, ctx->num_shader_buffers);
+       index = LLVMBuildSub(ctx->gallivm.builder,
+                            LLVMConstInt(ctx->i32, SI_NUM_SHADER_BUFFERS - 1, 
0),
+                            index, "");
+
+       return ac_build_indexed_load_const(&ctx->ac, rsrc_ptr, index);
+}
+
 static LLVMValueRef fetch_constant(
        struct lp_build_tgsi_context *bld_base,
        const struct tgsi_full_src_register *reg,
        enum tgsi_opcode_type type,
        unsigned swizzle)
 {
        struct si_shader_context *ctx = si_shader_context(bld_base);
        struct lp_build_context *base = &bld_base->base;
        const struct tgsi_ind_register *ireg = &reg->Indirect;
        unsigned buf, idx;
@@ -5576,20 +5591,21 @@ static bool si_compile_tgsi_main(struct 
si_shader_context *ctx,
                break;
        case PIPE_SHADER_COMPUTE:
                ctx->declare_memory_region = declare_compute_memory;
                break;
        default:
                assert(!"Unsupported shader type");
                return false;
        }
 
        ctx->abi.load_ubo = load_ubo;
+       ctx->abi.load_ssbo = load_ssbo;
 
        create_function(ctx);
        preload_ring_buffers(ctx);
 
        /* For GFX9 merged shaders:
         * - Set EXEC. If the prolog is present, set EXEC there instead.
         * - Add a barrier before the second shader.
         *
         * The same thing for monolithic shaders is done in
         * si_build_wrapper_function.
diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c 
b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
index 3dac14d..565be81 100644
--- a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
+++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
@@ -76,36 +76,29 @@ static LLVMValueRef get_buffer_size(
        }
 
        return size;
 }
 
 static LLVMValueRef
 shader_buffer_fetch_rsrc(struct si_shader_context *ctx,
                         const struct tgsi_full_src_register *reg)
 {
        LLVMValueRef index;
-       LLVMValueRef rsrc_ptr = LLVMGetParam(ctx->main_fn,
-                                            
ctx->param_const_and_shader_buffers);
 
        if (!reg->Register.Indirect) {
-               index = LLVMConstInt(ctx->i32,
-                                    
si_get_shaderbuf_slot(reg->Register.Index), 0);
+               index = LLVMConstInt(ctx->i32, reg->Register.Index, false);
        } else {
-               index = si_get_bounded_indirect_index(ctx, &reg->Indirect,
-                                                     reg->Register.Index,
-                                                     ctx->num_shader_buffers);
-               index = LLVMBuildSub(ctx->gallivm.builder,
-                                    LLVMConstInt(ctx->i32, 
SI_NUM_SHADER_BUFFERS - 1, 0),
-                                    index, "");
+               index = si_get_indirect_index(ctx, &reg->Indirect,
+                                             reg->Register.Index);
        }
 
-       return ac_build_indexed_load_const(&ctx->ac, rsrc_ptr, index);
+       return ctx->abi.load_ssbo(&ctx->abi, index, false);
 }
 
 static bool tgsi_is_array_sampler(unsigned target)
 {
        return target == TGSI_TEXTURE_1D_ARRAY ||
               target == TGSI_TEXTURE_SHADOW1D_ARRAY ||
               target == TGSI_TEXTURE_2D_ARRAY ||
               target == TGSI_TEXTURE_SHADOW2D_ARRAY ||
               target == TGSI_TEXTURE_CUBE_ARRAY ||
               target == TGSI_TEXTURE_SHADOWCUBE_ARRAY ||
-- 
2.9.3

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to