nir: abort io info gathering if location is not set or is a temp value

Unlike spirv glsl varyings might not have explicit locations set.
nir_shader_gather_info() was once only called at the end of linking
but these days it even gets called in NIR optimisation loops via
nir_opt_phi_precision.

In the following patches we implement a NIR version of the GLSL
varying linker which means we will have varyings with no location
set when nir_shader_gather_info() gets called the first few times,
and temp values set only for the purpose of removing unmatched
varyings between shaders for some calls after that.

Here rather than asserting we simply abort the io info gathering,
when we hit these values.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15731>
This commit is contained in:
Timothy Arceri 2022-03-16 16:58:02 +11:00 committed by Marge Bot
parent cba2fd51a2
commit 99ab530617
1 changed files with 11 additions and 3 deletions

View File

@ -79,7 +79,9 @@ set_io_mask(nir_shader *shader, nir_variable *var, int offset, int len,
nir_deref_instr *deref, bool is_output_read)
{
for (int i = 0; i < len; i++) {
assert(var->data.location != -1);
/* Varyings might not have been assigned values yet so abort. */
if (var->data.location == -1)
return;
int idx = var->data.location + offset + i;
bool is_patch_generic = var->data.patch &&
@ -90,11 +92,17 @@ set_io_mask(nir_shader *shader, nir_variable *var, int offset, int len,
uint64_t bitfield;
if (is_patch_generic) {
assert(idx >= VARYING_SLOT_PATCH0 && idx < VARYING_SLOT_TESS_MAX);
/* Varyings might still have temp locations so abort */
if (idx < VARYING_SLOT_PATCH0 || idx >= VARYING_SLOT_TESS_MAX)
return;
bitfield = BITFIELD64_BIT(idx - VARYING_SLOT_PATCH0);
}
else {
assert(idx < VARYING_SLOT_MAX);
/* Varyings might still have temp locations so abort */
if (idx >= VARYING_SLOT_MAX)
return;
bitfield = BITFIELD64_BIT(idx);
}