diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp index 16c39462..b06b6feb 100644 --- a/src/d3d11/d3d11_device.cpp +++ b/src/d3d11/d3d11_device.cpp @@ -1361,7 +1361,7 @@ namespace dxvk { const Rc& adapter, D3D_FEATURE_LEVEL featureLevel) { // We currently only support 11_0 interfaces - if (featureLevel > D3D_FEATURE_LEVEL_11_0) + if (featureLevel > GetMaxFeatureLevel()) return false; // Check whether all features are supported @@ -2170,4 +2170,28 @@ namespace dxvk { m_resourceInitCommands = 0; } + + D3D_FEATURE_LEVEL D3D11Device::GetMaxFeatureLevel() { + static const std::array, 6> s_featureLevels = {{ + { "11_0", D3D_FEATURE_LEVEL_11_0 }, + { "10_1", D3D_FEATURE_LEVEL_10_1 }, + { "10_0", D3D_FEATURE_LEVEL_10_0 }, + { "9_3", D3D_FEATURE_LEVEL_9_3 }, + { "9_2", D3D_FEATURE_LEVEL_9_2 }, + { "9_1", D3D_FEATURE_LEVEL_9_1 }, + }}; + + const std::string maxLevel = env::getEnvVar(L"DXVK_FEATURE_LEVEL"); + + auto entry = std::find_if(s_featureLevels.begin(), s_featureLevels.end(), + [&] (const std::pair& pair) { + return pair.first == maxLevel; + }); + + return entry != s_featureLevels.end() + ? entry->second + : D3D_FEATURE_LEVEL_11_0; + + } + } diff --git a/src/d3d11/d3d11_device.h b/src/d3d11/d3d11_device.h index ee4f0333..88ba89d7 100644 --- a/src/d3d11/d3d11_device.h +++ b/src/d3d11/d3d11_device.h @@ -333,6 +333,8 @@ namespace dxvk { void UnlockResourceInitContext(uint64_t CommandCount); void SubmitResourceInitCommands(); + static D3D_FEATURE_LEVEL GetMaxFeatureLevel(); + }; }