From a0a88e329de1ea5216736d1042b657adaa547e3e Mon Sep 17 00:00:00 2001 From: Icenowy Zheng Date: Fri, 1 May 2026 00:37:18 +0800 Subject: [PATCH] dri: try to enable GL_ARB_compatiblity when supported GL core version is 3.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Marek Olšák Part-of: --- src/gallium/frontends/dri/dri_util.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/gallium/frontends/dri/dri_util.c b/src/gallium/frontends/dri/dri_util.c index 0d02d3f5ff4..21e2a7436d8 100644 --- a/src/gallium/frontends/dri/dri_util.c +++ b/src/gallium/frontends/dri/dri_util.c @@ -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