[Mesa-dev] [PATCH] glsl: allow ForceGLSLVersion to override #version directives

Ilia Mirkin imirkin at alum.mit.edu
Sun Apr 26 13:57:18 PDT 2015


With force_glsl_version=150, I get:

heaven_x64: main/ff_fragment_shader.cpp:532: ir_rvalue*
get_gl_Color(texenv_fragment_program*): Assertion `var' failed.

Might be because it'll end up affecting compat context as well?

On Sun, Apr 26, 2015 at 4:48 PM, Marek Olšák <maraeo at gmail.com> wrote:
> There are comments at the beginning of the file explaining some of the
> workarounds. I think some of them predate Heaven 4.0 and might not be
> needed for 4.0.
>
> How about setting version 150?
>
> <option name="force_glsl_version" value="150" />
>
> Marek
>
> On Sun, Apr 26, 2015 at 9:38 PM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
>> Brian, Marek,
>>
>> We now have a new fun situation relating to this, perhaps you have
>> thoughts on how to resolve this. Unigine Heaven 4.0 has, in the drirc,
>> has
>>
>>             <option name="force_glsl_version" value="130" />
>>
>> However some shaders in Heaven have #version 150 (the ones that do
>> tess, at least), which in turn causes issues with the new semantics.
>> It appears that this was added in commit 0f6a7cb00c86f to deal with
>> Heaven 3.0. However there's no way to tell them apart in the drirc...
>> thoughts? [Are the other attributes in there needed too? The midshader
>> one definitely is.]
>>
>>   -ilia
>>
>>
>> On Fri, Mar 27, 2015 at 2:44 PM, Brian Paul <brianp at vmware.com> wrote:
>>>
>>> The Geeks3d GpuTest GiMark test for Windows has several shaders with
>>> #version 330 that don't actually use any 3.30 features.  Other shaders in
>>> the test use #version 130.  Furthermore, when a context is created, only a
>>> 3.0 context is requested.  We don't support GL 3.0 w/ 3.30 shaders but if I
>>> override the #version 330 with 130 then everything works fine.
>>>
>>> -Brian
>>>
>>>
>>> On 03/27/2015 12:13 PM, Ilia Mirkin wrote:
>>>>
>>>> What's the use-case for applying a different version to a shader with
>>>> an explicit #version?
>>>>
>>>> On Fri, Mar 27, 2015 at 2:13 PM, Brian Paul <brianp at vmware.com> wrote:
>>>>>
>>>>> Previously, the ctx->Const.ForceGLSLVersion setting only worked if
>>>>> the shader lacked a #version directive.  Now, the ForceGLSLVersion
>>>>> setting will override the #version directive too.
>>>>>
>>>>> This change should be safe since it should be rare to have an app
>>>>> that has a mix of shader versions and we only wanted to override
>>>>> the #version for shaders which lacked the #version directive.
>>>>> ---
>>>>>   src/glsl/glsl_parser_extras.cpp | 11 +++++++----
>>>>>   src/glsl/glsl_parser_extras.h   |  1 +
>>>>>   src/mesa/main/mtypes.h          |  4 ++--
>>>>>   3 files changed, 10 insertions(+), 6 deletions(-)
>>>>>
>>>>> diff --git a/src/glsl/glsl_parser_extras.cpp
>>>>> b/src/glsl/glsl_parser_extras.cpp
>>>>> index 79624bc..0aa3c54 100644
>>>>> --- a/src/glsl/glsl_parser_extras.cpp
>>>>> +++ b/src/glsl/glsl_parser_extras.cpp
>>>>> @@ -73,8 +73,8 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct
>>>>> gl_context *_ctx,
>>>>>      this->uses_builtin_functions = false;
>>>>>
>>>>>      /* Set default language version and extensions */
>>>>> -   this->language_version = ctx->Const.ForceGLSLVersion ?
>>>>> -                            ctx->Const.ForceGLSLVersion : 110;
>>>>> +   this->language_version = 110;
>>>>> +   this->forced_language_version = ctx->Const.ForceGLSLVersion;
>>>>>      this->es_shader = false;
>>>>>      this->ARB_texture_rectangle_enable = true;
>>>>>
>>>>> @@ -320,11 +320,14 @@
>>>>> _mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int
>>>>> version,
>>>>>         this->ARB_texture_rectangle_enable = false;
>>>>>      }
>>>>>
>>>>> -   this->language_version = version;
>>>>> +   if (this->forced_language_version)
>>>>> +      this->language_version = this->forced_language_version;
>>>>> +   else
>>>>> +      this->language_version = version;
>>>>>
>>>>>      bool supported = false;
>>>>>      for (unsigned i = 0; i < this->num_supported_versions; i++) {
>>>>> -      if (this->supported_versions[i].ver == (unsigned) version
>>>>> +      if (this->supported_versions[i].ver == this->language_version
>>>>>             && this->supported_versions[i].es == this->es_shader) {
>>>>>            supported = true;
>>>>>            break;
>>>>> diff --git a/src/glsl/glsl_parser_extras.h
>>>>> b/src/glsl/glsl_parser_extras.h
>>>>> index 0975c86..1f5478b 100644
>>>>> --- a/src/glsl/glsl_parser_extras.h
>>>>> +++ b/src/glsl/glsl_parser_extras.h
>>>>> @@ -226,6 +226,7 @@ struct _mesa_glsl_parse_state {
>>>>>
>>>>>      bool es_shader;
>>>>>      unsigned language_version;
>>>>> +   unsigned forced_language_version;
>>>>>      gl_shader_stage stage;
>>>>>
>>>>>      /**
>>>>> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
>>>>> index 8e1dba6..f718768 100644
>>>>> --- a/src/mesa/main/mtypes.h
>>>>> +++ b/src/mesa/main/mtypes.h
>>>>> @@ -3527,8 +3527,8 @@ struct gl_constants
>>>>>      GLboolean ForceGLSLExtensionsWarn;
>>>>>
>>>>>      /**
>>>>> -    * If non-zero, forces GLSL shaders without the #version directive to
>>>>> behave
>>>>> -    * as if they began with "#version ForceGLSLVersion".
>>>>> +    * If non-zero, forces GLSL shaders to behave as if they began
>>>>> +    * with "#version ForceGLSLVersion".
>>>>>       */
>>>>>      GLuint ForceGLSLVersion;
>>>>>
>>>>> --
>>>>> 1.9.1
>>>>>
>>>>> _______________________________________________
>>>>> mesa-dev mailing list
>>>>> mesa-dev at lists.freedesktop.org
>>>>>
>>>>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.freedesktop.org_mailman_listinfo_mesa-2Ddev&d=AwIBaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=T0t4QG7chq2ZwJo6wilkFznRSFy-8uDKartPGbomVj8&m=ldpjgViUPOu17CxrbA3nCCexS68kJbTju51AqpuolTA&s=95-rcxtOJ28IZZjXd3g1FPtmCrob8AIQ5HG_21mXNZc&e=
>>>
>>>


More information about the mesa-dev mailing list