kmsdrm: also do pending modeseting in SwapWindowDoubleBuffered().

This commit is contained in:
Manuel Alfayate Corchete 2020-09-12 04:56:55 +02:00
parent 9e9227add3
commit 5bed30dd61
1 changed files with 34 additions and 17 deletions

View File

@ -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"); 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 */ /* Tell the display (KMS) that it will have to wait on the fence */
/* for the GPU-side 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"); 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, */ /* Issue a non-blocking atomic commit: for triple buffering, */
/* this must not block so the game can start building another */ /* 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"); 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!. /* 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)) { if (drm_atomic_commit(_this, SDL_TRUE)) {