From be4e6484ae600e1757fc2d13461ded9777829fbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Sat, 3 Sep 2022 18:34:49 +0200 Subject: [PATCH] render-device: Unmake the EGLContext after checking whether hw accelerated When creating a render device, we create a temporary EGLContext where we then query the `GL_RENDERER` string to check whether the renderer is any of the known software renderers. After we're done, we destroy the context and move on. This should be fine as according to specification eglDestroyContext(), with the context being actually destroyed a bit later when it's no longer current, but mesa, when running RK3399 (Pinebook Pro), this results in a crash in a future eglMakeCurrent(): #0 in dri_unbind_context () at ../src/gallium/frontends/dri/dri_context.c:266 #1 in driUnbindContext () at ../src/gallium/frontends/dri/dri_util.c:763 #2 in dri2_make_current () at ../src/egl/drivers/dri2/egl_dri2.c:1814 #3 in eglMakeCurrent () at ../src/egl/main/eglapi.c:907 ... We can avoid this, however, by calling eglMakeCurrent() with EGL_NO_CONTEXT on the EGLDisplay, prior to destroying, effectively avoiding the crash, so lets do that. Related: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7194 Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2414 Part-of: --- src/backends/native/meta-render-device.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/backends/native/meta-render-device.c b/src/backends/native/meta-render-device.c index 982f30814..65e482ad9 100644 --- a/src/backends/native/meta-render-device.c +++ b/src/backends/native/meta-render-device.c @@ -114,10 +114,15 @@ detect_hardware_rendering (MetaRenderDevice *render_device) if (g_str_has_prefix (renderer_str, "llvmpipe") || g_str_has_prefix (renderer_str, "softpipe") || g_str_has_prefix (renderer_str, "swrast")) - goto out_has_context; + goto out_current_context; priv->is_hardware_rendering = TRUE; +out_current_context: + meta_egl_make_current (egl, priv->egl_display, + EGL_NO_SURFACE, EGL_NO_SURFACE, + EGL_NO_CONTEXT, NULL); + out_has_context: meta_egl_destroy_context (egl, priv->egl_display, egl_context, NULL); }