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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2612>
This commit is contained in:
Jonas Ådahl 2022-09-03 18:34:49 +02:00
parent b1a687ae57
commit be4e6484ae

View File

@ -114,10 +114,15 @@ detect_hardware_rendering (MetaRenderDevice *render_device)
if (g_str_has_prefix (renderer_str, "llvmpipe") || if (g_str_has_prefix (renderer_str, "llvmpipe") ||
g_str_has_prefix (renderer_str, "softpipe") || g_str_has_prefix (renderer_str, "softpipe") ||
g_str_has_prefix (renderer_str, "swrast")) g_str_has_prefix (renderer_str, "swrast"))
goto out_has_context; goto out_current_context;
priv->is_hardware_rendering = TRUE; 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: out_has_context:
meta_egl_destroy_context (egl, priv->egl_display, egl_context, NULL); meta_egl_destroy_context (egl, priv->egl_display, egl_context, NULL);
} }