microsoft/compiler: When sorting patch varyings, adjust location to be in normal varying range

This way, patch varyings come before the patch sysvals (tess levels).

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14399>
This commit is contained in:
Jesse Natalie 2022-01-03 13:33:53 -08:00 committed by Marge Bot
parent 4bb4d0454d
commit 8e42891f69
1 changed files with 8 additions and 2 deletions

View File

@ -1723,10 +1723,16 @@ static int
variable_location_cmp(const nir_variable* a, const nir_variable* b)
{
// Sort by driver_location, location, then index
unsigned a_location = a->data.location;
if (a_location >= VARYING_SLOT_PATCH0)
a_location -= VARYING_SLOT_PATCH0;
unsigned b_location = b->data.location;
if (b_location >= VARYING_SLOT_PATCH0)
b_location -= VARYING_SLOT_PATCH0;
return a->data.driver_location != b->data.driver_location ?
a->data.driver_location - b->data.driver_location :
a->data.location != b->data.location ?
a->data.location - b->data.location :
a_location != b_location ?
a_location - b_location :
a->data.index - b->data.index;
}