summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D12
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-03-30 03:05:30 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-03-30 03:05:30 +0000
commitb0b568e32e854a720e97e1085151f54c7e62f047 (patch)
tree8d3d99becd2b835ed247e4c90f38c6409287aab3 /Graphics/GraphicsEngineD3D12
parentImplemented hardware adapter and display mode enumeration (diff)
downloadDiligentCore-b0b568e32e854a720e97e1085151f54c7e62f047.tar.gz
DiligentCore-b0b568e32e854a720e97e1085151f54c7e62f047.zip
Implemented option to specify hardware adapter when initializing the engine in d3d mode
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
-rw-r--r--Graphics/GraphicsEngineD3D12/src/RenderDeviceFactoryD3D12.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/Graphics/GraphicsEngineD3D12/src/RenderDeviceFactoryD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/RenderDeviceFactoryD3D12.cpp
index 8e41f986..fb7cb83b 100644
--- a/Graphics/GraphicsEngineD3D12/src/RenderDeviceFactoryD3D12.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/RenderDeviceFactoryD3D12.cpp
@@ -89,7 +89,6 @@ void GetHardwareAdapter(IDXGIFactory2* pFactory, IDXGIAdapter1** ppAdapter)
// actual device yet.
if (SUCCEEDED(D3D12CreateDevice(adapter, D3D_FEATURE_LEVEL_11_0, _uuidof(ID3D12Device), nullptr)))
{
- LOG_INFO_MESSAGE("D3D12-capabale hardware found: ", NarrowString(desc.Description), " (", desc.DedicatedVideoMemory>>20, " MB)");
break;
}
}
@@ -162,8 +161,29 @@ void EngineFactoryD3D12Impl::CreateDeviceAndContextsD3D12( const EngineD3D12Attr
CHECK_D3D_RESULT_THROW(hr, "Failed to create DXGI factory")
CComPtr<IDXGIAdapter1> hardwareAdapter;
- GetHardwareAdapter(factory, &hardwareAdapter);
-
+ if(CreationAttribs.AdapterId == EngineD3D12Attribs::DefaultAdapterId)
+ {
+ GetHardwareAdapter(factory, &hardwareAdapter);
+ if(hardwareAdapter == nullptr)
+ LOG_ERROR_AND_THROW("No suitable hardware adapter found");
+ }
+ else
+ {
+ auto Adapters = FindCompatibleAdapters();
+ if(CreationAttribs.AdapterId < Adapters.size())
+ hardwareAdapter = Adapters[CreationAttribs.AdapterId];
+ else
+ {
+ LOG_ERROR_AND_THROW(CreationAttribs.AdapterId, " is not a valid hardware adapter id. Total number of compatible adapters available on this system: ", Adapters.size());
+ }
+ }
+
+ {
+ DXGI_ADAPTER_DESC1 desc;
+ hardwareAdapter->GetDesc1(&desc);
+ LOG_INFO_MESSAGE("D3D12-capabale hardware found: ", NarrowString(desc.Description), " (", desc.DedicatedVideoMemory >> 20, " MB)");
+ }
+
hr = D3D12CreateDevice(hardwareAdapter, D3D_FEATURE_LEVEL_11_0, __uuidof(d3d12Device), reinterpret_cast<void**>(static_cast<ID3D12Device**>(&d3d12Device)) );
if( FAILED(hr))
{