From c22dc143d1c1e6ff831b112f8d1de0b1f28d7a22 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 30 Jan 2018 12:19:53 +0100 Subject: [PATCH] [d3d119 Implemented DXVK_FEATURE_LEVEL to restrict D3D feature levels --- src/d3d11/d3d11_device.cpp | 26 +++++++++++++++++++++++++- src/d3d11/d3d11_device.h | 2 ++ 2 files changed, 27 insertions(+), 1 deletion(-) 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(); + }; }