Commit 0feaf7d196b2044f49052616f59df9255c2bf2b5

Manuel Alfayate Corchete 2020-12-28T14:37:58

[KMS/DRM][Vulkan] Correct non-existing property. Remove hacky surface destruction code (TTY buffer isn't there after a Vulkan window is created).

diff --git a/src/video/kmsdrm/SDL_kmsdrmopengles.c b/src/video/kmsdrm/SDL_kmsdrmopengles.c
index 664621d..a828f3a 100644
--- a/src/video/kmsdrm/SDL_kmsdrmopengles.c
+++ b/src/video/kmsdrm/SDL_kmsdrmopengles.c
@@ -228,7 +228,7 @@ KMSDRM_GLES_SwapWindowFenced(_THIS, SDL_Window * window)
         add_connector_property(dispdata->atomic_req, dispdata->connector, "CRTC_ID", dispdata->crtc->crtc->crtc_id);
         KMSDRM_drmModeCreatePropertyBlob(viddata->drm_fd, &dispdata->mode, sizeof(dispdata->mode), &blob_id);
         add_crtc_property(dispdata->atomic_req, dispdata->crtc, "MODE_ID", blob_id);
-        add_crtc_property(dispdata->atomic_req, dispdata->crtc, "ACTIVE", 1);
+        add_crtc_property(dispdata->atomic_req, dispdata->crtc, "active", 1);
         dispdata->modeset_pending = SDL_FALSE;
     }
 
@@ -330,7 +330,7 @@ KMSDRM_GLES_SwapWindowDoubleBuffered(_THIS, SDL_Window * window)
         add_connector_property(dispdata->atomic_req, dispdata->connector, "CRTC_ID", dispdata->crtc->crtc->crtc_id);
         KMSDRM_drmModeCreatePropertyBlob(viddata->drm_fd, &dispdata->mode, sizeof(dispdata->mode), &blob_id);
         add_crtc_property(dispdata->atomic_req, dispdata->crtc, "MODE_ID", blob_id);
-        add_crtc_property(dispdata->atomic_req, dispdata->crtc, "ACTIVE", 1);
+        add_crtc_property(dispdata->atomic_req, dispdata->crtc, "active", 1);
         dispdata->modeset_pending = SDL_FALSE;
     }
 
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c
index b8ec424..57fced5 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.c
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c
@@ -1319,45 +1319,26 @@ KMSDRM_GBMDeinit (_THIS, SDL_DisplayData *dispdata)
     dispdata->gbm_init = SDL_FALSE;
 }
 
-/* Destroy the window surfaces and buffers. Have the PRIMARY PLANE
-   disconnected from these buffers before doing so, or have the PRIMARY PLANE
-   reading the original FB where the TTY lives, before doing this, or CRTC will
-   be disconnected by the kernel. */
 void
 KMSDRM_DestroySurfaces(_THIS, SDL_Window *window)
 {
     SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
-    SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0);
-    KMSDRM_PlaneInfo plane_info = {0};
-
-    /********************************************************************/
-    /* BLOCK 1: protect the PRIMARY PLANE before destroying the buffers */
-    /* it's using, by making it point to the original CRTC buffer,      */
-    /* where the TTY console should be.                                 */
-    /********************************************************************/
 
-    plane_info.plane = dispdata->display_plane;
-    plane_info.crtc_id = dispdata->crtc->crtc->crtc_id;
-    plane_info.fb_id = dispdata->crtc->crtc->buffer_id;
-    plane_info.src_w = dispdata->mode.hdisplay;
-    plane_info.src_h = dispdata->mode.vdisplay;
-    plane_info.crtc_w = dispdata->mode.hdisplay;
-    plane_info.crtc_h = dispdata->mode.vdisplay;
+    /***************************/
+    /* Destroy the EGL surface */
+    /***************************/
 
-    drm_atomic_set_plane_props(&plane_info);
+    SDL_EGL_MakeCurrent(_this, EGL_NO_SURFACE, EGL_NO_CONTEXT);
 
-    /* Issue blocking atomic commit. */
-    if (drm_atomic_commit(_this, SDL_TRUE)) {
-        SDL_SetError("Failed to issue atomic commit on surfaces destruction.");
+    if (windata->egl_surface != EGL_NO_SURFACE) {
+        SDL_EGL_DestroySurface(_this, windata->egl_surface);
+        windata->egl_surface = EGL_NO_SURFACE;
     }
 
-    /****************************************************************************/
-    /* BLOCK 2: We can finally destroy the window GBM and EGL surfaces, and     */
-    /* GBM buffers now that the buffers are not being used by the PRIMARY PLANE */
-    /* anymore.                                                                 */
-    /****************************************************************************/
+    /***************************/
+    /* Destroy the GBM buffers */
+    /***************************/
 
-    /* Destroy the GBM surface and buffers. */
     if (windata->bo) {
         KMSDRM_gbm_surface_release_buffer(windata->gs, windata->bo);
         windata->bo = NULL;
@@ -1368,16 +1349,9 @@ KMSDRM_DestroySurfaces(_THIS, SDL_Window *window)
         windata->next_bo = NULL;
     }
 
-    /***************************************************************************/
-    /* Destroy the EGL surface.                                                */
-    /***************************************************************************/
-
-    SDL_EGL_MakeCurrent(_this, EGL_NO_SURFACE, EGL_NO_CONTEXT);
-
-    if (windata->egl_surface != EGL_NO_SURFACE) {
-        SDL_EGL_DestroySurface(_this, windata->egl_surface);
-        windata->egl_surface = EGL_NO_SURFACE;
-    }
+    /***************************/
+    /* Destroy the GBM surface */
+    /***************************/
 
     if (windata->gs) {
         KMSDRM_gbm_surface_destroy(windata->gs);
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.h b/src/video/kmsdrm/SDL_kmsdrmvideo.h
index edb0e16..1023c1d 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.h
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.h
@@ -57,7 +57,7 @@ typedef struct SDL_VideoData
 
     SDL_bool video_init;        /* Has VideoInit succeeded? */
 
-    SDL_bool vulkan_mode;       /* Are we in Vulkan mode? One VK window is enough. */
+    SDL_bool vulkan_mode;       /* Are we in Vulkan mode? One VK window is enough to be. */
 
 } SDL_VideoData;