1 |
From e5b1fde8c2e35938cda8373dbd502bfa608fa8d9 Mon Sep 17 00:00:00 2001 |
2 |
From: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> |
3 |
Date: Mon, 24 Dec 2018 15:41:56 +0100 |
4 |
Subject: [PATCH 55/78] radv: Implement buffer stores with less than 4 |
5 |
components. |
6 |
|
7 |
We started using it in the btoi paths for r32g32b32, and the LLVM IR |
8 |
checker will complain about it because we end up with intrinsics with |
9 |
the wrong type extension in the name. |
10 |
|
11 |
Fixes: 593996bc02 ("radv: implement buffer to image operations for R32G32B32") |
12 |
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> |
13 |
(cherry picked from commit 9a45a190ad22849a492506389413046948e0b093) |
14 |
Signed-off-by: Emil Velikov <emil.velikov@collabora.com> |
15 |
|
16 |
Conflicts: |
17 |
src/amd/common/ac_nir_to_llvm.c |
18 |
--- |
19 |
src/amd/common/ac_nir_to_llvm.c | 16 +++++++++++++--- |
20 |
1 file changed, 13 insertions(+), 3 deletions(-) |
21 |
|
22 |
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c |
23 |
index c950b81dca..bd0e93b839 100644 |
24 |
--- a/src/amd/common/ac_nir_to_llvm.c |
25 |
+++ b/src/amd/common/ac_nir_to_llvm.c |
26 |
@@ -2380,17 +2380,27 @@ static void visit_image_store(struct ac_nir_context *ctx, |
27 |
glc = ctx->ac.i1true; |
28 |
|
29 |
if (dim == GLSL_SAMPLER_DIM_BUF) { |
30 |
+ char name[48]; |
31 |
+ const char *types[] = { "f32", "v2f32", "v4f32" }; |
32 |
LLVMValueRef rsrc = get_image_buffer_descriptor(ctx, instr, true); |
33 |
+ LLVMValueRef src = ac_to_float(&ctx->ac, get_src(ctx, instr->src[3])); |
34 |
+ unsigned src_channels = ac_get_llvm_num_components(src); |
35 |
|
36 |
- params[0] = ac_to_float(&ctx->ac, get_src(ctx, instr->src[3])); /* data */ |
37 |
+ if (src_channels == 3) |
38 |
+ src = ac_build_expand(&ctx->ac, src, 3, 4); |
39 |
+ |
40 |
+ params[0] = src; /* data */ |
41 |
params[1] = rsrc; |
42 |
params[2] = LLVMBuildExtractElement(ctx->ac.builder, get_src(ctx, instr->src[1]), |
43 |
ctx->ac.i32_0, ""); /* vindex */ |
44 |
params[3] = ctx->ac.i32_0; /* voffset */ |
45 |
+ snprintf(name, sizeof(name), "%s.%s", |
46 |
+ "llvm.amdgcn.buffer.store.format", |
47 |
+ types[CLAMP(src_channels, 1, 3) - 1]); |
48 |
+ |
49 |
params[4] = glc; /* glc */ |
50 |
params[5] = ctx->ac.i1false; /* slc */ |
51 |
- ac_build_intrinsic(&ctx->ac, "llvm.amdgcn.buffer.store.format.v4f32", ctx->ac.voidt, |
52 |
- params, 6, 0); |
53 |
+ ac_build_intrinsic(&ctx->ac, name, ctx->ac.voidt, params, 6, 0); |
54 |
} else { |
55 |
struct ac_image_args args = {}; |
56 |
args.opcode = ac_image_store; |
57 |
-- |
58 |
2.20.1 |
59 |
|