spirv: Handle OOB vector extract operations

We use vtn_vector_extract to handle vector component level derefs.  This
makes us gracefully handle the case where your vector component is OOB
and give you an undef.  The SPIR-V working group is still working out
whether or not this is technically legal but it's very little code for
us to handle it so we may as well.

Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4495>
(cherry picked from commit 380bf556bf)
This commit is contained in:
Jason Ekstrand 2020-04-09 16:44:33 -05:00 committed by Dylan Baker
parent 5ef9dccff3
commit 29200718b5
2 changed files with 5 additions and 2 deletions

View file

@ -796,7 +796,7 @@
"description": "spirv: Handle OOB vector extract operations",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"master_sha": null,
"because_sha": null
},

View file

@ -3330,7 +3330,10 @@ vtn_ssa_transpose(struct vtn_builder *b, struct vtn_ssa_value *src)
nir_ssa_def *
vtn_vector_extract(struct vtn_builder *b, nir_ssa_def *src, unsigned index)
{
return nir_channel(&b->nb, src, index);
if (index > src->num_components)
return nir_ssa_undef(&b->nb, src->num_components, src->bit_size);
else
return nir_channel(&b->nb, src, index);
}
nir_ssa_def *