[5/9] radeonsi: use the ac helper for image stores

Submitted by Marek Olšák on June 4, 2019, 12:02 a.m.

Details

Message ID 20190604000258.9143-5-maraeo@gmail.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Marek Olšák June 4, 2019, 12:02 a.m.
From: Marek Olšák <marek.olsak@amd.com>

---
 .../drivers/radeonsi/si_shader_tgsi_mem.c     | 35 ++++---------------
 1 file changed, 6 insertions(+), 29 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
index 63184a4f396..cc634f495ef 100644
--- a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
+++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c
@@ -723,50 +723,27 @@  static void store_emit(
 
 	if (inst->Dst[0].Register.File == TGSI_FILE_BUFFER) {
 		store_emit_buffer(ctx, args.resource, inst->Dst[0].Register.WriteMask,
 				  ac_build_gather_values(&ctx->ac, chans, 4),
 				  voffset, args.cache_policy, writeonly_memory);
 		return;
 	}
 
 	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);
 		args.dim = ac_image_dim_from_tgsi_target(ctx->screen, inst->Memory.Texture);
 		args.attributes = ac_get_store_intr_attribs(writeonly_memory);
 		args.dmask = 0xf;
 
 		emit_data->output[emit_data->chan] =
 			ac_build_image_opcode(&ctx->ac, &args);
 	}