nir/gather_info: clear clip/cull_distance_array_size if the IO is not present

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38465>
This commit is contained in:
Marek Olšák 2025-11-25 15:42:09 -05:00 committed by Marge Bot
parent a03b686805
commit bdcb7bc674

View file

@ -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;
}
}