mirror of
https://github.com/libretro/RetroArch
synced 2025-01-26 09:35:21 +00:00
Add experimental video_hard_sync.
This commit is contained in:
parent
175e657071
commit
741ed2cc03
1
Makefile
1
Makefile
@ -218,6 +218,7 @@ ifeq ($(HAVE_OPENGL), 1)
|
||||
LIBS += -framework OpenGL
|
||||
else
|
||||
LIBS += -lGL
|
||||
DEFINES += -DHAVE_GL_SYNC
|
||||
endif
|
||||
endif
|
||||
|
||||
|
@ -114,7 +114,7 @@ endif
|
||||
|
||||
ifeq ($(HAVE_OPENGL), 1)
|
||||
OBJ += gfx/gl.o gfx/math/matrix.o gfx/fonts/gl_font.o gfx/fonts/gl_raster_font.o gfx/gfx_context.o gfx/context/wgl_ctx.o gfx/shader_glsl.o
|
||||
DEFINES += -DHAVE_OPENGL -DHAVE_OVERLAY -DHAVE_GLSL
|
||||
DEFINES += -DHAVE_OPENGL -DHAVE_OVERLAY -DHAVE_GLSL -DHAVE_GL_SYNC
|
||||
LIBS += -lopengl32 -lgdi32
|
||||
endif
|
||||
|
||||
|
@ -239,6 +239,9 @@ static const bool disable_composition = false;
|
||||
// Video VSYNC (recommended)
|
||||
static const bool vsync = true;
|
||||
|
||||
// Attempts to hard-synchronize CPU and GPU. Can reduce latency at cost of performance.
|
||||
static const bool hard_sync = false;
|
||||
|
||||
// Threaded video. Will possibly increase performance significantly at cost of worse synchronization and latency.
|
||||
static const bool video_threaded = false;
|
||||
|
||||
|
@ -158,6 +158,7 @@ struct settings
|
||||
unsigned fullscreen_x;
|
||||
unsigned fullscreen_y;
|
||||
bool vsync;
|
||||
bool hard_sync;
|
||||
bool smooth;
|
||||
bool force_aspect;
|
||||
bool crop_overscan;
|
||||
|
37
gfx/gl.c
37
gfx/gl.c
@ -124,6 +124,24 @@ static bool load_eglimage_proc(gl_t *gl)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GL_SYNC
|
||||
static PFNGLFENCESYNCPROC pglFenceSync;
|
||||
static PFNGLDELETESYNCPROC pglDeleteSync;
|
||||
static PFNGLCLIENTWAITSYNCPROC pglClientWaitSync;
|
||||
|
||||
static bool load_sync_proc(gl_t *gl)
|
||||
{
|
||||
if (!gl_query_extension("ARB_sync"))
|
||||
return false;
|
||||
|
||||
LOAD_GL_SYM(FenceSync);
|
||||
LOAD_GL_SYM(DeleteSync);
|
||||
LOAD_GL_SYM(ClientWaitSync);
|
||||
|
||||
return pglFenceSync && pglDeleteSync && pglClientWaitSync;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FBO
|
||||
#if defined(_WIN32) && !defined(RARCH_CONSOLE)
|
||||
static PFNGLGENFRAMEBUFFERSPROC pglGenFramebuffers;
|
||||
@ -1448,6 +1466,19 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei
|
||||
context_swap_buffers_func();
|
||||
g_extern.frame_count++;
|
||||
|
||||
#ifdef HAVE_GL_SYNC
|
||||
if (gl->use_sync)
|
||||
{
|
||||
RARCH_PERFORMANCE_INIT(gl_fence);
|
||||
RARCH_PERFORMANCE_START(gl_fence);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
GLsync sync = pglFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
pglClientWaitSync(sync, 0, 1000000000);
|
||||
pglDeleteSync(sync);
|
||||
RARCH_PERFORMANCE_STOP(gl_fence);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_OPENGLES) && defined(HAVE_FFMPEG)
|
||||
if (gl->pbo_readback_enable)
|
||||
gl_pbo_async_readback(gl);
|
||||
@ -1538,6 +1569,12 @@ static bool resolve_extensions(gl_t *gl)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GL_SYNC
|
||||
gl->use_sync = g_settings.video.hard_sync && load_sync_proc(gl);
|
||||
if (gl->use_sync)
|
||||
RARCH_LOG("[GL]: Using ARB_sync to reduce latency.\n");
|
||||
#endif
|
||||
|
||||
#ifdef NO_GL_CLAMP_TO_BORDER
|
||||
// NOTE: This will be a serious problem for some shaders.
|
||||
gl->border_type = GL_CLAMP_TO_EDGE;
|
||||
|
@ -282,6 +282,9 @@ typedef struct gl
|
||||
GLfloat rgui_texture_alpha;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GL_SYNC
|
||||
bool use_sync;
|
||||
#endif
|
||||
} gl_t;
|
||||
|
||||
// Windows ... <_<
|
||||
|
@ -69,6 +69,9 @@
|
||||
# Video vsync.
|
||||
# video_vsync = true
|
||||
|
||||
# Attempts to hard-synchronize CPU and GPU. Can reduce latency at cost of performance.
|
||||
# video_hard_sync = false
|
||||
|
||||
# Use threaded video driver. Using this might improve performance at possible cost of latency and more video stuttering.
|
||||
# video_threaded = false
|
||||
|
||||
|
@ -164,6 +164,7 @@ void config_set_defaults(void)
|
||||
g_settings.video.fullscreen_y = fullscreen_y;
|
||||
g_settings.video.disable_composition = disable_composition;
|
||||
g_settings.video.vsync = vsync;
|
||||
g_settings.video.hard_sync = hard_sync;
|
||||
g_settings.video.threaded = video_threaded;
|
||||
g_settings.video.smooth = video_smooth;
|
||||
g_settings.video.force_aspect = force_aspect;
|
||||
@ -443,6 +444,7 @@ bool config_load_file(const char *path)
|
||||
CONFIG_GET_INT(video.monitor_index, "video_monitor_index");
|
||||
CONFIG_GET_BOOL(video.disable_composition, "video_disable_composition");
|
||||
CONFIG_GET_BOOL(video.vsync, "video_vsync");
|
||||
CONFIG_GET_BOOL(video.hard_sync, "video_hard_sync");
|
||||
CONFIG_GET_BOOL(video.threaded, "video_threaded");
|
||||
CONFIG_GET_BOOL(video.smooth, "video_smooth");
|
||||
CONFIG_GET_BOOL(video.force_aspect, "video_force_aspect");
|
||||
|
Loading…
x
Reference in New Issue
Block a user