diff options
author | Ian Romanick <[email protected]> | 2013-01-21 23:27:30 -0500 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2013-01-25 09:07:35 -0500 |
commit | 007de494d2cd110786075f8aa014d8a0547d2063 (patch) | |
tree | 150070f39e06201c8dfc300ec4cc1c6b82cb44b9 /src/glsl | |
parent | 25e75b0a134f8f4de326c310349fc13f5ca906f2 (diff) |
glsl: Recurse into uniform blocks just like uniform structures
v2: Inspite of the spell checker, spell recurse correctly. Suggested by
Carl Worth.
Signed-off-by: Ian Romanick <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/glsl')
-rw-r--r-- | src/glsl/link_uniforms.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp index c15bb30afe5..c77f83abab1 100644 --- a/src/glsl/link_uniforms.cpp +++ b/src/glsl/link_uniforms.cpp @@ -72,6 +72,14 @@ uniform_field_visitor::process(ir_variable *var) char *name = ralloc_strdup(NULL, var->name); recursion(var->type, &name, strlen(name), false); ralloc_free(name); + } else if (t->is_interface()) { + char *name = ralloc_strdup(NULL, var->type->name); + recursion(var->type, &name, strlen(name), false); + ralloc_free(name); + } else if (t->is_array() && t->fields.array->is_interface()) { + char *name = ralloc_strdup(NULL, var->type->fields.array->name); + recursion(var->type, &name, strlen(name), false); + ralloc_free(name); } else { this->visit_field(t, var->name, false); } @@ -87,18 +95,26 @@ uniform_field_visitor::recursion(const glsl_type *t, char **name, * individually, then each field of the resulting array elements processed * individually. */ - if (t->is_record()) { + if (t->is_record() || t->is_interface()) { for (unsigned i = 0; i < t->length; i++) { const char *field = t->fields.structure[i].name; size_t new_length = name_length; - /* Append '.field' to the current uniform name. */ - ralloc_asprintf_rewrite_tail(name, &new_length, ".%s", field); + if (t->fields.structure[i].type->is_record()) + this->visit_field(&t->fields.structure[i]); + + /* Append '.field' to the current uniform name. */ + if (name_length == 0) { + ralloc_asprintf_rewrite_tail(name, &new_length, "%s", field); + } else { + ralloc_asprintf_rewrite_tail(name, &new_length, ".%s", field); + } recursion(t->fields.structure[i].type, name, new_length, t->fields.structure[i].row_major); } - } else if (t->is_array() && t->fields.array->is_record()) { + } else if (t->is_array() && (t->fields.array->is_record() + || t->fields.array->is_interface())) { for (unsigned i = 0; i < t->length; i++) { size_t new_length = name_length; |