[Mesa-dev] [PATCH 3/3] mesa: glsl: force version too when force_glsl_extensions_warn is used

Ian Romanick idr at freedesktop.org
Thu Aug 23 09:39:16 PDT 2012


On 08/22/2012 01:23 AM, Maxim Levitsky wrote:
> Unfortunelly some buggy programs use extensions without asking ether for
> proper GLSL version nor ask for particular extension.
>
> Moreover the force_glsl_extensions_warn hack is only effective for some
> extensions (GL_EXT_texture_array) but unfortunelly isnt effective for other
> extensions (I suspect these that declare new built in functions)
> Example of this is recently added ARB_shader_bit_encoding extension.
> Forcing GLSL version to high value seems to fix this, not sure if this
> is acceptable hack though.
>
> This can be reproducted in Unigine Heaven with "ambient occlusion" on.
> Note that even with this path shader compilatin fails, because code in Unigine
> that gets activated when this extension gets enabled expects implicit conversions
> between signed and unsigned immidiate constants. Whether GLSL shold allow this is open
> for debate.
>
> Signed-off-by: Maxim Levitsky <maximlevitsky at gmail.com>
> ---
>   src/glsl/glsl_parser_extras.cpp |    4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
> index 872fcda..754166b 100644
> --- a/src/glsl/glsl_parser_extras.cpp
> +++ b/src/glsl/glsl_parser_extras.cpp
> @@ -105,8 +105,10 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
>
>      this->supported_version_string = supported;
>
> -   if (ctx->Const.ForceGLSLExtensionsWarn)
> +   if (ctx->Const.ForceGLSLExtensionsWarn) {
>         _mesa_glsl_process_extension("all", NULL, "warn", NULL, this);
> +      this->language_version = 130;
> +   }

Even if we do this, this is not the way to do it.  I think a separate 
over-ride to a specific GLSL version is preferable.  This is for two 
main reasons.  First, this will explode on an implementation that 
doesn't support GLSL 1.30.  Second, applications like this tend to 
detect the maximum version and assume that.  If we set 1.30, but the 
application is expecting 1.40, it will still fail.

>      this->default_uniform_qualifier = new(this) ast_type_qualifier();
>      this->default_uniform_qualifier->flags.q.shared = 1;
>


More information about the mesa-dev mailing list