From 9d518272a6a7deb8f82cdfa2a1d6a56e8af5a006 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 15 Apr 2021 10:20:29 -0400 Subject: [PATCH] zink: fix tcs input reservation for user vars tcs user vars are var_size[32], which isn't actually how many slots they need, just how big the variable is (oops), so this needs to be divided by MAX_PATCH_VERTICES to get the real slot count slot mapping has always been broken for all tcs inputs, but this probably fixes all of the related issues there, including unlimited crashes when playing Tomb Raider Fixes: 2d98efd3232 ("zink: pre-populate locations in variables") Acked-by: Erik Faye-Lund Part-of: (cherry picked from commit 001c6f820164be6c80b3e0d05b84f083234c90e9) --- .pick_status.json | 2 +- src/gallium/drivers/zink/zink_compiler.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index d9f4ca1fe94..4957a17a6d0 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -931,7 +931,7 @@ "description": "zink: fix tcs input reservation for user vars", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": "2d98efd3232565fe4942627e2e8c23a0eb2a670c" }, diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c index 7b06c19cee7..cff1f6d671f 100644 --- a/src/gallium/drivers/zink/zink_compiler.c +++ b/src/gallium/drivers/zink/zink_compiler.c @@ -550,7 +550,10 @@ assign_io_locations(nir_shader *nir, unsigned char *shader_slot_map, if (shader_slot_map[var->data.location] == 0xff) { assert(reserved < MAX_VARYING); shader_slot_map[var->data.location] = reserved; - reserved += glsl_count_vec4_slots(var->type, false, false); + if (nir->info.stage == MESA_SHADER_TESS_CTRL && var->data.location >= VARYING_SLOT_VAR0) + reserved += (glsl_count_vec4_slots(var->type, false, false) / 32 /*MAX_PATCH_VERTICES*/); + else + reserved += glsl_count_vec4_slots(var->type, false, false); } slot = shader_slot_map[var->data.location]; assert(slot < MAX_VARYING);