radeonsi: implement and use ac_shader_abi::load_ssbo
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Sat, 24 Jun 2017 18:03:46 +0000 (20:03 +0200)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Mon, 31 Jul 2017 12:55:41 +0000 (14:55 +0200)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c

index bf66879571a1c08451413e27c5dd8af610f47e9e..6b55e7f4f6c5bd352c68199b2c88cb52b6e92b3a 100644 (file)
@@ -1806,6 +1806,21 @@ static LLVMValueRef load_ubo(struct ac_shader_abi *abi, LLVMValueRef index)
        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,
@@ -5646,6 +5661,7 @@ static bool si_compile_tgsi_main(struct si_shader_context *ctx,
        }
 
        ctx->abi.load_ubo = load_ubo;
+       ctx->abi.load_ssbo = load_ssbo;
 
        create_function(ctx);
        preload_ring_buffers(ctx);
index e04a8796fdc8d7df9ed85f3e6324ecad9965c6fb..42f977d7cedf16ea8798d7a4391e38d64529ded6 100644 (file)
@@ -76,22 +76,15 @@ 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)