Mesa (master): i965: Use allow_higher_compat_version option during screen initialization

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jan 28 03:29:05 UTC 2021


Module: Mesa
Branch: master
Commit: f11a827941c5cc0bf986863975a77e4d892f00e1
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f11a827941c5cc0bf986863975a77e4d892f00e1

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Fri Oct 30 12:28:22 2020 -0700

i965: Use allow_higher_compat_version option during screen initialization

Currently, `allow_higher_compat_version` is only used during context
creation.  Doing that means an application that doesn't request a
specific version can be given a version higher than 3.0.

However, an application still cannot request a higher version via
glXCreateContextAttribsARB.  The GLX and DRI layers will only see that
version 3.0 is supported, so context creation will fail before the drive
is called.  For this to work, max_gl_compat_version must be set to a
higher version.

This enables running many piglit tests on i965 with
allow_higher_compat_version.

v2: Fix a typo in a comment.  Noticed by Tim.  Fix a typo in the commit
message.  Noticed by the spell checker. :)

v3: Don't parse driconf again.  Suggested by Tim.

Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7387>

---

 src/mesa/drivers/dri/i965/brw_context.c  | 23 +++++++++++++++++++++++
 src/mesa/drivers/dri/i965/intel_screen.c | 11 +++++++++++
 2 files changed, 34 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index bdb754d41eb..c26387fdf9f 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -1148,6 +1148,29 @@ brwCreateContext(gl_api api,
    _mesa_override_extensions(ctx);
    _mesa_compute_version(ctx);
 
+#ifndef NDEBUG
+   /* Enforce that the version of the context that was created is at least as
+    * high as the version that was advertised via GLX / EGL / whatever window
+    * system.
+    */
+   const __DRIscreen *const dri_screen = brw->screen->driScrnPriv;
+
+   switch (api) {
+   case API_OPENGL_COMPAT:
+      assert(ctx->Version >= dri_screen->max_gl_compat_version);
+      break;
+   case API_OPENGLES:
+      assert(ctx->Version >= dri_screen->max_gl_es1_version);
+      break;
+   case API_OPENGLES2:
+      assert(ctx->Version >= dri_screen->max_gl_es2_version);
+      break;
+   case API_OPENGL_CORE:
+      assert(ctx->Version >= dri_screen->max_gl_core_version);
+      break;
+   }
+#endif
+
    /* GL_ARB_gl_spirv */
    if (ctx->Extensions.ARB_gl_spirv) {
       brw_initialize_spirv_supported_capabilities(brw);
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index 1c7f0ae3e75..97acef16364 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -2502,6 +2502,17 @@ set_max_gl_versions(struct intel_screen *screen)
       dri_screen->max_gl_compat_version =
          MIN2(32, dri_screen->max_gl_compat_version);
    }
+
+   /* Using the `allow_higher_compat_version` option during context creation
+    * means that an application that doesn't request a specific version can be
+    * given a version higher than 3.0.  However, an application still cannot
+    * request a higher version.  For that to work, max_gl_compat_version must
+    * be set.
+    */
+   if (dri_screen->max_gl_compat_version < dri_screen->max_gl_core_version) {
+      if (driQueryOptionb(&screen->optionCache, "allow_higher_compat_version"))
+         dri_screen->max_gl_compat_version = dri_screen->max_gl_core_version;
+   }
 }
 
 static void



More information about the mesa-commit mailing list