summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D12
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2019-12-28 05:13:26 +0000
committerassiduous <assiduous@diligentgraphics.com>2019-12-28 05:13:26 +0000
commit9ead3562fb06c14098b7885cc7c736ea4bbc292c (patch)
treef1518a3383204ea2d72f6cb3e372dacdbff553a2 /Graphics/GraphicsEngineD3D12
parentFixed minor issue with draw command test (diff)
downloadDiligentCore-9ead3562fb06c14098b7885cc7c736ea4bbc292c.tar.gz
DiligentCore-9ead3562fb06c14098b7885cc7c736ea4bbc292c.zip
Added AdapterType member to DeviceCaps struct (API Version 240048)
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
-rw-r--r--Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
index e67ffb29..4522c226 100644
--- a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp
@@ -22,6 +22,7 @@
*/
#include "pch.h"
+#include <dxgi1_4.h>
#include "RenderDeviceD3D12Impl.h"
#include "PipelineStateD3D12Impl.h"
#include "ShaderD3D12Impl.h"
@@ -37,6 +38,26 @@
namespace Diligent
{
+static CComPtr<IDXGIAdapter1> DXGIAdapterFromD3D12Device(ID3D12Device* pd3d12Device)
+{
+ CComPtr<IDXGIFactory4> pDXIFactory;
+
+ HRESULT hr = CreateDXGIFactory1(__uuidof(pDXIFactory), reinterpret_cast<void**>(static_cast<IDXGIFactory4**>(&pDXIFactory)));
+ if (SUCCEEDED(hr))
+ {
+ auto AdapterLUID = pd3d12Device->GetAdapterLuid();
+
+ CComPtr<IDXGIAdapter1> pDXGIAdapter1;
+ pDXIFactory->EnumAdapterByLuid(AdapterLUID, __uuidof(pDXGIAdapter1), reinterpret_cast<void**>(static_cast<IDXGIAdapter1**>(&pDXGIAdapter1)));
+ return pDXGIAdapter1;
+ }
+ else
+ {
+ LOG_ERROR("Unable to create DXIFactory");
+ }
+ return nullptr;
+}
+
D3D_FEATURE_LEVEL RenderDeviceD3D12Impl::GetD3DFeatureLevel() const
{
D3D_FEATURE_LEVEL FeatureLevels[] =
@@ -138,6 +159,21 @@ RenderDeviceD3D12Impl::RenderDeviceD3D12Impl(IReferenceCounters* pRefCo
// 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;
+
+ if (auto pDXGIAdapter1 = DXGIAdapterFromD3D12Device(pd3d12Device))
+ {
+ DXGI_ADAPTER_DESC1 AdapterDesc = {};
+
+ auto hr = pDXGIAdapter1->GetDesc1(&AdapterDesc);
+ if (SUCCEEDED(hr))
+ {
+ m_DeviceCaps.AdaterType = (AdapterDesc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) ? ADAPTER_TYPE_SOFTWARE : ADAPTER_TYPE_HARDWARE;
+ }
+ else
+ {
+ LOG_ERROR_MESSAGE("Failed to get DXGIDevice adapter desc. Adapter type will be unknown.");
+ }
+ }
}
RenderDeviceD3D12Impl::~RenderDeviceD3D12Impl()