[KMSDRM] Unload GL/EGL libs and destroy GBM only when we are destroying the last window.

This commit is contained in:
vanfanel 2021-03-18 12:02:54 +01:00 committed by Sam Lantinga
parent c35e71892e
commit 82ff6045fa

View File

@ -1079,7 +1079,7 @@ KMSDRM_DestroyWindow(_THIS, SDL_Window *window)
return; return;
} }
if ( !is_vulkan && viddata->gbm_init ) { if ( !is_vulkan && viddata->gbm_init) {
/* Destroy the window display's cursor GBM BO. */ /* Destroy the window display's cursor GBM BO. */
KMSDRM_DestroyCursorBO(_this, SDL_GetDisplayForWindow(window)); KMSDRM_DestroyCursorBO(_this, SDL_GetDisplayForWindow(window));
@ -1087,14 +1087,18 @@ KMSDRM_DestroyWindow(_THIS, SDL_Window *window)
/* Destroy GBM surface and buffers. */ /* Destroy GBM surface and buffers. */
KMSDRM_DestroySurfaces(_this, window); KMSDRM_DestroySurfaces(_this, window);
/* Unload EGL/GL library and free egl_data. */ /* Unload library and deinit GBM, but only if this is the last remaining window.*/
if (_this->egl_data) { if (viddata->num_windows < 2) {
SDL_EGL_UnloadLibrary(_this);
_this->gl_config.driver_loaded = 0;
}
/* Free display plane, and destroy GBM device. */ /* Unload EGL/GL library and free egl_data. */
KMSDRM_GBMDeinit(_this, dispdata); if (_this->egl_data) {
SDL_EGL_UnloadLibrary(_this);
_this->gl_config.driver_loaded = 0;
}
/* Free display plane, and destroy GBM device. */
KMSDRM_GBMDeinit(_this, dispdata);
}
} else { } else {