From 138cbf3f4b3e12dcef921068c9374156761e471b Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Mon, 21 Feb 2022 12:09:43 -0500 Subject: [PATCH] Now try Metal, Vulkan and then finally Dummy in that order This only applies to the SDL backend though, this will be expanded upon though. --- platforms/sdl/main.cpp.in | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/platforms/sdl/main.cpp.in b/platforms/sdl/main.cpp.in index 7014d3d..441d2db 100644 --- a/platforms/sdl/main.cpp.in +++ b/platforms/sdl/main.cpp.in @@ -16,6 +16,8 @@ #include "gfx_metal.hpp" #endif +#include "gfx_dummy.hpp" + #ifdef PLATFORM_WINDOWS #include #pragma comment(lib, "windowsapp") @@ -391,17 +393,33 @@ void* platform::get_next_image(window_ptr window) { return nullptr; } +template +void try_initialize() { + if(gfx_interface == nullptr) { + auto backend = new GFXBackend(); + const bool supported = backend->is_supported(); + if(!supported) { + prism::log("Failed to initialize GFX backend... trying next..."); + } else { + gfx_interface = backend; + platform::initialize_context(gfx_interface->required_context()); + } + } +} + int main(int argc, char* argv[]) { SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER); // determine gfx context at the beginning #ifdef ENABLE_METAL - gfx_interface = new GFXMetal(); -#else - gfx_interface = new GFXVulkan(); + try_initialize(); #endif - platform::initialize_context(gfx_interface->required_context()); +#ifdef ENABLE_VULKAN + try_initialize(); +#endif + + try_initialize(); engine = new prism::engine(argc, argv);