Skip to content

glsl: Use a stable attr sort on Windows

Jesse Natalie requested to merge jenatali/mesa:stable-attr-sort into main

This is a problem that's burned me before (piglit!623 (merged)): The stability guarantees of qsort is different between different C runtimes. Looks like generally on Linux you get a stable sort, while the MSVCRT doesn't give you a stable sort. The end result is portability problems - apps that work on Windows proprietary drivers and on Linux Mesa drivers don't work on Windows Mesa drivers. This is caused by apps not setting vertex attribute locations, letting them get automatically assigned, and assuming that they'll be in source declaration order, which is true as long as they all take one slot and qsort is stable.

The easiest way to get a stable sort is to use std::stable_sort. This compiler is already C++. I know the STL is taboo on Linux, but it's generally fine on Windows. Any objections to using it here?

Merge request reports