summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolai Hähnle <nicolai.haehnle@amd.com>2017-05-20 17:19:50 +0200
committerNicolai Hähnle <nicolai.haehnle@amd.com>2017-07-05 12:33:51 +0200
commit4205c8526870eae22314c9685bd90ba9e9bd8a3e (patch)
tree5e6503b984ad2e1e92cb8c4b4744083be381de8b
parent28f8c3c011545aaa81c8441faa9661e7fc4f95f6 (diff)
ac/nir,radeonsi: add ac_shader_abi::load_ubo
-rw-r--r--src/amd/common/ac_nir_to_llvm.c3
-rw-r--r--src/amd/common/ac_shader_abi.h2
-rw-r--r--src/gallium/drivers/radeonsi/si_shader.c14
3 files changed, 19 insertions, 0 deletions
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 034b1c3a72..4f3ed24b8b 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -2468,6 +2468,9 @@ static LLVMValueRef visit_load_ubo_buffer(struct ac_nir_context *ctx,
LLVMValueRef offset = get_src(ctx, instr->src[1]);
int num_components = instr->num_components;
+ if (ctx->abi->load_ubo)
+ rsrc = ctx->abi->load_ubo(ctx->abi, rsrc);
+
if (instr->dest.ssa.bit_size == 64)
num_components *= 2;
diff --git a/src/amd/common/ac_shader_abi.h b/src/amd/common/ac_shader_abi.h
index 81fbc22bb4..b0161d9f22 100644
--- a/src/amd/common/ac_shader_abi.h
+++ b/src/amd/common/ac_shader_abi.h
@@ -46,6 +46,8 @@ struct ac_shader_abi {
void (*emit_outputs)(struct ac_shader_abi *abi,
unsigned max_outputs,
LLVMValueRef *addrs);
+
+ LLVMValueRef (*load_ubo)(struct ac_shader_abi *abi, LLVMValueRef index);
};
#endif /* AC_SHADER_ABI_H */
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index 2d1a5808b9..ae61d20359 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -1774,6 +1774,18 @@ static LLVMValueRef load_const_buffer_desc(struct si_shader_context *ctx, int i)
LLVMConstInt(ctx->i32, si_get_constbuf_slot(i), 0));
}
+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 fetch_constant(
struct lp_build_tgsi_context *bld_base,
const struct tgsi_full_src_register *reg,
@@ -5580,6 +5592,8 @@ static bool si_compile_tgsi_main(struct si_shader_context *ctx,
return false;
}
+ ctx->abi.load_ubo = load_ubo;
+
create_function(ctx);
preload_ring_buffers(ctx);