egl: Factor some common terminate cleanup up to common code
authorAdam Jackson <ajax@redhat.com>
Tue, 20 Sep 2022 18:55:37 +0000 (14:55 -0400)
committerMarge Bot <emma+marge@anholt.net>
Tue, 27 Sep 2022 16:00:45 +0000 (16:00 +0000)
It's a little difficult to see from the diff, but this is effectively
the same calling sequence as before, and more importantly it means the
backend only cleans up backend state rather than needing to call up to
the core.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18824>

src/egl/drivers/dri2/egl_dri2.c
src/egl/drivers/wgl/egl_wgl.c
src/egl/main/eglapi.c
src/egl/main/egldisplay.c

index 13d9575..356548e 100644 (file)
@@ -1225,7 +1225,6 @@ dri2_display_release(_EGLDisplay *disp)
    if (!p_atomic_dec_zero(&dri2_dpy->ref_count))
       return;
 
-   _eglCleanupDisplay(disp);
    dri2_display_destroy(disp);
 }
 
@@ -1327,9 +1326,6 @@ dri2_egl_surface_free_local_buffers(struct dri2_egl_surface *dri2_surf)
 static EGLBoolean
 dri2_terminate(_EGLDisplay *disp)
 {
-   /* Release all non-current Context/Surfaces. */
-   _eglReleaseDisplayResources(disp);
-
    dri2_display_release(disp);
 
    return EGL_TRUE;
index 9165ae5..f069b45 100644 (file)
@@ -357,7 +357,6 @@ wgl_display_release(_EGLDisplay *disp)
    if (!p_atomic_dec_zero(&wgl_dpy->ref_count))
       return;
 
-   _eglCleanupDisplay(disp);
    wgl_display_destroy(disp);
 }
 
@@ -370,9 +369,6 @@ wgl_display_release(_EGLDisplay *disp)
 static EGLBoolean
 wgl_terminate(_EGLDisplay *disp)
 {
-   /* Release all non-current Context/Surfaces. */
-   _eglReleaseDisplayResources(disp);
-
    wgl_display_release(disp);
 
    return EGL_TRUE;
index f9d32b9..57df75c 100644 (file)
@@ -779,14 +779,9 @@ eglTerminate(EGLDisplay dpy)
       RETURN_EGL_ERROR(NULL, EGL_BAD_DISPLAY, EGL_FALSE);
 
    if (disp->Initialized) {
+      _eglReleaseDisplayResources(disp);
       disp->Driver->Terminate(disp);
-      /* do not reset disp->Driver */
-      disp->ClientAPIsString[0] = 0;
-      disp->Initialized = EGL_FALSE;
-
-      /* Reset blob cache funcs on terminate. */
-      disp->BlobCacheSet = NULL;
-      disp->BlobCacheGet = NULL;
+      _eglCleanupDisplay(disp);
    }
 
    simple_mtx_unlock(&disp->Mutex);
index 39850e3..52a9102 100644 (file)
@@ -370,7 +370,13 @@ _eglCleanupDisplay(_EGLDisplay *disp)
       disp->Configs = NULL;
    }
 
-   /* XXX incomplete */
+   /* do not reset disp->Driver */
+   disp->ClientAPIsString[0] = 0;
+   disp->Initialized = EGL_FALSE;
+
+   /* Reset blob cache funcs on terminate. */
+   disp->BlobCacheSet = NULL;
+   disp->BlobCacheGet = NULL;
 }