aboutsummaryrefslogtreecommitdiffstats
path: root/src/amd/common/ac_nir_to_llvm.c
diff options
context:
space:
mode:
authorBas Nieuwenhuizen <[email protected]>2018-12-24 15:41:56 +0100
committerBas Nieuwenhuizen <[email protected]>2019-01-07 14:54:14 +0100
commit9a45a190ad22849a492506389413046948e0b093 (patch)
treeef7555c0d84d39fae76e02749183694f3f33c92c /src/amd/common/ac_nir_to_llvm.c
parent00ad77b9f683e561b1ac45fbb89eb2bafe45c8c6 (diff)
radv: Implement buffer stores with less than 4 components.
We started using it in the btoi paths for r32g32b32, and the LLVM IR checker will complain about it because we end up with intrinsics with the wrong type extension in the name. Fixes: 593996bc02 ("radv: implement buffer to image operations for R32G32B32") Reviewed-by: Samuel Pitoiset <[email protected]>
Diffstat (limited to 'src/amd/common/ac_nir_to_llvm.c')
-rw-r--r--src/amd/common/ac_nir_to_llvm.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 84dbe174575..8dea35178b3 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -2392,24 +2392,33 @@ static void visit_image_store(struct ac_nir_context *ctx,
glc = ctx->ac.i1true;
if (dim == GLSL_SAMPLER_DIM_BUF) {
+ char name[48];
+ const char *types[] = { "f32", "v2f32", "v4f32" };
LLVMValueRef rsrc = get_image_buffer_descriptor(ctx, instr, true);
+ LLVMValueRef src = ac_to_float(&ctx->ac, get_src(ctx, instr->src[3]));
+ unsigned src_channels = ac_get_llvm_num_components(src);
- params[0] = ac_to_float(&ctx->ac, get_src(ctx, instr->src[3])); /* data */
+ if (src_channels == 3)
+ src = ac_build_expand(&ctx->ac, src, 3, 4);
+
+ params[0] = src; /* data */
params[1] = rsrc;
params[2] = LLVMBuildExtractElement(ctx->ac.builder, get_src(ctx, instr->src[1]),
ctx->ac.i32_0, ""); /* vindex */
params[3] = ctx->ac.i32_0; /* voffset */
+ snprintf(name, sizeof(name), "%s.%s",
+ HAVE_LLVM >= 0x800 ? "llvm.amdgcn.struct.buffer.store.format"
+ : "llvm.amdgcn.buffer.store.format",
+ types[CLAMP(src_channels, 1, 3) - 1]);
+
if (HAVE_LLVM >= 0x800) {
params[4] = ctx->ac.i32_0; /* soffset */
params[5] = glc ? ctx->ac.i32_1 : ctx->ac.i32_0;
- ac_build_intrinsic(&ctx->ac, "llvm.amdgcn.struct.buffer.store.format.v4f32", ctx->ac.voidt,
- params, 6, 0);
} else {
params[4] = glc; /* glc */
params[5] = ctx->ac.i1false; /* slc */
- ac_build_intrinsic(&ctx->ac, "llvm.amdgcn.buffer.store.format.v4f32", ctx->ac.voidt,
- params, 6, 0);
}
+ ac_build_intrinsic(&ctx->ac, name, ctx->ac.voidt, params, 6, 0);
} else {
struct ac_image_args args = {};
args.opcode = ac_image_store;