spirv: Add better validation to Op[Spec]Constant
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 12 Dec 2017 06:15:04 +0000 (22:15 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Mon, 8 Jan 2018 22:57:44 +0000 (14:57 -0800)
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/compiler/spirv/spirv_to_nir.c

index 6f5d3e1d64f0e9533cf0f1dfb3878c1120d0329c..014de781cc13276334fac7920de58b8fe66d5b61 100644 (file)
@@ -1300,7 +1300,9 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode,
    }
 
    case SpvOpConstant: {
-      vtn_assert(glsl_type_is_scalar(val->type->type));
+      vtn_fail_if(val->type->base_type != vtn_base_type_scalar,
+                  "Result type of %s must be a scalar",
+                  spirv_op_to_string(opcode));
       int bit_size = glsl_get_bit_size(val->type->type);
       switch (bit_size) {
       case 64:
@@ -1317,8 +1319,11 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode,
       }
       break;
    }
+
    case SpvOpSpecConstant: {
-      vtn_assert(glsl_type_is_scalar(val->type->type));
+      vtn_fail_if(val->type->base_type != vtn_base_type_scalar,
+                  "Result type of %s must be a scalar",
+                  spirv_op_to_string(opcode));
       int bit_size = glsl_get_bit_size(val->type->type);
       switch (bit_size) {
       case 64: