From 914df58d2e5604130dabbedbf8b29f7570370430 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 12 Sep 2018 03:59:25 +0200 Subject: [PATCH] (WGL) Adaptive Vsync should work now for WGL --- configuration.c | 1 + configuration.h | 1 + gfx/drivers_context/wgl_ctx.c | 76 ++++++++++++++++++++++++++--------- gfx/drivers_context/x_ctx.c | 2 +- gfx/video_driver.c | 7 +++- intl/msg_hash_ar.h | 8 ++++ intl/msg_hash_chs.h | 8 ++++ intl/msg_hash_cht.h | 8 ++++ intl/msg_hash_de.h | 8 ++++ intl/msg_hash_eo.h | 8 ++++ intl/msg_hash_es.h | 8 ++++ intl/msg_hash_fr.h | 8 ++++ intl/msg_hash_it.h | 8 ++++ intl/msg_hash_ja.h | 8 ++++ intl/msg_hash_ko.h | 8 ++++ intl/msg_hash_lbl.h | 2 + intl/msg_hash_nl.h | 8 ++++ intl/msg_hash_pl.h | 8 ++++ intl/msg_hash_pt_br.h | 8 ++++ intl/msg_hash_pt_pt.h | 8 ++++ intl/msg_hash_ru.h | 8 ++++ intl/msg_hash_us.h | 8 ++++ intl/msg_hash_vn.h | 8 ++++ menu/cbs/menu_cbs_sublabel.c | 4 ++ menu/menu_displaylist.c | 3 ++ menu/menu_setting.c | 34 ++++++++++++++++ msg_hash.h | 1 + 27 files changed, 247 insertions(+), 20 deletions(-) diff --git a/configuration.c b/configuration.c index cd33faec0d..4c8b373ff3 100644 --- a/configuration.c +++ b/configuration.c @@ -1306,6 +1306,7 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings, SETTING_BOOL("video_fullscreen", &settings->bools.video_fullscreen, true, fullscreen, false); SETTING_BOOL("bundle_assets_extract_enable", &settings->bools.bundle_assets_extract_enable, true, bundle_assets_extract_enable, false); SETTING_BOOL("video_vsync", &settings->bools.video_vsync, true, vsync, false); + SETTING_BOOL("video_adaptive_vsync", &settings->bools.video_adaptive_vsync, true, false, false); SETTING_BOOL("video_hard_sync", &settings->bools.video_hard_sync, true, hard_sync, false); SETTING_BOOL("video_black_frame_insertion", &settings->bools.video_black_frame_insertion, true, black_frame_insertion, false); SETTING_BOOL("crt_switch_resolution", &settings->bools.crt_switch_resolution, true, crt_switch_resolution, false); diff --git a/configuration.h b/configuration.h index 5405104055..c3a4c9c539 100644 --- a/configuration.h +++ b/configuration.h @@ -73,6 +73,7 @@ typedef struct settings bool video_fullscreen; bool video_windowed_fullscreen; bool video_vsync; + bool video_adaptive_vsync; bool video_hard_sync; bool video_black_frame_insertion; bool video_vfilter; diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c index ed646ff1ea..b90a8e40c3 100644 --- a/gfx/drivers_context/wgl_ctx.c +++ b/gfx/drivers_context/wgl_ctx.c @@ -91,6 +91,7 @@ static HGLRC win32_hw_hrc; static HDC win32_hdc; static bool win32_use_hw_ctx = false; static bool win32_core_hw_context_enable = false; +static bool wgl_adaptive_vsync = false; #ifdef HAVE_VULKAN static gfx_ctx_vulkan_data_t win32_vk; @@ -105,9 +106,41 @@ static enum gfx_ctx_api win32_api = GFX_CTX_NONE; static dylib_t dll_handle = NULL; /* Handle to OpenGL32.dll */ #endif +#ifdef HAVE_OPENGL +static bool wgl_has_extension(const char *extension, const char *extensions) +{ + const char *start = NULL; + const char *terminator = NULL; + const char *where = strchr(extension, ' '); + + if (where || *extension == '\0') + return false; + + if (!extensions) + return false; + + start = extensions; + + for (;;) + { + where = strstr(start, extension); + if (!where) + break; + + terminator = where + strlen(extension); + if (where == start || *(where - 1) == ' ') + if (*terminator == ' ' || *terminator == '\0') + return true; + + start = terminator; + } + return false; +} +#endif + typedef struct gfx_ctx_cgl_data { - bool adaptive_vsync; + void *empty; } gfx_ctx_wgl_data_t; static gfx_ctx_proc_t gfx_ctx_wgl_get_proc_address(const char *symbol) @@ -264,6 +297,23 @@ static void create_gl_context(HWND hwnd, bool *quit) else RARCH_ERR("[WGL]: wglCreateContextAttribsARB not supported.\n"); } + + { + + const char *(WINAPI * wglGetExtensionsStringARB) (HDC) = 0; + const char *extensions = NULL; + + wglGetExtensionsStringARB = (const char *(WINAPI *) (HDC)) + gfx_ctx_wgl_get_proc_address("wglGetExtensionsStringARB"); + if (wglGetExtensionsStringARB) + extensions = wglGetExtensionsStringARB(win32_hdc); + RARCH_LOG("[WGL] extensions: %s\n", extensions); + if (wgl_has_extension("WGL_EXT_swap_control_tear", extensions)) + { + RARCH_LOG("[WGL]: Adaptive VSync supported.\n"); + wgl_adaptive_vsync = true; + } + } } #endif @@ -323,7 +373,7 @@ static void gfx_ctx_wgl_swap_interval(void *data, int interval) if (!p_swap_interval) return; - RARCH_LOG("[WGL]: wglSwapInterval(%u)\n", win32_interval); + RARCH_LOG("[WGL]: wglSwapInterval(%i)\n", win32_interval); if (!p_swap_interval(win32_interval)) RARCH_WARN("[WGL]: wglSwapInterval() failed.\n"); #endif @@ -479,6 +529,7 @@ static void *gfx_ctx_wgl_init(video_frame_info_t *video_info, void *video_driver #ifdef HAVE_DYNAMIC dll_handle = dylib_load("OpenGL32.dll"); #endif + win32_window_reset(); win32_monitor_init(); @@ -573,6 +624,7 @@ static void gfx_ctx_wgl_destroy(void *data) if (wgl) free(wgl); + wgl_adaptive_vsync = false; win32_core_hw_context_enable = false; g_win32_inited = false; win32_major = 0; @@ -727,21 +779,15 @@ static void *gfx_ctx_wgl_get_context_data(void *data) static uint32_t gfx_ctx_wgl_get_flags(void *data) { uint32_t flags = 0; - gfx_ctx_wgl_data_t *wgl = (gfx_ctx_wgl_data_t*)data; - - (void)wgl; BIT32_SET(flags, GFX_CTX_FLAGS_NONE); switch (win32_api) { case GFX_CTX_OPENGL_API: - if (wgl) + if (wgl_adaptive_vsync) { - if (wgl->adaptive_vsync) - { - BIT32_SET(flags, GFX_CTX_FLAGS_ADAPTIVE_VSYNC); - } + BIT32_SET(flags, GFX_CTX_FLAGS_ADAPTIVE_VSYNC); } if (win32_core_hw_context_enable) @@ -759,19 +805,13 @@ static uint32_t gfx_ctx_wgl_get_flags(void *data) static void gfx_ctx_wgl_set_flags(void *data, uint32_t flags) { - gfx_ctx_wgl_data_t *wgl = (gfx_ctx_wgl_data_t*)data; - - (void)wgl; - switch (win32_api) { case GFX_CTX_OPENGL_API: #ifdef HAVE_OPENGL - if (wgl) + if (BIT32_GET(flags, GFX_CTX_FLAGS_ADAPTIVE_VSYNC)) { - if (BIT32_GET(flags, GFX_CTX_FLAGS_ADAPTIVE_VSYNC)) - if (gl_query_extension("WGL_EXT_swap_control_tear")) - wgl->adaptive_vsync = true; + wgl_adaptive_vsync = true; } if (BIT32_GET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT)) diff --git a/gfx/drivers_context/x_ctx.c b/gfx/drivers_context/x_ctx.c index 3d921777fa..bd3e1a7600 100644 --- a/gfx/drivers_context/x_ctx.c +++ b/gfx/drivers_context/x_ctx.c @@ -1209,7 +1209,7 @@ static void gfx_ctx_x_set_flags(void *data, uint32_t flags) case GFX_CTX_OPENGL_API: case GFX_CTX_OPENGL_ES_API: if (BIT32_GET(flags, GFX_CTX_FLAGS_ADAPTIVE_VSYNC)) - if (gl_query_extension("GLX_EXT_swap_control_tear")) + if (GLXExtensionSupported(g_x11_dpy, "GLX_EXT_swap_control_tear")) x->adaptive_vsync = true; if (BIT32_GET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT)) x->core_hw_context_enable = true; diff --git a/gfx/video_driver.c b/gfx/video_driver.c index f3af9a5661..1459dfb9f2 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -3204,9 +3204,14 @@ bool video_context_driver_get_video_output_size(gfx_ctx_size_t *size_data) bool video_context_driver_swap_interval(int *interval) { + int current_interval = *interval; + settings_t *settings = config_get_ptr(); + bool adaptive_vsync_enabled = settings->bools.video_adaptive_vsync; if (!current_video_context.swap_interval) return false; - current_video_context.swap_interval(video_context_data, *interval); + if (adaptive_vsync_enabled && current_interval == 1) + current_interval = -1; + current_video_context.swap_interval(video_context_data, current_interval); return true; } diff --git a/intl/msg_hash_ar.h b/intl/msg_hash_ar.h index 881210a828..d9f60eac47 100644 --- a/intl/msg_hash_ar.h +++ b/intl/msg_hash_ar.h @@ -3541,3 +3541,11 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SUSTAINED_PERFORMANCE_MODE, "Sustained Performance Mode") MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_MPV_SUPPORT, "mpv support") +MSG_HASH( + MENU_ENUM_LABEL_VALUE_VIDEO_ADAPTIVE_VSYNC, + "Adaptive Vsync" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_ADAPTIVE_VSYNC, + "V-Sync is enabled until performance falls below the target refresh rate. Can minimize stuttering when performance falls below realtime, and can be more energy efficient." + ) diff --git a/intl/msg_hash_chs.h b/intl/msg_hash_chs.h index c8ff8960de..2f0bb64b8e 100644 --- a/intl/msg_hash_chs.h +++ b/intl/msg_hash_chs.h @@ -3325,3 +3325,11 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SUSTAINED_PERFORMANCE_MODE, "Sustained Performance Mode") MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_MPV_SUPPORT, "mpv support") +MSG_HASH( + MENU_ENUM_LABEL_VALUE_VIDEO_ADAPTIVE_VSYNC, + "Adaptive Vsync" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_ADAPTIVE_VSYNC, + "V-Sync is enabled until performance falls below the target refresh rate. Can minimize stuttering when performance falls below realtime, and can be more energy efficient." + ) diff --git a/intl/msg_hash_cht.h b/intl/msg_hash_cht.h index dcc7565720..9c42ab1356 100644 --- a/intl/msg_hash_cht.h +++ b/intl/msg_hash_cht.h @@ -3317,3 +3317,11 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SUSTAINED_PERFORMANCE_MODE, "Sustained Performance Mode") MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_MPV_SUPPORT, "mpv support") +MSG_HASH( + MENU_ENUM_LABEL_VALUE_VIDEO_ADAPTIVE_VSYNC, + "Adaptive Vsync" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_ADAPTIVE_VSYNC, + "V-Sync is enabled until performance falls below the target refresh rate. Can minimize stuttering when performance falls below realtime, and can be more energy efficient." + ) diff --git a/intl/msg_hash_de.h b/intl/msg_hash_de.h index 239899abab..21043221fc 100644 --- a/intl/msg_hash_de.h +++ b/intl/msg_hash_de.h @@ -3427,3 +3427,11 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SUSTAINED_PERFORMANCE_MODE, "Sustained Performance Mode") MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_MPV_SUPPORT, "mpv support") +MSG_HASH( + MENU_ENUM_LABEL_VALUE_VIDEO_ADAPTIVE_VSYNC, + "Adaptive Vsync" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_ADAPTIVE_VSYNC, + "V-Sync is enabled until performance falls below the target refresh rate. Can minimize stuttering when performance falls below realtime, and can be more energy efficient." + ) diff --git a/intl/msg_hash_eo.h b/intl/msg_hash_eo.h index e157edfc74..fede89901c 100644 --- a/intl/msg_hash_eo.h +++ b/intl/msg_hash_eo.h @@ -3192,3 +3192,11 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SUSTAINED_PERFORMANCE_MODE, "Sustained Performance Mode") MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_MPV_SUPPORT, "mpv support") +MSG_HASH( + MENU_ENUM_LABEL_VALUE_VIDEO_ADAPTIVE_VSYNC, + "Adaptive Vsync" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_ADAPTIVE_VSYNC, + "V-Sync is enabled until performance falls below the target refresh rate. Can minimize stuttering when performance falls below realtime, and can be more energy efficient." + ) diff --git a/intl/msg_hash_es.h b/intl/msg_hash_es.h index 34ede5266d..dadcb3b461 100644 --- a/intl/msg_hash_es.h +++ b/intl/msg_hash_es.h @@ -7422,3 +7422,11 @@ MSG_HASH( MSG_FAILED_TO_SET_DISK, "Fallo al establecer disco" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_VIDEO_ADAPTIVE_VSYNC, + "Adaptive Vsync" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_ADAPTIVE_VSYNC, + "V-Sync is enabled until performance falls below the target refresh rate. Can minimize stuttering when performance falls below realtime, and can be more energy efficient." + ) diff --git a/intl/msg_hash_fr.h b/intl/msg_hash_fr.h index b5d3ab766a..24d45b77ee 100644 --- a/intl/msg_hash_fr.h +++ b/intl/msg_hash_fr.h @@ -3351,3 +3351,11 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SUSTAINED_PERFORMANCE_MODE, "Sustained Performance Mode") MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_MPV_SUPPORT, "mpv support") +MSG_HASH( + MENU_ENUM_LABEL_VALUE_VIDEO_ADAPTIVE_VSYNC, + "Adaptive Vsync" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_ADAPTIVE_VSYNC, + "V-Sync is enabled until performance falls below the target refresh rate. Can minimize stuttering when performance falls below realtime, and can be more energy efficient." + ) diff --git a/intl/msg_hash_it.h b/intl/msg_hash_it.h index ec334aef13..11074b5ab2 100644 --- a/intl/msg_hash_it.h +++ b/intl/msg_hash_it.h @@ -3411,3 +3411,11 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SUSTAINED_PERFORMANCE_MODE, "Modalità delle Prestazioni Sostenute") MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_MPV_SUPPORT, "supporto mpv ") +MSG_HASH( + MENU_ENUM_LABEL_VALUE_VIDEO_ADAPTIVE_VSYNC, + "Adaptive Vsync" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_ADAPTIVE_VSYNC, + "V-Sync is enabled until performance falls below the target refresh rate. Can minimize stuttering when performance falls below realtime, and can be more energy efficient." + ) diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index 7911d839f5..bfbb911e3a 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -3812,3 +3812,11 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_DOWNLOAD_PLAYLIST_THUMBNAIL_PROGRESS, "成功した数: %1 失敗した数: %2") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_CORE_OPTIONS, "コア設定") +MSG_HASH( + MENU_ENUM_LABEL_VALUE_VIDEO_ADAPTIVE_VSYNC, + "Adaptive Vsync" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_ADAPTIVE_VSYNC, + "V-Sync is enabled until performance falls below the target refresh rate. Can minimize stuttering when performance falls below realtime, and can be more energy efficient." + ) diff --git a/intl/msg_hash_ko.h b/intl/msg_hash_ko.h index f867b18e6c..a36c182ecd 100644 --- a/intl/msg_hash_ko.h +++ b/intl/msg_hash_ko.h @@ -3312,3 +3312,11 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SUSTAINED_PERFORMANCE_MODE, "Sustained Performance Mode") MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_MPV_SUPPORT, "mpv support") +MSG_HASH( + MENU_ENUM_LABEL_VALUE_VIDEO_ADAPTIVE_VSYNC, + "Adaptive Vsync" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_ADAPTIVE_VSYNC, + "V-Sync is enabled until performance falls below the target refresh rate. Can minimize stuttering when performance falls below realtime, and can be more energy efficient." + ) diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index 1dac8eef33..2272899afd 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -1257,6 +1257,8 @@ MSG_HASH(MENU_ENUM_LABEL_VIDEO_VI_WIDTH, "video_vi_width") MSG_HASH(MENU_ENUM_LABEL_VIDEO_VSYNC, "video_vsync") +MSG_HASH(MENU_ENUM_LABEL_VIDEO_ADAPTIVE_VSYNC, + "video_adaptive_vsync") MSG_HASH(MENU_ENUM_LABEL_VIDEO_WINDOWED_FULLSCREEN, "video_windowed_fullscreen") MSG_HASH(MENU_ENUM_LABEL_VIDEO_WINDOW_WIDTH, diff --git a/intl/msg_hash_nl.h b/intl/msg_hash_nl.h index 63f5d9db7a..e34bf9b3e3 100644 --- a/intl/msg_hash_nl.h +++ b/intl/msg_hash_nl.h @@ -3194,3 +3194,11 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SUSTAINED_PERFORMANCE_MODE, "Sustained Performance Mode") MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_MPV_SUPPORT, "mpv support") +MSG_HASH( + MENU_ENUM_LABEL_VALUE_VIDEO_ADAPTIVE_VSYNC, + "Adaptive Vsync" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_ADAPTIVE_VSYNC, + "V-Sync is enabled until performance falls below the target refresh rate. Can minimize stuttering when performance falls below realtime, and can be more energy efficient." + ) diff --git a/intl/msg_hash_pl.h b/intl/msg_hash_pl.h index a5f446850f..635f78986e 100644 --- a/intl/msg_hash_pl.h +++ b/intl/msg_hash_pl.h @@ -3622,3 +3622,11 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SUSTAINED_PERFORMANCE_MODE, "Trwały tryb wydajności") MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_MPV_SUPPORT, "Wsparcie dla MPV") +MSG_HASH( + MENU_ENUM_LABEL_VALUE_VIDEO_ADAPTIVE_VSYNC, + "Adaptive Vsync" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_ADAPTIVE_VSYNC, + "V-Sync is enabled until performance falls below the target refresh rate. Can minimize stuttering when performance falls below realtime, and can be more energy efficient." + ) diff --git a/intl/msg_hash_pt_br.h b/intl/msg_hash_pt_br.h index 96d3f2dc6e..651740f6da 100644 --- a/intl/msg_hash_pt_br.h +++ b/intl/msg_hash_pt_br.h @@ -7441,3 +7441,11 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_QT_CORE_OPTIONS, "Opções de Núcleo" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_VIDEO_ADAPTIVE_VSYNC, + "Adaptive Vsync" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_ADAPTIVE_VSYNC, + "V-Sync is enabled until performance falls below the target refresh rate. Can minimize stuttering when performance falls below realtime, and can be more energy efficient." + ) diff --git a/intl/msg_hash_pt_pt.h b/intl/msg_hash_pt_pt.h index c20eaff54a..b153480cfc 100644 --- a/intl/msg_hash_pt_pt.h +++ b/intl/msg_hash_pt_pt.h @@ -3286,3 +3286,11 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SUSTAINED_PERFORMANCE_MODE, "Sustained Performance Mode") MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_MPV_SUPPORT, "mpv support") +MSG_HASH( + MENU_ENUM_LABEL_VALUE_VIDEO_ADAPTIVE_VSYNC, + "Adaptive Vsync" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_ADAPTIVE_VSYNC, + "V-Sync is enabled until performance falls below the target refresh rate. Can minimize stuttering when performance falls below realtime, and can be more energy efficient." + ) diff --git a/intl/msg_hash_ru.h b/intl/msg_hash_ru.h index d18c31f741..b1ccf90a49 100644 --- a/intl/msg_hash_ru.h +++ b/intl/msg_hash_ru.h @@ -3482,3 +3482,11 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SUSTAINED_PERFORMANCE_MODE, "Sustained Performance Mode") MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_MPV_SUPPORT, "mpv support") +MSG_HASH( + MENU_ENUM_LABEL_VALUE_VIDEO_ADAPTIVE_VSYNC, + "Adaptive Vsync" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_ADAPTIVE_VSYNC, + "V-Sync is enabled until performance falls below the target refresh rate. Can minimize stuttering when performance falls below realtime, and can be more energy efficient." + ) diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index be02410a94..b254dd85af 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -7442,3 +7442,11 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_QT_CORE_OPTIONS, "Core Options" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_VIDEO_ADAPTIVE_VSYNC, + "Adaptive Vsync" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_ADAPTIVE_VSYNC, + "V-Sync is enabled until performance falls below the target refresh rate. Can minimize stuttering when performance falls below realtime, and can be more energy efficient." + ) diff --git a/intl/msg_hash_vn.h b/intl/msg_hash_vn.h index 9cd2329191..dcc872ed5e 100644 --- a/intl/msg_hash_vn.h +++ b/intl/msg_hash_vn.h @@ -3349,3 +3349,11 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SUSTAINED_PERFORMANCE_MODE, "Sustained Performance Mode") MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_MPV_SUPPORT, "mpv support") +MSG_HASH( + MENU_ENUM_LABEL_VALUE_VIDEO_ADAPTIVE_VSYNC, + "Adaptive Vsync" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_VIDEO_ADAPTIVE_VSYNC, + "V-Sync is enabled until performance falls below the target refresh rate. Can minimize stuttering when performance falls below realtime, and can be more energy efficient." + ) diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 2c292437f0..70727956c8 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -154,6 +154,7 @@ default_sublabel_macro(action_bind_sublabel_axis_threshold, MENU_ default_sublabel_macro(action_bind_sublabel_input_turbo_period, MENU_ENUM_SUBLABEL_INPUT_TURBO_PERIOD) default_sublabel_macro(action_bind_sublabel_input_duty_cycle, MENU_ENUM_SUBLABEL_INPUT_DUTY_CYCLE) default_sublabel_macro(action_bind_sublabel_video_vertical_sync, MENU_ENUM_SUBLABEL_VIDEO_VSYNC) +default_sublabel_macro(action_bind_sublabel_video_adaptive_vsync, MENU_ENUM_SUBLABEL_VIDEO_ADAPTIVE_VSYNC) default_sublabel_macro(action_bind_sublabel_core_allow_rotate, MENU_ENUM_SUBLABEL_VIDEO_ALLOW_ROTATE) default_sublabel_macro(action_bind_sublabel_dummy_on_core_shutdown, MENU_ENUM_SUBLABEL_DUMMY_ON_CORE_SHUTDOWN) default_sublabel_macro(action_bind_sublabel_dummy_check_missing_firmware, MENU_ENUM_SUBLABEL_CHECK_FOR_MISSING_FIRMWARE) @@ -1625,6 +1626,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_VIDEO_VSYNC: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_vertical_sync); break; + case MENU_ENUM_LABEL_VIDEO_ADAPTIVE_VSYNC: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_adaptive_vsync); + break; case MENU_ENUM_LABEL_INPUT_DUTY_CYCLE: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_duty_cycle); break; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 1801b78e16..5d2e3377be 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -6394,6 +6394,9 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_VIDEO_SWAP_INTERVAL, PARSE_ONLY_UINT, false); + menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_VIDEO_ADAPTIVE_VSYNC, + PARSE_ONLY_BOOL, false); if (menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_VIDEO_MAX_SWAPCHAIN_IMAGES, PARSE_ONLY_UINT, false) == 0) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index a83667cd68..decb1c23f9 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -4415,6 +4415,40 @@ static bool setting_append_list( } } + { + gfx_ctx_flags_t flags; + bool adaptive_vsync_supported = false; + + if (video_driver_get_flags(&flags)) + if (BIT32_GET(flags.flags, GFX_CTX_FLAGS_ADAPTIVE_VSYNC)) + adaptive_vsync_supported = true; + + flags.flags = 0; + + if (video_context_driver_get_flags(&flags)) + if (BIT32_GET(flags.flags, GFX_CTX_FLAGS_ADAPTIVE_VSYNC)) + adaptive_vsync_supported = true; + + if (adaptive_vsync_supported) + { + CONFIG_BOOL( + list, list_info, + &settings->bools.video_adaptive_vsync, + MENU_ENUM_LABEL_VIDEO_ADAPTIVE_VSYNC, + MENU_ENUM_LABEL_VALUE_VIDEO_ADAPTIVE_VSYNC, + false, + MENU_ENUM_LABEL_VALUE_OFF, + MENU_ENUM_LABEL_VALUE_ON, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler, + SD_FLAG_NONE + ); + } + } + CONFIG_UINT( list, list_info, &settings->uints.video_frame_delay, diff --git a/msg_hash.h b/msg_hash.h index 33b1719565..4287dffeb4 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -715,6 +715,7 @@ enum msg_hash_enums MENU_LABEL(VIDEO_BLACK_FRAME_INSERTION), MENU_LABEL(VIDEO_FRAME_DELAY), MENU_LABEL(VIDEO_VSYNC), + MENU_LABEL(VIDEO_ADAPTIVE_VSYNC), MENU_LABEL(VIDEO_HARD_SYNC), MENU_LABEL(VIDEO_HARD_SYNC_FRAMES), MENU_LABEL(VIDEO_WINDOWED_FULLSCREEN),