diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2021-02-25 06:05:53 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2021-03-19 00:38:11 +0000 |
| commit | 8a9d93b3f6e00288e07b9f34db6a5e652f89c14f (patch) | |
| tree | 39d326eff1d498d730502224dcabb7c99ca50b0e /Graphics/GraphicsEngineD3D12 | |
| parent | Few updated to RootParamsManager, RootSignatureD3D12, and ShaderResourceCache... (diff) | |
| download | DiligentCore-8a9d93b3f6e00288e07b9f34db6a5e652f89c14f.tar.gz DiligentCore-8a9d93b3f6e00288e07b9f34db6a5e652f89c14f.zip | |
Few updates to RenderDeviceD3D12Impl
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
| -rw-r--r-- | Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.hpp | 29 | ||||
| -rw-r--r-- | Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp | 39 |
2 files changed, 40 insertions, 28 deletions
diff --git a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.hpp index 513aa8b4..37ce8965 100644 --- a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.hpp +++ b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.hpp @@ -29,6 +29,9 @@ /// \file /// Declaration of Diligent::RenderDeviceD3D12Impl class + +#include <atomic> + #include "RenderDeviceD3D12.h" #include "RenderDeviceD3DBase.hpp" #include "RenderDeviceNextGenBase.hpp" @@ -36,7 +39,6 @@ #include "CommandListManager.hpp" #include "CommandContext.hpp" #include "D3D12DynamicHeap.hpp" -#include "Atomics.hpp" #include "CommandQueueD3D12.h" #include "GenerateMips.hpp" #include "QueryManagerD3D12.hpp" @@ -216,8 +218,20 @@ public: IDXCompiler* GetDxCompiler() const { return m_pDxCompiler.get(); } - ID3D12Device2* GetD3D12Device2(); - ID3D12Device5* GetD3D12Device5(); +#define GET_D3D12_DEVICE(Version) \ + ID3D12Device##Version* GetD3D12Device##Version() \ + { \ + DEV_CHECK_ERR(m_MaxD3D12DeviceVersion >= Version, "ID3D12Device", Version, \ + " is not supported. Maximum supported version: ", \ + m_MaxD3D12DeviceVersion); \ + return static_cast<ID3D12Device##Version*>(m_pd3d12Device.p); \ + } + GET_D3D12_DEVICE(1) + GET_D3D12_DEVICE(2) + GET_D3D12_DEVICE(3) + GET_D3D12_DEVICE(4) + GET_D3D12_DEVICE(5) +#undef GET_D3D12_DEVICE struct Properties { @@ -248,9 +262,6 @@ private: CComPtr<ID3D12Device> m_pd3d12Device; - CComPtr<ID3D12Device2> m_pd3d12Device2; - CComPtr<ID3D12Device5> m_pd3d12Device5; - EngineD3D12CreateInfo m_EngineAttribs; CPUDescriptorHeap m_CPUDescriptorHeaps[D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES]; @@ -262,7 +273,7 @@ private: std::mutex m_ContextPoolMutex; std::vector<PooledCommandContext, STDAllocatorRawMem<PooledCommandContext>> m_ContextPool; #ifdef DILIGENT_DEVELOPMENT - Atomics::AtomicLong m_AllocatedCtxCounter = 0; + std::atomic_int m_AllocatedCtxCounter{0}; #endif D3D12DynamicMemoryManager m_DynamicMemoryManager; @@ -278,6 +289,10 @@ private: FixedBlockMemoryAllocator m_RootSignatureAllocator; RootSignatureCacheD3D12 m_RootSignatureCache; + +#ifdef DILIGENT_DEVELOPMENT + Uint32 m_MaxD3D12DeviceVersion = 0; +#endif }; } // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp index 03786c50..f90447f5 100644 --- a/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/RenderDeviceD3D12Impl.cpp @@ -92,24 +92,6 @@ static D3D_FEATURE_LEVEL GetD3DFeatureLevel(ID3D12Device* pd3d12Device) return FeatureLevelsData.MaxSupportedFeatureLevel; } -ID3D12Device2* RenderDeviceD3D12Impl::GetD3D12Device2() -{ - if (!m_pd3d12Device2) - { - CHECK_D3D_RESULT_THROW(m_pd3d12Device->QueryInterface(IID_PPV_ARGS(&m_pd3d12Device2)), "Failed to get ID3D12Device2"); - } - return m_pd3d12Device2; -} - -ID3D12Device5* RenderDeviceD3D12Impl::GetD3D12Device5() -{ - if (!m_pd3d12Device5) - { - CHECK_D3D_RESULT_THROW(m_pd3d12Device->QueryInterface(IID_PPV_ARGS(&m_pd3d12Device5)), "Failed to get ID3D12Device5"); - } - return m_pd3d12Device5; -} - RenderDeviceD3D12Impl::RenderDeviceD3D12Impl(IReferenceCounters* pRefCounters, IMemoryAllocator& RawMemAllocator, IEngineFactory* pEngineFactory, @@ -360,6 +342,21 @@ RenderDeviceD3D12Impl::RenderDeviceD3D12Impl(IReferenceCounters* pRefCo SamCaps.BorderSamplingModeSupported = True; SamCaps.AnisotropicFilteringSupported = True; SamCaps.LODBiasSupported = True; + + +#ifdef DILIGENT_DEVELOPMENT +# define CHECK_D3D12_DEVICE_VERSION(Version) \ + if (CComQIPtr<ID3D12Device##Version>{m_pd3d12Device}) \ + m_MaxD3D12DeviceVersion = Version; + + CHECK_D3D12_DEVICE_VERSION(1) + CHECK_D3D12_DEVICE_VERSION(2) + CHECK_D3D12_DEVICE_VERSION(3) + CHECK_D3D12_DEVICE_VERSION(4) + CHECK_D3D12_DEVICE_VERSION(5) + +# undef CHECK_D3D12_DEVICE_VERSION +#endif } catch (...) { @@ -408,7 +405,7 @@ void RenderDeviceD3D12Impl::FreeCommandContext(PooledCommandContext&& Ctx) std::lock_guard<std::mutex> LockGuard(m_ContextPoolMutex); m_ContextPool.emplace_back(std::move(Ctx)); #ifdef DILIGENT_DEVELOPMENT - Atomics::AtomicDecrement(m_AllocatedCtxCounter); + m_AllocatedCtxCounter.fetch_add(-1); #endif } @@ -528,7 +525,7 @@ RenderDeviceD3D12Impl::PooledCommandContext RenderDeviceD3D12Impl::AllocateComma Ctx->Reset(m_CmdListManager); Ctx->SetID(ID); #ifdef DILIGENT_DEVELOPMENT - Atomics::AtomicIncrement(m_AllocatedCtxCounter); + m_AllocatedCtxCounter.fetch_add(1); #endif return Ctx; } @@ -539,7 +536,7 @@ RenderDeviceD3D12Impl::PooledCommandContext RenderDeviceD3D12Impl::AllocateComma auto pCtx = new (pRawMem) CommandContext(m_CmdListManager); pCtx->SetID(ID); #ifdef DILIGENT_DEVELOPMENT - Atomics::AtomicIncrement(m_AllocatedCtxCounter); + m_AllocatedCtxCounter.fetch_add(1); #endif return PooledCommandContext(pCtx, CmdCtxAllocator); } |
