From 4773f5a293d103ea225b54274026018275d208d9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Mon, 3 Jun 2019 19:43:44 -0400 Subject: [PATCH] radeonsi: use the ac helper for index buffer stores in the culling shader --- src/amd/common/ac_llvm_build.c | 5 +++-- src/amd/common/ac_llvm_build.h | 1 + src/amd/common/ac_nir_to_llvm.c | 2 +- .../radeonsi/si_compute_prim_discard.c | 21 ++++++++----------- .../drivers/radeonsi/si_shader_tgsi_mem.c | 2 +- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c index 0972406b5cb..88e89d1dfb4 100644 --- a/src/amd/common/ac_llvm_build.c +++ b/src/amd/common/ac_llvm_build.c @@ -1194,16 +1194,17 @@ ac_build_buffer_store_format(struct ac_llvm_context *ctx, LLVMValueRef voffset, unsigned num_channels, bool glc, + bool slc, bool writeonly_memory) { if (HAVE_LLVM >= 0x800) { ac_build_llvm8_buffer_store_common(ctx, rsrc, data, vindex, voffset, NULL, num_channels, - ctx->f32, glc, false, + ctx->f32, glc, slc, writeonly_memory, true, true); } else { ac_build_llvm7_buffer_store_common(ctx, rsrc, data, vindex, voffset, - num_channels, glc, false, + num_channels, glc, slc, writeonly_memory, true); } } diff --git a/src/amd/common/ac_llvm_build.h b/src/amd/common/ac_llvm_build.h index 5ed9a112457..bbdb01184e6 100644 --- a/src/amd/common/ac_llvm_build.h +++ b/src/amd/common/ac_llvm_build.h @@ -282,6 +282,7 @@ ac_build_buffer_store_format(struct ac_llvm_context *ctx, LLVMValueRef voffset, unsigned num_channels, bool glc, + bool slc, bool writeonly_memory); LLVMValueRef diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index 360e139bf5f..67dca7cabde 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -2556,7 +2556,7 @@ static void visit_image_store(struct ac_nir_context *ctx, ac_build_buffer_store_format(&ctx->ac, rsrc, src, vindex, ctx->ac.i32_0, src_channels, - args.cache_policy & ac_glc, + args.cache_policy & ac_glc, false, writeonly_memory); } else { args.opcode = ac_image_store; diff --git a/src/gallium/drivers/radeonsi/si_compute_prim_discard.c b/src/gallium/drivers/radeonsi/si_compute_prim_discard.c index 362c63c2e44..3bed818d5ad 100644 --- a/src/gallium/drivers/radeonsi/si_compute_prim_discard.c +++ b/src/gallium/drivers/radeonsi/si_compute_prim_discard.c @@ -856,18 +856,15 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) } /* Write indices for accepted primitives. */ - LLVMValueRef buf_args[] = { - ac_to_float(&ctx->ac, ac_build_expand_to_vec4(&ctx->ac, - ac_build_gather_values(&ctx->ac, index, 3), 3)), - output_indexbuf, - LLVMBuildAdd(builder, start, prim_index, ""), - ctx->i32_0, /* voffset */ - ctx->i1true, /* glc */ - LLVMConstInt(ctx->i1, INDEX_STORES_USE_SLC, 0), - }; - ac_build_intrinsic(&ctx->ac, "llvm.amdgcn.buffer.store.format.v4f32", - ctx->voidt, buf_args, 6, - ac_get_store_intr_attribs(true)); + LLVMValueRef vindex = LLVMBuildAdd(builder, start, prim_index, ""); + LLVMValueRef vdata = ac_build_gather_values(&ctx->ac, index, 3); + + if (!ac_has_vec3_support(ctx->ac.chip_class, true)) + vdata = ac_build_expand_to_vec4(&ctx->ac, vdata, 3); + + ac_build_buffer_store_format(&ctx->ac, output_indexbuf, vdata, + vindex, ctx->i32_0, 3, true, + INDEX_STORES_USE_SLC, true); } lp_build_endif(&if_accepted); diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c index 2cf1f902cee..5f60d8dc33f 100644 --- a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c +++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c @@ -728,7 +728,7 @@ static void store_emit( ac_build_gather_values(&ctx->ac, chans, num_channels), vindex, ctx->i32_0 /* voffset */, num_channels, - !!(args.cache_policy & ac_glc), + !!(args.cache_policy & ac_glc), false, writeonly_memory); } else { args.opcode = ac_image_store; -- 2.30.2