diff options
author | Paul Berry <stereotype441@gmail.com> | 2013-10-22 15:11:51 -0700 |
---|---|---|
committer | Paul Berry <stereotype441@gmail.com> | 2013-10-24 22:01:10 -0700 |
commit | 99512dc40d762d15d636ea711c496bd0350ef7f1 (patch) | |
tree | 679d5dffee517cf4816497f7a37a6e48305a576e /src | |
parent | e17d671d9f64fe135a10ec54dd5b5a6beacfd991 (diff) |
glsl: Keep track of centroid/interpolation mode for interface block members.
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/glsl/ast_to_hir.cpp | 9 | ||||
-rw-r--r-- | src/glsl/builtin_variables.cpp | 4 | ||||
-rw-r--r-- | src/glsl/glsl_types.cpp | 10 | ||||
-rw-r--r-- | src/glsl/glsl_types.h | 12 | ||||
-rw-r--r-- | src/glsl/lower_named_interface_blocks.cpp | 3 |
5 files changed, 38 insertions, 0 deletions
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index d216fee3839..8b49b8488a0 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; } } @@ -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) { diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp index 1f62fcf9bdd..018daf67fec 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++; } @@ -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); } } diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp index 80a6e71a721..bc8d87f5fa6 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 e60c19132d6..4b5b6efb393 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 726ffdc0da8..87ed60b971e 100644 --- a/src/glsl/lower_named_interface_blocks.cpp +++ b/src/glsl/lower_named_interface_blocks.cpp @@ -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, |