mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-16 11:06:49 +01:00
[KMS/DRM] Small refactoring on the SwapWindow function.
This commit is contained in:
parent
e1fb969b76
commit
21003b7db2
@ -128,6 +128,7 @@ KMSDRM_GLES_SwapWindowFenced(_THIS, SDL_Window * window)
|
|||||||
SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
|
SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
|
||||||
KMSDRM_FBInfo *fb;
|
KMSDRM_FBInfo *fb;
|
||||||
KMSDRM_PlaneInfo info = {0};
|
KMSDRM_PlaneInfo info = {0};
|
||||||
|
SDL_bool modesetting = SDL_FALSE;
|
||||||
|
|
||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
/* Create the GPU-side FENCE OBJECT. It will be inserted into the */
|
/* Create the GPU-side FENCE OBJECT. It will be inserted into the */
|
||||||
@ -228,6 +229,7 @@ KMSDRM_GLES_SwapWindowFenced(_THIS, SDL_Window * window)
|
|||||||
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);
|
||||||
|
modesetting = SDL_TRUE;
|
||||||
dispdata->modeset_pending = SDL_FALSE;
|
dispdata->modeset_pending = SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,15 +238,10 @@ KMSDRM_GLES_SwapWindowFenced(_THIS, SDL_Window * window)
|
|||||||
/* this must not block so the game can start building another */
|
/* this must not block so the game can start building another */
|
||||||
/* frame, even if the just-requested pageflip hasnt't completed. */
|
/* frame, even if the just-requested pageflip hasnt't completed. */
|
||||||
/*****************************************************************/
|
/*****************************************************************/
|
||||||
if (drm_atomic_commit(_this, SDL_FALSE, dispdata->modeset_pending)) {
|
if (drm_atomic_commit(_this, SDL_FALSE, modesetting)) {
|
||||||
return SDL_SetError("Failed to issue atomic commit on pageflip");
|
return SDL_SetError("Failed to issue atomic commit on pageflip");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we had a pending modesetting, we have done it by now. */
|
|
||||||
if (dispdata->modeset_pending) {
|
|
||||||
dispdata->modeset_pending = SDL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Release the previous front buffer so EGL can chose it as back buffer
|
/* Release the previous front buffer so EGL can chose it as back buffer
|
||||||
and render on it again. */
|
and render on it again. */
|
||||||
if (windata->bo) {
|
if (windata->bo) {
|
||||||
@ -286,6 +283,7 @@ KMSDRM_GLES_SwapWindowDoubleBuffered(_THIS, SDL_Window * window)
|
|||||||
SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
|
SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
|
||||||
KMSDRM_FBInfo *fb;
|
KMSDRM_FBInfo *fb;
|
||||||
KMSDRM_PlaneInfo info = {0};
|
KMSDRM_PlaneInfo info = {0};
|
||||||
|
SDL_bool modesetting = SDL_FALSE;
|
||||||
|
|
||||||
/**********************************************************************************/
|
/**********************************************************************************/
|
||||||
/* In double-buffer mode, atomic_commit will always be synchronous/blocking (ie: */
|
/* In double-buffer mode, atomic_commit will always be synchronous/blocking (ie: */
|
||||||
@ -337,19 +335,16 @@ KMSDRM_GLES_SwapWindowDoubleBuffered(_THIS, SDL_Window * window)
|
|||||||
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);
|
||||||
|
modesetting = SDL_TRUE;
|
||||||
|
dispdata->modeset_pending = SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Issue the one and only atomic commit where all changes will be requested!.
|
/* Issue the one and only atomic commit where all changes will be requested!.
|
||||||
Blocking for double buffering: won't return until completed. */
|
Blocking for double buffering: won't return until completed. */
|
||||||
if (drm_atomic_commit(_this, SDL_TRUE, dispdata->modeset_pending)) {
|
if (drm_atomic_commit(_this, SDL_TRUE, modesetting)) {
|
||||||
return SDL_SetError("Failed to issue atomic commit on pageflip");
|
return SDL_SetError("Failed to issue atomic commit on pageflip");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we had a pending modesetting, we have done it by now. */
|
|
||||||
if (dispdata->modeset_pending) {
|
|
||||||
dispdata->modeset_pending = SDL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Release last front buffer so EGL can chose it as back buffer and render on it again. */
|
/* Release last front buffer so EGL can chose it as back buffer and render on it again. */
|
||||||
if (windata->bo) {
|
if (windata->bo) {
|
||||||
KMSDRM_gbm_surface_release_buffer(windata->gs, windata->bo);
|
KMSDRM_gbm_surface_release_buffer(windata->gs, windata->bo);
|
||||||
|
Loading…
Reference in New Issue
Block a user