radeonsi: use the ac helper for image stores
authorMarek Olšák <marek.olsak@amd.com>
Mon, 3 Jun 2019 20:35:37 +0000 (16:35 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 12 Jun 2019 00:05:21 +0000 (20:05 -0400)
src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c

index 896f51f..2cf1f90 100644 (file)
@@ -723,36 +723,13 @@ static void store_emit(
 
        if (target == TGSI_TEXTURE_BUFFER) {
                unsigned num_channels = util_last_bit(inst->Dst[0].Register.WriteMask);
-               num_channels = util_next_power_of_two(num_channels);
-
-               LLVMValueRef buf_args[6] = {
-                       ac_build_gather_values(&ctx->ac, chans, 4),
-                       args.resource,
-                       vindex,
-                       ctx->i32_0, /* voffset */
-               };
-
-               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);
-               }
-
-               const char *types[] = { "f32", "v2f32", "v4f32" };
-               char name[128];
 
-               snprintf(name, sizeof(name), "%s.%s",
-                        HAVE_LLVM >= 0x0800 ? "llvm.amdgcn.struct.buffer.store.format" :
-                                              "llvm.amdgcn.buffer.store.format",
-                        types[CLAMP(num_channels, 1, 3) - 1]);
-
-               emit_data->output[emit_data->chan] = ac_build_intrinsic(
-                       &ctx->ac,
-                       name,
-                       ctx->voidt, buf_args, 6,
-                       ac_get_store_intr_attribs(writeonly_memory));
+               ac_build_buffer_store_format(&ctx->ac, args.resource,
+                                            ac_build_gather_values(&ctx->ac, chans, num_channels),
+                                            vindex, ctx->i32_0 /* voffset */,
+                                            num_channels,
+                                            !!(args.cache_policy & ac_glc),
+                                            writeonly_memory);
        } else {
                args.opcode = ac_image_store;
                args.data[0] = ac_build_gather_values(&ctx->ac, chans, 4);