From 78ea304a06cda5ddfed9cabb7c13ea2a82392ece Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Tue, 30 Jan 2024 14:48:12 +0100 Subject: [PATCH] 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: dfbc03fa884 ("spirv: Fix locations for per-patch varyings") Signed-off-by: Samuel Pitoiset Part-of: --- src/compiler/spirv/vtn_variables.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c index e1a956843ec..9cde5ca1f9b 100644 --- a/src/compiler/spirv/vtn_variables.c +++ b/src/compiler/spirv/vtn_variables.c @@ -2044,7 +2044,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; } }