summaryrefslogtreecommitdiffstats
path: root/src/glsl/ast_to_hir.cpp
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2013-06-29 19:29:16 -0700
committerMatt Turner <[email protected]>2013-07-11 20:58:59 -0700
commit1b0d6aef03161eff4c9933548e964fec1258ea44 (patch)
tree07945e9514fac1588c57cde6b1bbcf386d380568 /src/glsl/ast_to_hir.cpp
parentae79e86d4c0d82b4102e2ec65c93c8240fd22e9d (diff)
glsl: Add support for C-style initializers.
Required by GL_ARB_shading_language_420pack. Parts based on work done by Todd Previte and Ken Graunke, implementing basic support for C-style initializers of arrays. Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/glsl/ast_to_hir.cpp')
-rw-r--r--src/glsl/ast_to_hir.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index c316127ff89..01203134d6d 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -4005,7 +4005,19 @@ ast_type_specifier::hir(exec_list *instructions,
return NULL;
}
- if (this->structure != NULL)
+ /* _mesa_ast_set_aggregate_type() sets the <structure> field so that
+ * process_record_constructor() can do type-checking on C-style initializer
+ * expressions of structs, but ast_struct_specifier should only be translated
+ * to HIR if it is declaring the type of a structure.
+ *
+ * The ->is_declaration field is false for initializers of variables
+ * declared separately from the struct's type definition.
+ *
+ * struct S { ... }; (is_declaration = true)
+ * struct T { ... } t = { ... }; (is_declaration = true)
+ * S s = { ... }; (is_declaration = false)
+ */
+ if (this->structure != NULL && this->structure->is_declaration)
return this->structure->hir(instructions, state);
return NULL;