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

This commit is contained in:
Manuel Alfayate Corchete 2020-12-28 14:37:58 +01:00
parent 7186584b8d
commit 0feaf7d196
3 changed files with 16 additions and 42 deletions

View File

@ -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); 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); 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, "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; 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); 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); 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, "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; dispdata->modeset_pending = SDL_FALSE;
} }

View File

@ -1319,45 +1319,26 @@ KMSDRM_GBMDeinit (_THIS, SDL_DisplayData *dispdata)
dispdata->gbm_init = SDL_FALSE; 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 void
KMSDRM_DestroySurfaces(_THIS, SDL_Window *window) KMSDRM_DestroySurfaces(_THIS, SDL_Window *window)
{ {
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata; 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 */ /* Destroy the EGL surface */
/* it's using, by making it point to the original CRTC buffer, */ /***************************/
/* where the TTY console should be. */
/********************************************************************/
plane_info.plane = dispdata->display_plane; SDL_EGL_MakeCurrent(_this, EGL_NO_SURFACE, EGL_NO_CONTEXT);
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;
drm_atomic_set_plane_props(&plane_info); if (windata->egl_surface != EGL_NO_SURFACE) {
SDL_EGL_DestroySurface(_this, windata->egl_surface);
/* Issue blocking atomic commit. */ windata->egl_surface = EGL_NO_SURFACE;
if (drm_atomic_commit(_this, SDL_TRUE)) {
SDL_SetError("Failed to issue atomic commit on surfaces destruction.");
} }
/****************************************************************************/ /***************************/
/* BLOCK 2: We can finally destroy the window GBM and EGL surfaces, and */ /* Destroy the GBM buffers */
/* GBM buffers now that the buffers are not being used by the PRIMARY PLANE */ /***************************/
/* anymore. */
/****************************************************************************/
/* Destroy the GBM surface and buffers. */
if (windata->bo) { if (windata->bo) {
KMSDRM_gbm_surface_release_buffer(windata->gs, windata->bo); KMSDRM_gbm_surface_release_buffer(windata->gs, windata->bo);
windata->bo = NULL; windata->bo = NULL;
@ -1368,16 +1349,9 @@ KMSDRM_DestroySurfaces(_THIS, SDL_Window *window)
windata->next_bo = NULL; windata->next_bo = NULL;
} }
/***************************************************************************/ /***************************/
/* Destroy the EGL surface. */ /* Destroy the GBM 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;
}
if (windata->gs) { if (windata->gs) {
KMSDRM_gbm_surface_destroy(windata->gs); KMSDRM_gbm_surface_destroy(windata->gs);

View File

@ -57,7 +57,7 @@ typedef struct SDL_VideoData
SDL_bool video_init; /* Has VideoInit succeeded? */ 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; } SDL_VideoData;