mesa: Track the additional data in gl_shader_variable
authorIan Romanick <ian.d.romanick@intel.com>
Thu, 19 May 2016 17:25:47 +0000 (10:25 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Thu, 26 May 2016 23:19:16 +0000 (16:19 -0700)
The interface type, interpolation mode, precision, the type of the
outermost structure, and whether or not the variable has an explicit
location will be used for SSO validation on OpenGL ES.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Reviewed-by: Alejandro PiƱeiro <apinheiro@igalia.com>
src/compiler/glsl/linker.cpp
src/mesa/main/mtypes.h

index 8e6455310bb5fc37930ef12a18983bf40ca1cc67..1d5552915cadb65c43caff6d6301a29028002fd2 100644 (file)
@@ -3660,7 +3660,8 @@ static gl_shader_variable *
 create_shader_variable(struct gl_shader_program *shProg,
                        const ir_variable *in,
                        const char *name, const glsl_type *type,
-                       bool use_implicit_location, int location)
+                       bool use_implicit_location, int location,
+                       const glsl_type *outermost_struct_type)
 {
    gl_shader_variable *out = ralloc(shProg, struct gl_shader_variable);
    if (!out)
@@ -3703,10 +3704,15 @@ create_shader_variable(struct gl_shader_program *shProg,
    }
 
    out->type = type;
+   out->outermost_struct_type = outermost_struct_type;
+   out->interface_type = in->get_interface_type();
    out->component = in->data.location_frac;
    out->index = in->data.index;
    out->patch = in->data.patch;
    out->mode = in->data.mode;
+   out->interpolation = in->data.interpolation;
+   out->explicit_location = in->data.explicit_location;
+   out->precision = in->data.precision;
 
    return out;
 }
@@ -3715,7 +3721,8 @@ static bool
 add_shader_variable(struct gl_shader_program *shProg, unsigned stage_mask,
                     GLenum programInterface, ir_variable *var,
                     const char *name, const glsl_type *type,
-                    bool use_implicit_location, int location)
+                    bool use_implicit_location, int location,
+                    const glsl_type *outermost_struct_type = NULL)
 {
    const bool is_vertex_input =
       programInterface == GL_PROGRAM_INPUT &&
@@ -3732,13 +3739,17 @@ add_shader_variable(struct gl_shader_program *shProg, unsigned stage_mask,
        *     structure member to enumerate is itself a structure or array,
        *     these enumeration rules are applied recursively."
        */
+      if (outermost_struct_type == NULL)
+         outermost_struct_type = type;
+
       unsigned field_location = location;
       for (unsigned i = 0; i < type->length; i++) {
          const struct glsl_struct_field *field = &type->fields.structure[i];
          char *field_name = ralloc_asprintf(shProg, "%s.%s", name, field->name);
          if (!add_shader_variable(shProg, stage_mask, programInterface,
                                   var, field_name, field->type,
-                                  use_implicit_location, field_location))
+                                  use_implicit_location, field_location,
+                                  outermost_struct_type))
             return false;
 
          field_location +=
@@ -3772,7 +3783,8 @@ add_shader_variable(struct gl_shader_program *shProg, unsigned stage_mask,
        */
       gl_shader_variable *sha_v =
          create_shader_variable(shProg, var, prefixed_name, type,
-                                use_implicit_location, location);
+                                use_implicit_location, location,
+                                outermost_struct_type);
       if (!sha_v)
          return false;
 
index e16663d28803590c29d65f07a2da03e9d09d5609..e8ab195a91b25830d59a7aac207837ec24ba1db6 100644 (file)
@@ -2546,6 +2546,17 @@ struct gl_shader_variable
     */
    const struct glsl_type *type;
 
+   /**
+    * If the variable is in an interface block, this is the type of the block.
+    */
+   const struct glsl_type *interface_type;
+
+   /**
+    * For variables inside structs (possibly recursively), this is the
+    * outermost struct type.
+    */
+   const struct glsl_type *outermost_struct_type;
+
    /**
     * Declared name of the variable
     */
@@ -2600,6 +2611,27 @@ struct gl_shader_variable
     * \sa (n)ir_variable_mode
     */
    unsigned mode:4;
+
+   /**
+    * Interpolation mode for shader inputs / outputs
+    *
+    * \sa ir_variable_interpolation
+    */
+   unsigned interpolation:2;
+
+   /**
+    * Was the location explicitly set in the shader?
+    *
+    * If the location is explicitly set in the shader, it \b cannot be changed
+    * by the linker or by the API (e.g., calls to \c glBindAttribLocation have
+    * no effect).
+    */
+   unsigned explicit_location:1;
+
+   /**
+    * Precision qualifier.
+    */
+   unsigned precision:2;
 };
 
 /**