panvk: Add MAX_VS_ATTRIBS to image indices in panvk_nir_lower_descriptors

It's only a couple lines of code since we're already doing this for
UBOs.  It doesn't need to be a separate pass.

Reviewed-by: Ryan Mckeever <ryan.mckeever@collabora.com>
Reviewed-by: Lars-Ivar Hesselberg Simonsen <lars-ivar.simonsen@arm.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41320>
This commit is contained in:
Faith Ekstrand 2026-05-01 12:16:01 -04:00 committed by Marge Bot
parent c73d4e14f9
commit 0a69efb22b
2 changed files with 21 additions and 13 deletions

View file

@ -49,6 +49,7 @@ struct lower_desc_info {
};
struct lower_desc_ctx {
mesa_shader_stage stage;
const struct panvk_descriptor_set_layout *set_layouts[MAX_SETS];
struct lower_desc_info desc_info;
struct hash_table_u64 *ht;
@ -161,14 +162,22 @@ shader_desc_idx(uint32_t set, uint32_t binding,
const struct lower_desc_map *map;
#if PAN_ARCH < 9
uint32_t table = PANVK_BIFROST_DESC_TABLE_INVALID;
if (bind_layout->type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) {
map = &ctx->desc_info.dyn_ubos;
} else if (bind_layout->type == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC) {
map = &ctx->desc_info.dyn_ssbos;
} else {
uint32_t table = desc_type_to_table_type(bind_layout, src.sampler_subdesc);
table = desc_type_to_table_type(bind_layout, src.sampler_subdesc);
assert(table < PANVK_BIFROST_DESC_TABLE_COUNT);
/* For some reason, GCC thinks the initialization above will lead to an
* OOB array access on ctx->desc_info.others[table] even though it
* clearly gets overwritten above. This gets rid of the warning.
*/
if (table >= PANVK_BIFROST_DESC_TABLE_COUNT)
return 0;
map = &ctx->desc_info.others[table];
}
#else
@ -180,11 +189,17 @@ shader_desc_idx(uint32_t set, uint32_t binding,
uint32_t idx = entry - map->map;
#if PAN_ARCH < 9
/* Adjust the destination index for all dynamic UBOs, which are laid out
* just after the regular UBOs in the UBO table. */
if (bind_layout->type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) {
/* Adjust the destination index for all dynamic UBOs, which are laid out
* just after the regular UBOs in the UBO table.
*/
idx += ctx->desc_info.others[PANVK_BIFROST_DESC_TABLE_UBO].count;
} else if (subdesc.type == VK_DESCRIPTOR_TYPE_SAMPLER) {
} else if (table == PANVK_BIFROST_DESC_TABLE_IMG) {
/* Images go after attributes in the attribute table. */
idx += ctx->stage == MESA_SHADER_VERTEX ? MAX_VS_ATTRIBS : 0;
}
if (subdesc.type == VK_DESCRIPTOR_TYPE_SAMPLER) {
/* the Cb/Cr planes share the same sampler, so in a 3 plane arrangement
* the number of planes can exceed the number of samplers */
idx += MIN2(subdesc.plane, bind_layout->samplers_per_desc - 1);
@ -1284,6 +1299,7 @@ panvk_per_arch(nir_lower_descriptors)(
struct panvk_shader_desc_info *desc_info)
{
struct lower_desc_ctx ctx = {
.stage = nir->info.stage,
.add_bounds_checks =
rs->storage_buffers !=
VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_DISABLED_EXT ||

View file

@ -966,14 +966,6 @@ panvk_compile_nir(struct panvk_device *dev, nir_shader *nir,
NIR_PASS(_, nir, nir_shader_intrinsics_pass, panvk_lower_load_vs_input,
nir_metadata_control_flow, NULL);
/* since valhall, panvk_per_arch(nir_lower_descriptors) separates the
* driver set and the user sets, and does not need pan_nir_lower_image_index
*/
if (PAN_ARCH < 9 && nir->info.stage == MESA_SHADER_VERTEX) {
NIR_PASS(_, nir, pan_nir_lower_image_index, MAX_VS_ATTRIBS);
NIR_PASS(_, nir, pan_nir_lower_texel_buffer_fetch_index, MAX_VS_ATTRIBS);
}
pan_postprocess_nir(nir, &input, &shader->info);
if (noperspective_varyings && nir->info.stage == MESA_SHADER_VERTEX) {