nir/spirv: Add stub support for extension instructions
authorJason Ekstrand <jason.ekstrand@intel.com>
Wed, 29 Apr 2015 21:32:55 +0000 (14:32 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Mon, 31 Aug 2015 23:58:20 +0000 (16:58 -0700)
src/glsl/nir/spirv_to_nir.c

index 3a49ad965ba8b12e98d66b5227157dfe2198b507..bc7b98f2e0dd9726b2df6916529a9e82ee8e012b 100644 (file)
@@ -64,6 +64,9 @@ struct vtn_builder {
 
    unsigned value_id_bound;
    struct vtn_value *values;
+
+   SpvExecutionModel execution_model;
+   struct vtn_value *entry_point;
 };
 
 static void
@@ -91,6 +94,21 @@ vtn_string_literal(struct vtn_builder *b, const uint32_t *words,
    return ralloc_strndup(b, (char *)words, (word_count - 2) * sizeof(*words));
 }
 
+static void
+vtn_handle_extension(struct vtn_builder *b, SpvOp opcode,
+                     const uint32_t *w, unsigned count)
+{
+   switch (opcode) {
+   case SpvOpExtInstImport:
+      /* Do nothing for the moment */
+      break;
+
+   case SpvOpExtInst:
+   default:
+      unreachable("Unhandled opcode");
+   }
+}
+
 typedef void (*decoration_foreach_cb)(struct vtn_builder *,
                                       struct vtn_value *,
                                       const struct vtn_decoration *,
@@ -216,6 +234,7 @@ vtn_handle_instruction(struct vtn_builder *b, SpvOp opcode,
    case SpvOpSourceExtension:
    case SpvOpMemberName:
    case SpvOpLine:
+   case SpvOpExtension:
       /* Unhandled, but these are for debug so that's ok. */
       break;
 
@@ -232,6 +251,22 @@ vtn_handle_instruction(struct vtn_builder *b, SpvOp opcode,
       vtn_push_token(b, w[2], vtn_value_type_undef);
       break;
 
+   case SpvOpMemoryModel:
+      assert(w[1] == SpvAddressingModelLogical);
+      assert(w[2] == SpvMemoryModelGLSL450);
+      break;
+
+   case SpvOpEntryPoint:
+      assert(b->entry_point == NULL);
+      b->entry_point = &b->values[w[2]];
+      b->execution_model = w[1];
+      break;
+
+   case SpvOpExtInstImport:
+   case SpvOpExtInst:
+      vtn_handle_extension(b, opcode, w, count);
+      break;
+
    case SpvOpTypeVoid:
    case SpvOpTypeBool:
    case SpvOpTypeInt: