From 9ead3562fb06c14098b7885cc7c736ea4bbc292c Mon Sep 17 00:00:00 2001 From: assiduous Date: Fri, 27 Dec 2019 21:13:26 -0800 Subject: Added AdapterType member to DeviceCaps struct (API Version 240048) --- Graphics/GraphicsEngine/interface/APIInfo.h | 2 +- Graphics/GraphicsEngine/interface/DeviceCaps.h | 3 ++ .../src/RenderDeviceD3D11Impl.cpp | 43 ++++++++++++++++++++++ .../src/RenderDeviceD3D12Impl.cpp | 36 ++++++++++++++++++ .../src/RenderDeviceGLImpl.cpp | 2 + .../src/RenderDeviceVkImpl.cpp | 1 + 6 files changed, 86 insertions(+), 1 deletion(-) (limited to 'Graphics') 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 DXGIAdapterFromD3D11Device(ID3D11Device* pd3d11Device) +{ + CComPtr pDXGIDevice; + + auto hr = pd3d11Device->QueryInterface(__uuidof(pDXGIDevice), reinterpret_cast(static_cast(&pDXGIDevice))); + if (SUCCEEDED(hr)) + { + CComPtr pDXGIAdapter; + hr = pDXGIDevice->GetAdapter(&pDXGIAdapter); + if (SUCCEEDED(hr)) + { + CComPtr pDXGIAdapter1; + pDXGIAdapter->QueryInterface(__uuidof(pDXGIAdapter1), reinterpret_cast(static_cast(&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 #include "RenderDeviceD3D12Impl.h" #include "PipelineStateD3D12Impl.h" #include "ShaderD3D12Impl.h" @@ -37,6 +38,26 @@ namespace Diligent { +static CComPtr DXGIAdapterFromD3D12Device(ID3D12Device* pd3d12Device) +{ + CComPtr pDXIFactory; + + HRESULT hr = CreateDXGIFactory1(__uuidof(pDXIFactory), reinterpret_cast(static_cast(&pDXIFactory))); + if (SUCCEEDED(hr)) + { + auto AdapterLUID = pd3d12Device->GetAdapterLuid(); + + CComPtr pDXGIAdapter1; + pDXIFactory->EnumAdapterByLuid(AdapterLUID, __uuidof(pDXGIAdapter1), reinterpret_cast(static_cast(&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) -- cgit v1.2.3