Mesa (master): glsl: do not lookup struct types by typename
Nicolai Hähnle
nh at kemper.freedesktop.org
Tue Jun 13 07:36:29 UTC 2017
Module: Mesa
Branch: master
Commit: 0cb1f25d86b0be00a84d1c4f3062cd64c4118b42
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0cb1f25d86b0be00a84d1c4f3062cd64c4118b42
Author: Nicolai Hähnle <nicolai.haehnle at amd.com>
Date: Sun May 14 19:58:53 2017 +0200
glsl: do not lookup struct types by typename
This changes the logic during the conversion of the declaration list
struct S {
...
} v;
from AST to IR, but should not change the end result.
When assigning the type of v, instead of looking `S' up in the symbol
table, we read the type from the member variable of ast_struct_specifier.
This change is necessary for the subsequent change to how anonymous types
are handled.
v2: remove a type override when redefining a structure; should be
the same type in that case anyway
Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
---
src/compiler/glsl/ast.h | 1 +
src/compiler/glsl/ast_to_hir.cpp | 14 ++++++++------
src/compiler/glsl/glsl_parser_extras.cpp | 1 +
3 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h
index 9327e03979..3bf4b08580 100644
--- a/src/compiler/glsl/ast.h
+++ b/src/compiler/glsl/ast.h
@@ -844,6 +844,7 @@ public:
/* List of ast_declarator_list * */
exec_list declarations;
bool is_declaration;
+ const glsl_type *type;
};
diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index e07e5f509b..c67dfe5e88 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -2359,7 +2359,10 @@ ast_type_specifier::glsl_type(const char **name,
{
const struct glsl_type *type;
- type = state->symbols->get_type(this->type_name);
+ if (structure)
+ type = structure->type;
+ else
+ type = state->symbols->get_type(this->type_name);
*name = this->type_name;
YYLTYPE loc = this->get_location();
@@ -7504,13 +7507,12 @@ ast_struct_specifier::hir(exec_list *instructions,
validate_identifier(this->name, loc, state);
- const glsl_type *t =
- glsl_type::get_record_instance(fields, decl_count, this->name);
+ type = glsl_type::get_record_instance(fields, decl_count, this->name);
- if (!state->symbols->add_type(name, t)) {
+ if (!state->symbols->add_type(name, type)) {
const glsl_type *match = state->symbols->get_type(name);
/* allow struct matching for desktop GL - older UE4 does this */
- if (match != NULL && state->is_version(130, 0) && match->record_compare(t, false))
+ if (match != NULL && state->is_version(130, 0) && match->record_compare(type, false))
_mesa_glsl_warning(& loc, state, "struct `%s' previously defined", name);
else
_mesa_glsl_error(& loc, state, "struct `%s' previously defined", name);
@@ -7519,7 +7521,7 @@ ast_struct_specifier::hir(exec_list *instructions,
const glsl_type *,
state->num_user_structures + 1);
if (s != NULL) {
- s[state->num_user_structures] = t;
+ s[state->num_user_structures] = type;
state->user_structures = s;
state->num_user_structures++;
}
diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp
index 0f892b03a1..398bab55dd 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -1690,6 +1690,7 @@ ast_struct_specifier::ast_struct_specifier(void *lin_ctx, const char *identifier
this->declarations.push_degenerate_list_at_head(&declarator_list->link);
is_declaration = true;
layout = NULL;
+ type = NULL;
}
void ast_subroutine_list::print(void) const
More information about the mesa-commit
mailing list