nir/spirv: Separate handling of preamble from type/var/const instructions
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 31 Dec 2015 00:35:34 +0000 (16:35 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 31 Dec 2015 01:45:43 +0000 (17:45 -0800)
src/glsl/nir/spirv/spirv_to_nir.c

index b6f5dd761bb36a1ed38b8f0317754baaff11d14b..fd7e9e8dbc1bb4186fd3956f5dd4cfbacd9970f8 100644 (file)
@@ -3319,6 +3319,38 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode,
       vtn_handle_decoration(b, opcode, w, count);
       break;
 
+   default:
+      return false; /* End of preamble */
+   }
+
+   return true;
+}
+
+static bool
+vtn_handle_variable_or_type_instruction(struct vtn_builder *b, SpvOp opcode,
+                                        const uint32_t *w, unsigned count)
+{
+   switch (opcode) {
+   case SpvOpSource:
+   case SpvOpSourceExtension:
+   case SpvOpExtension:
+   case SpvOpCapability:
+   case SpvOpExtInstImport:
+   case SpvOpMemoryModel:
+   case SpvOpEntryPoint:
+   case SpvOpExecutionMode:
+   case SpvOpString:
+   case SpvOpName:
+   case SpvOpMemberName:
+   case SpvOpLine:
+   case SpvOpDecorationGroup:
+   case SpvOpDecorate:
+   case SpvOpMemberDecorate:
+   case SpvOpGroupDecorate:
+   case SpvOpGroupMemberDecorate:
+      assert(!"Invalid opcode types and variables section");
+      break;
+
    case SpvOpTypeVoid:
    case SpvOpTypeBool:
    case SpvOpTypeInt:
@@ -3617,6 +3649,10 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
    words = vtn_foreach_instruction(b, words, word_end,
                                    vtn_handle_preamble_instruction);
 
+   /* Handle all variable, type, and constant instructions */
+   words = vtn_foreach_instruction(b, words, word_end,
+                                   vtn_handle_variable_or_type_instruction);
+
    vtn_build_cfg(b, words, word_end);
 
    foreach_list_typed(struct vtn_function, func, node, &b->functions) {