summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D12
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-10-17 16:41:00 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-10-17 16:41:00 +0000
commit31443aba7aeee91f553cd3d440bb971e51f90974 (patch)
tree4badb5aeff5f78d2221948bd793f4f56af7a63f6 /Graphics/GraphicsEngineD3D12
parentA bunch of updates to specify minimum feature level for D3D11/D3D12 backends ... (diff)
downloadDiligentCore-31443aba7aeee91f553cd3d440bb971e51f90974.tar.gz
DiligentCore-31443aba7aeee91f553cd3d440bb971e51f90974.zip
Updated d3d backend initialization + d3d shader model selection
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
-rw-r--r--Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp11
-rw-r--r--Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp8
-rw-r--r--Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp26
3 files changed, 18 insertions, 27 deletions
diff --git a/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp
index 0c91b8c9..fcb73975 100644
--- a/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp
@@ -153,16 +153,19 @@ void EngineFactoryD3D12Impl::CreateDeviceAndContextsD3D12(const EngineD3D12Creat
HRESULT hr = CreateDXGIFactory1(__uuidof(factory), reinterpret_cast<void**>(static_cast<IDXGIFactory4**>(&factory)) );
CHECK_D3D_RESULT_THROW(hr, "Failed to create DXGI factory");
+ // Direct3D12 does not support feature levels below 11.0
+ const auto MinimumFeatureLevel = EngineCI.MinimumFeatureLevel >= DIRECT3D_FEATURE_LEVEL_11_0 ? EngineCI.MinimumFeatureLevel : DIRECT3D_FEATURE_LEVEL_11_0;
+
CComPtr<IDXGIAdapter1> hardwareAdapter;
if(EngineCI.AdapterId == EngineD3D12CreateInfo::DefaultAdapterId)
{
- GetHardwareAdapter(factory, &hardwareAdapter, GetD3DFeatureLevel(EngineCI.MinimumFeatureLevel));
+ GetHardwareAdapter(factory, &hardwareAdapter, GetD3DFeatureLevel(MinimumFeatureLevel));
if(hardwareAdapter == nullptr)
LOG_ERROR_AND_THROW("No suitable hardware adapter found");
}
else
{
- auto Adapters = FindCompatibleAdapters(EngineCI.MinimumFeatureLevel);
+ auto Adapters = FindCompatibleAdapters(MinimumFeatureLevel);
if(EngineCI.AdapterId < Adapters.size())
hardwareAdapter = Adapters[EngineCI.AdapterId];
else
@@ -178,7 +181,7 @@ void EngineFactoryD3D12Impl::CreateDeviceAndContextsD3D12(const EngineD3D12Creat
}
constexpr auto MaxFeatureLevel = DIRECT3D_FEATURE_LEVEL_12_1;
- for (auto FeatureLevel = MaxFeatureLevel; FeatureLevel >= EngineCI.MinimumFeatureLevel; FeatureLevel = static_cast<DIRECT3D_FEATURE_LEVEL>(Uint8{FeatureLevel}-1))
+ for (auto FeatureLevel = MaxFeatureLevel; FeatureLevel >= MinimumFeatureLevel; FeatureLevel = static_cast<DIRECT3D_FEATURE_LEVEL>(Uint8{FeatureLevel}-1))
{
auto d3dFeatureLevel = GetD3DFeatureLevel(FeatureLevel);
hr = D3D12CreateDevice(hardwareAdapter, d3dFeatureLevel, __uuidof(d3d12Device), reinterpret_cast<void**>(static_cast<ID3D12Device**>(&d3d12Device)) );
@@ -196,7 +199,7 @@ void EngineFactoryD3D12Impl::CreateDeviceAndContextsD3D12(const EngineD3D12Creat
hr = factory->EnumWarpAdapter( __uuidof(warpAdapter), reinterpret_cast<void**>(static_cast<IDXGIAdapter**>(&warpAdapter)) );
CHECK_D3D_RESULT_THROW(hr, "Failed to enum warp adapter");
- for (auto FeatureLevel = MaxFeatureLevel; FeatureLevel >= EngineCI.MinimumFeatureLevel; FeatureLevel = static_cast<DIRECT3D_FEATURE_LEVEL>(Uint8{FeatureLevel}-1))
+ for (auto FeatureLevel = MaxFeatureLevel; FeatureLevel >= MinimumFeatureLevel; FeatureLevel = static_cast<DIRECT3D_FEATURE_LEVEL>(Uint8{FeatureLevel}-1))
{
auto d3dFeatureLevel = GetD3DFeatureLevel(FeatureLevel);
hr = D3D12CreateDevice( warpAdapter, d3dFeatureLevel, __uuidof(d3d12Device), reinterpret_cast<void**>(static_cast<ID3D12Device**>(&d3d12Device)) );
diff --git a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
index 27f37dc0..adb16b36 100644
--- a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
@@ -117,7 +117,6 @@ RenderDeviceD3D12Impl :: RenderDeviceD3D12Impl(IReferenceCounters* pRe
case D3D_FEATURE_LEVEL_11_1:
m_DeviceCaps.MajorVersion = 11;
m_DeviceCaps.MinorVersion = FeatureLevel == D3D_FEATURE_LEVEL_11_1 ? 1 : 0;
- m_DeviceCaps.bBindlessSupported = FeatureLevel == D3D_FEATURE_LEVEL_11_1;
break;
case D3D_FEATURE_LEVEL_10_0:
@@ -129,8 +128,13 @@ RenderDeviceD3D12Impl :: RenderDeviceD3D12Impl(IReferenceCounters* pRe
default:
UNEXPECTED("Unexpected D3D feature level");
}
- m_DeviceCaps.bSeparableProgramSupported = True;
+ m_DeviceCaps.bSeparableProgramSupported = True;
m_DeviceCaps.bMultithreadedResourceCreationSupported = True;
+
+ // Direct3D12 supports shader model 5.1 on all feature levels (even on 11.0),
+ // so bindless resources are always available.
+ // https://docs.microsoft.com/en-us/windows/win32/direct3d12/hardware-feature-levels#feature-level-support
+ m_DeviceCaps.bBindlessSupported = True;
}
RenderDeviceD3D12Impl::~RenderDeviceD3D12Impl()
diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp
index c189bf3e..f6dfb74d 100644
--- a/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp
@@ -32,29 +32,13 @@
namespace Diligent
{
-static const char* GetD3D12ShaderModel(RenderDeviceD3D12Impl* pDevice)
+static const char* GetD3D12ShaderModel(RenderDeviceD3D12Impl* /*pDevice*/)
{
- auto d3dDeviceFeatureLevel = pDevice->GetD3DFeatureLevel();
- switch(d3dDeviceFeatureLevel)
- {
- case D3D_FEATURE_LEVEL_12_1:
- case D3D_FEATURE_LEVEL_12_0:
- case D3D_FEATURE_LEVEL_11_1:
- return "5_1";
-
- case D3D_FEATURE_LEVEL_11_0:
- return "5_0";
-
- case D3D_FEATURE_LEVEL_10_1:
- return "4_1";
+ //auto d3dDeviceFeatureLevel = pDevice->GetD3DFeatureLevel();
- case D3D_FEATURE_LEVEL_10_0:
- return "4_0";
-
- default:
- UNEXPECTED("Unexpected D3D feature level ", static_cast<Uint32>(d3dDeviceFeatureLevel));
- return "4_0";
- }
+ // Direct3D12 supports shader model 5.1 on all feature levels.
+ // https://docs.microsoft.com/en-us/windows/win32/direct3d12/hardware-feature-levels#feature-level-support
+ return "5_1";
}
ShaderD3D12Impl::ShaderD3D12Impl(IReferenceCounters* pRefCounters,