[Mesa-dev] [PATCH 1/2] mesa: simplify MESA_GL_VERSION_OVERRIDE behavior of API override

Ian Romanick idr at freedesktop.org
Wed Mar 7 16:44:08 UTC 2018


On 03/06/2018 03:27 PM, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
> 
> ---
>  docs/envvars.html       |  3 ++-
>  src/mesa/main/version.c | 16 +++++-----------
>  2 files changed, 7 insertions(+), 12 deletions(-)
> 
> diff --git a/docs/envvars.html b/docs/envvars.html
> index ea42a50..3ef3ab1 100644
> --- a/docs/envvars.html
> +++ b/docs/envvars.html
> @@ -92,22 +92,23 @@ glGetString(GL_VERSION) and possibly the GL API type.
>  <li> FC is an optional suffix that indicates a forward compatible context.
>  This is only valid for versions >= 3.0.
>  <li> GL versions < 3.0 are set to a compatibility (non-Core) profile
>  <li> GL versions = 3.0, see below
>  <li> GL versions > 3.0 are set to a Core profile
>  <li> Examples: 2.1, 3.0, 3.0FC, 3.1, 3.1FC
>  <ul>
>  <li> 2.1 - select a compatibility (non-Core) profile with GL version 2.1
>  <li> 3.0 - select a compatibility (non-Core) profile with GL version 3.0
>  <li> 3.0FC - select a Core+Forward Compatible profile with GL version 3.0
> -<li> 3.1 - select a Core profile with GL version 3.1
> +<li> 3.1 - keep the same profile and set GL version 3.1
>  <li> 3.1FC - select a Core+Forward Compatible profile with GL version 3.1
> +<li> 3.1COMPAT - select a compatibility (non-Core) profile with GL version 3.1

I don't think we should mention profiles here.  Before OpenGL 3.2 there
is no such thing as a profile.  It doesn't exist.  I think this is more
accurate:

<li> 3.1 - Select OpenGL 3.1.  GL_ARB_compatibility will be enabled per the driver default.
<li> 3.1FC - Select OpenGL 3.1 with forward compatibility enabled.  GL_ARB_compatibilty will not be enabled.
<li> 3.1COMPAT - Select OpenGL 3.1 with GL_ARB_compatibilty forced enabled.

>  </ul>
>  <li> Mesa may not really implement all the features of the given version.
>  (for developers only)
>  </ul>
>  <li>MESA_GLES_VERSION_OVERRIDE - changes the value returned by
>  glGetString(GL_VERSION) for OpenGL ES.
>  <ul>
>  <li> The format should be MAJOR.MINOR
>  <li> Examples: 2.0, 3.0, 3.1
>  <li> Mesa may not really implement all the features of the given version.
> diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c
> index a280690..9ad49db 100644
> --- a/src/mesa/main/version.c
> +++ b/src/mesa/main/version.c
> @@ -133,48 +133,42 @@ create_version_string(struct gl_context *ctx, const char *prefix)
>     }
>  }
>  
>  /**
>   * Override the context's version and/or API type if the
>   * environment variable MESA_GL_VERSION_OVERRIDE is set.
>   *
>   * Example uses of MESA_GL_VERSION_OVERRIDE:
>   *
>   * 2.1: select a compatibility (non-Core) profile with GL version 2.1
> - * 3.0: select a compatibility (non-Core) profile with GL version 3.0
> - * 3.0FC: select a Core+Forward Compatible profile with GL version 3.0
> - * 3.1: select a Core profile with GL version 3.1
> - * 3.1FC: select a Core+Forward Compatible profile with GL version 3.1
> + * X.Y: override GL version to X.Y without changing the profile
> + * X.YFC: select a Core+Forward Compatible profile with GL version X.Y
> + * X.YCOMPAT: select a Compatibility profile with GL version X.Y
>   */
>  bool
>  _mesa_override_gl_version_contextless(struct gl_constants *consts,
>                                        gl_api *apiOut, GLuint *versionOut)
>  {
>     int version;
>     bool fwd_context, compat_context;
>  
>     get_gl_override(*apiOut, &version, &fwd_context, &compat_context);
>  
>     if (version > 0) {
>        *versionOut = version;
>  
> -      /* If the API is a desktop API, adjust the context flags.  We may also
> -       * need to modify the API depending on the version.  For example, Mesa
> -       * does not support a GL 3.3 compatibility profile.
> -       */
> +      /* Modify the API and context flags as needed. */
>        if (*apiOut == API_OPENGL_CORE || *apiOut == API_OPENGL_COMPAT) {
>           if (version >= 30 && fwd_context) {
>              *apiOut = API_OPENGL_CORE;
>              consts->ContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
> -         } else if (version >= 31 && !compat_context) {
> -            *apiOut = API_OPENGL_CORE;
> -         } else {
> +         } else if (compat_context) {

I seem to have missed what it is we're trying to fix.  Without this
patch, if I run 'MESA_GL_VERSION_OVERRIDE=3.1 glxinfo | grep version' I
get more or less the behavior that I expect:

    Max core profile version: 3.1
    Max compat profile version: 3.0
OpenGL version string: 3.1 (Core Profile) Mesa 18.1.0-devel (git-877efedf4a)
OpenGL shading language version string: 4.50

I am wondering where the non-core profile version information is. :(

With this patch, I get

    Max core profile version: 4.5
    Max compat profile version: 3.1
OpenGL core profile version string: 3.1 (Core Profile) Mesa 18.1.0-devel (git-cd435e0882)
OpenGL core profile shading language version string: 4.50
OpenGL version string: 3.1 Mesa 18.1.0-devel (git-cd435e0882)
OpenGL shading language version string: 4.50

Which doesn't seem right... but maybe I'm misunderstanding.  With this
patch, 'MESA_GL_VERSION_OVERRIDE=3.1FC glxinfo | grep version' gives the
same behavior as =3.1 without the patch.

Without this change, MESA_GL_VERSION_OVERRIDE=3.2 seems pretty broken: 

    Max core profile version: 3.2
    Max compat profile version: 3.0
OpenGL core profile version string: 3.2 (Core Profile) Mesa 18.1.0-devel (git-877efedf4a)
OpenGL core profile shading language version string: 4.50
Mesa: User error: GL_INVALID_ENUM in glGetString(GL_EXTENSIONS)
OpenGL version string: 3.2 (Core Profile) Mesa 18.1.0-devel (git-877efedf4a)
OpenGL shading language version string: 4.50

>              *apiOut = API_OPENGL_COMPAT;
>           }
>        }
>  
>        return true;
>     }
>     return false;
>  }
>  
>  void


More information about the mesa-dev mailing list