From 6e67f2a99617c618d66b7041c99f77ffcba8e19a Mon Sep 17 00:00:00 2001 From: Lorenzo Rossi Date: Sat, 4 Apr 2026 22:08:15 +0200 Subject: [PATCH] pan/compiler: Don't crash nopersp if pos is undefined VS does not need to write the position, it can also leave it as undefined. We agree that there isn't much sense in noperspective varyings with undefined perspective, but we still do not want to crash. This does lead to some real crashes if we mistake some int varying to noperspective (see next commit). Signed-off-by: Lorenzo Rossi Reviewed-by: Christoph Pillmayer Reviewed-by: Faith Ekstrand Reviewed-by: Lars-Ivar Hesselberg Simonsen Part-of: --- src/panfrost/compiler/pan_nir_lower_noperspective.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/panfrost/compiler/pan_nir_lower_noperspective.c b/src/panfrost/compiler/pan_nir_lower_noperspective.c index f130f8fc0dc..12925f0ea35 100644 --- a/src/panfrost/compiler/pan_nir_lower_noperspective.c +++ b/src/panfrost/compiler/pan_nir_lower_noperspective.c @@ -256,8 +256,11 @@ pan_nir_lower_noperspective_vs(nir_shader *shader) return false; nir_intrinsic_instr *pos_store = find_pos_store(impl); - assert(pos_store); - assert(nir_intrinsic_write_mask(pos_store) & BITFIELD_BIT(3)); + /* gl_Position may be written, it can also be left undefined */ + bool has_pos_w = + pos_store && !!(nir_intrinsic_write_mask(pos_store) & BITFIELD_BIT(3)); + if (!has_pos_w) + return false; nir_builder b = nir_builder_at(nir_after_instr(&pos_store->instr));