[KMS/DRM] Small refactoring on the SwapWindow function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
diff --git a/src/video/kmsdrm/SDL_kmsdrmopengles.c b/src/video/kmsdrm/SDL_kmsdrmopengles.c
index 0c21a2a..a782bab 100644
--- a/src/video/kmsdrm/SDL_kmsdrmopengles.c
+++ b/src/video/kmsdrm/SDL_kmsdrmopengles.c
@@ -128,6 +128,7 @@ KMSDRM_GLES_SwapWindowFenced(_THIS, SDL_Window * window)
SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
KMSDRM_FBInfo *fb;
KMSDRM_PlaneInfo info = {0};
+ SDL_bool modesetting = SDL_FALSE;
/******************************************************************/
/* 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);
add_crtc_property(dispdata->atomic_req, dispdata->crtc, "MODE_ID", blob_id);
add_crtc_property(dispdata->atomic_req, dispdata->crtc, "active", 1);
+ modesetting = SDL_TRUE;
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 */
/* 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");
}
- /* 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
and render on it again. */
if (windata->bo) {
@@ -286,6 +283,7 @@ KMSDRM_GLES_SwapWindowDoubleBuffered(_THIS, SDL_Window * window)
SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
KMSDRM_FBInfo *fb;
KMSDRM_PlaneInfo info = {0};
+ SDL_bool modesetting = SDL_FALSE;
/**********************************************************************************/
/* 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);
add_crtc_property(dispdata->atomic_req, dispdata->crtc, "MODE_ID", blob_id);
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!.
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");
}
- /* 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. */
if (windata->bo) {
KMSDRM_gbm_surface_release_buffer(windata->gs, windata->bo);