egl: handle NULL loaderPrivate in dri_is_thread_safe
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Mon, 2 Jan 2023 16:27:41 +0000 (17:27 +0100)
committerEric Engestrom <eric@engestrom.ch>
Wed, 11 Jan 2023 17:44:21 +0000 (17:44 +0000)
This can happen when a context is created from
loader_dri3_blit_context_get and glthread is enabled.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7949
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7960
Cc: mesa-stable
Acked-by: Eric Engestrom <eric@igalia.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20479>
(cherry picked from commit b111e8aa4940e8b155f38b5ef238c295ded8a6b4)

.pick_status.json
src/egl/drivers/dri2/egl_dri2.c

index d0c2ce7..3dd47a4 100644 (file)
         "description": "egl: handle NULL loaderPrivate in dri_is_thread_safe",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
index 0157665..1f718b4 100644 (file)
@@ -158,12 +158,20 @@ dri2_gl_flush()
 }
 
 static GLboolean
-dri_is_thread_safe(void *loaderPrivate)
+dri_is_thread_safe(UNUSED void *loaderPrivate)
 {
+#ifdef HAVE_X11_PLATFORM
    struct dri2_egl_surface *dri2_surf = loaderPrivate;
-   UNUSED _EGLDisplay *display =  dri2_surf->base.Resource.Display;
 
-#ifdef HAVE_X11_PLATFORM
+   /* loader_dri3_blit_context_get creates a context with
+    * loaderPrivate being NULL. Enabling glthread for a blitting
+    * context isn't useful so return false.
+    */
+   if (!loaderPrivate)
+      return false;
+
+   _EGLDisplay *display =  dri2_surf->base.Resource.Display;
+
    Display *xdpy = (Display*)display->PlatformDisplay;
 
    /* Check Xlib is running in thread safe mode when running on EGL/X11-xlib