[Mesa-dev] [PATCH 06/11] spirv: Add better validation to Op[Spec]Constant

Jason Ekstrand jason at jlekstrand.net
Sun Dec 17 05:46:16 UTC 2017


---
 src/compiler/spirv/spirv_to_nir.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index 208ec95..d65c0d0 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -1300,6 +1300,9 @@ vtn_handle_constant(struct vtn_builder *b, SpvOp opcode,
    }
 
    case SpvOpConstant: {
+      vtn_fail_if(val->type->base_type != vtn_base_type_scalar,
+                  "Result type of %s must be a scalar",
+                  spirv_op_to_string(opcode));
       vtn_assert(glsl_type_is_scalar(val->type->type));
       int bit_size = glsl_get_bit_size(val->type->type);
       switch (bit_size) {
@@ -1317,8 +1320,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:
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list