mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2025-04-16 21:46:03 +02:00
Fixed bug 3902 - Add a specific KMSDRM hint for low latency video
This commit is contained in:
parent
f24c6672a7
commit
2ac567b715
@ -797,6 +797,16 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
#define SDL_HINT_RPI_VIDEO_LAYER "SDL_RPI_VIDEO_LAYER"
|
#define SDL_HINT_RPI_VIDEO_LAYER "SDL_RPI_VIDEO_LAYER"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Tell SDL the KMS/DRM video driver that we want double buffer only.
|
||||||
|
*
|
||||||
|
* By default KMS/DRM will use a triple buffer solution that wastes no CPU
|
||||||
|
* time on waiting for vsync after issuing a flip, but introduces a frame of
|
||||||
|
* latency. Waiting for vsync immediately after issuing a flip on the other
|
||||||
|
* hand is recommended for cases where low latency is an important factor.
|
||||||
|
*/
|
||||||
|
#define SDL_HINT_KMSDRM_DOUBLE_BUFFER "SDL_KMSDRM_DOUBLE_BUFFER"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A variable controlling what driver to use for OpenGL ES contexts.
|
* \brief A variable controlling what driver to use for OpenGL ES contexts.
|
||||||
*
|
*
|
||||||
|
@ -171,6 +171,12 @@ KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window) {
|
|||||||
} else {
|
} else {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not queue pageflip: %d", ret);
|
SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not queue pageflip: %d", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Wait immediately for vsync (as if we only had two buffers), for low input-lag scenarios.
|
||||||
|
Run your SDL2 program with "SDL_KMSDRM_DOUBLE_BUFFER=1 <program_name>" to enable this. */
|
||||||
|
if (wdata->double_buffer) {
|
||||||
|
KMSDRM_WaitPageFlip(_this, wdata, -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "../SDL_sysvideo.h"
|
#include "../SDL_sysvideo.h"
|
||||||
#include "SDL_syswm.h"
|
#include "SDL_syswm.h"
|
||||||
#include "SDL_log.h"
|
#include "SDL_log.h"
|
||||||
|
#include "SDL_hints.h"
|
||||||
#include "../../events/SDL_mouse_c.h"
|
#include "../../events/SDL_mouse_c.h"
|
||||||
#include "../../events/SDL_keyboard_c.h"
|
#include "../../events/SDL_keyboard_c.h"
|
||||||
|
|
||||||
@ -522,6 +523,12 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
|
|||||||
}
|
}
|
||||||
#endif /* SDL_VIDEO_OPENGL_EGL */
|
#endif /* SDL_VIDEO_OPENGL_EGL */
|
||||||
|
|
||||||
|
/* In case we want low-latency, double-buffer video, we take note here */
|
||||||
|
wdata->double_buffer = SDL_FALSE;
|
||||||
|
if (SDL_GetHintBoolean(SDL_HINT_KMSDRM_DOUBLE_BUFFER, SDL_FALSE)) {
|
||||||
|
wdata->double_buffer = SDL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Window is created, but we have yet to set up CRTC to one of the GBM buffers if we want
|
/* Window is created, but we have yet to set up CRTC to one of the GBM buffers if we want
|
||||||
drmModePageFlip to work, and we can't do it until EGL is completely setup, because we
|
drmModePageFlip to work, and we can't do it until EGL is completely setup, because we
|
||||||
need to do eglSwapBuffers so we can get a valid GBM buffer object to call
|
need to do eglSwapBuffers so we can get a valid GBM buffer object to call
|
||||||
|
@ -63,6 +63,7 @@ typedef struct SDL_WindowData
|
|||||||
struct gbm_bo *next_bo;
|
struct gbm_bo *next_bo;
|
||||||
SDL_bool waiting_for_flip;
|
SDL_bool waiting_for_flip;
|
||||||
SDL_bool crtc_ready;
|
SDL_bool crtc_ready;
|
||||||
|
SDL_bool double_buffer;
|
||||||
#if SDL_VIDEO_OPENGL_EGL
|
#if SDL_VIDEO_OPENGL_EGL
|
||||||
EGLSurface egl_surface;
|
EGLSurface egl_surface;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user