From 380bf556bfe34357f802dc49e1e104dc8fdf951a Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Thu, 9 Apr 2020 16:44:33 -0500 Subject: [PATCH] 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 Part-of: --- src/compiler/spirv/spirv_to_nir.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index 3ebe85e46ab..e0e8fdba27c 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -3314,7 +3314,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 * -- 2.30.2