From 4945cf1b446c309a4e11985566f8bf3b538e6325 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Mon, 11 May 2026 09:29:53 +0200 Subject: [PATCH] spirv: preserve the explicit stride for untyped pointers with matrices Make sure to cast with the deref type that contains more information than the returned type because it's valid in SPIR-V. This fixes dEQP-VK.binding_model.descriptor_heap.graphics.*_vectors and also the PositiveGpuAV.HeapWithUntypedPointers VVL test. Cc: mesa-stable Signed-off-by: Samuel Pitoiset (cherry picked from commit 975ae012087a74491c75972583ab6d3197566b80) Part-of: --- .pick_status.json | 2 +- src/compiler/spirv/vtn_variables.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index d11c6d9c18f..fc876106b78 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -904,7 +904,7 @@ "description": "spirv: preserve the explicit stride for untyped pointers with matrices", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c index fd597a3d6e7..392b3c29bc3 100644 --- a/src/compiler/spirv/vtn_variables.c +++ b/src/compiler/spirv/vtn_variables.c @@ -2665,9 +2665,20 @@ vtn_cast_pointer(struct vtn_builder *b, struct vtn_pointer *p, vtn_assert(pointed == casted->type->pointed); if (p->deref) { + const struct glsl_type *deref_type = pointed->type; + + /* Preserve the explicit stride when casting an untyped pointer to a raw + * SPIR-V matrix type because the raw type lacks it. + */ + if (glsl_type_is_matrix(p->deref->type) && + glsl_type_is_matrix(deref_type) && + glsl_get_explicit_stride(p->deref->type) > 0 && + glsl_get_explicit_stride(deref_type) == 0) + deref_type = p->deref->type; + casted->deref = nir_build_deref_cast(&b->nb, &p->deref->def, p->deref->modes, - pointed->type, 0); + deref_type, 0); } else if (p->desc_index != NULL) { /* Nothing to do for descriptor index pointers. */ } else if (p->var != NULL) {