From c461ad7b4459b3271320b44fd20026c8ba5ee786 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Thu, 7 Nov 2024 22:24:33 +1000 Subject: [PATCH] D3D11Device: Ensure we don't drop to feature level 10 on query failure --- src/util/d3d11_device.cpp | 3 +++ src/util/d3d_common.cpp | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/util/d3d11_device.cpp b/src/util/d3d11_device.cpp index 35eabbf76..a8bcfc6a8 100644 --- a/src/util/d3d11_device.cpp +++ b/src/util/d3d11_device.cpp @@ -96,6 +96,9 @@ bool D3D11Device::CreateDeviceAndMainSwapChain(std::string_view adapter, Feature return false; } + // just in case the max query failed, apparently happens for some people... + m_max_feature_level = std::max(m_max_feature_level, m_device->GetFeatureLevel()); + // we re-grab these later, see below dxgi_adapter.Reset(); temp_context.Reset(); diff --git a/src/util/d3d_common.cpp b/src/util/d3d_common.cpp index 61a3a944f..7736bccca 100644 --- a/src/util/d3d_common.cpp +++ b/src/util/d3d_common.cpp @@ -99,12 +99,15 @@ D3D_FEATURE_LEVEL D3DCommon::GetDeviceMaxFeatureLevel(IDXGIAdapter1* adapter) D3D_FEATURE_LEVEL_12_2, D3D_FEATURE_LEVEL_12_1, D3D_FEATURE_LEVEL_12_0, D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_10_0}; - D3D_FEATURE_LEVEL max_supported_level = requested_feature_levels.back(); + D3D_FEATURE_LEVEL max_supported_level; HRESULT hr = D3D11CreateDevice(adapter, adapter ? D3D_DRIVER_TYPE_UNKNOWN : D3D_DRIVER_TYPE_HARDWARE, nullptr, 0, requested_feature_levels.data(), static_cast(requested_feature_levels.size()), D3D11_SDK_VERSION, nullptr, &max_supported_level, nullptr); if (FAILED(hr)) + { WARNING_LOG("D3D11CreateDevice() for getting max feature level failed: 0x{:08X}", static_cast(hr)); + max_supported_level = requested_feature_levels.back(); + } return max_supported_level; }