[Mesa-dev] [PATCH 1/5] glsl: Overwrite storage qualifier of builtin redeclarations.
Fabian Bieler
fabianbieler at fastmail.fm
Wed May 8 15:50:50 PDT 2013
Prior to GLSL version 1.3 builtin variables such as gl_Position have no storage
qualifiers (in or out). However, the internal declarations in Mesa have storage
qualifiers regardless of version.
As the code to identify a redeclaration checks for identical storage qualifiers
you cannot redeclare builtins in GLSL 1.1 and 1.2.
To work around this, this patch copies the storage qualifier from the internal
declaration to the redeclaration.
---
src/glsl/ast_to_hir.cpp | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index e595110..9ef73b5 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -2168,6 +2168,19 @@ get_variable_being_redeclared(ir_variable *var, ast_declaration *decl,
YYLTYPE loc = decl->get_location();
+ /* Prior to version GLSL 1.3 builtin variables were not declared with
+ * storage qualifiers, however our predeclarations have storage qualifiers
+ * regardless of version. When a builtin is redeclared the code below checks
+ * that the two declarations have identical storage qualifiers.
+ *
+ * To work around this copy the storage qualifier to the redeclaration.
+ */
+ if (!state->is_version(130, 300)
+ && strncmp(var->name, "gl_", 3) == 0
+ && var->mode == ir_var_auto) {
+ var->mode = earlier->mode;
+ }
+
/* From page 24 (page 30 of the PDF) of the GLSL 1.50 spec,
*
* "It is legal to declare an array without a size and then
--
1.8.1.2
More information about the mesa-dev
mailing list