zink: Fix NIR validation error in cubemap-to-array lowering

The cubemap-to-array pass was changing variable types from samplerCubeArray
to sampler2DArray but leaving the corresponding deref instruction types
unchanged. This caused NIR validation to fail with "instr->type ==
instr->var->type" assertion.

Fix by updating both the variable type and the deref instruction type
to maintain consistency required by NIR validation.

Cc: mesa-stable
Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35117>
(cherry picked from commit 86f7ce06be)
This commit is contained in:
Christian Gmeiner 2025-05-22 19:34:48 +02:00 committed by Eric Engestrom
parent 3b265663aa
commit f1672e0be2
2 changed files with 4 additions and 2 deletions

View file

@ -2274,7 +2274,7 @@
"description": "zink: Fix NIR validation error in cubemap-to-array lowering",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -388,9 +388,11 @@ lower_cube_coords(nir_builder *b, nir_def *coord, bool is_array)
static void
rewrite_cube_var_type(nir_builder *b, nir_tex_instr *tex)
{
nir_variable *sampler = nir_deref_instr_get_variable(nir_instr_as_deref(tex->src[nir_tex_instr_src_index(tex, nir_tex_src_texture_deref)].src.ssa->parent_instr));
nir_deref_instr *texture_deref = nir_instr_as_deref(tex->src[nir_tex_instr_src_index(tex, nir_tex_src_texture_deref)].src.ssa->parent_instr);
nir_variable *sampler = nir_deref_instr_get_variable(texture_deref);
assert(sampler);
sampler->type = make_2darray_from_cubemap_with_array(sampler->type);
texture_deref->type = sampler->type;
}
/* txb(s, coord, bias) = txl(s, coord, lod(s, coord).y + bias) */