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: 2d98efd323 ("zink: pre-populate locations in variables")

Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10269>
(cherry picked from commit 001c6f8201)
This commit is contained in:
Mike Blumenkrantz 2021-04-15 10:20:29 -04:00 committed by Eric Engestrom
parent 54908b2307
commit 9d518272a6
2 changed files with 5 additions and 2 deletions

View file

@ -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"
},

View file

@ -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);