Mesa (staging/20.0): spirv: Handle OOB vector extract operations

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Apr 20 18:56:30 UTC 2020


Module: Mesa
Branch: staging/20.0
Commit: 29200718b5baa3d64e7caf6606a277cccaa3f01c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=29200718b5baa3d64e7caf6606a277cccaa3f01c

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Thu Apr  9 16:44:33 2020 -0500

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 at lists.freedesktop.org
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4495>
(cherry picked from commit 380bf556bfe34357f802dc49e1e104dc8fdf951a)

---

 .pick_status.json                 | 2 +-
 src/compiler/spirv/spirv_to_nir.c | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index c35b0a1cfc4..f89d75a2ef0 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -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
     },
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index 2f9d2eecad9..3c05d2f20fe 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -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 *



More information about the mesa-commit mailing list