Mesa (master): spirv/nir: Add some useful asserts for type decorations

Jason Ekstrand jekstrand at kemper.freedesktop.org
Tue Jul 18 16:46:32 UTC 2017


Module: Mesa
Branch: master
Commit: a96888923758475e1396a21bf70f9fc3390e76ec
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a96888923758475e1396a21bf70f9fc3390e76ec

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Wed Jul  5 15:30:22 2017 -0700

spirv/nir: Add some useful asserts for type decorations

Now that vtn_type has piles of unions, we should assert sanity before
setting fields that may stomp others.

Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>

---

 src/compiler/spirv/spirv_to_nir.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index 763dbf4e68..89ebc5f674 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -599,12 +599,16 @@ type_decoration_cb(struct vtn_builder *b,
 
    switch (dec->decoration) {
    case SpvDecorationArrayStride:
+      assert(type->base_type == vtn_base_type_matrix ||
+             type->base_type == vtn_base_type_array);
       type->stride = dec->literals[0];
       break;
    case SpvDecorationBlock:
+      assert(type->base_type == vtn_base_type_struct);
       type->block = true;
       break;
    case SpvDecorationBufferBlock:
+      assert(type->base_type == vtn_base_type_struct);
       type->buffer_block = true;
       break;
    case SpvDecorationGLSLShared:




More information about the mesa-commit mailing list