aboutsummaryrefslogtreecommitdiffstats
path: root/graphics/mesa-dri/files/patch-648dc52
blob: 4345fbf6c8d173e0069c0593d6962be72908d8eb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
https://gitlab.freedesktop.org/mesa/mesa/commit/648dc52367c6

--- src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c.orig  2019-01-17 11:26:22 UTC
+++ src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
@@ -698,17 +698,25 @@ static void store_emit(
    }
 
    if (target == TGSI_TEXTURE_BUFFER) {
-       LLVMValueRef buf_args[] = {
+       LLVMValueRef buf_args[6] = {
            value,
            args.resource,
            vindex,
            ctx->i32_0, /* voffset */
-           LLVMConstInt(ctx->i1, !!(args.cache_policy & ac_glc), 0),
-           LLVMConstInt(ctx->i1, !!(args.cache_policy & ac_slc), 0),
        };
 
+       if (HAVE_LLVM >= 0x0800) {
+           buf_args[4] = ctx->i32_0; /* soffset */
+           buf_args[5] = LLVMConstInt(ctx->i1, args.cache_policy, 0);
+       } else {
+           buf_args[4] = LLVMConstInt(ctx->i1, !!(args.cache_policy & ac_glc), 0);
+           buf_args[5] = LLVMConstInt(ctx->i1, !!(args.cache_policy & ac_slc), 0);
+       }
+
        emit_data->output[emit_data->chan] = ac_build_intrinsic(
-           &ctx->ac, "llvm.amdgcn.buffer.store.format.v4f32",
+           &ctx->ac,
+           HAVE_LLVM >= 0x0800 ? "llvm.amdgcn.struct.buffer.store.format.v4f32" :
+                         "llvm.amdgcn.buffer.store.format.v4f32",
            ctx->voidt, buf_args, 6,
            ac_get_store_intr_attribs(writeonly_memory));
    } else {
@@ -830,8 +838,35 @@ static void atomic_emit(
        vindex = args.coords[0]; /* for buffers only */
    }
 
-   if (inst->Src[0].Register.File == TGSI_FILE_BUFFER ||
+   if (HAVE_LLVM >= 0x0800 &&
+       inst->Src[0].Register.File != TGSI_FILE_BUFFER &&
        inst->Memory.Texture == TGSI_TEXTURE_BUFFER) {
+       LLVMValueRef buf_args[7];
+       unsigned num_args = 0;
+
+       buf_args[num_args++] = args.data[0];
+       if (inst->Instruction.Opcode == TGSI_OPCODE_ATOMCAS)
+           buf_args[num_args++] = args.data[1];
+
+       buf_args[num_args++] = args.resource;
+       buf_args[num_args++] = vindex;
+       buf_args[num_args++] = voffset;
+       buf_args[num_args++] = ctx->i32_0; /* soffset */
+       buf_args[num_args++] = LLVMConstInt(ctx->i32, args.cache_policy & ac_slc, 0);
+
+       char intrinsic_name[64];
+       snprintf(intrinsic_name, sizeof(intrinsic_name),
+            "llvm.amdgcn.struct.buffer.atomic.%s", action->intr_name);
+       emit_data->output[emit_data->chan] =
+           ac_to_float(&ctx->ac,
+                   ac_build_intrinsic(&ctx->ac, intrinsic_name,
+                              ctx->i32, buf_args, num_args, 0));
+       return;
+   }
+
+   if (inst->Src[0].Register.File == TGSI_FILE_BUFFER ||
+       (HAVE_LLVM < 0x0800 &&
+        inst->Memory.Texture == TGSI_TEXTURE_BUFFER)) {
        LLVMValueRef buf_args[7];
        unsigned num_args = 0;
 
 src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c | 45 ++++++++++++++++++++---
 src/gallium/drivers/radeonsi/si_state.c           |  7 +---
 2 files changed, 42 insertions(+), 10 deletions(-)

--- src/gallium/drivers/radeonsi/si_state.c.orig    2019-01-17 11:26:22 UTC
+++ src/gallium/drivers/radeonsi/si_state.c
@@ -3613,14 +3613,11 @@ si_make_buffer_descriptor(struct si_screen *screen, st
     * - For VMEM and inst.IDXEN == 0 or STRIDE == 0, it's in byte units.
     * - For VMEM and inst.IDXEN == 1 and STRIDE != 0, it's in units of STRIDE.
     */
-   if (screen->info.chip_class >= GFX9)
-       /* When vindex == 0, LLVM sets IDXEN = 0, thus changing units
+   if (screen->info.chip_class >= GFX9 && HAVE_LLVM < 0x0800)
+       /* When vindex == 0, LLVM < 8.0 sets IDXEN = 0, thus changing units
         * from STRIDE to bytes. This works around it by setting
         * NUM_RECORDS to at least the size of one element, so that
         * the first element is readable when IDXEN == 0.
-        *
-        * TODO: Fix this in LLVM, but do we need a new intrinsic where
-        *       IDXEN is enforced?
         */
        num_records = num_records ? MAX2(num_records, stride) : 0;
    else if (screen->info.chip_class == VI)