From e54cb1b121410862761b04828617875a54f6b021 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 23 Apr 2018 14:15:21 +0200 Subject: [PATCH] Only show black frame insertion for the video drivers/context drivers that support it --- gfx/drivers/d3d8.c | 11 +++++++++- gfx/drivers/d3d9.c | 11 +++++++++- gfx/drivers/gl.c | 2 ++ gfx/drivers/vulkan.c | 1 + gfx/video_driver.h | 3 ++- menu/menu_setting.c | 50 ++++++++++++++++++++++++++++++-------------- 6 files changed, 59 insertions(+), 19 deletions(-) diff --git a/gfx/drivers/d3d8.c b/gfx/drivers/d3d8.c index e0306cb6b2..94fc4f7269 100644 --- a/gfx/drivers/d3d8.c +++ b/gfx/drivers/d3d8.c @@ -1860,8 +1860,17 @@ static void d3d8_set_video_mode(void *data, #endif } +static uint32_t d3d8_get_flags(void *data) +{ + uint32_t flags = 0; + + BIT32_SET(flags, GFX_CTX_FLAGS_BLACK_FRAME_INSERTION); + + return flags; +} + static const video_poke_interface_t d3d_poke_interface = { - NULL, /* get_flags */ + d3d8_get_flags, NULL, /* set_coords */ d3d8_set_mvp, d3d8_load_texture, diff --git a/gfx/drivers/d3d9.c b/gfx/drivers/d3d9.c index 1aa709efb4..bb5593314c 100644 --- a/gfx/drivers/d3d9.c +++ b/gfx/drivers/d3d9.c @@ -1886,8 +1886,17 @@ static void d3d9_set_video_mode(void *data, #endif } +static uint32_t d3d9_get_flags(void *data) +{ + uint32_t flags = 0; + + BIT32_SET(flags, GFX_CTX_FLAGS_BLACK_FRAME_INSERTION); + + return flags; +} + static const video_poke_interface_t d3d9_poke_interface = { - NULL, /* get_flags */ + d3d9_get_flags, NULL, /* set_coords */ d3d9_set_mvp, d3d9_load_texture, diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 8b7681c029..0cf00d7a7a 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -2607,6 +2607,8 @@ static uint32_t gl_get_flags(void *data) if (gl_check_capability(GL_CAPS_SYNC)) BIT32_SET(flags, GFX_CTX_FLAGS_HARD_SYNC); + BIT32_SET(flags, GFX_CTX_FLAGS_BLACK_FRAME_INSERTION); + return flags; } diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index 731f347b5c..a4f2c55267 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -2307,6 +2307,7 @@ static uint32_t vulkan_get_flags(void *data) uint32_t flags = 0; BIT32_SET(flags, GFX_CTX_FLAGS_CUSTOMIZABLE_SWAPCHAIN_IMAGES); + BIT32_SET(flags, GFX_CTX_FLAGS_BLACK_FRAME_INSERTION); return flags; } diff --git a/gfx/video_driver.h b/gfx/video_driver.h index b05e4790f1..90a93e6794 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -114,7 +114,8 @@ enum display_flags GFX_CTX_FLAGS_GL_CORE_CONTEXT, GFX_CTX_FLAGS_MULTISAMPLING, GFX_CTX_FLAGS_CUSTOMIZABLE_SWAPCHAIN_IMAGES, - GFX_CTX_FLAGS_HARD_SYNC + GFX_CTX_FLAGS_HARD_SYNC, + GFX_CTX_FLAGS_BLACK_FRAME_INSERTION }; enum shader_uniform_type diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 7bec767190..a17aaeea15 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -3673,22 +3673,40 @@ static bool setting_append_list( settings_data_list_current_add_flags(list, list_info, SD_FLAG_LAKKA_ADVANCED); #if !defined(RARCH_MOBILE) - CONFIG_BOOL( - list, list_info, - &settings->bools.video_black_frame_insertion, - MENU_ENUM_LABEL_VIDEO_BLACK_FRAME_INSERTION, - MENU_ENUM_LABEL_VALUE_VIDEO_BLACK_FRAME_INSERTION, - black_frame_insertion, - 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 - ); - settings_data_list_current_add_flags(list, list_info, SD_FLAG_LAKKA_ADVANCED); + { + gfx_ctx_flags_t flags; + bool black_frame_insertion_supported = false; + + if (video_driver_get_flags(&flags)) + if (BIT32_GET(flags.flags, GFX_CTX_FLAGS_BLACK_FRAME_INSERTION)) + black_frame_insertion_supported = true; + + flags.flags = 0; + + if (video_context_driver_get_flags(&flags)) + if (BIT32_GET(flags.flags, GFX_CTX_FLAGS_BLACK_FRAME_INSERTION)) + black_frame_insertion_supported = true; + + if (black_frame_insertion_supported) + { + CONFIG_BOOL( + list, list_info, + &settings->bools.video_black_frame_insertion, + MENU_ENUM_LABEL_VIDEO_BLACK_FRAME_INSERTION, + MENU_ENUM_LABEL_VALUE_VIDEO_BLACK_FRAME_INSERTION, + black_frame_insertion, + 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 + ); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_LAKKA_ADVANCED); + } + } #endif END_SUB_GROUP(list, list_info, parent_group); START_SUB_GROUP(