summaryrefslogtreecommitdiffstats
path: root/Graphics
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
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')
-rw-r--r--Graphics/GraphicsEngine/interface/APIInfo.h2
-rw-r--r--Graphics/GraphicsEngine/interface/DeviceCaps.h3
-rw-r--r--Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp43
-rw-r--r--Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp36
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp2
-rw-r--r--Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp1
6 files changed, 86 insertions, 1 deletions
diff --git a/Graphics/GraphicsEngine/interface/APIInfo.h b/Graphics/GraphicsEngine/interface/APIInfo.h
index b61f8255..af49cb4c 100644
--- a/Graphics/GraphicsEngine/interface/APIInfo.h
+++ b/Graphics/GraphicsEngine/interface/APIInfo.h
@@ -26,7 +26,7 @@
/// \file
/// Diligent API information
-#define DILIGENT_API_VERSION 240047
+#define DILIGENT_API_VERSION 240048
#include "../../../Primitives/interface/BasicTypes.h"
diff --git a/Graphics/GraphicsEngine/interface/DeviceCaps.h b/Graphics/GraphicsEngine/interface/DeviceCaps.h
index 1d26afdd..ebee2167 100644
--- a/Graphics/GraphicsEngine/interface/DeviceCaps.h
+++ b/Graphics/GraphicsEngine/interface/DeviceCaps.h
@@ -95,6 +95,9 @@ namespace Diligent
/// Similar to MajorVersion, this value indicates the maximum supported feature level.
Int32 MinorVersion = 0;
+ /// Adapter type. See Diligent::ADAPTER_TYPE.
+ ADAPTER_TYPE AdaterType = ADAPTER_TYPE_UNKNOWN;
+
/// Indicates if device supports separable programs
Bool bSeparableProgramSupported = True;
diff --git a/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp
index d54b82e7..7b95aef3 100644
--- a/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp
+++ b/Graphics/GraphicsEngineD3D11/src/RenderDeviceD3D11Impl.cpp
@@ -40,6 +40,34 @@
namespace Diligent
{
+static CComPtr<IDXGIAdapter1> DXGIAdapterFromD3D11Device(ID3D11Device* pd3d11Device)
+{
+ CComPtr<IDXGIDevice> pDXGIDevice;
+
+ auto hr = pd3d11Device->QueryInterface(__uuidof(pDXGIDevice), reinterpret_cast<void**>(static_cast<IDXGIDevice**>(&pDXGIDevice)));
+ if (SUCCEEDED(hr))
+ {
+ CComPtr<IDXGIAdapter> pDXGIAdapter;
+ hr = pDXGIDevice->GetAdapter(&pDXGIAdapter);
+ if (SUCCEEDED(hr))
+ {
+ CComPtr<IDXGIAdapter1> pDXGIAdapter1;
+ pDXGIAdapter->QueryInterface(__uuidof(pDXGIAdapter1), reinterpret_cast<void**>(static_cast<IDXGIAdapter1**>(&pDXGIAdapter1)));
+ return pDXGIAdapter1;
+ }
+ else
+ {
+ LOG_ERROR("Failed to get DXGI Adapter from DXGI Device.");
+ }
+ }
+ else
+ {
+ LOG_ERROR("Failed to query IDXGIDevice from D3D device.");
+ }
+
+ return nullptr;
+}
+
RenderDeviceD3D11Impl::RenderDeviceD3D11Impl(IReferenceCounters* pRefCounters,
IMemoryAllocator& RawMemAllocator,
IEngineFactory* pEngineFactory,
@@ -96,6 +124,21 @@ RenderDeviceD3D11Impl::RenderDeviceD3D11Impl(IReferenceCounters* pRefCo
// above 11.0 (for example, 11.1 or 12.0), so bindless resources are never available.
// https://docs.microsoft.com/en-us/windows/win32/direct3d11/overviews-direct3d-11-devices-downlevel-intro#overview-for-each-feature-level
m_DeviceCaps.bBindlessSupported = False;
+
+ if (auto pDXGIAdapter1 = DXGIAdapterFromD3D11Device(pd3d11Device))
+ {
+ 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.");
+ }
+ }
}
void RenderDeviceD3D11Impl::TestTextureFormat(TEXTURE_FORMAT TexFormat)
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()
diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp
index 02dacc62..30c66bca 100644
--- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp
@@ -103,6 +103,8 @@ RenderDeviceGLImpl::RenderDeviceGLImpl(IReferenceCounters* pRefCounters,
m_GPUInfo.Vendor = GPU_VENDOR::ATI;
else if (Vendor.find("qualcomm"))
m_GPUInfo.Vendor = GPU_VENDOR::QUALCOMM;
+
+ m_DeviceCaps.AdaterType = ADAPTER_TYPE_HARDWARE;
}
RenderDeviceGLImpl::~RenderDeviceGLImpl()
diff --git a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp
index 35f2b1ad..13c3775d 100644
--- a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp
@@ -144,6 +144,7 @@ RenderDeviceVkImpl::RenderDeviceVkImpl(IReferenceCounters*
m_DeviceCaps.DevType = DeviceType::Vulkan;
m_DeviceCaps.MajorVersion = 1;
m_DeviceCaps.MinorVersion = 0;
+ m_DeviceCaps.AdaterType = ADAPTER_TYPE_HARDWARE;
m_DeviceCaps.bSeparableProgramSupported = True;
m_DeviceCaps.bMultithreadedResourceCreationSupported = True;
for (Uint32 fmt = 1; fmt < m_TextureFormatsInfo.size(); ++fmt)