nir: fix uniform cloning helper

glsl allows for ubos to have the same name but different bindings.

Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Fixes: b47b8d16d9 ("nir: expose reusable linking helpers for cloning uniform loads")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12852
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34138>
(cherry picked from commit 2b2132d2ac)
This commit is contained in:
Timothy Arceri 2025-03-24 15:20:55 +11:00 committed by Eric Engestrom
parent 20e09c3081
commit de5de2ec60
2 changed files with 4 additions and 2 deletions

View file

@ -4034,7 +4034,7 @@
"description": "nir: fix uniform cloning helper",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "b47b8d16d94792cc4694f350b4bad212e357e9f0",
"notes": null

View file

@ -1171,7 +1171,9 @@ nir_clone_uniform_variable(nir_shader *nir, nir_variable *uniform, bool spirv)
nir_foreach_variable_with_modes(v, nir, uniform->data.mode) {
if ((spirv && uniform->data.mode & nir_var_mem_ubo &&
v->data.binding == uniform->data.binding) ||
(!spirv && !strcmp(uniform->name, v->name))) {
(!spirv &&
((!strcmp(uniform->name, v->name) && !uniform->data.explicit_binding && !v->data.explicit_binding) ||
(uniform->data.explicit_binding && v->data.explicit_binding && v->data.binding == uniform->data.binding)))) {
new_var = v;
break;
}