spirv/nir: Add some useful asserts for type decorations
authorJason Ekstrand <jason.ekstrand@intel.com>
Wed, 5 Jul 2017 22:30:22 +0000 (15:30 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Tue, 18 Jul 2017 16:43:12 +0000 (09:43 -0700)
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@igalia.com>
src/compiler/spirv/spirv_to_nir.c

index 763dbf4..89ebc5f 100644 (file)
@@ -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: