From 8f27b8a0351b4c1403a79155bb0c37055263d779 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Thu, 26 Sep 2019 08:05:03 -0700 Subject: Added EngineD3D12CreateInfo::EnableDebugLayer (updated API Version to 240030) --- Graphics/GraphicsEngine/interface/APIInfo.h | 2 +- Graphics/GraphicsEngine/interface/GraphicsTypes.h | 5 ++++- Graphics/GraphicsEngineD3D12/include/CommandListD3D12Impl.h | 10 +++++++++- Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp | 2 ++ Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp | 6 ++---- 5 files changed, 18 insertions(+), 7 deletions(-) (limited to 'Graphics') diff --git a/Graphics/GraphicsEngine/interface/APIInfo.h b/Graphics/GraphicsEngine/interface/APIInfo.h index 7d4ab626..2f02c994 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 240029 +#define DILIGENT_API_VERSION 240030 #include "../../../Primitives/interface/BasicTypes.h" diff --git a/Graphics/GraphicsEngine/interface/GraphicsTypes.h b/Graphics/GraphicsEngine/interface/GraphicsTypes.h index 9904b5c0..fb5332b3 100644 --- a/Graphics/GraphicsEngine/interface/GraphicsTypes.h +++ b/Graphics/GraphicsEngine/interface/GraphicsTypes.h @@ -1351,6 +1351,9 @@ namespace Diligent /// Id of the hardware adapter the engine should be initialized on Uint32 AdapterId = DefaultAdapterId; + /// Enable Direct3D12 debug layer. + bool EnableDebugLayer = false; + /// Size of the CPU descriptor heap allocations for different heap types. Uint32 CPUDescriptorHeapAllocationSize[4] = { @@ -1403,7 +1406,7 @@ namespace Diligent /// Attributes specific to Vulkan engine struct EngineVkCreateInfo : public EngineCreateInfo { - /// Enable validation layers. Validation is always enabled in Debug mode + /// Enable Vulkan validation layers. bool EnableValidation = false; /// Number of global Vulkan extensions diff --git a/Graphics/GraphicsEngineD3D12/include/CommandListD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/CommandListD3D12Impl.h index 3e3577af..5bb92d51 100644 --- a/Graphics/GraphicsEngineD3D12/include/CommandListD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/CommandListD3D12Impl.h @@ -53,7 +53,15 @@ public: ~CommandListD3D12Impl() { - DEV_CHECK_ERR(m_pCmdContext == nullptr && m_pDeferredCtx == nullptr, "Destroying a command list that has not been executed"); + if (m_pCmdContext != nullptr) + { + LOG_WARNING_MESSAGE("Destroying command list that has not been executed"); + m_pDevice->DisposeCommandContext(std::move(m_pCmdContext)); + } + else + { + VERIFY_EXPR(m_pDeferredCtx == nullptr); + } } RenderDeviceD3D12Impl::PooledCommandContext Close(RefCntAutoPtr& pDeferredCtx) diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp index 64fd4817..42532555 100644 --- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp @@ -606,6 +606,8 @@ namespace Diligent m_State = State{}; + // Setting pipeline state to null makes sure that render targets and other + // states will be restored in the command list next time a PSO is bound. m_pPipelineState = nullptr; } diff --git a/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp index 0dfa412f..a11d698a 100644 --- a/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp +++ b/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp @@ -147,8 +147,8 @@ void EngineFactoryD3D12Impl::CreateDeviceAndContextsD3D12(const EngineD3D12Creat CComPtr d3d12Device; try { -#ifdef DEVELOPMENT // Enable the D3D12 debug layer. + if (EngineCI.EnableDebugLayer) { CComPtr debugController; if (SUCCEEDED(D3D12GetDebugInterface(__uuidof(debugController), reinterpret_cast(static_cast(&debugController)) ))) @@ -156,7 +156,6 @@ void EngineFactoryD3D12Impl::CreateDeviceAndContextsD3D12(const EngineD3D12Creat debugController->EnableDebugLayer(); } } -#endif CComPtr factory; HRESULT hr = CreateDXGIFactory1(__uuidof(factory), reinterpret_cast(static_cast(&factory)) ); @@ -199,7 +198,7 @@ void EngineFactoryD3D12Impl::CreateDeviceAndContextsD3D12(const EngineD3D12Creat CHECK_D3D_RESULT_THROW(hr, "Failed to crate warp device"); } -#ifdef DEVELOPMENT + if (EngineCI.EnableDebugLayer) { CComPtr pInfoQueue; hr = d3d12Device->QueryInterface(__uuidof(pInfoQueue), reinterpret_cast(static_cast(&pInfoQueue))); @@ -235,7 +234,6 @@ void EngineFactoryD3D12Impl::CreateDeviceAndContextsD3D12(const EngineD3D12Creat VERIFY(SUCCEEDED(hr), "Failed to set break on error"); } } -#endif #ifndef RELEASE // Prevent the GPU from overclocking or underclocking to get consistent timings -- cgit v1.2.3