ac/llvm: pass soffset to buffer_load/store_format

this will be needed in the future

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39536>
This commit is contained in:
Marek Olšák 2026-01-10 20:50:55 -05:00 committed by Marge Bot
parent d6a5bb3808
commit f096652aec
3 changed files with 16 additions and 11 deletions

View file

@ -889,10 +889,10 @@ static void ac_build_buffer_store_common(struct ac_llvm_context *ctx, LLVMValueR
}
void ac_build_buffer_store_format(struct ac_llvm_context *ctx, LLVMValueRef rsrc, LLVMValueRef data,
LLVMValueRef vindex, LLVMValueRef voffset, enum gl_access_qualifier access,
bool may_subdword)
LLVMValueRef vindex, LLVMValueRef voffset, LLVMValueRef soffset,
enum gl_access_qualifier access, bool may_subdword)
{
ac_build_buffer_store_common(ctx, rsrc, data, vindex, voffset, NULL, access, may_subdword, true);
ac_build_buffer_store_common(ctx, rsrc, data, vindex, voffset, soffset, access, may_subdword, true);
}
/* buffer_store_dword(,x2,x3,x4) <- the suffix is selected by the type of vdata. */
@ -1052,10 +1052,11 @@ LLVMValueRef ac_build_buffer_load(struct ac_llvm_context *ctx, LLVMValueRef rsrc
LLVMValueRef ac_build_buffer_load_format(struct ac_llvm_context *ctx, LLVMValueRef rsrc,
LLVMValueRef vindex, LLVMValueRef voffset,
unsigned num_channels, enum gl_access_qualifier access,
LLVMValueRef soffset, unsigned num_channels,
enum gl_access_qualifier access,
bool can_speculate, bool d16, bool tfe)
{
return ac_build_buffer_load_common(ctx, rsrc, vindex, voffset, ctx->i32_0,
return ac_build_buffer_load_common(ctx, rsrc, vindex, voffset, soffset,
num_channels, d16 ? ctx->f16 : ctx->f32, access,
can_speculate, true, tfe);
}

View file

@ -232,7 +232,8 @@ void ac_build_buffer_store_dword(struct ac_llvm_context *ctx, LLVMValueRef rsrc,
enum gl_access_qualifier access, bool may_subdword);
void ac_build_buffer_store_format(struct ac_llvm_context *ctx, LLVMValueRef rsrc, LLVMValueRef data,
LLVMValueRef vindex, LLVMValueRef voffset, enum gl_access_qualifier access, bool may_subdword);
LLVMValueRef vindex, LLVMValueRef voffset, LLVMValueRef soffset,
enum gl_access_qualifier access, bool may_subdword);
LLVMValueRef ac_build_buffer_load(struct ac_llvm_context *ctx, LLVMValueRef rsrc, int num_channels,
LLVMValueRef vindex, LLVMValueRef voffset, LLVMValueRef soffset,
@ -241,8 +242,9 @@ LLVMValueRef ac_build_buffer_load(struct ac_llvm_context *ctx, LLVMValueRef rsrc
LLVMValueRef ac_build_buffer_load_format(struct ac_llvm_context *ctx, LLVMValueRef rsrc,
LLVMValueRef vindex, LLVMValueRef voffset,
unsigned num_channels, enum gl_access_qualifier access,
bool can_speculate, bool d16, bool tfe);
LLVMValueRef soffset, unsigned num_channels,
enum gl_access_qualifier access, bool can_speculate,
bool d16, bool tfe);
LLVMValueRef ac_build_buffer_load_short(struct ac_llvm_context *ctx, LLVMValueRef rsrc,
LLVMValueRef voffset, LLVMValueRef soffset,

View file

@ -2279,7 +2279,8 @@ static void visit_image_store(struct ac_nir_context *ctx, const nir_intrinsic_in
vindex =
LLVMBuildExtractElement(ctx->ac.builder, get_src(ctx, instr->src[1]), ctx->ac.i32_0, "");
ac_build_buffer_store_format(&ctx->ac, rsrc, src, vindex, ctx->ac.i32_0, args.access, true);
ac_build_buffer_store_format(&ctx->ac, rsrc, src, vindex, ctx->ac.i32_0, ctx->ac.i32_0,
args.access, true);
} else {
bool level_zero = nir_src_is_const(instr->src[4]) && nir_src_as_uint(instr->src[4]) == 0;
@ -3038,13 +3039,14 @@ static bool visit_intrinsic(struct ac_nir_context *ctx, nir_intrinsic_instr *ins
if (instr->intrinsic == nir_intrinsic_load_buffer_amd && uses_format) {
assert(instr->def.bit_size == 16 || instr->def.bit_size == 32);
result = ac_build_buffer_load_format(&ctx->ac, descriptor, vidx, voffset,
result = ac_build_buffer_load_format(&ctx->ac, descriptor, vidx, voffset, addr_soffset,
num_components - is_sparse, access, reorder,
instr->def.bit_size == 16, is_sparse);
result = ac_to_integer(&ctx->ac, result);
} 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, access, true);
ac_build_buffer_store_format(&ctx->ac, descriptor, store_data, vidx, voffset,
addr_soffset, access, true);
} else if (instr->intrinsic == nir_intrinsic_load_buffer_amd ||
instr->intrinsic == nir_intrinsic_load_typed_buffer_amd) {
/* LLVM is unable to select instructions for larger than 32-bit channel types.