glsl: Keep track of centroid/interpolation mode for interface block members.
authorPaul Berry <stereotype441@gmail.com>
Tue, 22 Oct 2013 22:11:51 +0000 (15:11 -0700)
committerPaul Berry <stereotype441@gmail.com>
Fri, 25 Oct 2013 05:01:10 +0000 (22:01 -0700)
Fixes piglit tests:
- interface-block-interpolation-{array,named,unnamed}
- glsl-1.50-interface-block-centroid {array,named,unnamed}

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/glsl/ast_to_hir.cpp
src/glsl/builtin_variables.cpp
src/glsl/glsl_types.cpp
src/glsl/glsl_types.h
src/glsl/lower_named_interface_blocks.cpp

index d216fee38396549ea39fe9d2109dd626624e130d..8b49b8488a00e169ae648b769db6d1e661f9157f 100644 (file)
@@ -4525,6 +4525,9 @@ ast_process_structure_or_interface_block(exec_list *instructions,
          fields[i].type = field_type;
         fields[i].name = decl->identifier;
          fields[i].location = -1;
+         fields[i].interpolation =
+            interpret_interpolation_qualifier(qual, var_mode, state, &loc);
+         fields[i].centroid = qual->flags.q.centroid ? 1 : 0;
 
          if (qual->flags.q.row_major || qual->flags.q.column_major) {
             if (!qual->flags.q.uniform) {
@@ -4789,6 +4792,10 @@ ast_interface_block::hir(exec_list *instructions,
          } else {
             fields[i].location =
                earlier_per_vertex->fields.structure[j].location;
+            fields[i].interpolation =
+               earlier_per_vertex->fields.structure[j].interpolation;
+            fields[i].centroid =
+               earlier_per_vertex->fields.structure[j].centroid;
          }
       }
 
@@ -4924,6 +4931,8 @@ ast_interface_block::hir(exec_list *instructions,
             new(state) ir_variable(fields[i].type,
                                    ralloc_strdup(state, fields[i].name),
                                    var_mode);
+         var->interpolation = fields[i].interpolation;
+         var->centroid = fields[i].centroid;
          var->init_interface_type(block_type);
 
          if (redeclaring_per_vertex) {
index 1f62fcf9bdddbff670ddd6e5dd5279cbe9e77ed3..018daf67fec16da5949df71b6b2058ba2ab25431 100644 (file)
@@ -326,6 +326,8 @@ per_vertex_accumulator::add_field(int slot, const glsl_type *type,
    this->fields[this->num_fields].name = name;
    this->fields[this->num_fields].row_major = false;
    this->fields[this->num_fields].location = slot;
+   this->fields[this->num_fields].interpolation = INTERP_QUALIFIER_NONE;
+   this->fields[this->num_fields].centroid = 0;
    this->num_fields++;
 }
 
@@ -899,6 +901,8 @@ builtin_variable_generator::generate_varyings()
          ir_variable *var =
             add_variable(fields[i].name, fields[i].type, ir_var_shader_out,
                          fields[i].location);
+         var->interpolation = fields[i].interpolation;
+         var->centroid = fields[i].centroid;
          var->init_interface_type(per_vertex_out_type);
       }
    }
index 80a6e71a721d4fdf60d5a50eb68bafcd1daf68c4..bc8d87f5fa6ca1eeced6768acea093e3a0a4fdac 100644 (file)
@@ -101,6 +101,8 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
       this->fields.structure[i].name = ralloc_strdup(this->fields.structure,
                                                     fields[i].name);
       this->fields.structure[i].location = fields[i].location;
+      this->fields.structure[i].interpolation = fields[i].interpolation;
+      this->fields.structure[i].centroid = fields[i].centroid;
       this->fields.structure[i].row_major = fields[i].row_major;
    }
 }
@@ -126,6 +128,8 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
       this->fields.structure[i].name = ralloc_strdup(this->fields.structure,
                                                     fields[i].name);
       this->fields.structure[i].location = fields[i].location;
+      this->fields.structure[i].interpolation = fields[i].interpolation;
+      this->fields.structure[i].centroid = fields[i].centroid;
       this->fields.structure[i].row_major = fields[i].row_major;
    }
 }
@@ -455,6 +459,12 @@ glsl_type::record_key_compare(const void *a, const void *b)
       if (key1->fields.structure[i].location
           != key2->fields.structure[i].location)
          return 1;
+      if (key1->fields.structure[i].interpolation
+          != key2->fields.structure[i].interpolation)
+         return 1;
+      if (key1->fields.structure[i].centroid
+          != key2->fields.structure[i].centroid)
+         return 1;
    }
 
    return 0;
index e60c19132d60415c21e9a493581e18dfa5a3eddb..4b5b6efb393d07621225a1e534297174d940d124 100644 (file)
@@ -590,6 +590,18 @@ struct glsl_struct_field {
     * Ignored for structs.
     */
    int location;
+
+   /**
+    * For interface blocks, the interpolation mode (as in
+    * ir_variable::interpolation).  0 otherwise.
+    */
+   unsigned interpolation:2;
+
+   /**
+    * For interface blocks, 1 if this variable uses centroid interpolation (as
+    * in ir_variable::centroid).  0 otherwise.
+    */
+   unsigned centroid:1;
 };
 
 static inline unsigned int
index 726ffdc0da899cccff5e80ad24d3075fcf36015c..87ed60b971e52df2a22ffa6194f73a27853eea14 100644 (file)
@@ -152,6 +152,9 @@ flatten_named_interface_blocks_declarations::run(exec_list *instructions)
             }
             new_var->location = iface_t->fields.structure[i].location;
             new_var->explicit_location = (new_var->location >= 0);
+            new_var->interpolation =
+               iface_t->fields.structure[i].interpolation;
+            new_var->centroid = iface_t->fields.structure[i].centroid;
 
             new_var->init_interface_type(iface_t);
             hash_table_insert(interface_namespace, new_var,