[Mesa-dev] [PATCH 4/4] glsl: Keep track of centroid/interpolation mode for interface block members.
Paul Berry
stereotype441 at gmail.com
Wed Oct 23 00:24:29 CEST 2013
Fixes piglit tests:
- interface-block-interpolation-{array,named,unnamed}
- glsl-1.50-interface-block-centroid {array,named,unnamed}
---
src/glsl/ast_to_hir.cpp | 9 +++++++++
src/glsl/builtin_variables.cpp | 4 ++++
src/glsl/glsl_types.cpp | 10 ++++++++++
src/glsl/glsl_types.h | 12 ++++++++++++
src/glsl/lower_named_interface_blocks.cpp | 3 +++
5 files changed, 38 insertions(+)
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 5d94e34..df91b1a 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -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;
}
}
@@ -4925,6 +4932,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) {
diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp
index 64f3406..43df8ea 100644
--- a/src/glsl/builtin_variables.cpp
+++ b/src/glsl/builtin_variables.cpp
@@ -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++;
}
@@ -900,6 +902,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);
}
}
diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
index 80a6e71..bc8d87f 100644
--- a/src/glsl/glsl_types.cpp
+++ b/src/glsl/glsl_types.cpp
@@ -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;
diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h
index e60c191..4b5b6ef 100644
--- a/src/glsl/glsl_types.h
+++ b/src/glsl/glsl_types.h
@@ -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
diff --git a/src/glsl/lower_named_interface_blocks.cpp b/src/glsl/lower_named_interface_blocks.cpp
index f415252..66e88bf 100644
--- a/src/glsl/lower_named_interface_blocks.cpp
+++ b/src/glsl/lower_named_interface_blocks.cpp
@@ -151,6 +151,9 @@ flatten_named_interface_blocks_declarations::run(exec_list *instructions)
(ir_variable_mode) var->mode);
}
new_var->location = iface_t->fields.structure[i].location;
+ 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,
--
1.8.4.1
More information about the mesa-dev
mailing list