dri: try to enable GL_ARB_compatiblity when supported GL core version is 3.1
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

OpenGL 3.1 is a transitional version in the progression of dropping
legacy features. It does not feature a "Compatibility Profile", instead
only GL_ARB_compatiblity extension is defined for it.

Programs that queries GL_CONTEXT_PROFILE_MASK at runtime and call the
compatibility codepath when this query doesn't exist or the query
returns GL_CONTEXT_COMPATIBILITY_PROFILE_BIT will work on OpenGL
implementation with a version < 3.1 or a version > 3.1, but not on
implementations targetting OpenGL 3.1 and lacking GL_ARB_compatiblity.
As most programmers now have hardwares and drivers targetting version >
3.1 installed, such error is hard to catch.

So try the best to enable GL_ARB_compatiblity on drivers exposing
exactly OpenGL 3.1 to satisfy such programs. It's still possible to use
MESA_GL_VERSION_OVERRIDE=3.1FC to acquire a context w/o
GL_ARB_compatiblity on such drivers.

Fixes the overview functionality of kwin_wayland on panfrost with
Mali-G57 (which exposes OpenGL 3.1 on current Mesa), although the
problematic profile detection code is in Qt instead of KWin.

Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41298>
This commit is contained in:
Icenowy Zheng 2026-05-01 00:37:18 +08:00 committed by Marge Bot
parent f583f6e717
commit a0a88e329d

View file

@ -527,6 +527,19 @@ driCreateContextAttribs(struct dri_screen *screen, int api,
screen->max_gl_compat_version < 31)
mesa_api = API_OPENGL_CORE;
/* If the screen supports at maximum OpenGL 3.1, it's free to implement
* GL_ARB_compatibility or not. However, as OpenGL 3.1 is a corner case
* on the Core vs Compatiblity thing (it has no Compatibility Profile
* defined, only GL_ARB_compatibility extension defined), some applications
* will misbehave without GL_ARB_compatibility, so try hard to support
* GL_ARB_compatiblity in such case.
*/
if (mesa_api == API_OPENGL_CORE &&
ctx_config.major_version == 3 && ctx_config.minor_version == 1 &&
screen->max_gl_compat_version == 31 &&
screen->max_gl_core_version == 31)
mesa_api = API_OPENGL_COMPAT;
/* The latest version of EGL_KHR_create_context spec says:
*
* "If the EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR flag bit is set in