glsl: Allow redeclaration of gl_Color and its variants in GLSL 1.30
authorChad Versace <chad.versace@intel.com>
Thu, 16 Dec 2010 00:32:47 +0000 (16:32 -0800)
committerChad Versace <chad.versace@intel.com>
Tue, 4 Jan 2011 18:49:10 +0000 (10:49 -0800)
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

index 2baeffc067fd8b2546f3be4173dd3eb834375cd8..6770eed34337dd38bcf1e710b77ab28dba6fe6c2 100644 (file)
@@ -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);