From 9e186b45871e095b186bab873ba56101596f3f1d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 13 Feb 2016 20:45:45 +0100 Subject: [PATCH] Create GFX_CTL_SWAP_INTERVAL --- gfx/d3d/d3d.cpp | 3 ++- gfx/drivers/gl.c | 13 +++++++++---- gfx/drivers/vg.c | 7 +++++-- gfx/video_context_driver.c | 14 ++++++++------ gfx/video_context_driver.h | 5 ++--- 5 files changed, 26 insertions(+), 16 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 8219be4104..fde7602d9d 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -825,6 +825,7 @@ static bool d3d_restore(void *data) static void d3d_set_nonblock_state(void *data, bool state) { + unsigned interval = state ? 0 : 1; d3d_video_t *d3d = (d3d_video_t*)data; if (!d3d) @@ -832,7 +833,7 @@ static void d3d_set_nonblock_state(void *data, bool state) d3d->video_info.vsync = !state; - gfx_ctx_swap_interval(state ? 0 : 1); + gfx_ctx_ctl(GFX_CTL_SWAP_INTERVAL, &interval); #ifndef _XBOX d3d->needs_restore = true; d3d_restore(d3d); diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index e24c52c26f..034a411864 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -2003,6 +2003,7 @@ static void gl_free(void *data) static void gl_set_nonblock_state(void *data, bool state) { + unsigned interval; gl_t *gl = (gl_t*)data; settings_t *settings = config_get_ptr(); @@ -2012,8 +2013,10 @@ static void gl_set_nonblock_state(void *data, bool state) RARCH_LOG("[GL]: VSync => %s\n", state ? "off" : "on"); context_bind_hw_render(gl, false); - gfx_ctx_swap_interval( - state ? 0 : settings->video.swap_interval); + + interval = state ? 0 : settings->video.swap_interval; + + gfx_ctx_ctl(GFX_CTL_SWAP_INTERVAL, &interval); context_bind_hw_render(gl, true); } @@ -2452,6 +2455,7 @@ static void gl_begin_debug(gl_t *gl) static void *gl_init(const video_info_t *video, const input_driver_t **input, void **input_data) { + unsigned interval; unsigned win_width, win_height, temp_width = 0, temp_height = 0; bool force_smooth = false; const char *vendor = NULL; @@ -2473,8 +2477,9 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo gfx_ctx_get_video_size(&gl->full_x, &gl->full_y); RARCH_LOG("Detecting screen resolution %ux%u.\n", gl->full_x, gl->full_y); - gfx_ctx_swap_interval( - video->vsync ? settings->video.swap_interval : 0); + interval = video->vsync ? settings->video.swap_interval : 0; + + gfx_ctx_ctl(GFX_CTL_SWAP_INTERVAL, &interval); win_width = video->width; win_height = video->height; diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index 82a4f61c14..250735b063 100644 --- a/gfx/drivers/vg.c +++ b/gfx/drivers/vg.c @@ -69,7 +69,8 @@ static PFNVGCREATEEGLIMAGETARGETKHRPROC pvgCreateEGLImageTargetKHR; static void vg_set_nonblock_state(void *data, bool state) { - gfx_ctx_swap_interval(state ? 0 : 1); + unsigned interval = state ? 0 : 1; + gfx_ctx_ctl(GFX_CTL_SWAP_INTERVAL, &interval); } static INLINE bool vg_query_extension(const char *ext) @@ -84,6 +85,7 @@ static INLINE bool vg_query_extension(const char *ext) static void *vg_init(const video_info_t *video, const input_driver_t **input, void **input_data) { + unsigned interval; unsigned temp_width = 0, temp_height = 0; VGfloat clearColor[4] = {0, 0, 0, 1}; settings_t *settings = config_get_ptr(); @@ -102,8 +104,9 @@ static void *vg_init(const video_info_t *video, const input_driver_t **input, vo if (temp_width != 0 && temp_height != 0) video_driver_set_size(&temp_width, &temp_height); - gfx_ctx_swap_interval(video->vsync ? 1 : 0); + interval = video->vsync ? 1 : 0; + gfx_ctx_ctl(GFX_CTL_SWAP_INTERVAL, &interval); gfx_ctx_ctl(GFX_CTL_UPDATE_WINDOW_TITLE, NULL); vg->mTexType = video->rgb32 ? VG_sXRGB_8888 : VG_sRGB_565; diff --git a/gfx/video_context_driver.c b/gfx/video_context_driver.c index 145e8832f0..9bc414545b 100644 --- a/gfx/video_context_driver.c +++ b/gfx/video_context_driver.c @@ -150,12 +150,6 @@ void gfx_ctx_get_video_size(unsigned *width, unsigned *height) current_video_context->get_video_size(video_context_data, width, height); } -void gfx_ctx_swap_interval(unsigned interval) -{ - if (current_video_context) - current_video_context->swap_interval(video_context_data, interval); -} - bool gfx_ctx_set_resize(unsigned width, unsigned height) { if (!current_video_context) @@ -432,6 +426,14 @@ bool gfx_ctx_ctl(enum gfx_ctx_ctl_state state, void *data) size_data->width, size_data->height); } break; + case GFX_CTL_SWAP_INTERVAL: + { + unsigned *interval = (unsigned*)data; + if (!current_video_context || !current_video_context->swap_interval) + return false; + current_video_context->swap_interval(video_context_data, *interval); + } + break; case GFX_CTL_NONE: default: break; diff --git a/gfx/video_context_driver.h b/gfx/video_context_driver.h index e7a478d9f7..b7dd2a5edc 100644 --- a/gfx/video_context_driver.h +++ b/gfx/video_context_driver.h @@ -71,7 +71,8 @@ enum gfx_ctx_ctl_state GFX_CTL_FIND_NEXT_DRIVER, /* Finds previous driver in graphics context driver array. */ GFX_CTL_FIND_PREV_DRIVER, - GFX_CTL_GET_VIDEO_OUTPUT_SIZE + GFX_CTL_GET_VIDEO_OUTPUT_SIZE, + GFX_CTL_SWAP_INTERVAL }; typedef void (*gfx_ctx_proc_t)(void); @@ -234,8 +235,6 @@ void gfx_ctx_get_video_size(unsigned *width, unsigned *height); bool gfx_ctx_set_resize(unsigned width, unsigned height); -void gfx_ctx_swap_interval(unsigned interval); - const char *gfx_ctx_get_ident(void); void gfx_ctx_input_driver(