Skip to content

Commit

Permalink
Fixed bug 4296 - kmsdrm video driver leaks 1 bo in KMSDRM_GLES_SetupC…
Browse files Browse the repository at this point in the history
…rtc()

Icenowy Zheng

One front buffer is locked in GLES_SetupCrtc() and overrides the next_bo just locked in KMSDRM_GLES_SwapWindow, then the next_bo gets lost and is not released even when quitting the video.

It may leads to problems with GLES drivers that doesn't clean up GBM correctly if there's any bo left (e.g. the Mali Utgard r6p2 blob). In the case of Mali Utgard r6p2 blob, the DRM device file is still hold by the blob, and if you try to SDL_Quit to let another program to run (this is done by EmulationStation), the new program will fail to open DRM device.
  • Loading branch information
slouken committed Oct 6, 2018
1 parent 367f9b9 commit 3ac9e2a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/video/kmsdrm/SDL_kmsdrmopengles.c
Expand Up @@ -54,13 +54,13 @@ KMSDRM_GLES_SetupCrtc(_THIS, SDL_Window * window) {
return SDL_FALSE;
}

wdata->next_bo = KMSDRM_gbm_surface_lock_front_buffer(wdata->gs);
if (wdata->next_bo == NULL) {
wdata->crtc_bo = KMSDRM_gbm_surface_lock_front_buffer(wdata->gs);
if (wdata->crtc_bo == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not lock GBM surface front buffer on CRTC setup");
return SDL_FALSE;
}

fb_info = KMSDRM_FBFromBO(_this, wdata->next_bo);
fb_info = KMSDRM_FBFromBO(_this, wdata->crtc_bo);
if (fb_info == NULL) {
return SDL_FALSE;
}
Expand Down
4 changes: 4 additions & 0 deletions src/video/kmsdrm/SDL_kmsdrmvideo.c
Expand Up @@ -566,6 +566,10 @@ KMSDRM_DestroyWindow(_THIS, SDL_Window * window)
if(data) {
/* Wait for any pending page flips and unlock buffer */
KMSDRM_WaitPageFlip(_this, data, -1);
if (data->crtc_bo != NULL) {
KMSDRM_gbm_surface_release_buffer(data->gs, data->crtc_bo);
data->crtc_bo = NULL;
}
if (data->next_bo != NULL) {
KMSDRM_gbm_surface_release_buffer(data->gs, data->next_bo);
data->next_bo = NULL;
Expand Down
1 change: 1 addition & 0 deletions src/video/kmsdrm/SDL_kmsdrmvideo.h
Expand Up @@ -62,6 +62,7 @@ typedef struct SDL_WindowData
struct gbm_surface *gs;
struct gbm_bo *current_bo;
struct gbm_bo *next_bo;
struct gbm_bo *crtc_bo;
SDL_bool waiting_for_flip;
SDL_bool crtc_ready;
SDL_bool double_buffer;
Expand Down

0 comments on commit 3ac9e2a

Please sign in to comment.