summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/radeonsi/si_shader.c
diff options
context:
space:
mode:
authorBas Nieuwenhuizen <[email protected]>2016-03-29 17:51:49 +0200
committerBas Nieuwenhuizen <[email protected]>2016-04-19 18:10:30 +0200
commit84a6761ae34105fbdb38757a07e229b2392545d3 (patch)
tree3ba48603a3c686a77b73bb5148983ef67d984421 /src/gallium/drivers/radeonsi/si_shader.c
parent753a3e472b4c026d96f9984b02b53f596a0d595e (diff)
radeonsi: add shared memory
Declares the shared memory as a global variable so that LLVM is aware of it and it does not conflict with passes like AMDGPUPromoteAlloca. v2: - Use ctx->i8. - Dropped null-check for declare_memory_region. - Changed memory region array to single region. Signed-off-by: Bas Nieuwenhuizen <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]>
Diffstat (limited to 'src/gallium/drivers/radeonsi/si_shader.c')
-rw-r--r--src/gallium/drivers/radeonsi/si_shader.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index 68171c831d2..9229fa10450 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -121,6 +121,8 @@ struct si_shader_context
LLVMTypeRef v4i32;
LLVMTypeRef v4f32;
LLVMTypeRef v8i32;
+
+ LLVMValueRef shared_memory;
};
static struct si_shader_context *si_shader_context(
@@ -1320,6 +1322,30 @@ static void declare_system_value(
radeon_bld->system_values[index] = value;
}
+static void declare_compute_memory(struct radeon_llvm_context *radeon_bld,
+ const struct tgsi_full_declaration *decl)
+{
+ struct si_shader_context *ctx =
+ si_shader_context(&radeon_bld->soa.bld_base);
+ struct si_shader_selector *sel = ctx->shader->selector;
+ struct gallivm_state *gallivm = &radeon_bld->gallivm;
+
+ LLVMTypeRef i8p = LLVMPointerType(ctx->i8, LOCAL_ADDR_SPACE);
+ LLVMValueRef var;
+
+ assert(decl->Declaration.MemType == TGSI_MEMORY_TYPE_SHARED);
+ assert(decl->Range.First == decl->Range.Last);
+ assert(!ctx->shared_memory);
+
+ var = LLVMAddGlobalInAddressSpace(gallivm->module,
+ LLVMArrayType(ctx->i8, sel->local_size),
+ "compute_lds",
+ LOCAL_ADDR_SPACE);
+ LLVMSetAlignment(var, 4);
+
+ ctx->shared_memory = LLVMBuildBitCast(gallivm->builder, var, i8p, "");
+}
+
static LLVMValueRef fetch_constant(
struct lp_build_tgsi_context *bld_base,
const struct tgsi_full_src_register *reg,
@@ -5824,6 +5850,7 @@ int si_compile_tgsi_shader(struct si_screen *sscreen,
bld_base->emit_epilogue = si_llvm_return_fs_outputs;
break;
case TGSI_PROCESSOR_COMPUTE:
+ ctx.radeon_bld.declare_memory_region = declare_compute_memory;
break;
default:
assert(!"Unsupported shader type");