From afcbccb0781343eeed1b8543c23dcdc21748bcf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 6 Nov 2022 19:21:54 -0500 Subject: [PATCH] ac/llvm: implement ACCESS_USE_FORMAT_AMD as buffer_load/store_format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Rhys Perry Reviewed-by: Timur Kristóf Part-of: --- src/amd/llvm/ac_nir_to_llvm.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/amd/llvm/ac_nir_to_llvm.c b/src/amd/llvm/ac_nir_to_llvm.c index db4e8c9626e..dffa06ac630 100644 --- a/src/amd/llvm/ac_nir_to_llvm.c +++ b/src/amd/llvm/ac_nir_to_llvm.c @@ -4188,6 +4188,7 @@ static bool visit_intrinsic(struct ac_nir_context *ctx, nir_intrinsic_instr *ins bool reorder = nir_intrinsic_can_reorder(instr); bool coherent = nir_intrinsic_access(instr) & ACCESS_COHERENT; bool slc = nir_intrinsic_access(instr) & ACCESS_STREAM_CACHE_POLICY; + bool uses_format = nir_intrinsic_access(instr) & ACCESS_USES_FORMAT_AMD; enum ac_image_cache_policy cache_policy = 0; if (swizzled) @@ -4197,7 +4198,18 @@ static bool visit_intrinsic(struct ac_nir_context *ctx, nir_intrinsic_instr *ins if (coherent) cache_policy |= ac_glc; - if (instr->intrinsic == nir_intrinsic_load_buffer_amd) { + LLVMValueRef voffset = LLVMBuildAdd(ctx->ac.builder, addr_voffset, + LLVMConstInt(ctx->ac.i32, const_offset, 0), ""); + + if (instr->intrinsic == nir_intrinsic_load_buffer_amd && uses_format) { + assert(instr->dest.ssa.bit_size == 16 || instr->dest.ssa.bit_size == 32); + result = ac_build_buffer_load_format(&ctx->ac, descriptor, vidx, voffset, num_components, + cache_policy, reorder, + instr->dest.ssa.bit_size == 16, false); + } else if (instr->intrinsic == nir_intrinsic_store_buffer_amd && uses_format) { + assert(instr->src[0].ssa->bit_size == 16 || instr->src[0].ssa->bit_size == 32); + ac_build_buffer_store_format(&ctx->ac, descriptor, store_data, vidx, voffset, cache_policy); + } else if (instr->intrinsic == nir_intrinsic_load_buffer_amd) { LLVMTypeRef channel_type; if (instr->dest.ssa.bit_size == 8) channel_type = ctx->ac.i8; @@ -4212,8 +4224,6 @@ static bool visit_intrinsic(struct ac_nir_context *ctx, nir_intrinsic_instr *ins else unreachable("Unsupported channel type for load_buffer_amd"); - LLVMValueRef voffset = LLVMBuildAdd(ctx->ac.builder, addr_voffset, - LLVMConstInt(ctx->ac.i32, const_offset, 0), ""); result = ac_build_buffer_load(&ctx->ac, descriptor, num_components, vidx, voffset, addr_soffset, channel_type, cache_policy, reorder, false);