nvk/lower_descriptors: Move load_root_table up

Reviewed-by: Mary Guillemard <mary@mary.zone>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40639>
This commit is contained in:
Mel Henning 2026-03-13 17:03:05 -04:00 committed by Marge Bot
parent fc00e2c815
commit 153454a6fd

View file

@ -561,6 +561,44 @@ lower_load_constant(nir_builder *b, nir_intrinsic_instr *load,
return true;
}
static nir_def *
_load_root_table(nir_builder *b,
unsigned num_components, unsigned bit_size,
uint32_t root_table_offset,
const struct lower_descriptors_ctx *ctx)
{
unsigned align_mul = bit_size / 8;
return nir_ldc_nv(b, num_components, bit_size,
nir_imm_int(b, 0), /* Root table */
nir_imm_int(b, root_table_offset),
.align_mul = align_mul,
.align_offset = 0);
}
#define load_root_table(b, nc, bs, member, ctx) \
_load_root_table(b, nc, bs, nvk_root_descriptor_offset(member), ctx)
static bool
_lower_sysval_to_root_table(nir_builder *b, nir_intrinsic_instr *intrin,
uint32_t root_table_offset,
const struct lower_descriptors_ctx *ctx)
{
b->cursor = nir_instr_remove(&intrin->instr);
nir_def *val = _load_root_table(b, intrin->def.num_components,
intrin->def.bit_size,
root_table_offset, ctx);
nir_def_rewrite_uses(&intrin->def, val);
return true;
}
#define lower_sysval_to_root_table(b, intrin, member, ctx) \
_lower_sysval_to_root_table(b, intrin, \
nvk_root_descriptor_offset(member), \
ctx)
static nir_def *
load_descriptor_set_addr(nir_builder *b, uint32_t set,
UNUSED const struct lower_descriptors_ctx *ctx)
@ -762,44 +800,6 @@ try_lower_load_vulkan_descriptor(nir_builder *b, nir_intrinsic_instr *intrin,
return true;
}
static nir_def *
_load_root_table(nir_builder *b,
unsigned num_components, unsigned bit_size,
uint32_t root_table_offset,
const struct lower_descriptors_ctx *ctx)
{
unsigned align_mul = bit_size / 8;
return nir_ldc_nv(b, num_components, bit_size,
nir_imm_int(b, 0), /* Root table */
nir_imm_int(b, root_table_offset),
.align_mul = align_mul,
.align_offset = 0);
}
#define load_root_table(b, nc, bs, member, ctx) \
_load_root_table(b, nc, bs, nvk_root_descriptor_offset(member), ctx)
static bool
_lower_sysval_to_root_table(nir_builder *b, nir_intrinsic_instr *intrin,
uint32_t root_table_offset,
const struct lower_descriptors_ctx *ctx)
{
b->cursor = nir_instr_remove(&intrin->instr);
nir_def *val = _load_root_table(b, intrin->def.num_components,
intrin->def.bit_size,
root_table_offset, ctx);
nir_def_rewrite_uses(&intrin->def, val);
return true;
}
#define lower_sysval_to_root_table(b, intrin, member, ctx) \
_lower_sysval_to_root_table(b, intrin, \
nvk_root_descriptor_offset(member), \
ctx)
static bool
lower_load_push_constant(nir_builder *b, nir_intrinsic_instr *load,
const struct lower_descriptors_ctx *ctx)