From 5d4720642da9a0229b57f6f47dbe3a27a8c04a5a Mon Sep 17 00:00:00 2001 From: SunDaw Date: Mon, 9 Oct 2023 22:00:19 +0200 Subject: [PATCH] try creating D3D11Device without debug flag if failed --- .../Sources/kinc/backend/graphics4/Direct3D11.c.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Backends/Graphics4/Direct3D11/Sources/kinc/backend/graphics4/Direct3D11.c.h b/Backends/Graphics4/Direct3D11/Sources/kinc/backend/graphics4/Direct3D11.c.h index d4d877281..7ba75b6d6 100644 --- a/Backends/Graphics4/Direct3D11/Sources/kinc/backend/graphics4/Direct3D11.c.h +++ b/Backends/Graphics4/Direct3D11/Sources/kinc/backend/graphics4/Direct3D11.c.h @@ -212,6 +212,16 @@ void kinc_g4_internal_init(void) { #endif HRESULT result = D3D11CreateDevice(adapter, D3D_DRIVER_TYPE_HARDWARE, NULL, flags, featureLevels, ARRAYSIZE(featureLevels), D3D11_SDK_VERSION, &dx_ctx.device, &featureLevel, &dx_ctx.context); + +#ifdef _DEBUG + if (result == E_FAIL || result == DXGI_ERROR_SDK_COMPONENT_MISSING) { + kinc_log(KINC_LOG_LEVEL_WARNING, "%s", "Failed to create device with D3D11_CREATE_DEVICE_DEBUG, trying without"); + flags &= ~D3D11_CREATE_DEVICE_DEBUG; + result = D3D11CreateDevice(adapter, D3D_DRIVER_TYPE_HARDWARE, NULL, flags, featureLevels, ARRAYSIZE(featureLevels), D3D11_SDK_VERSION, + &dx_ctx.device, &featureLevel, &dx_ctx.context); + } +#endif + if (result != S_OK) { kinc_log(KINC_LOG_LEVEL_WARNING, "%s", "Falling back to the WARP driver, things will be slow."); kinc_microsoft_affirm(D3D11CreateDevice(adapter, D3D_DRIVER_TYPE_WARP, NULL, flags, featureLevels, ARRAYSIZE(featureLevels), D3D11_SDK_VERSION,