nir/spirv: don't declare builtin blocks
authorConnor Abbott <connor.w.abbott@intel.com>
Thu, 16 Jul 2015 18:04:22 +0000 (11:04 -0700)
committerConnor Abbott <connor.w.abbott@intel.com>
Thu, 16 Jul 2015 18:04:22 +0000 (11:04 -0700)
They aren't used, and the backend was barfing on them. Also, remove a
hack in in compiler.cpp now that they're gone.

src/glsl/nir/spirv_to_nir.c
src/glsl/nir/spirv_to_nir_private.h
src/vulkan/compiler.cpp

index ee44a3f291e597d2b0ca3e93296aeed829ee2718..65a995c29dea3e993458e2a327fe7a0ef82cfc37 100644 (file)
@@ -359,6 +359,7 @@ struct_member_decoration_cb(struct vtn_builder *b,
                                                  ctx->type->members[member]);
       ctx->type->members[member]->is_builtin = true;
       ctx->type->members[member]->builtin = dec->literals[0];
+      ctx->type->builtin_block = true;
       break;
    case SpvDecorationOffset:
       ctx->type->offsets[member] = dec->literals[0];
@@ -404,7 +405,7 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
 {
    struct vtn_value *val = vtn_push_value(b, w[1], vtn_value_type_type);
 
-   val->type = ralloc(b, struct vtn_type);
+   val->type = rzalloc(b, struct vtn_type);
    val->type->is_builtin = false;
 
    switch (opcode) {
@@ -1230,13 +1231,18 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,
       var->type = type->type;
       var->name = ralloc_strdup(var, val->name);
 
-      if (type->block)
+      bool builtin_block = false;
+      if (type->block) {
          var->interface_type = type->type;
-      else if (glsl_type_is_array(type->type) &&
-               (type->array_element->block || type->array_element->buffer_block))
+         builtin_block = type->builtin_block;
+      } else if (glsl_type_is_array(type->type) &&
+                 (type->array_element->block ||
+                  type->array_element->buffer_block)) {
          var->interface_type = type->array_element->type;
-      else
+         builtin_block = type->array_element->builtin_block;
+      } else {
          var->interface_type = NULL;
+      }
 
       switch ((SpvStorageClass)w[3]) {
       case SpvStorageClassUniform:
@@ -1294,6 +1300,12 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,
       if (var->data.mode == nir_var_uniform && var->interface_type)
          break;
 
+      /* Builtin blocks are lowered to individual variables during SPIR-V ->
+       * NIR, so don't declare them either.
+       */
+      if (builtin_block)
+         break;
+
       switch (var->data.mode) {
       case nir_var_shader_in:
          exec_list_push_tail(&b->shader->inputs, &var->node);
index fa0489b877d3fe3c0932908855e852aea69f3b6a..a964cc80fade5928794105c17cc0eb2875b2c791 100644 (file)
@@ -96,6 +96,11 @@ struct vtn_type {
    /* for structs, whether it was decorated as an "SSBO-like" block */
    bool buffer_block;
 
+   /* for structs with block == true, whether this is a builtin block (i.e. a
+    * block that contains only builtins).
+    */
+   bool builtin_block;
+
    /* for arrays and matrices, the array stride */
    unsigned stride;
 
index cf34e7b4414cddfbcde542f245fe03830846936d..9152de63ec976bba7e214a83fb25e4db7a7e2cdc 100644 (file)
@@ -959,10 +959,6 @@ setup_nir_io(struct gl_program *prog,
    }
 
    foreach_list_typed(nir_variable, var, node, &shader->outputs) {
-      /* XXX glslang gives us this but we never use it */
-      if (!strcmp(var->name, "gl_PerVertex"))
-         continue;
-
       prog->OutputsWritten |= BITFIELD64_BIT(var->data.location);
    }
 }