mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 08:30:16 +00:00
Merge pull request #9547 from Rinnegatamante/videodrivers
Graceful switch between video drivers.
This commit is contained in:
commit
7bed40d17b
@ -85,6 +85,8 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static void gfx_ctx_wgl_destroy(void *data);
|
||||
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_OPENGL_CORE)
|
||||
typedef HGLRC (APIENTRY *wglCreateContextAttribsProc)(HDC, HGLRC, const int*);
|
||||
static wglCreateContextAttribsProc pcreate_context;
|
||||
@ -563,7 +565,7 @@ static void *gfx_ctx_wgl_init(video_frame_info_t *video_info, void *video_driver
|
||||
return NULL;
|
||||
|
||||
if (g_win32_inited)
|
||||
goto error;
|
||||
gfx_ctx_wgl_destroy(NULL);
|
||||
|
||||
#ifdef HAVE_DYNAMIC
|
||||
dll_handle = dylib_load("OpenGL32.dll");
|
||||
|
@ -9231,10 +9231,6 @@ MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_DISC_INFORMATION,
|
||||
"挿入されたディスクの情報を表示します。"
|
||||
)
|
||||
MSG_HASH(
|
||||
MSG_INCOMPATIBLE_CORE_FOR_VIDEO_DRIVER,
|
||||
"このコアは設定されたビデオドライバに対応しません。"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_QT_RESET,
|
||||
"リセット"
|
||||
|
@ -9107,10 +9107,6 @@ MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_DISC_INFORMATION,
|
||||
"삽입된 미디어 디스크의 정보를 봅니다."
|
||||
)
|
||||
MSG_HASH(
|
||||
MSG_INCOMPATIBLE_CORE_FOR_VIDEO_DRIVER,
|
||||
"현재 코어가 비디오 드라이버와 호환되지 않습니다."
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_QT_RESET,
|
||||
"초기화"
|
||||
|
@ -9111,10 +9111,6 @@ MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_DISC_INFORMATION,
|
||||
"Ver informações sobre discos de mídia inseridos."
|
||||
)
|
||||
MSG_HASH(
|
||||
MSG_INCOMPATIBLE_CORE_FOR_VIDEO_DRIVER,
|
||||
"Este núcleo não é compatível com o driver de vídeo atual."
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_QT_RESET,
|
||||
"Reiniciar"
|
||||
|
@ -9202,10 +9202,6 @@ MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_DISC_INFORMATION,
|
||||
"View information about inserted media discs."
|
||||
)
|
||||
MSG_HASH(
|
||||
MSG_INCOMPATIBLE_CORE_FOR_VIDEO_DRIVER,
|
||||
"This core is not compatible with the current video driver."
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_QT_RESET,
|
||||
"Reset"
|
||||
|
@ -4773,9 +4773,6 @@ unsigned menu_displaylist_build_list(file_list_t *list, enum menu_displaylist_ct
|
||||
case DISPLAYLIST_LATENCY_SETTINGS_LIST:
|
||||
{
|
||||
menu_displaylist_build_info_t build_list[] = {
|
||||
{MENU_ENUM_LABEL_VIDEO_MAX_SWAPCHAIN_IMAGES, PARSE_ONLY_UINT },
|
||||
{MENU_ENUM_LABEL_VIDEO_HARD_SYNC, PARSE_ONLY_BOOL },
|
||||
{MENU_ENUM_LABEL_VIDEO_HARD_SYNC_FRAMES, PARSE_ONLY_UINT },
|
||||
{MENU_ENUM_LABEL_VIDEO_FRAME_DELAY, PARSE_ONLY_UINT },
|
||||
{MENU_ENUM_LABEL_AUDIO_LATENCY, PARSE_ONLY_UINT },
|
||||
{MENU_ENUM_LABEL_INPUT_POLL_TYPE_BEHAVIOR, PARSE_ONLY_UINT },
|
||||
@ -4786,6 +4783,25 @@ unsigned menu_displaylist_build_list(file_list_t *list, enum menu_displaylist_ct
|
||||
{MENU_ENUM_LABEL_RUN_AHEAD_HIDE_WARNINGS, PARSE_ONLY_BOOL },
|
||||
};
|
||||
|
||||
if (video_driver_test_all_flags(GFX_CTX_FLAGS_CUSTOMIZABLE_SWAPCHAIN_IMAGES))
|
||||
{
|
||||
menu_displaylist_parse_settings_enum(list,
|
||||
MENU_ENUM_LABEL_VIDEO_MAX_SWAPCHAIN_IMAGES,
|
||||
PARSE_ONLY_UINT, false);
|
||||
count++;
|
||||
}
|
||||
if (video_driver_test_all_flags(GFX_CTX_FLAGS_HARD_SYNC))
|
||||
{
|
||||
menu_displaylist_parse_settings_enum(list,
|
||||
MENU_ENUM_LABEL_VIDEO_HARD_SYNC,
|
||||
PARSE_ONLY_BOOL, false);
|
||||
count++;
|
||||
menu_displaylist_parse_settings_enum(list,
|
||||
MENU_ENUM_LABEL_VIDEO_HARD_SYNC_FRAMES,
|
||||
PARSE_ONLY_UINT, false);
|
||||
count++;
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(build_list); i++)
|
||||
{
|
||||
if (menu_displaylist_parse_settings_enum(list,
|
||||
@ -7421,18 +7437,24 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
|
||||
menu_displaylist_parse_settings_enum(info->list,
|
||||
MENU_ENUM_LABEL_VIDEO_ADAPTIVE_VSYNC,
|
||||
PARSE_ONLY_BOOL, false);
|
||||
if (menu_displaylist_parse_settings_enum(info->list,
|
||||
if (video_driver_test_all_flags(GFX_CTX_FLAGS_CUSTOMIZABLE_SWAPCHAIN_IMAGES))
|
||||
{
|
||||
menu_displaylist_parse_settings_enum(info->list,
|
||||
MENU_ENUM_LABEL_VIDEO_MAX_SWAPCHAIN_IMAGES,
|
||||
PARSE_ONLY_UINT, false) == 0)
|
||||
PARSE_ONLY_UINT, false);
|
||||
count++;
|
||||
if (menu_displaylist_parse_settings_enum(info->list,
|
||||
}
|
||||
if (video_driver_test_all_flags(GFX_CTX_FLAGS_HARD_SYNC))
|
||||
{
|
||||
menu_displaylist_parse_settings_enum(info->list,
|
||||
MENU_ENUM_LABEL_VIDEO_HARD_SYNC,
|
||||
PARSE_ONLY_BOOL, false) == 0)
|
||||
PARSE_ONLY_BOOL, false);
|
||||
count++;
|
||||
if (menu_displaylist_parse_settings_enum(info->list,
|
||||
menu_displaylist_parse_settings_enum(info->list,
|
||||
MENU_ENUM_LABEL_VIDEO_HARD_SYNC_FRAMES,
|
||||
PARSE_ONLY_UINT, false) == 0)
|
||||
PARSE_ONLY_UINT, false);
|
||||
count++;
|
||||
}
|
||||
if (menu_displaylist_parse_settings_enum(info->list,
|
||||
MENU_ENUM_LABEL_VIDEO_FRAME_DELAY,
|
||||
PARSE_ONLY_UINT, false) == 0)
|
||||
|
@ -9574,8 +9574,6 @@ static bool setting_append_list(
|
||||
SETTINGS_DATA_LIST_CURRENT_ADD_FLAGS(list, list_info, SD_FLAG_CMD_APPLY_AUTO);
|
||||
SETTINGS_DATA_LIST_CURRENT_ADD_FLAGS(list, list_info, SD_FLAG_LAKKA_ADVANCED);
|
||||
|
||||
if (video_driver_test_all_flags(GFX_CTX_FLAGS_CUSTOMIZABLE_SWAPCHAIN_IMAGES))
|
||||
{
|
||||
CONFIG_UINT(
|
||||
list, list_info,
|
||||
&settings->uints.video_max_swapchain_images,
|
||||
@ -9589,10 +9587,7 @@ static bool setting_append_list(
|
||||
general_read_handler);
|
||||
menu_settings_list_current_add_range(list, list_info, 1, 4, 1, true, true);
|
||||
SETTINGS_DATA_LIST_CURRENT_ADD_FLAGS(list, list_info, SD_FLAG_CMD_APPLY_AUTO);
|
||||
}
|
||||
|
||||
if (video_driver_test_all_flags(GFX_CTX_FLAGS_HARD_SYNC))
|
||||
{
|
||||
CONFIG_BOOL(
|
||||
list, list_info,
|
||||
&settings->bools.video_hard_sync,
|
||||
@ -9606,8 +9601,7 @@ static bool setting_append_list(
|
||||
parent_group,
|
||||
general_write_handler,
|
||||
general_read_handler,
|
||||
SD_FLAG_NONE
|
||||
);
|
||||
SD_FLAG_NONE);
|
||||
|
||||
CONFIG_UINT(
|
||||
list, list_info,
|
||||
@ -9622,7 +9616,6 @@ static bool setting_append_list(
|
||||
general_read_handler);
|
||||
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
|
||||
menu_settings_list_current_add_range(list, list_info, 0, 3, 1, true, true);
|
||||
}
|
||||
|
||||
if (video_driver_test_all_flags(GFX_CTX_FLAGS_ADAPTIVE_VSYNC))
|
||||
{
|
||||
|
@ -2599,7 +2599,6 @@ enum msg_hash_enums
|
||||
MSG_DISC_DUMP_FAILED_TO_READ_FROM_DRIVE,
|
||||
MSG_DISC_DUMP_FAILED_TO_WRITE_TO_DISK,
|
||||
MSG_NO_DISC_INSERTED,
|
||||
MSG_INCOMPATIBLE_CORE_FOR_VIDEO_DRIVER,
|
||||
MENU_LABEL(DELETE_PLAYLIST),
|
||||
|
||||
MSG_LAST
|
||||
|
61
retroarch.c
61
retroarch.c
@ -942,7 +942,7 @@ static char current_library_name[1024] = {0};
|
||||
static char current_library_version[1024] = {0};
|
||||
static char current_valid_extensions[1024] = {0};
|
||||
static char error_string[255] = {0};
|
||||
|
||||
static char cached_video_driver[32] = {0};
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
/* MENU INPUT GLOBAL VARIABLES */
|
||||
@ -4965,6 +4965,13 @@ bool command_event(enum event_command cmd, void *data)
|
||||
command_event_disable_overrides();
|
||||
retroarch_unset_runtime_shader_preset();
|
||||
|
||||
if (cached_video_driver[0])
|
||||
{
|
||||
settings_t *settings = configuration_settings;
|
||||
strcpy(settings->arrays.video_driver, cached_video_driver);
|
||||
cached_video_driver[0] = 0;
|
||||
}
|
||||
|
||||
if ( runloop_remaps_core_active
|
||||
|| runloop_remaps_content_dir_active
|
||||
|| runloop_remaps_game_active
|
||||
@ -6122,6 +6129,12 @@ void main_exit(void *args)
|
||||
{
|
||||
settings_t *settings = configuration_settings;
|
||||
|
||||
if (cached_video_driver[0])
|
||||
{
|
||||
strcpy(settings->arrays.video_driver, cached_video_driver);
|
||||
cached_video_driver[0] = 0;
|
||||
}
|
||||
|
||||
if (settings->bools.config_save_on_exit)
|
||||
command_event(CMD_EVENT_MENU_SAVE_CURRENT_CONFIG, NULL);
|
||||
|
||||
@ -7268,39 +7281,6 @@ static bool dynamic_request_hw_context(enum retro_hw_context_type type,
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool dynamic_verify_hw_context(enum retro_hw_context_type type,
|
||||
unsigned minor, unsigned major)
|
||||
{
|
||||
const char *video_ident = (current_video) ? current_video->ident : NULL;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case RETRO_HW_CONTEXT_VULKAN:
|
||||
if (!string_is_equal(video_ident, "vulkan"))
|
||||
return false;
|
||||
break;
|
||||
case RETRO_HW_CONTEXT_OPENGLES2:
|
||||
case RETRO_HW_CONTEXT_OPENGLES3:
|
||||
case RETRO_HW_CONTEXT_OPENGLES_VERSION:
|
||||
case RETRO_HW_CONTEXT_OPENGL:
|
||||
case RETRO_HW_CONTEXT_OPENGL_CORE:
|
||||
if (!string_is_equal(video_ident, "gl") &&
|
||||
!string_is_equal(video_ident, "glcore"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case RETRO_HW_CONTEXT_DIRECT3D:
|
||||
if (!(string_is_equal(video_ident, "d3d11") && major == 11))
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void rarch_log_libretro(enum retro_log_level level,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
@ -7867,10 +7847,6 @@ static bool rarch_environment_cb(unsigned cmd, void *data)
|
||||
cb->context_type, cb->version_minor, cb->version_major))
|
||||
return false;
|
||||
|
||||
if (!dynamic_verify_hw_context(
|
||||
cb->context_type, cb->version_minor, cb->version_major))
|
||||
return false;
|
||||
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGL_CORE)
|
||||
if (!gl_set_core_context(cb->context_type)) { }
|
||||
#endif
|
||||
@ -19211,6 +19187,8 @@ static bool video_driver_find_driver(void)
|
||||
if (hwr && hw_render_context_is_vulkan(hwr->context_type))
|
||||
{
|
||||
RARCH_LOG("[Video]: Using HW render, Vulkan driver forced.\n");
|
||||
strcpy(cached_video_driver, settings->arrays.video_driver);
|
||||
strcpy(settings->arrays.video_driver, "vulkan");
|
||||
current_video = &video_vulkan;
|
||||
}
|
||||
#endif
|
||||
@ -19225,9 +19203,13 @@ static bool video_driver_find_driver(void)
|
||||
!string_is_equal(settings->arrays.video_driver, "glcore"))
|
||||
{
|
||||
#if defined(HAVE_OPENGL_CORE)
|
||||
strcpy(cached_video_driver, settings->arrays.video_driver);
|
||||
strcpy(settings->arrays.video_driver, "glcore");
|
||||
current_video = &video_gl_core;
|
||||
RARCH_LOG("[Video]: Forcing \"glcore\" driver.\n");
|
||||
#else
|
||||
strcpy(cached_video_driver, settings->arrays.video_driver);
|
||||
strcpy(settings->arrays.video_driver, "gl");
|
||||
current_video = &video_gl2;
|
||||
RARCH_LOG("[Video]: Forcing \"gl\" driver.\n");
|
||||
#endif
|
||||
@ -21281,7 +21263,8 @@ static void drivers_init(int flags)
|
||||
{
|
||||
/* Initialize menu driver */
|
||||
if (flags & DRIVER_MENU_MASK)
|
||||
menu_driver_init(video_is_threaded);
|
||||
if (!menu_driver_init(video_is_threaded))
|
||||
RARCH_ERR("Unable to init menu driver.\n");
|
||||
}
|
||||
#else
|
||||
/* Qt uses core info, even if the menu is disabled */
|
||||
|
@ -589,41 +589,6 @@ static bool content_load(content_ctx_info_t *info)
|
||||
char **rarch_argv_ptr = (char**)info->argv;
|
||||
int *rarch_argc_ptr = (int*)&info->argc;
|
||||
struct rarch_main_wrap *wrap_args = NULL;
|
||||
core_info_t core_info = {0};
|
||||
core_info_list_t *core_info_list = NULL;
|
||||
gfx_ctx_ident_t ident_info = {0};
|
||||
|
||||
video_context_driver_get_ident(&ident_info);
|
||||
|
||||
/* only check for supported hw api on X11/GLX and Windows since that is where it is currently implemented */
|
||||
#ifdef HAVE_X11
|
||||
if (!string_is_empty(ident_info.ident) && string_is_equal(ident_info.ident, "x"))
|
||||
#else
|
||||
#if defined(_WIN32) && !defined(_XBOX)
|
||||
if (!string_is_empty(ident_info.ident) && string_is_equal(ident_info.ident, "wgl"))
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
core_info_get_list(&core_info_list);
|
||||
|
||||
if (core_info_list)
|
||||
{
|
||||
if (core_info_list_get_info(core_info_list, &core_info, path_get(RARCH_PATH_CORE)))
|
||||
{
|
||||
if (!core_info_hw_api_supported(&core_info))
|
||||
{
|
||||
RARCH_ERR("This core is not compatible with the current video driver.\n");
|
||||
runloop_msg_queue_push(
|
||||
msg_hash_to_str(MSG_INCOMPATIBLE_CORE_FOR_VIDEO_DRIVER),
|
||||
100, 250, true, NULL,
|
||||
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
RARCH_LOG("This core is compatible with the current video driver.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wrap_args = (struct rarch_main_wrap*)
|
||||
calloc(1, sizeof(*wrap_args));
|
||||
|
Loading…
Reference in New Issue
Block a user