kmsdrm: more coherent returns for SwapWindow.
parent
d3d9d432ac
commit
68ac9349aa
|
@ -81,11 +81,12 @@ KMSDRM_GLES_SwapWindow(_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};
|
||||||
int ret;
|
|
||||||
|
|
||||||
/* Recreate the GBM / EGL surfaces if the window has been reconfigured. */
|
/* Recreate the GBM / EGL surfaces if the window has been reconfigured. */
|
||||||
if (windata->egl_surface_dirty) {
|
if (windata->egl_surface_dirty) {
|
||||||
KMSDRM_CreateSurfaces(_this, window);
|
if (KMSDRM_CreateSurfaces(_this, window)) {
|
||||||
|
return SDL_SetError("Failed to do pending surfaces creation");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
@ -101,7 +102,7 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window)
|
||||||
/* Mark, at EGL level, the buffer that we want to become the new front buffer.
|
/* Mark, at EGL level, the buffer that we want to become the new front buffer.
|
||||||
However, it won't really happen until we request a pageflip at the KMS level and it completes. */
|
However, it won't really happen until we request a pageflip at the KMS level and it completes. */
|
||||||
if (! _this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, windata->egl_surface)) {
|
if (! _this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, windata->egl_surface)) {
|
||||||
SDL_EGL_SetError("Failed to swap EGL buffers", "eglSwapBuffers");
|
return SDL_EGL_SetError("Failed to swap EGL buffers", "eglSwapBuffers");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* It's safe to get the gpu_fence FD now, because eglSwapBuffers flushes it down the cmdstream,
|
/* It's safe to get the gpu_fence FD now, because eglSwapBuffers flushes it down the cmdstream,
|
||||||
|
@ -139,8 +140,7 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window)
|
||||||
info.crtc_h = windata->output_h;
|
info.crtc_h = windata->output_h;
|
||||||
info.crtc_x = windata->output_x;
|
info.crtc_x = windata->output_x;
|
||||||
|
|
||||||
ret = drm_atomic_set_plane_props(&info);
|
if (drm_atomic_set_plane_props(&info)) {
|
||||||
if (ret) {
|
|
||||||
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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,10 +148,10 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window)
|
||||||
Just in case we come here after a DestroySurfaces() call. */
|
Just in case we come here after a DestroySurfaces() call. */
|
||||||
if (add_connector_property(dispdata->atomic_req, dispdata->connector , "CRTC_ID",
|
if (add_connector_property(dispdata->atomic_req, dispdata->connector , "CRTC_ID",
|
||||||
dispdata->crtc->crtc->crtc_id) < 0)
|
dispdata->crtc->crtc->crtc_id) < 0)
|
||||||
SDL_SetError("Failed to set CONNECTOR prop CRTC_ID to zero before buffer destruction");
|
return SDL_SetError("Failed to set CONNECTOR prop CRTC_ID to zero before buffer destruction");
|
||||||
|
|
||||||
if (add_crtc_property(dispdata->atomic_req, dispdata->crtc , "ACTIVE", 1) < 0)
|
if (add_crtc_property(dispdata->atomic_req, dispdata->crtc , "ACTIVE", 1) < 0)
|
||||||
SDL_SetError("Failed to set CRTC prop ACTIVE to zero before buffer destruction");
|
return SDL_SetError("Failed to set CRTC prop ACTIVE to zero before buffer destruction");
|
||||||
|
|
||||||
/* Set the IN_FENCE and OUT_FENCE props only here, since this is the only place
|
/* Set the IN_FENCE and OUT_FENCE props only here, since this is the only place
|
||||||
on which we're interested in managing who and when should access the buffers
|
on which we're interested in managing who and when should access the buffers
|
||||||
|
@ -168,8 +168,7 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window)
|
||||||
/* 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!.
|
||||||
We need e a non-blocking atomic commit for triple buffering, because we
|
We need e a non-blocking atomic commit for triple buffering, because we
|
||||||
must not block on this atomic commit so we can re-enter program loop once more. */
|
must not block on this atomic commit so we can re-enter program loop once more. */
|
||||||
ret = drm_atomic_commit(_this, SDL_FALSE);
|
if (drm_atomic_commit(_this, SDL_FALSE)) {
|
||||||
if (ret) {
|
|
||||||
return SDL_SetError("Failed to issue atomic commit on pageflip");
|
return SDL_SetError("Failed to issue atomic commit on pageflip");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +199,7 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window)
|
||||||
/* Block ends. */
|
/* Block ends. */
|
||||||
/***************/
|
/***************/
|
||||||
|
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -210,11 +209,12 @@ KMSDRM_GLES_SwapWindowDB(_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};
|
||||||
int ret;
|
|
||||||
|
|
||||||
/* Recreate the GBM / EGL surfaces if the window has been reconfigured. */
|
/* Recreate the GBM / EGL surfaces if the window has been reconfigured. */
|
||||||
if (windata->egl_surface_dirty) {
|
if (windata->egl_surface_dirty) {
|
||||||
KMSDRM_CreateSurfaces(_this, window);
|
if (KMSDRM_CreateSurfaces(_this, window)) {
|
||||||
|
return SDL_SetError("Failed to do pending surfaces creation");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************************************/
|
/****************************************************************************************************/
|
||||||
|
@ -227,7 +227,7 @@ KMSDRM_GLES_SwapWindowDB(_THIS, SDL_Window * window)
|
||||||
/* Mark, at EGL level, the buffer that we want to become the new front buffer.
|
/* Mark, at EGL level, the buffer that we want to become the new front buffer.
|
||||||
However, it won't really happen until we request a pageflip at the KMS level and it completes. */
|
However, it won't really happen until we request a pageflip at the KMS level and it completes. */
|
||||||
if (! _this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, windata->egl_surface)) {
|
if (! _this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, windata->egl_surface)) {
|
||||||
SDL_EGL_SetError("Failed to swap EGL buffers", "eglSwapBuffers");
|
return SDL_EGL_SetError("Failed to swap EGL buffers", "eglSwapBuffers");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Lock the buffer that is marked by eglSwapBuffers() to become the next front buffer (so it can not
|
/* Lock the buffer that is marked by eglSwapBuffers() to become the next front buffer (so it can not
|
||||||
|
@ -252,8 +252,7 @@ KMSDRM_GLES_SwapWindowDB(_THIS, SDL_Window * window)
|
||||||
info.crtc_h = windata->output_h;
|
info.crtc_h = windata->output_h;
|
||||||
info.crtc_x = windata->output_x;
|
info.crtc_x = windata->output_x;
|
||||||
|
|
||||||
ret = drm_atomic_set_plane_props(&info);
|
if (drm_atomic_set_plane_props(&info)) {
|
||||||
if (ret) {
|
|
||||||
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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,16 +260,14 @@ KMSDRM_GLES_SwapWindowDB(_THIS, SDL_Window * window)
|
||||||
Just in case we come here after a DestroySurfaces() call. */
|
Just in case we come here after a DestroySurfaces() call. */
|
||||||
if (add_connector_property(dispdata->atomic_req, dispdata->connector , "CRTC_ID",
|
if (add_connector_property(dispdata->atomic_req, dispdata->connector , "CRTC_ID",
|
||||||
dispdata->crtc->crtc->crtc_id) < 0)
|
dispdata->crtc->crtc->crtc_id) < 0)
|
||||||
SDL_SetError("Failed to set CONNECTOR prop CRTC_ID to zero before buffer destruction");
|
return SDL_SetError("Failed to set CONNECTOR prop CRTC_ID to zero before buffer destruction");
|
||||||
|
|
||||||
if (add_crtc_property(dispdata->atomic_req, dispdata->crtc , "ACTIVE", 1) < 0)
|
if (add_crtc_property(dispdata->atomic_req, dispdata->crtc , "ACTIVE", 1) < 0)
|
||||||
SDL_SetError("Failed to set CRTC prop ACTIVE to zero before buffer destruction");
|
return SDL_SetError("Failed to set CRTC prop ACTIVE to zero before buffer destruction");
|
||||||
|
|
||||||
/* 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. */
|
||||||
ret = drm_atomic_commit(_this, SDL_TRUE);
|
if (drm_atomic_commit(_this, SDL_TRUE)) {
|
||||||
|
|
||||||
if (ret) {
|
|
||||||
return SDL_SetError("Failed to issue atomic commit");
|
return SDL_SetError("Failed to issue atomic commit");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,7 +279,7 @@ KMSDRM_GLES_SwapWindowDB(_THIS, SDL_Window * window)
|
||||||
/* Take note of current front buffer, so we can free it next time we come here. */
|
/* Take note of current front buffer, so we can free it next time we come here. */
|
||||||
windata->bo = windata->next_bo;
|
windata->bo = windata->next_bo;
|
||||||
|
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue