glsl/builtins: Fix {texture1D,texture2D,shadow1D}ArrayLod availibility.
authorPaul Berry <stereotype441@gmail.com>
Thu, 12 Sep 2013 16:11:37 +0000 (09:11 -0700)
committerPaul Berry <stereotype441@gmail.com>
Fri, 13 Sep 2013 21:59:06 +0000 (14:59 -0700)
These functions are defined in EXT_texture_array, which makes no
mention of what shader types they should be allowed in.  At the time
EXT_texture_array was introduced, functions ending in "Lod" were
available only in vertex shaders, however this restriction was lifted
in later spec versions and extensions.

We already have the function lod_exists_in_stage() for figuring out
whether functions ending in "Lod" should be available, so just re-use
that.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/glsl/builtin_functions.cpp

index c468bd505aba64c7e92f9d9d4a03482a7990d60f..528af0dc65d8f444cf0d8075272be160045d411d 100644 (file)
@@ -214,9 +214,9 @@ gpu_shader5(const _mesa_glsl_parse_state *state)
 }
 
 static bool
-vs_texture_array(const _mesa_glsl_parse_state *state)
+texture_array_lod(const _mesa_glsl_parse_state *state)
 {
-   return state->target == vertex_shader &&
+   return lod_exists_in_stage(state) &&
           state->EXT_texture_array_enable;
 }
 
@@ -1609,7 +1609,7 @@ builtin_builder::create_builtins()
                 NULL);
 
    add_function("texture1DArrayLod",
-                _texture(ir_txl, vs_texture_array, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type),
+                _texture(ir_txl, texture_array_lod, glsl_type::vec4_type, glsl_type::sampler1DArray_type, glsl_type::vec2_type),
                 NULL);
 
    add_function("texture1DProjLod",
@@ -1642,7 +1642,7 @@ builtin_builder::create_builtins()
                 NULL);
 
    add_function("texture2DArrayLod",
-                _texture(ir_txl, vs_texture_array, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type),
+                _texture(ir_txl, texture_array_lod, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type),
                 NULL);
 
    add_function("texture2DProjLod",
@@ -1725,7 +1725,7 @@ builtin_builder::create_builtins()
                 NULL);
 
    add_function("shadow1DArrayLod",
-                _texture(ir_txl, vs_texture_array, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type),
+                _texture(ir_txl, texture_array_lod, glsl_type::vec4_type, glsl_type::sampler1DArrayShadow_type, glsl_type::vec3_type),
                 NULL);
 
    add_function("shadow1DProjLod",