From aa43466f2e229656b8fc1d893796393ca8ffa613 Mon Sep 17 00:00:00 2001 From: Dedmen Miller Date: Sat, 14 Feb 2026 17:03:24 +0100 Subject: [PATCH] Fix CPU fallback when D3D11CreateDevice fails Fixes #16 --- src/win/AppWin.cpp | 3 +++ src/win/d3d11/GPUContextD3D11.cpp | 1 + 2 files changed, 4 insertions(+) diff --git a/src/win/AppWin.cpp b/src/win/AppWin.cpp index fe01307..e034be0 100644 --- a/src/win/AppWin.cpp +++ b/src/win/AppWin.cpp @@ -115,6 +115,9 @@ AppWin::AppWin(Settings settings, Config config) Platform::instance().set_gpu_driver(gpu_driver_.get()); } else { gpu_context_.reset(); + // CPU fallback + surface_factory_.reset(new DIBSurfaceFactory(GetDC(0))); + Platform::instance().set_surface_factory(surface_factory_.get()); } #elif defined(DRIVER_D3D12) gpu_context_.reset(new GPUContextD3D12()); diff --git a/src/win/d3d11/GPUContextD3D11.cpp b/src/win/d3d11/GPUContextD3D11.cpp index 2a29e01..b75fdd9 100644 --- a/src/win/d3d11/GPUContextD3D11.cpp +++ b/src/win/d3d11/GPUContextD3D11.cpp @@ -62,6 +62,7 @@ GPUContextD3D11::GPUContextD3D11() { // Failed to create D3D11 device, fallback to CPU renderer immediate_context_.Reset(); device_.Reset(); + return; } // Create Enabled Blend State