From bdcb7bc674ae9794a9956496435009d4b2f4b9bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 25 Nov 2025 15:42:09 -0500 Subject: [PATCH] nir/gather_info: clear clip/cull_distance_array_size if the IO is not present Part-of: --- src/compiler/nir/nir_gather_info.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/compiler/nir/nir_gather_info.c b/src/compiler/nir/nir_gather_info.c index b5e28432a03..0fb27bdae59 100644 --- a/src/compiler/nir/nir_gather_info.c +++ b/src/compiler/nir/nir_gather_info.c @@ -1140,4 +1140,19 @@ nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint) shader->info.ray_queries += MAX2(glsl_get_aoa_size(var->type), 1); } } + + /* Clip distance varyings might have been eliminated because they only + * contained out-of-bounds writes. Clear clip/cull distance array sizes + * in shader_info if they no longer exist. The array sizes refer to + * outputs except FS where they refer to inputs. + */ + uint64_t clipdist_io_mask = shader->info.stage == MESA_SHADER_FRAGMENT ? + shader->info.inputs_read : + shader->info.outputs_written; + if (!(clipdist_io_mask & + (BITFIELD64_RANGE(VARYING_SLOT_CLIP_DIST0, 2) | + BITFIELD64_RANGE(VARYING_SLOT_CULL_DIST0, 2)))) { + shader->info.clip_distance_array_size = 0; + shader->info.cull_distance_array_size = 0; + } }