nir/spirv: Make the builtins array distinguish between in and out
authorJason Ekstrand <jason.ekstrand@intel.com>
Fri, 23 Oct 2015 00:54:24 +0000 (17:54 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Fri, 23 Oct 2015 00:54:24 +0000 (17:54 -0700)
src/glsl/nir/spirv_to_nir.c
src/glsl/nir/spirv_to_nir_private.h

index 973ff7c6777aa807108b97a86649c35030799245..245ee7424add4bd85eafbec1888ed41abe00dce4 100644 (file)
@@ -830,7 +830,10 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value *val, int member,
       if (builtin == SpvBuiltInFragCoord || builtin == SpvBuiltInSamplePosition)
          var->data.origin_upper_left = b->origin_upper_left;
 
-      b->builtins[dec->literals[0]] = var;
+      if (mode == nir_var_shader_out)
+         b->builtins[dec->literals[0]].out = var;
+      else
+         b->builtins[dec->literals[0]].in = var;
       break;
    }
    case SpvDecorationRowMajor:
@@ -866,7 +869,11 @@ get_builtin_variable(struct vtn_builder *b,
                      const struct glsl_type *type,
                      SpvBuiltIn builtin)
 {
-   nir_variable *var = b->builtins[builtin];
+   nir_variable *var;
+   if (mode == nir_var_shader_out)
+      var = b->builtins[builtin].out;
+   else
+      var = b->builtins[builtin].in;
 
    if (!var) {
       int location;
@@ -880,7 +887,10 @@ get_builtin_variable(struct vtn_builder *b,
       if (builtin == SpvBuiltInFragCoord || builtin == SpvBuiltInSamplePosition)
          var->data.origin_upper_left = b->origin_upper_left;
 
-      b->builtins[builtin] = var;
+      if (mode == nir_var_shader_out)
+         b->builtins[builtin].out = var;
+      else
+         b->builtins[builtin].in = var;
    }
 
    return var;
index 96044b05aac061cb7d06010bed76b154b92cb94b..45111f816bc9959d864b07c6984bc0d0472e4837 100644 (file)
@@ -172,7 +172,10 @@ struct vtn_builder {
    /*
     * NIR variable for each SPIR-V builtin.
     */
-   nir_variable *builtins[42]; /* XXX need symbolic constant from SPIR-V header */
+   struct {
+      nir_variable *in;
+      nir_variable *out;
+   } builtins[42]; /* XXX need symbolic constant from SPIR-V header */
 
    unsigned value_id_bound;
    struct vtn_value *values;