Mesa (master): glsl: Allow redeclaration of gl_Color and its variants in GLSL 1.30

Chad Versace chadversary at kemper.freedesktop.org
Tue Jan 4 18:51:27 UTC 2011


Module: Mesa
Branch: master
Commit: b84e3f570f4b5aba1dd96760e090ae976d0e1cba
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b84e3f570f4b5aba1dd96760e090ae976d0e1cba

Author: Chad Versace <chad.versace at intel.com>
Date:   Wed Dec 15 16:32:47 2010 -0800

glsl: Allow redeclaration of gl_Color and its variants in GLSL 1.30

Allow redeclaration of the following built-in variables with an
interpolation qualifier in language versions >= 1.30:
   * gl_FrontColor
   * gl_BackColor
   * gl_FrontSecondaryColor
   * gl_BackSecondaryColor
   * gl_Color
   * gl_SecondaryColor

See section 4.3.7 of the GLSL 1.30 spec.

---

 src/glsl/ast_to_hir.cpp |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 2baeffc..6770eed 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -2344,6 +2344,27 @@ ast_declarator_list::hir(exec_list *instructions,
 	     */
 	    earlier->origin_upper_left = var->origin_upper_left;
 	    earlier->pixel_center_integer = var->pixel_center_integer;
+
+	 /* According to section 4.3.7 of the GLSL 1.30 spec,
+	  * the following built-in varaibles can be redeclared with an
+	  * interpolation qualifier:
+	  *    * gl_FrontColor
+	  *    * gl_BackColor
+	  *    * gl_FrontSecondaryColor
+	  *    * gl_BackSecondaryColor
+	  *    * gl_Color
+	  *    * gl_SecondaryColor
+	  */
+	 } else if (state->language_version >= 130
+	            && (strcmp(var->name, "gl_FrontColor") == 0
+                        || strcmp(var->name, "gl_BackColor") == 0
+                        || strcmp(var->name, "gl_FrontSecondaryColor") == 0
+                        || strcmp(var->name, "gl_BackSecondaryColor") == 0
+                        || strcmp(var->name, "gl_Color") == 0
+                        || strcmp(var->name, "gl_SecondaryColor") == 0)
+	            && earlier->type == var->type
+	            && earlier->mode == var->mode) {
+	    earlier->interpolation = var->interpolation;
 	 } else {
 	    YYLTYPE loc = this->get_location();
 	    _mesa_glsl_error(&loc, state, "`%s' redeclared", decl->identifier);




More information about the mesa-commit mailing list