Skip to content

Commit

Permalink
D3D11Device: Ensure we don't drop to feature level 10 on query failure
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Nov 7, 2024
1 parent 886ef4c commit c461ad7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/util/d3d11_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 4 additions & 1 deletion src/util/d3d_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<UINT>(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<unsigned>(hr));
max_supported_level = requested_feature_levels.back();
}

return max_supported_level;
}
Expand Down

0 comments on commit c461ad7

Please sign in to comment.