summaryrefslogtreecommitdiffstats
path: root/src/amd/common
diff options
context:
space:
mode:
authorNicolai Hähnle <[email protected]>2017-06-24 19:17:54 +0200
committerNicolai Hähnle <[email protected]>2017-07-31 14:55:40 +0200
commitb78eae6f2a65cf1f755d0fb6cd7ae638c08f9712 (patch)
tree017c2dfc800e41d8ca9df325b3ffa41bdeffde75 /src/amd/common
parentaa66fec47e6139ff50959b1326d621f2213ccc06 (diff)
ac/nir: load buffer descriptors via ac_shader_abi::load_ssbo
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/amd/common')
-rw-r--r--src/amd/common/ac_nir_to_llvm.c28
-rw-r--r--src/amd/common/ac_shader_abi.h10
2 files changed, 30 insertions, 8 deletions
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 47f17b2f65c..7de1941bc8c 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -2251,10 +2251,8 @@ static void visit_store_ssbo(struct nir_to_llvm_context *ctx,
LLVMValueRef base_data, base_offset;
LLVMValueRef params[6];
- if (ctx->stage == MESA_SHADER_FRAGMENT)
- ctx->shader_info->fs.writes_memory = true;
-
- params[1] = get_src(ctx->nir, instr->src[1]);
+ params[1] = ctx->abi.load_ssbo(&ctx->abi,
+ get_src(ctx->nir, instr->src[1]), true);
params[2] = LLVMConstInt(ctx->i32, 0, false); /* vindex */
params[4] = ctx->i1false; /* glc */
params[5] = ctx->i1false; /* slc */
@@ -2331,14 +2329,14 @@ static LLVMValueRef visit_atomic_ssbo(struct nir_to_llvm_context *ctx,
const char *name;
LLVMValueRef params[6];
int arg_count = 0;
- if (ctx->stage == MESA_SHADER_FRAGMENT)
- ctx->shader_info->fs.writes_memory = true;
if (instr->intrinsic == nir_intrinsic_ssbo_atomic_comp_swap) {
params[arg_count++] = llvm_extract_elem(&ctx->ac, get_src(ctx->nir, instr->src[3]), 0);
}
params[arg_count++] = llvm_extract_elem(&ctx->ac, get_src(ctx->nir, instr->src[2]), 0);
- params[arg_count++] = get_src(ctx->nir, instr->src[0]);
+ params[arg_count++] = ctx->abi.load_ssbo(&ctx->abi,
+ get_src(ctx->nir, instr->src[0]),
+ true);
params[arg_count++] = LLVMConstInt(ctx->i32, 0, false); /* vindex */
params[arg_count++] = get_src(ctx->nir, instr->src[1]); /* voffset */
params[arg_count++] = ctx->i1false; /* slc */
@@ -2412,7 +2410,9 @@ static LLVMValueRef visit_load_buffer(struct nir_to_llvm_context *ctx,
unreachable("unhandled number of components");
LLVMValueRef params[] = {
- get_src(ctx->nir, instr->src[0]),
+ ctx->abi.load_ssbo(&ctx->abi,
+ get_src(ctx->nir, instr->src[0]),
+ false),
LLVMConstInt(ctx->i32, 0, false),
offset,
ctx->i1false,
@@ -4138,6 +4138,17 @@ static void visit_intrinsic(struct ac_nir_context *ctx,
}
}
+static LLVMValueRef radv_load_ssbo(struct ac_shader_abi *abi,
+ LLVMValueRef buffer, bool write)
+{
+ struct nir_to_llvm_context *ctx = nir_to_llvm_context_from_abi(abi);
+
+ if (write && ctx->stage == MESA_SHADER_FRAGMENT)
+ ctx->shader_info->fs.writes_memory = true;
+
+ return buffer;
+}
+
static LLVMValueRef radv_get_sampler_desc(struct ac_shader_abi *abi,
unsigned descriptor_set,
unsigned base_index,
@@ -6250,6 +6261,7 @@ LLVMModuleRef ac_translate_nir_to_llvm(LLVMTargetMachineRef tm,
ctx.abi.chip_class = options->chip_class;
ctx.abi.inputs = &ctx.inputs[0];
ctx.abi.emit_outputs = handle_shader_outputs_post;
+ ctx.abi.load_ssbo = radv_load_ssbo;
ctx.abi.load_sampler_desc = radv_get_sampler_desc;
nir_foreach_variable(variable, &nir->outputs)
diff --git a/src/amd/common/ac_shader_abi.h b/src/amd/common/ac_shader_abi.h
index fe804cf5c8e..efbd7de4608 100644
--- a/src/amd/common/ac_shader_abi.h
+++ b/src/amd/common/ac_shader_abi.h
@@ -59,6 +59,16 @@ struct ac_shader_abi {
LLVMValueRef (*load_ubo)(struct ac_shader_abi *abi, LLVMValueRef index);
/**
+ * Load the descriptor for the given buffer.
+ *
+ * \param buffer the buffer as presented in NIR: this is the descriptor
+ * in Vulkan, and the buffer index in OpenGL/Gallium
+ * \param write whether buffer contents will be written
+ */
+ LLVMValueRef (*load_ssbo)(struct ac_shader_abi *abi,
+ LLVMValueRef buffer, bool write);
+
+ /**
* Load a descriptor associated to a sampler.
*
* \param descriptor_set the descriptor set index (only for Vulkan)