Create GFX_CTL_SWAP_INTERVAL

This commit is contained in:
twinaphex 2016-02-13 20:45:45 +01:00
parent 46c9ff36ef
commit 9e186b4587
5 changed files with 26 additions and 16 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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(