From d3df85a1979b999e2f9b411e4f32aedc2bdbbe78 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: (cherry picked from commit 78ea304a06cda5ddfed9cabb7c13ea2a82392ece) --- .pick_status.json | 2 +- src/compiler/spirv/vtn_variables.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index d59dab2e7bf..300b2aced5b 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -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 diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c index ce4b19134ab..49c07b950c9 100644 --- a/src/compiler/spirv/vtn_variables.c +++ b/src/compiler/spirv/vtn_variables.c @@ -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; } }