Browse Source

Fix KMSDRM double buffering.

(cherry picked from commit 5ab1151508ef514b9c5f944da8fc1f3dd6ea0558)
vanfanel 9 months ago
parent
commit
7d83e03ac2
2 changed files with 7 additions and 1 deletions
  1. 1 1
      src/video/kmsdrm/SDL_kmsdrmopengles.c
  2. 6 0
      src/video/kmsdrm/SDL_kmsdrmvideo.c

+ 1 - 1
src/video/kmsdrm/SDL_kmsdrmopengles.c

@@ -192,7 +192,7 @@ int KMSDRM_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window)
            we have waited here, there won't be a pending pageflip so the
            WaitPageflip at the beginning of this function will be a no-op.
            Just leave it here and don't worry.
-           Run your SDL program with "SDL_KMSDRM_DOUBLE_BUFFER=1 <program_name>"
+           Run your SDL program with "SDL_VIDEO_DOUBLE_BUFFER=1 <program_name>"
            to enable this. */
         if (windata->double_buffer) {
             if (!KMSDRM_WaitPageflip(_this, windata)) {

+ 6 - 0
src/video/kmsdrm/SDL_kmsdrmvideo.c

@@ -1567,6 +1567,12 @@ int KMSDRM_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_Properti
     SDL_SetNumberProperty(props, SDL_PROP_WINDOW_KMSDRM_DRM_FD_NUMBER, viddata->drm_fd);
     SDL_SetPointerProperty(props, SDL_PROP_WINDOW_KMSDRM_GBM_DEVICE_POINTER, viddata->gbm_dev);
 
+    /* Do we want a double buffering scheme to get low video lag? */
+    windata->double_buffer = SDL_FALSE;
+    if (SDL_GetHintBoolean(SDL_HINT_VIDEO_DOUBLE_BUFFER, SDL_FALSE)) {
+        windata->double_buffer = SDL_TRUE;
+    }
+
     if (!is_vulkan && !vulkan_mode) { /* NON-Vulkan block. */
 
         /* Maybe you didn't ask for an OPENGL window, but that's what you will get.