[Mesa-dev] [PATCH 2/6] mesa: enable OpenGL 3.1 with ARB_compatibility

Marek Olšák maraeo at gmail.com
Thu Feb 15 00:11:20 UTC 2018


From: Marek Olšák <marek.olsak at amd.com>

---
 docs/features.txt                      |  8 ++++----
 docs/relnotes/18.1.0.html              |  5 +++--
 src/mesa/drivers/dri/common/dri_util.c |  8 --------
 src/mesa/main/version.c                | 16 ++++++++++------
 4 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/docs/features.txt b/docs/features.txt
index 1672460..5eae34b 100644
--- a/docs/features.txt
+++ b/docs/features.txt
@@ -17,24 +17,24 @@ DONE (<driver>, ...)
     all the drivers in the brackets.
 
 in progress
     The extension is started but not finished yet.
 
 not started
     The extension isn't started yet.
 
 # OpenGL Core and Compatibility context support
 
-OpenGL 3.1 and later versions are only supported with the Core profile.
-There are no plans to support GL_ARB_compatibility. The last supported OpenGL
-version with all deprecated features is 3.0. Some of the later GL features
-are exposed in the 3.0 context as extensions.
+Some drivers do not support the Compatibility profile or ARB_compatibility.
+Such drivers are limited to OpenGL 3.0 if the Core profile is not requested
+by applications. Some of the later GL features are exposed in the 3.0 context
+as extensions.
 
 
 Feature                                                 Status
 ------------------------------------------------------- ------------------------
 
 GL 3.0, GLSL 1.30 --- all DONE: freedreno, i965, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe, swr
 
   glBindFragDataLocation, glGetFragDataLocation         DONE
   GL_NV_conditional_render (Conditional rendering)      DONE ()
   GL_ARB_map_buffer_range (Map buffer subranges)        DONE ()
diff --git a/docs/relnotes/18.1.0.html b/docs/relnotes/18.1.0.html
index b8a0cd0..d272e72 100644
--- a/docs/relnotes/18.1.0.html
+++ b/docs/relnotes/18.1.0.html
@@ -19,38 +19,39 @@
 <p>
 Mesa 18.1.0 is a new development release. People who are concerned
 with stability and reliability should stick with a previous release or
 wait for Mesa 18.1.1.
 </p>
 <p>
 Mesa 18.1.0 implements the OpenGL 4.5 API, but the version reported by
 glGetString(GL_VERSION) or glGetIntegerv(GL_MAJOR_VERSION) /
 glGetIntegerv(GL_MINOR_VERSION) depends on the particular driver being used.
 Some drivers don't support all the features required in OpenGL 4.5.  OpenGL
-4.5 is <strong>only</strong> available if requested at context creation
-because compatibility contexts are not supported.
+4.5 is <strong>only</strong> available if requested at context creation.
+Compatibility contexts may report a lower version depending on each driver.
 </p>
 
 
 <h2>SHA256 checksums</h2>
 <pre>
 TBD.
 </pre>
 
 
 <h2>New features</h2>
 
 <p>
 Note: some of the new features are only available with certain drivers.
 </p>
 
 <ul>
+<li>OpenGL 3.1 with ARB_compatibility on nv50, nvc0, r600, radeonsi, softpipe, llvmpipe, svga</li>
 <li>GL_EXT_semaphore on radeonsi</li>
 <li>GL_EXT_semaphore_fd on radeonsi</li>
 </ul>
 
 <h2>Bug fixes</h2>
 
 <ul>
 TBD
 </ul>
 
diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c
index e6a7d23..a34f38d 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -374,28 +374,20 @@ driCreateContextAttribs(__DRIscreen *screen, int api,
 	default:
 	    /* We can't create a context that satisfies the requirements of an
 	     * attribute that we don't understand.  Return failure.
 	     */
 	    assert(!"Should not get here.");
 	    *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
 	    return NULL;
 	}
     }
 
-    /* Mesa does not support the GL_ARB_compatibilty extension or the
-     * compatibility profile.  This means that we treat a API_OPENGL_COMPAT 3.1 as
-     * API_OPENGL_CORE and reject API_OPENGL_COMPAT 3.2+.
-     */
-    if (mesa_api == API_OPENGL_COMPAT &&
-        ctx_config.major_version == 3 && ctx_config.minor_version == 1)
-       mesa_api = API_OPENGL_CORE;
-
     if (mesa_api == API_OPENGL_COMPAT
         && ((ctx_config.major_version > 3)
             || (ctx_config.major_version == 3 &&
                 ctx_config.minor_version >= 2))) {
        *error = __DRI_CTX_ERROR_BAD_API;
        return NULL;
     }
 
     /* The latest version of EGL_KHR_create_context spec says:
      *
diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c
index d26baab..a280690 100644
--- a/src/mesa/main/version.c
+++ b/src/mesa/main/version.c
@@ -573,25 +573,25 @@ compute_version_es2(const struct gl_extensions *extensions,
       return 0;
    }
 }
 
 GLuint
 _mesa_get_version(const struct gl_extensions *extensions,
                   struct gl_constants *consts, gl_api api)
 {
    switch (api) {
    case API_OPENGL_COMPAT:
-      /* Disable GLSL 1.40 and later for legacy contexts.
-       * This disallows creation of the GL 3.1 compatibility context. */
+      /* Disable higher GLSL versions for legacy contexts.
+       * This disallows creation of higher compatibility contexts. */
       if (!consts->AllowHigherCompatVersion) {
-         if (consts->GLSLVersion > 130) {
-            consts->GLSLVersion = 130;
+         if (consts->GLSLVersion > 140) {
+            consts->GLSLVersion = 140;
          }
       }
       /* fall through */
    case API_OPENGL_CORE:
       return compute_version(extensions, consts, api);
    case API_OPENGLES:
       return compute_version_es1(extensions);
    case API_OPENGLES2:
       return compute_version_es2(extensions, consts);
    }
@@ -600,29 +600,29 @@ _mesa_get_version(const struct gl_extensions *extensions,
 
 /**
  * Set the context's Version and VersionString fields.
  * This should only be called once as part of context initialization
  * or to perform version check for GLX_ARB_create_context_profile.
  */
 void
 _mesa_compute_version(struct gl_context *ctx)
 {
    if (ctx->Version)
-      return;
+      goto done;
 
    ctx->Version = _mesa_get_version(&ctx->Extensions, &ctx->Const, ctx->API);
    ctx->Extensions.Version = ctx->Version;
 
    /* Make sure that the GLSL version lines up with the GL version. In some
     * cases it can be too high, e.g. if an extension is missing.
     */
-   if (ctx->API == API_OPENGL_CORE) {
+   if (_mesa_is_desktop_gl(ctx) && ctx->Version >= 31) {
       switch (ctx->Version) {
       case 31:
          ctx->Const.GLSLVersion = 140;
          break;
       case 32:
          ctx->Const.GLSLVersion = 150;
          break;
       default:
          ctx->Const.GLSLVersion = ctx->Version * 10;
          break;
@@ -644,20 +644,24 @@ _mesa_compute_version(struct gl_context *ctx)
       break;
 
    case API_OPENGLES2:
       if (!ctx->Version) {
          _mesa_problem(ctx, "Incomplete OpenGL ES 2.0 support.");
          return;
       }
       create_version_string(ctx, "OpenGL ES ");
       break;
    }
+
+done:
+   if (ctx->API == API_OPENGL_COMPAT && ctx->Version >= 31)
+      ctx->Extensions.ARB_compatibility = GL_TRUE;
 }
 
 
 void
 _mesa_get_driver_uuid(struct gl_context *ctx, GLint *uuid)
 {
    ctx->Driver.GetDriverUuid(ctx, (char*) uuid);
 }
 
 void
-- 
2.7.4



More information about the mesa-dev mailing list