mirror of
https://github.com/cemu-project/Cemu.git
synced 2026-07-09 17:14:47 -06:00
More robust graphics API fallback
This commit is contained in:
parent
6d27e9525a
commit
3ac95c4f43
@ -108,15 +108,28 @@ bool ActiveSettings::WaitForGX2DrawDoneEnabled()
|
||||
|
||||
GraphicAPI ActiveSettings::GetGraphicsAPI()
|
||||
{
|
||||
GraphicAPI api = g_current_game_profile->GetGraphicsAPI().value_or(GetConfig().graphic_api);
|
||||
|
||||
#if defined(ENABLE_VULKAN) && defined(ENABLE_OPENGL)
|
||||
// check if vulkan even available
|
||||
if (api == kVulkan && !g_vulkan_available)
|
||||
api = kOpenGL;
|
||||
const GraphicAPI api = g_current_game_profile->GetGraphicsAPI().value_or(GetConfig().graphic_api);
|
||||
std::optional<GraphicAPI> fallbackAPI;
|
||||
#ifdef ENABLE_VULKAN
|
||||
if (g_vulkan_available)
|
||||
{
|
||||
if (api == kVulkan)
|
||||
return api;
|
||||
fallbackAPI = kVulkan;
|
||||
}
|
||||
#endif
|
||||
|
||||
return api;
|
||||
#ifdef ENABLE_METAL
|
||||
if (api == kMetal)
|
||||
return api;
|
||||
fallbackAPI = fallbackAPI.value_or(kMetal);
|
||||
#endif
|
||||
#ifdef ENABLE_OPENGL
|
||||
if (api == kOpenGL)
|
||||
return api;
|
||||
fallbackAPI = fallbackAPI.value_or(kOpenGL);
|
||||
#endif
|
||||
cemu_assert(fallbackAPI.has_value());
|
||||
return *fallbackAPI;
|
||||
}
|
||||
|
||||
float ActiveSettings::GetTVGamma()
|
||||
|
||||
@ -123,7 +123,7 @@ XMLConfigParser CemuConfig::Load(XMLConfigParser& parser)
|
||||
|
||||
// graphics
|
||||
auto graphic = parser.get("Graphic");
|
||||
graphic_api = graphic.get("api", kOpenGL);
|
||||
graphic_api = graphic.get("api", kDefaultGraphicsAPI);
|
||||
graphic.get("device", legacy_graphic_device_uuid);
|
||||
if (graphic.get("vkDevice").valid())
|
||||
graphic.get("vkDevice", vk_graphic_device_uuid);
|
||||
|
||||
@ -73,6 +73,14 @@ enum GraphicAPI
|
||||
COUNT
|
||||
};
|
||||
|
||||
#if defined(ENABLE_VULKAN)
|
||||
constexpr GraphicAPI kDefaultGraphicsAPI = kVulkan;
|
||||
#elif defined(ENABLE_METAL)
|
||||
constexpr GraphicAPI kDefaultGraphicsAPI = kMetal;
|
||||
#elif defined(ENABLE_OPENGL)
|
||||
constexpr GraphicAPI kDefaultGraphicsAPI = kOpenGL;
|
||||
#endif
|
||||
|
||||
enum AudioChannels
|
||||
{
|
||||
kMono = 0,
|
||||
@ -430,13 +438,7 @@ struct CemuConfig
|
||||
ConfigValueBounds<CafeConsoleLanguage> console_language{ CafeConsoleLanguage::EN };
|
||||
|
||||
// graphics
|
||||
#if defined(ENABLE_VULKAN)
|
||||
ConfigValue<GraphicAPI> graphic_api{ kVulkan };
|
||||
#elif defined(ENABLE_METAL)
|
||||
ConfigValue<GraphicAPI> graphic_api{ kMetal };
|
||||
#elif defined(ENABLE_OPENGL)
|
||||
ConfigValue<GraphicAPI> graphic_api{ kOpenGL };
|
||||
#endif
|
||||
ConfigValue<GraphicAPI> graphic_api{ kDefaultGraphicsAPI };
|
||||
std::array<uint8, 16> legacy_graphic_device_uuid{}; // placeholder option for backwards compatibility with settings from 2.6 and before (renamed to "vkDevice")
|
||||
std::array<uint8, 16> vk_graphic_device_uuid;
|
||||
uint64 mtl_graphic_device_uuid{ 0 };
|
||||
|
||||
Loading…
Reference in New Issue
Block a user