From c05d340184b6924e353f3e9b2f1728fa77e6c938 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 22 Jan 2026 20:13:21 -0500 Subject: [PATCH] ac: remove txf buffer code from ACO & LLVM Reviewed-by: Georg Lehmann (aco) Part-of: --- .../instruction_selection/aco_select_nir.cpp | 53 ++----------------- src/amd/llvm/ac_nir_to_llvm.c | 23 ++------ 2 files changed, 8 insertions(+), 68 deletions(-) diff --git a/src/amd/compiler/instruction_selection/aco_select_nir.cpp b/src/amd/compiler/instruction_selection/aco_select_nir.cpp index 35c5c0f8c17..03019d3b667 100644 --- a/src/amd/compiler/instruction_selection/aco_select_nir.cpp +++ b/src/amd/compiler/instruction_selection/aco_select_nir.cpp @@ -290,20 +290,16 @@ visit_tex(isel_context* ctx, nir_tex_instr* instr) has_derivs = true; } - unsigned dim = 0; - bool da = false; - if (instr->sampler_dim != GLSL_SAMPLER_DIM_BUF) { - dim = ac_get_sampler_dim(ctx->options->gfx_level, instr->sampler_dim, instr->is_array); - da = should_declare_array((ac_image_dim)dim); - } + assert(instr->sampler_dim != GLSL_SAMPLER_DIM_BUF); + + unsigned dim = ac_get_sampler_dim(ctx->options->gfx_level, instr->sampler_dim, instr->is_array); + bool da = should_declare_array((ac_image_dim)dim); /* Build tex instruction */ unsigned dmask = nir_def_components_read(&instr->def); /* Mask out the bit set for the sparse info. */ if (instr->is_sparse) dmask &= ~(1u << (instr->def.num_components - 1)); - if (instr->sampler_dim == GLSL_SAMPLER_DIM_BUF) - dmask = u_bit_consecutive(0, util_last_bit(dmask)); /* Set the 5th bit for the sparse code. */ if (instr->is_sparse) dmask = MAX2(dmask, 1) | 0x10; @@ -430,47 +426,6 @@ visit_tex(isel_context* ctx, nir_tex_instr* instr) coords[1] = new_coords[1]; } - if (instr->sampler_dim == GLSL_SAMPLER_DIM_BUF) { - // FIXME: if (ctx->abi->gfx9_stride_size_workaround) return - // ac_build_buffer_load_format_gfx9_safe() - - assert(coords.size() == 1); - aco_opcode op; - if (d16) { - switch (util_last_bit(dmask & 0xf)) { - case 1: op = aco_opcode::buffer_load_format_d16_x; break; - case 2: op = aco_opcode::buffer_load_format_d16_xy; break; - case 3: op = aco_opcode::buffer_load_format_d16_xyz; break; - case 4: op = aco_opcode::buffer_load_format_d16_xyzw; break; - default: UNREACHABLE("Tex instruction loads more than 4 components."); - } - } else { - switch (util_last_bit(dmask & 0xf)) { - case 1: op = aco_opcode::buffer_load_format_x; break; - case 2: op = aco_opcode::buffer_load_format_xy; break; - case 3: op = aco_opcode::buffer_load_format_xyz; break; - case 4: op = aco_opcode::buffer_load_format_xyzw; break; - default: UNREACHABLE("Tex instruction loads more than 4 components."); - } - } - - aco_ptr mubuf{ - create_instruction(op, Format::MUBUF, 3 + instr->is_sparse + 2 * disable_wqm, 1)}; - mubuf->operands[0] = Operand(resource); - mubuf->operands[1] = Operand(coords[0]); - mubuf->operands[2] = Operand::c32(0); - mubuf->definitions[0] = Definition(tmp_dst); - mubuf->mubuf().idxen = true; - mubuf->mubuf().tfe = instr->is_sparse; - if (mubuf->mubuf().tfe) - mubuf->operands[3] = emit_tfe_init(bld, tmp_dst); - init_disable_wqm(bld, mubuf->mubuf(), disable_wqm); - ctx->block->instructions.emplace_back(std::move(mubuf)); - - expand_vector(ctx, tmp_dst, dst, instr->def.num_components, dmask); - return; - } - /* gather MIMG address components */ std::vector args; if (has_wqm_coord) { diff --git a/src/amd/llvm/ac_nir_to_llvm.c b/src/amd/llvm/ac_nir_to_llvm.c index 9793dcf0a07..d701de77f98 100644 --- a/src/amd/llvm/ac_nir_to_llvm.c +++ b/src/amd/llvm/ac_nir_to_llvm.c @@ -1465,19 +1465,7 @@ static LLVMValueRef build_tex_intrinsic(struct ac_nir_context *ctx, const nir_te struct ac_image_args *args) { assert((!args->tfe || !args->d16) && "unsupported"); - - if (instr->sampler_dim == GLSL_SAMPLER_DIM_BUF) { - unsigned mask = nir_def_components_read(&instr->def); - - /* Buffers don't support A16. */ - if (args->a16) - args->coords[0] = LLVMBuildZExt(ctx->ac.builder, args->coords[0], ctx->ac.i32, ""); - - return ac_build_buffer_load_format(&ctx->ac, args->resource, args->coords[0], ctx->ac.i32_0, - util_last_bit(mask), 0, true, - instr->def.bit_size == 16, - args->tfe); - } + assert(instr->sampler_dim != GLSL_SAMPLER_DIM_BUF); args->opcode = ac_image_sample; @@ -3553,8 +3541,7 @@ static void tex_fetch_ptrs(struct ac_nir_context *ctx, nir_tex_instr *instr, } } - enum ac_descriptor_type main_descriptor = - instr->sampler_dim == GLSL_SAMPLER_DIM_BUF ? AC_DESC_BUFFER : AC_DESC_IMAGE; + enum ac_descriptor_type main_descriptor = AC_DESC_IMAGE; if (plane >= 0) { assert(instr->op != nir_texop_txf_ms); @@ -3749,10 +3736,8 @@ static void visit_tex(struct ac_nir_context *ctx, nir_tex_instr *instr) args.dmask = BITFIELD_MASK(num_components); } - if (instr->sampler_dim != GLSL_SAMPLER_DIM_BUF) { - args.dim = ac_get_sampler_dim(ctx->ac.gfx_level, instr->sampler_dim, instr->is_array); - args.unorm = instr->sampler_dim == GLSL_SAMPLER_DIM_RECT; - } + args.dim = ac_get_sampler_dim(ctx->ac.gfx_level, instr->sampler_dim, instr->is_array); + args.unorm = instr->sampler_dim == GLSL_SAMPLER_DIM_RECT; /* Adjust the number of coordinates because we only need (x,y) for 2D * multisampled images and (x,y,layer) for 2D multisampled layered