Skip to content

glsl: remove qsort undefined behavior in gl_nir_link_varyings

Eric Smith requested to merge ericsmith/mesa:xfb-qsort-fixes into main
glsl: remove remove qsort undefined behavior in gl_nir_link_varyings

The comments in gl_nir_link_varyings.c discuss how the code depends on
certain undefined behavior of qsort. But in fact qsort no longer
behaves this way (at least on my Debian 12 system) and yet the code
still works. Moreover, relying on undefined behavior is a bad idea. This
patch makes the sorting behavior more explict.

It also fixes a problem encountered on panfrost, where qsort could
mix xfb and non-xfb varyings which started out separate. This was
because the sort functions were only checking the first variable
for whether it was xfb, when it fact they should have checked both.

Signed-off-by: Eric R. Smith <eric.smith@collabora.com>
Edited by Eric Smith

Merge request reports