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

Author: Paul Berry <stereotype...@gmail.com>
Date:   Sun Jul  7 11:49:22 2013 -0700

glsl: Make gl_TexCoord compatibility-only

gl_TexCoord was deprecated in GLSL 1.30.  In GLSL 1.40 it was marked
as ARB_compatibility-only, and in GLSL 1.50 and above it was marked as
only appearing in the compatibility profile.  It has never appeared in
GLSL ES.

However, Mesa erroneously included it in all desktop versions of GLSL,
even versions 1.40 and 1.50 (which do not currently support the
compatibility profile).  This patch makes gl_TexCoord available in the
compatibility profile (and GLSL versions 1.30 and prior) only.

NOTE: although this is a simple bug fix, it probably isn't sensible to
cherry-pick it to stable release branches, since its only effect is to
cause incorrectly-written shaders to fail to compile.

Reviewed-by: Ian Romanick <ian.d.roman...@intel.com>
Reviewed-by: Matt Turner <matts...@gmail.com>

---

 src/glsl/builtin_variables.cpp |   56 +++++++++++++++++++++------------------
 1 files changed, 30 insertions(+), 26 deletions(-)

diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp
index 58019c6..eccd15a 100644
--- a/src/glsl/builtin_variables.cpp
+++ b/src/glsl/builtin_variables.cpp
@@ -748,20 +748,22 @@ generate_110_vs_variables(exec_list *instructions,
    }
    generate_110_uniforms(instructions, state, add_deprecated);
 
-   /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec:
-    *
-    *     "As with all arrays, indices used to subscript gl_TexCoord must
-    *     either be an integral constant expressions, or this array must be
-    *     re-declared by the shader with a size. The size can be at most
-    *     gl_MaxTextureCoords. Using indexes close to 0 may aid the
-    *     implementation in preserving varying resources."
-    */
-   const glsl_type *const vec4_array_type =
-      glsl_type::get_array_instance(glsl_type::vec4_type, 0);
+   if (add_deprecated) {
+      /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec:
+       *
+       *     "As with all arrays, indices used to subscript gl_TexCoord must
+       *     either be an integral constant expressions, or this array must be
+       *     re-declared by the shader with a size. The size can be at most
+       *     gl_MaxTextureCoords. Using indexes close to 0 may aid the
+       *     implementation in preserving varying resources."
+       */
+      const glsl_type *const vec4_array_type =
+         glsl_type::get_array_instance(glsl_type::vec4_type, 0);
 
-   add_variable(instructions, state->symbols,
-               "gl_TexCoord", vec4_array_type, ir_var_shader_out,
-                VARYING_SLOT_TEX0);
+      add_variable(instructions, state->symbols,
+                   "gl_TexCoord", vec4_array_type, ir_var_shader_out,
+                   VARYING_SLOT_TEX0);
+   }
 
    generate_ARB_draw_buffers_variables(instructions, state, false,
                                       vertex_shader);
@@ -944,20 +946,22 @@ generate_110_fs_variables(exec_list *instructions,
 
    generate_110_uniforms(instructions, state, add_deprecated);
 
-   /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec:
-    *
-    *     "As with all arrays, indices used to subscript gl_TexCoord must
-    *     either be an integral constant expressions, or this array must be
-    *     re-declared by the shader with a size. The size can be at most
-    *     gl_MaxTextureCoords. Using indexes close to 0 may aid the
-    *     implementation in preserving varying resources."
-    */
-   const glsl_type *const vec4_array_type =
-      glsl_type::get_array_instance(glsl_type::vec4_type, 0);
+   if (add_deprecated) {
+      /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec:
+       *
+       *     "As with all arrays, indices used to subscript gl_TexCoord must
+       *     either be an integral constant expressions, or this array must be
+       *     re-declared by the shader with a size. The size can be at most
+       *     gl_MaxTextureCoords. Using indexes close to 0 may aid the
+       *     implementation in preserving varying resources."
+       */
+      const glsl_type *const vec4_array_type =
+         glsl_type::get_array_instance(glsl_type::vec4_type, 0);
 
-   add_variable(instructions, state->symbols,
-               "gl_TexCoord", vec4_array_type, ir_var_shader_in,
-                VARYING_SLOT_TEX0);
+      add_variable(instructions, state->symbols,
+                   "gl_TexCoord", vec4_array_type, ir_var_shader_in,
+                   VARYING_SLOT_TEX0);
+   }
 
    generate_ARB_draw_buffers_variables(instructions, state, false,
                                       fragment_shader);

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to