Try dx11 if dx9 and opengl both fail

Fix for MINIDUMP-5F
This commit is contained in:
Flyinghead 2023-01-23 12:06:26 +01:00
parent 41ba110ef4
commit 2b14c3e605
1 changed files with 13 additions and 0 deletions

View File

@ -35,6 +35,7 @@ GraphicsContext *GraphicsContext::instance;
void initRenderApi(void *window, void *display) void initRenderApi(void *window, void *display)
{ {
bool dx11Failed = false;
#ifdef USE_VULKAN #ifdef USE_VULKAN
if (isVulkan(config::RendererType)) if (isVulkan(config::RendererType))
{ {
@ -52,6 +53,7 @@ void initRenderApi(void *window, void *display)
theDX11Context.setWindow(window, display); theDX11Context.setWindow(window, display);
if (theDX11Context.init()) if (theDX11Context.init())
return; return;
dx11Failed = true;
WARN_LOG(RENDERER, "DirectX 11 init failed. Falling back to DirectX 9."); WARN_LOG(RENDERER, "DirectX 11 init failed. Falling back to DirectX 9.");
config::RendererType = RenderType::DirectX9; config::RendererType = RenderType::DirectX9;
} }
@ -73,6 +75,17 @@ void initRenderApi(void *window, void *display)
theGLContext.setWindow(window, display); theGLContext.setWindow(window, display);
if (theGLContext.init()) if (theGLContext.init())
return; return;
#endif
#ifdef USE_DX11
if (!dx11Failed)
{
// Try dx11 as a last resort if it hasn't been tried before
WARN_LOG(RENDERER, "OpenGL init failed. Trying DirectX 11.");
config::RendererType = RenderType::DirectX11;
theDX11Context.setWindow(window, display);
if (theDX11Context.init())
return;
}
#endif #endif
die("Cannot initialize the graphics API"); die("Cannot initialize the graphics API");
} }