video_set_nonblock_state - remove settings dependency

This commit is contained in:
twinaphex 2020-02-16 22:26:07 +01:00
parent 47af95469a
commit ec302bc4fc
39 changed files with 122 additions and 155 deletions

View File

@ -184,11 +184,8 @@ static bool caca_gfx_frame(void *data, const void *frame,
return true;
}
static void caca_gfx_set_nonblock_state(void *data, bool toggle)
{
(void)data;
(void)toggle;
}
static void caca_gfx_set_nonblock_state(void *data, bool a,
bool b, unsigned c) { }
static bool caca_gfx_alive(void *data)
{

View File

@ -935,7 +935,8 @@ static bool ctr_frame(void* data, const void* frame,
return true;
}
static void ctr_set_nonblock_state(void* data, bool toggle)
static void ctr_set_nonblock_state(void* data, bool toggle,
bool a, unsigned b)
{
ctr_video_t* ctr = (ctr_video_t*)data;

View File

@ -1527,7 +1527,9 @@ static bool d3d10_gfx_frame(
return true;
}
static void d3d10_gfx_set_nonblock_state(void* data, bool toggle)
static void d3d10_gfx_set_nonblock_state(void* data, bool toggle,
bool adaptive_vsync_enabled,
unsigned swap_interval)
{
d3d10_video_t* d3d10 = (d3d10_video_t*)data;

View File

@ -1605,7 +1605,10 @@ static bool d3d11_gfx_frame(
return true;
}
static void d3d11_gfx_set_nonblock_state(void* data, bool toggle)
static void d3d11_gfx_set_nonblock_state(void* data,
bool toggle,
bool adaptive_vsync_enabled,
unsigned swap_interval)
{
d3d11_video_t* d3d11 = (d3d11_video_t*)data;

View File

@ -1599,7 +1599,9 @@ static bool d3d12_gfx_frame(
return true;
}
static void d3d12_gfx_set_nonblock_state(void* data, bool toggle)
static void d3d12_gfx_set_nonblock_state(void* data, bool toggle,
bool adaptive_vsync_enabled,
unsigned swap_interval)
{
d3d12_video_t* d3d12 = (d3d12_video_t*)data;
d3d12->chain.vsync = !toggle;

View File

@ -993,7 +993,9 @@ static bool d3d8_restore(void *data)
return true;
}
static void d3d8_set_nonblock_state(void *data, bool state)
static void d3d8_set_nonblock_state(void *data, bool state,
bool adaptive_vsync_enabled,
unsigned swap_interval)
{
int interval = 0;
d3d8_video_t *d3d = (d3d8_video_t*)data;

View File

@ -1021,21 +1021,25 @@ static bool d3d9_restore(void *data)
return true;
}
static void d3d9_set_nonblock_state(void *data, bool state)
static void d3d9_set_nonblock_state(void *data, bool state,
bool adaptive_vsync_enabled,
unsigned swap_interval)
{
#ifdef _XBOX
int interval = 0;
#endif
d3d9_video_t *d3d = (d3d9_video_t*)data;
if (!d3d)
return;
#ifdef _XBOX
if (!state)
interval = 1;
#endif
d3d->video_info.vsync = !state;
(void)interval;
#ifdef _XBOX
d3d9_set_render_state(d3d->dev,
D3D9_PRESENTATIONINTERVAL,

View File

@ -533,27 +533,11 @@ static void dispmanx_set_texture_frame(void *data, const void *frame, bool rgb32
dispmanx_surface_update_async(frame, _dispvars->menu_surface);
}
static void dispmanx_gfx_set_nonblock_state(void *data, bool state)
{
struct dispmanx_video *vid = data;
static void dispmanx_gfx_set_nonblock_state(void *a, bool b,
bool c, unsigned d) { }
(void)data;
(void)vid;
/* TODO */
}
static bool dispmanx_gfx_alive(void *data)
{
(void)data;
return true; /* always alive */
}
static bool dispmanx_gfx_focus(void *data)
{
(void)data;
return true; /* fb device always has focus */
}
static bool dispmanx_gfx_alive(void *data) { return true; }
static bool dispmanx_gfx_focus(void *data) { return true; }
static void dispmanx_gfx_viewport_info(void *data, struct video_viewport *vp)
{

View File

@ -879,27 +879,11 @@ static void drm_set_texture_frame(void *data, const void *frame, bool rgb32,
drm_surface_update(_drmvars, frame_output, _drmvars->menu_surface);
}
static void drm_gfx_set_nonblock_state(void *data, bool state)
{
struct drm_video *vid = data;
static void drm_gfx_set_nonblock_state(void *a, bool b, bool c, unsigned d) { }
(void)data;
(void)vid;
static bool drm_gfx_alive(void *data) { return true; }
/* TODO */
}
static bool drm_gfx_alive(void *data)
{
(void)data;
return true; /* always alive */
}
static bool drm_gfx_focus(void *data)
{
(void)data;
return true; /* fb device always has focus */
}
static bool drm_gfx_focus(void *data) { return true; }
static void drm_gfx_viewport_info(void *data, struct video_viewport *vp)
{

View File

@ -1355,7 +1355,8 @@ fail:
return false;
}
static void exynos_gfx_set_nonblock_state(void *data, bool state)
static void exynos_gfx_set_nonblock_state(void *data, bool state,
bool adaptive_vsync_enabled, unsigned swap_interval)
{
struct exynos_video *vid = data;
if (vid && vid->data)

View File

@ -342,11 +342,7 @@ static bool fpga_gfx_frame(void *data, const void *frame,
return true;
}
static void fpga_gfx_set_nonblock_state(void *data, bool toggle)
{
(void)data;
(void)toggle;
}
static void fpga_gfx_set_nonblock_state(void *a, bool b, bool c, unsigned d) { }
static bool fpga_gfx_alive(void *data)
{

View File

@ -370,11 +370,7 @@ static bool gdi_gfx_frame(void *data, const void *frame,
return true;
}
static void gdi_gfx_set_nonblock_state(void *data, bool toggle)
{
(void)data;
(void)toggle;
}
static void gdi_gfx_set_nonblock_state(void *a, bool b, bool c, unsigned d) { }
static bool gdi_gfx_alive(void *data)
{

View File

@ -3227,11 +3227,13 @@ static void gl2_free(void *data)
gl2_destroy_resources(gl);
}
static void gl2_set_nonblock_state(void *data, bool state)
static void gl2_set_nonblock_state(
void *data, bool state,
bool adaptive_vsync_enabled,
unsigned swap_interval)
{
int interval = 0;
gl_t *gl = (gl_t*)data;
settings_t *settings = config_get_ptr();
if (!gl)
return;
@ -3241,12 +3243,10 @@ static void gl2_set_nonblock_state(void *data, bool state)
gl2_context_bind_hw_render(gl, false);
if (!state)
interval = settings->uints.video_swap_interval;
interval = swap_interval;
if (gl->ctx_driver->swap_interval)
{
bool adaptive_vsync_enabled = video_driver_test_all_flags(
GFX_CTX_FLAGS_ADAPTIVE_VSYNC) && settings->bools.video_adaptive_vsync;
if (adaptive_vsync_enabled && interval == 1)
interval = -1;
gl->ctx_driver->swap_interval(gl->ctx_data, interval);

View File

@ -925,11 +925,12 @@ static bool gl1_gfx_frame(void *data, const void *frame,
return true;
}
static void gl1_gfx_set_nonblock_state(void *data, bool state)
static void gl1_gfx_set_nonblock_state(void *data, bool state,
bool adaptive_vsync_enabled,
unsigned swap_interval)
{
int interval = 0;
gl1_t *gl1 = (gl1_t*)data;
settings_t *settings = config_get_ptr();
if (!gl1)
return;
@ -939,12 +940,10 @@ static void gl1_gfx_set_nonblock_state(void *data, bool state)
gl1_context_bind_hw_render(gl1, false);
if (!state)
interval = settings->uints.video_swap_interval;
interval = swap_interval;
if (gl1->ctx_driver->swap_interval)
{
bool adaptive_vsync_enabled = video_driver_test_all_flags(
GFX_CTX_FLAGS_ADAPTIVE_VSYNC) && settings->bools.video_adaptive_vsync;
if (adaptive_vsync_enabled && interval == 1)
interval = -1;
gl1->ctx_driver->swap_interval(gl1->ctx_data, interval);

View File

@ -1575,11 +1575,12 @@ static bool gl_core_alive(void *data)
return ret;
}
static void gl_core_set_nonblock_state(void *data, bool state)
static void gl_core_set_nonblock_state(void *data, bool state,
bool adaptive_vsync_enabled,
unsigned swap_interval)
{
int interval = 0;
gl_core_t *gl = (gl_core_t*)data;
settings_t *settings = config_get_ptr();
if (!gl)
return;
@ -1588,13 +1589,10 @@ static void gl_core_set_nonblock_state(void *data, bool state)
gl_core_context_bind_hw_render(gl, false);
if (!state)
interval = settings->uints.video_swap_interval;
interval = swap_interval;
if (gl->ctx_driver->swap_interval)
{
bool adaptive_vsync_enabled = video_driver_test_all_flags(
GFX_CTX_FLAGS_ADAPTIVE_VSYNC) && settings->bools.
video_adaptive_vsync;
if (adaptive_vsync_enabled && interval == 1)
interval = -1;
gl->ctx_driver->swap_interval(gl->ctx_data, interval);

View File

@ -1373,7 +1373,8 @@ static bool wiiu_gfx_frame(void *data, const void *frame,
return true;
}
static void wiiu_gfx_set_nonblock_state(void *data, bool toggle)
static void wiiu_gfx_set_nonblock_state(void *data, bool toggle,
bool adaptive_vsync_enabled, unsigned swap_interval)
{
wiiu_video_t *wiiu = (wiiu_video_t *) data;

View File

@ -1180,9 +1180,9 @@ static void gx_blit_line(gx_video_t *gx,
}
}
static void gx_set_nonblock_state(void *data, bool state)
static void gx_set_nonblock_state(void *data, bool state,
bool adaptive_vsync_enabled, unsigned swap_interval)
{
(void)data;
g_vsync = !state;
}

View File

@ -104,7 +104,8 @@ static bool metal_frame(void *data, const void *frame,
info:video_info];
}
static void metal_set_nonblock_state(void *data, bool non_block)
static void metal_set_nonblock_state(void *data, bool non_block,
bool adaptive_vsync_enabled, unsigned swap_interval)
{
MetalDriver *md = (__bridge MetalDriver *)data;
md.context.displaySyncEnabled = !non_block;

View File

@ -327,11 +327,7 @@ static bool network_gfx_frame(void *data, const void *frame,
return true;
}
static void network_gfx_set_nonblock_state(void *data, bool toggle)
{
(void)data;
(void)toggle;
}
static void network_gfx_set_nonblock_state(void *a, bool b, bool c, unsigned d) { }
static bool network_gfx_alive(void *data)
{

View File

@ -1017,14 +1017,15 @@ static bool omap_gfx_frame(void *data, const void *frame, unsigned width,
return true;
}
static void omap_gfx_set_nonblock_state(void *data, bool state)
static void omap_gfx_set_nonblock_state(void *data, bool state,
bool adaptive_vsync_enabled, unsigned swap_interval)
{
omap_video_t *vid;
if (!data)
return;
vid = data;
vid = data;
vid->omap->sync = !state;
}

View File

@ -365,7 +365,8 @@ static bool ps2_gfx_frame(void *data, const void *frame,
return true;
}
static void ps2_gfx_set_nonblock_state(void *data, bool toggle)
static void ps2_gfx_set_nonblock_state(void *data, bool toggle,
bool adaptive_vsync_enabled, unsigned swap_interval)
{
ps2_video_t *ps2 = (ps2_video_t*)data;

View File

@ -547,7 +547,8 @@ static bool psp_frame(void *data, const void *frame,
return true;
}
static void psp_set_nonblock_state(void *data, bool toggle)
static void psp_set_nonblock_state(void *data, bool toggle,
bool adaptive_vsync_enabled, unsigned swap_interval)
{
psp1_video_t *psp = (psp1_video_t*)data;

View File

@ -515,7 +515,8 @@ static bool sdl2_gfx_frame(void *data, const void *frame, unsigned width,
return true;
}
static void sdl2_gfx_set_nonblock_state(void *data, bool toggle)
static void sdl2_gfx_set_nonblock_state(void *data, bool toggle,
bool adaptive_vsync_enabled, unsigned swap_interval)
{
sdl2_video_t *vid = (sdl2_video_t*)data;

View File

@ -222,11 +222,7 @@ static void sdl_dingux_set_texture_frame(void *data, const void *frame, bool rgb
}
static void sdl_dingux_gfx_set_nonblock_state(void *data, bool state)
{
(void)data; /* Can SDL even do this? */
(void)state;
}
static void sdl_dingux_gfx_set_nonblock_state(void *a, bool b, bool c, unsigned d) { }
static void sdl_dingux_gfx_check_window(sdl_dingux_video_t *vid)
{

View File

@ -386,11 +386,7 @@ static bool sdl_gfx_frame(void *data, const void *frame, unsigned width,
return true;
}
static void sdl_gfx_set_nonblock_state(void *data, bool state)
{
(void)data; /* Can SDL even do this? */
(void)state;
}
static void sdl_gfx_set_nonblock_state(void *a, bool b, bool c, unsigned d) { }
static bool sdl_gfx_alive(void *data)
{

View File

@ -429,11 +429,7 @@ static bool sixel_gfx_frame(void *data, const void *frame,
return true;
}
static void sixel_gfx_set_nonblock_state(void *data, bool toggle)
{
(void)data;
(void)toggle;
}
static void sixel_gfx_set_nonblock_state(void *a, bool b, bool c, unsigned d) { }
static bool sixel_gfx_alive(void *data)
{

View File

@ -804,13 +804,7 @@ static bool sunxi_gfx_frame(void *data, const void *frame, unsigned width,
return true;
}
static void sunxi_gfx_set_nonblock_state(void *data, bool state)
{
struct sunxi_video *vid = data;
(void)vid;
(void)state;
}
static void sunxi_gfx_set_nonblock_state(void *a, bool b, bool c, unsigned d) { }
static bool sunxi_gfx_alive(void *data)
{

View File

@ -263,10 +263,10 @@ static bool switch_frame(void *data, const void *frame,
return true;
}
static void switch_set_nonblock_state(void *data, bool toggle)
static void switch_set_nonblock_state(void *data, bool toggle, bool c, unsigned d)
{
switch_video_t *sw = data;
sw->vsync = !toggle;
sw->vsync = !toggle;
}
static bool switch_alive(void *data)

View File

@ -500,7 +500,7 @@ static bool switch_frame(void *data, const void *frame,
return true;
}
static void switch_set_nonblock_state(void *data, bool toggle)
static void switch_set_nonblock_state(void *data, bool toggle, bool c, unsigned d)
{
switch_video_t *sw = data;
sw->vsync = !toggle;

View File

@ -77,16 +77,14 @@ typedef struct
static PFNVGCREATEEGLIMAGETARGETKHRPROC pvgCreateEGLImageTargetKHR;
static void vg_set_nonblock_state(void *data, bool state)
static void vg_set_nonblock_state(void *data, bool state,
bool adaptive_vsync_enabled, unsigned swap_interval)
{
vg_t *vg = (vg_t*)data;
int interval = state ? 0 : 1;
if (vg->ctx_driver && vg->ctx_driver->swap_interval)
{
settings_t *settings = config_get_ptr();
bool adaptive_vsync_enabled = video_driver_test_all_flags(
GFX_CTX_FLAGS_ADAPTIVE_VSYNC) && settings->bools.video_adaptive_vsync;
if (adaptive_vsync_enabled && interval == 1)
interval = -1;
vg->ctx_driver->swap_interval(vg->ctx_data, interval);

View File

@ -250,11 +250,7 @@ static bool vga_gfx_frame(void *data, const void *frame,
return true;
}
static void vga_gfx_set_nonblock_state(void *data, bool toggle)
{
(void)data;
(void)toggle;
}
static void vga_gfx_set_nonblock_state(void *a, bool b, bool c, unsigned d) { }
static bool vga_gfx_alive(void *data)
{

View File

@ -277,7 +277,7 @@ static bool vita2d_gfx_frame(void *data, const void *frame,
return true;
}
static void vita2d_gfx_set_nonblock_state(void *data, bool toggle)
static void vita2d_gfx_set_nonblock_state(void *data, bool toggle, bool c, unsigned d)
{
vita_video_t *vita = (vita_video_t *)data;

View File

@ -1309,13 +1309,12 @@ static void vulkan_check_swapchain(vk_t *vk)
}
}
static void vulkan_set_nonblock_state(void *data, bool state)
static void vulkan_set_nonblock_state(void *data, bool state,
bool adaptive_vsync_enabled,
unsigned swap_interval)
{
int interval = 0;
vk_t *vk = (vk_t*)data;
settings_t *settings = config_get_ptr();
bool adaptive_vsync_enabled = video_driver_test_all_flags(
GFX_CTX_FLAGS_ADAPTIVE_VSYNC) && settings->bools.video_adaptive_vsync;
if (!vk)
return;
@ -1323,7 +1322,7 @@ static void vulkan_set_nonblock_state(void *data, bool state)
RARCH_LOG("[Vulkan]: VSync => %s\n", state ? "off" : "on");
if (!state)
interval = settings->uints.video_swap_interval;
interval = swap_interval;
if (vk->ctx_driver->swap_interval)
{
@ -1332,8 +1331,8 @@ static void vulkan_set_nonblock_state(void *data, bool state)
vk->ctx_driver->swap_interval(vk->ctx_data, interval);
}
/* Changing vsync might require recreating the swapchain, which means new VkImages
* to render into. */
/* Changing vsync might require recreating the swapchain,
* which means new VkImages to render into. */
vulkan_check_swapchain(vk);
}

View File

@ -246,11 +246,7 @@ static bool xenon360_gfx_frame(void *data, const void *frame, unsigned width, un
return true;
}
static void xenon360_gfx_set_nonblock_state(void *data, bool state)
{
(void)data;
(void)state;
}
static void xenon360_gfx_set_nonblock_state(void *a, bool b, bool c, unsigned d) { }
static bool xenon360_gfx_alive(void *data)
{

View File

@ -118,10 +118,7 @@ static bool xshm_gfx_frame(void *data, const void *frame, unsigned width,
return true;
}
static void xshm_gfx_set_nonblock_state(void *data, bool toggle)
{
}
static void xshm_gfx_set_nonblock_state(void *a, bool b, bool c, unsigned d) { }
static bool xshm_gfx_alive(void *data)
{

View File

@ -85,7 +85,7 @@ typedef struct xv
unsigned width, unsigned height, unsigned pitch);
} xv_t;
static void xv_set_nonblock_state(void *data, bool state)
static void xv_set_nonblock_state(void *data, bool state, bool c, unsigned d)
{
xv_t *xv = (xv_t*)data;
Atom atom = XInternAtom(g_x11_dpy, "XV_SYNC_TO_VBLANK", true);

View File

@ -784,7 +784,9 @@ static bool video_thread_frame(void *data, const void *frame_,
return true;
}
static void video_thread_set_nonblock_state(void *data, bool state)
static void video_thread_set_nonblock_state(void *data, bool state,
bool adaptive_vsync_enabled,
unsigned swap_interval)
{
thread_video_t *thr = (thread_video_t*)data;
if (thr)

View File

@ -381,7 +381,7 @@ static bool video_null_frame(void *data, const void *frame,
return true;
}
static void video_null_set_nonblock_state(void *data, bool toggle) { }
static void video_null_set_nonblock_state(void *a, bool b, bool c, unsigned d) { }
static bool video_null_alive(void *data) { return true; }
static bool video_null_focus(void *data) { return true; }
static bool video_null_has_windowed(void *data) { return true; }
@ -6363,6 +6363,7 @@ static bool command_event_resize_windowed_scale(void)
static void command_event_reinit(const int flags)
{
settings_t *settings = configuration_settings;
video_driver_reinit(flags);
/* Poll input to avoid possibly stale data to corrupt things. */
if (current_input && current_input->poll)
@ -6371,10 +6372,13 @@ static void command_event_reinit(const int flags)
#ifdef HAVE_MENU
gfx_display_set_framebuffer_dirty_flag();
if (configuration_settings->bools.video_fullscreen)
if (settings->bools.video_fullscreen)
video_driver_hide_mouse();
if (menu_driver_alive && current_video->set_nonblock_state)
current_video->set_nonblock_state(video_driver_data, false);
current_video->set_nonblock_state(video_driver_data, false,
video_driver_test_all_flags(GFX_CTX_FLAGS_ADAPTIVE_VSYNC) &&
settings->bools.video_adaptive_vsync,
settings->uints.video_swap_interval);
#endif
}
@ -7116,8 +7120,15 @@ TODO: Add a setting for these tweaks */
video_driver_apply_state_changes();
break;
case CMD_EVENT_VIDEO_SET_BLOCKING_STATE:
if (current_video->set_nonblock_state)
current_video->set_nonblock_state(video_driver_data, false);
{
settings_t *settings = configuration_settings;
if (current_video->set_nonblock_state)
current_video->set_nonblock_state(video_driver_data, false,
video_driver_test_all_flags(GFX_CTX_FLAGS_ADAPTIVE_VSYNC) &&
settings->bools.video_adaptive_vsync,
settings->uints.video_swap_interval
);
}
break;
case CMD_EVENT_VIDEO_SET_ASPECT_RATIO:
video_driver_set_aspect_ratio();
@ -23322,8 +23333,13 @@ static void driver_adjust_system_rates(void)
if (runloop_force_nonblock)
{
settings_t *settings = configuration_settings;
if (current_video->set_nonblock_state)
current_video->set_nonblock_state(video_driver_data, true);
current_video->set_nonblock_state(video_driver_data, true,
video_driver_test_all_flags(GFX_CTX_FLAGS_ADAPTIVE_VSYNC) &&
settings->bools.video_adaptive_vsync,
settings->uints.video_swap_interval
);
}
else
driver_set_nonblock_state();
@ -23350,7 +23366,11 @@ void driver_set_nonblock_state(void)
bool video_nonblock = enable;
if (!settings->bools.video_vsync || runloop_force_nonblock)
video_nonblock = true;
current_video->set_nonblock_state(video_driver_data, video_nonblock);
current_video->set_nonblock_state(video_driver_data, video_nonblock,
video_driver_test_all_flags(GFX_CTX_FLAGS_ADAPTIVE_VSYNC) &&
settings->bools.video_adaptive_vsync,
settings->uints.video_swap_interval
);
}
}
@ -25782,7 +25802,11 @@ static void menu_driver_toggle(bool on)
/* Menu should always run with vsync on. */
if (current_video->set_nonblock_state)
current_video->set_nonblock_state(video_driver_data, false);
current_video->set_nonblock_state(video_driver_data, false,
video_driver_test_all_flags(GFX_CTX_FLAGS_ADAPTIVE_VSYNC) &&
settings->bools.video_adaptive_vsync,
settings->uints.video_swap_interval
);
/* Stop all rumbling before entering the menu. */
command_event(CMD_EVENT_RUMBLE_STOP, NULL);

View File

@ -1449,7 +1449,9 @@ typedef struct video_driver
* True = VSync is turned off.
* False = VSync is turned on.
* */
void (*set_nonblock_state)(void *data, bool toggle);
void (*set_nonblock_state)(void *data, bool toggle,
bool adaptive_vsync_enabled,
unsigned swap_interval);
/* Is the window still active? */
bool (*alive)(void *data);