Commit 5bed30dd610ea0d8b5ba65d72ec54596a09d98e5

Manuel Alfayate Corchete 2020-09-12T04:56:55

kmsdrm: also do pending modeseting in SwapWindowDoubleBuffered().

diff --git a/src/video/kmsdrm/SDL_kmsdrmopengles.c b/src/video/kmsdrm/SDL_kmsdrmopengles.c
index f7c2d85..12bd354 100644
--- a/src/video/kmsdrm/SDL_kmsdrmopengles.c
+++ b/src/video/kmsdrm/SDL_kmsdrmopengles.c
@@ -179,23 +179,6 @@ KMSDRM_GLES_SwapWindowFenced(_THIS, SDL_Window * window)
         return SDL_SetError("Failed to request prop changes for setting plane buffer and CRTC");
     }
 
-    /* Do we have a pending modesetting? If so, set the necessary 
-       props so it's included in the incoming atomic commit. */
-    if (dispdata->modeset_pending) {
-        SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata;
-	uint32_t blob_id;
-        dispdata->atomic_flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
- 	if (add_connector_property(dispdata->atomic_req, dispdata->connector, "CRTC_ID", dispdata->crtc->crtc->crtc_id) < 0)
-            return -1;
-        if (KMSDRM_drmModeCreatePropertyBlob(viddata->drm_fd, &dispdata->mode, sizeof(dispdata->mode), &blob_id) != 0)
-            return -1;
-        if (add_crtc_property(dispdata->atomic_req, dispdata->crtc, "MODE_ID", blob_id) < 0)
-            return -1;
-        if (add_crtc_property(dispdata->atomic_req, dispdata->crtc, "ACTIVE", 1) < 0)
-            return -1;
-        dispdata->modeset_pending = SDL_FALSE;
-    }
-
     /*****************************************************************/
     /* Tell the display (KMS) that it will have to wait on the fence */
     /* for the GPU-side FENCE.                                       */
@@ -223,6 +206,23 @@ KMSDRM_GLES_SwapWindowFenced(_THIS, SDL_Window * window)
             return SDL_SetError("Failed to set CRTC OUT_FENCE_PTR prop");
     }
 
+    /* Do we have a pending modesetting? If so, set the necessary 
+       props so it's included in the incoming atomic commit. */
+    if (dispdata->modeset_pending) {
+        SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata;
+	uint32_t blob_id;
+        dispdata->atomic_flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
+ 	if (add_connector_property(dispdata->atomic_req, dispdata->connector, "CRTC_ID", dispdata->crtc->crtc->crtc_id) < 0)
+            return -1;
+        if (KMSDRM_drmModeCreatePropertyBlob(viddata->drm_fd, &dispdata->mode, sizeof(dispdata->mode), &blob_id) != 0)
+            return -1;
+        if (add_crtc_property(dispdata->atomic_req, dispdata->crtc, "MODE_ID", blob_id) < 0)
+            return -1;
+        if (add_crtc_property(dispdata->atomic_req, dispdata->crtc, "ACTIVE", 1) < 0)
+            return -1;
+        dispdata->modeset_pending = SDL_FALSE;
+    }
+
     /*****************************************************************/   
     /* Issue a non-blocking atomic commit: for triple buffering,     */
     /* this must not block so the game can start building another    */
@@ -314,6 +314,23 @@ KMSDRM_GLES_SwapWindowDoubleBuffered(_THIS, SDL_Window * window)
         return SDL_SetError("Failed to request prop changes for setting plane buffer and CRTC");
     }
 
+    /* Do we have a pending modesetting? If so, set the necessary 
+       props so it's included in the incoming atomic commit. */
+    if (dispdata->modeset_pending) {
+        SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata;
+	uint32_t blob_id;
+        dispdata->atomic_flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
+ 	if (add_connector_property(dispdata->atomic_req, dispdata->connector, "CRTC_ID", dispdata->crtc->crtc->crtc_id) < 0)
+            return -1;
+        if (KMSDRM_drmModeCreatePropertyBlob(viddata->drm_fd, &dispdata->mode, sizeof(dispdata->mode), &blob_id) != 0)
+            return -1;
+        if (add_crtc_property(dispdata->atomic_req, dispdata->crtc, "MODE_ID", blob_id) < 0)
+            return -1;
+        if (add_crtc_property(dispdata->atomic_req, dispdata->crtc, "ACTIVE", 1) < 0)
+            return -1;
+        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)) {