spirv: handle OpUndef as part of the variable parsing pass
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Thu, 26 Jan 2017 16:57:25 +0000 (16:57 +0000)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Thu, 26 Jan 2017 17:29:29 +0000 (17:29 +0000)
Looking at the following bit of SPIRV shader :

...
%zero        = OpConstant %i32 0
%ivec3_0     = OpConstantComposite %ivec3 %zero %zero %zero
%vec3_undef  = OpUndef %ivec3
%sc_0        = OpSpecConstant %i32 0
%sc_1        = OpSpecConstant %i32 0
%sc_2        = OpSpecConstant %i32 0
...

Our compiler currently stops parsing variables & types on the OpUndef
and switches to instructions, leaving the following sc_[0-2] variables
untreated.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Cc: "17.0 13.0" <mesa-stable@lists.freedesktop.org>
src/compiler/spirv/spirv_to_nir.c
src/compiler/spirv/vtn_variables.c

index 6f18af2018cc6294f06a9fe71c53a72514c4fc6a..93bd158f11199e2ba3fb5fba517c53d8b6940b64 100644 (file)
@@ -2919,6 +2919,7 @@ vtn_handle_variable_or_type_instruction(struct vtn_builder *b, SpvOp opcode,
       vtn_handle_constant(b, opcode, w, count);
       break;
 
+   case SpvOpUndef:
    case SpvOpVariable:
       vtn_handle_variables(b, opcode, w, count);
       break;
index 05ac91eeddba2d5fb2f21119ab11626ab2cbd067..05345b303e5dd6ce5bd3a15f1aba1331b9e417b0 100644 (file)
@@ -1275,6 +1275,12 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,
                      const uint32_t *w, unsigned count)
 {
    switch (opcode) {
+   case SpvOpUndef: {
+      struct vtn_value *val = vtn_push_value(b, w[2], vtn_value_type_undef);
+      val->type = vtn_value(b, w[1], vtn_value_type_type)->type;
+      break;
+   }
+
    case SpvOpVariable: {
       struct vtn_variable *var = rzalloc(b, struct vtn_variable);
       var->type = vtn_value(b, w[1], vtn_value_type_type)->type;