kmsdrm: more coherent returns for SwapWindow.
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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
diff --git a/src/video/kmsdrm/SDL_kmsdrmopengles.c b/src/video/kmsdrm/SDL_kmsdrmopengles.c
index 5c1b0f2..e9c55c9 100644
--- a/src/video/kmsdrm/SDL_kmsdrmopengles.c
+++ b/src/video/kmsdrm/SDL_kmsdrmopengles.c
@@ -81,11 +81,12 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window)
SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
KMSDRM_FBInfo *fb;
KMSDRM_PlaneInfo info = {0};
- int ret;
/* Recreate the GBM / EGL surfaces if the window has been reconfigured. */
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.
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)) {
- 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,
@@ -139,8 +140,7 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window)
info.crtc_h = windata->output_h;
info.crtc_x = windata->output_x;
- ret = drm_atomic_set_plane_props(&info);
- if (ret) {
+ if (drm_atomic_set_plane_props(&info)) {
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. */
if (add_connector_property(dispdata->atomic_req, dispdata->connector , "CRTC_ID",
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)
- 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
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!.
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. */
- ret = drm_atomic_commit(_this, SDL_FALSE);
- if (ret) {
+ if (drm_atomic_commit(_this, SDL_FALSE)) {
return SDL_SetError("Failed to issue atomic commit on pageflip");
}
@@ -200,7 +199,7 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window)
/* Block ends. */
/***************/
- return ret;
+ return 0;
}
int
@@ -210,12 +209,13 @@ KMSDRM_GLES_SwapWindowDB(_THIS, SDL_Window * window)
SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata;
KMSDRM_FBInfo *fb;
KMSDRM_PlaneInfo info = {0};
- int ret;
/* Recreate the GBM / EGL surfaces if the window has been reconfigured. */
if (windata->egl_surface_dirty) {
- KMSDRM_CreateSurfaces(_this, window);
- }
+ if (KMSDRM_CreateSurfaces(_this, window)) {
+ return SDL_SetError("Failed to do pending surfaces creation");
+ }
+ }
/****************************************************************************************************/
/* In double-buffer mode, atomic commit will always be synchronous/blocking (ie: won't return until */
@@ -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.
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)) {
- 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
@@ -238,7 +238,7 @@ KMSDRM_GLES_SwapWindowDB(_THIS, SDL_Window * window)
}
fb = KMSDRM_FBFromBO(_this, windata->next_bo);
if (!fb) {
- return SDL_SetError("Failed to get a new framebuffer BO");
+ return SDL_SetError("Failed to get a new framebuffer BO");
}
/* Add the pageflip to the request list. */
@@ -252,8 +252,7 @@ KMSDRM_GLES_SwapWindowDB(_THIS, SDL_Window * window)
info.crtc_h = windata->output_h;
info.crtc_x = windata->output_x;
- ret = drm_atomic_set_plane_props(&info);
- if (ret) {
+ if (drm_atomic_set_plane_props(&info)) {
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. */
if (add_connector_property(dispdata->atomic_req, dispdata->connector , "CRTC_ID",
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)
- 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!.
Blocking for double buffering: won't return until completed. */
- ret = drm_atomic_commit(_this, SDL_TRUE);
-
- if (ret) {
+ if (drm_atomic_commit(_this, SDL_TRUE)) {
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. */
windata->bo = windata->next_bo;
- return ret;
+ return 0;
}
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c
index fe220d6..7d9245f 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.c
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c
@@ -1386,7 +1386,7 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
window->driverdata = windata;
if (KMSDRM_CreateSurfaces(_this, window)) {
- goto error;
+ goto error;
}
/* Add window to the internal list of tracked windows. Note, while it may