ac: remove txf buffer code from ACO & LLVM

Reviewed-by: Georg Lehmann <dadschoorse@gmail.com> (aco)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39474>
This commit is contained in:
Marek Olšák 2026-01-22 20:13:21 -05:00 committed by Marge Bot
parent 85916c8af0
commit c05d340184
2 changed files with 8 additions and 68 deletions

View file

@ -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<Instruction> 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<Temp> args;
if (has_wqm_coord) {

View file

@ -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