spirv: only consider IO variables when adjusting patch locations for TES

With TES, the primitive ID is an input variable but it's considered a
sysval by SPIRV->NIR. Though, its value is greater than
VARYING_SLOT_VAR0 which means its location was adjusted by mistake.

This fixes compiling a tessellation evaluation shader in debug build
with Enshrouded.

Fixes: dfbc03fa88 ("spirv: Fix locations for per-patch varyings")
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27413>
(cherry picked from commit 78ea304a06)
This commit is contained in:
Samuel Pitoiset 2024-01-30 14:48:12 +01:00 committed by Eric Engestrom
parent d0ea44cfdc
commit d3df85a197
2 changed files with 4 additions and 2 deletions

View file

@ -2014,7 +2014,7 @@
"description": "spirv: only consider IO variables when adjusting patch locations for TES",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "dfbc03fa88478126607c69723a61280f6e9a011f",
"notes": null

View file

@ -2024,7 +2024,9 @@ adjust_patch_locations(struct vtn_builder *b, struct vtn_variable *var)
for (uint16_t i = 0; i < num_data; i++) {
vtn_assert(data[i].location < VARYING_SLOT_PATCH0);
if (data[i].patch && data[i].location >= VARYING_SLOT_VAR0)
if (data[i].patch &&
(data[i].mode == nir_var_shader_in || data[i].mode == nir_var_shader_out) &&
data[i].location >= VARYING_SLOT_VAR0)
data[i].location += VARYING_SLOT_PATCH0 - VARYING_SLOT_VAR0;
}
}