From 5afeee8a82d07a18c36f73750114885940802479 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sun, 7 Oct 2018 20:05:43 -0700 Subject: Couple of minor updates to D3D12 and Vulkan device context implementations --- Graphics/GraphicsEngine/interface/DeviceContext.h | 5 +++-- Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp | 13 +++++++++---- Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp | 13 ++++++------- 3 files changed, 18 insertions(+), 13 deletions(-) (limited to 'Graphics') diff --git a/Graphics/GraphicsEngine/interface/DeviceContext.h b/Graphics/GraphicsEngine/interface/DeviceContext.h index 5469931d..785efa63 100644 --- a/Graphics/GraphicsEngine/interface/DeviceContext.h +++ b/Graphics/GraphicsEngine/interface/DeviceContext.h @@ -514,9 +514,10 @@ public: /// per frame, though it can be called with different frequency. Note that unless the GPU is idled, /// the resources may actually be released several frames after the one they were used in last time. /// \note After the call all dynamic resources become invalid and must be written again before the next use. - /// Also, all committed resources become invalid. + /// Also, all committed resources become invalid.\n /// For deferred contexts, this method must be called after all command lists referencing dynamic resources - /// have been executed through immediate context. + /// have been executed through immediate context.\n + /// The method does not Flush() the context. virtual void FinishFrame() = 0; }; diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp index 6cee61df..64361e5d 100644 --- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp @@ -120,7 +120,7 @@ namespace Diligent if (m_State.NumCommands != 0) { LOG_ERROR_MESSAGE(m_bIsDeferred ? - "There are outstanding commands in the deferred context being destroyed, which indicates that FinishCommandList() has not been called." : + "There are outstanding commands in deferred context #", m_ContextId, " being destroyed, which indicates that FinishCommandList() has not been called." : "There are outstanding commands in the immediate context being destroyed, which indicates the context has not been Flush()'ed.", " This is unexpected and may result in synchronization errors"); } @@ -577,7 +577,12 @@ namespace Diligent void DeviceContextD3D12Impl::Flush() { - VERIFY(!m_bIsDeferred, "Flush() should only be called for immediate contexts"); + if (m_bIsDeferred) + { + LOG_ERROR_MESSAGE("Flush() should only be called for immediate contexts"); + return; + } + Flush(true); } @@ -586,7 +591,7 @@ namespace Diligent if (GetNumCommandsInCtx() != 0) { LOG_ERROR_MESSAGE(m_bIsDeferred ? - "There are outstanding commands in the deferred device context when finishing the frame. This is an error and may cause unpredicted behaviour. Close all deferred contexts and execute them before finishing the frame" : + "There are outstanding commands in deferred device context #", m_ContextId, " when finishing the frame. This is an error and may cause unpredicted behaviour. Close all deferred contexts and execute them before finishing the frame" : "There are outstanding commands in the immediate device context when finishing the frame. This is an error and may cause unpredicted behaviour. Call Flush() to submit all commands for execution before finishing the frame"); } @@ -1072,7 +1077,7 @@ namespace Diligent { if (m_bIsDeferred) { - LOG_ERROR("Only immediate context can execute command list"); + LOG_ERROR_MESSAGE("Only immediate context can execute command list"); return; } // First execute commands in this context diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp index a29ca27d..c8f5e220 100644 --- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp @@ -102,11 +102,10 @@ namespace Diligent DeviceContextVkImpl::~DeviceContextVkImpl() { - auto* pDeviceVkImpl = m_pDevice.RawPtr(); if (m_State.NumCommands != 0) { LOG_ERROR_MESSAGE(m_bIsDeferred ? - "There are outstanding commands in the deferred context being destroyed, which indicates that FinishCommandList() has not been called." : + "There are outstanding commands in deferred context #", m_ContextId, " being destroyed, which indicates that FinishCommandList() has not been called." : "There are outstanding commands in the immediate context being destroyed, which indicates the context has not been Flush()'ed.", " This is unexpected and may result in synchronization errors"); } @@ -125,6 +124,8 @@ namespace Diligent DEV_CHECK_ERR(m_DynamicHeap.GetAllocatedMasterBlockCount() == 0, "All allocated dynamic heap master blocks must have been released"); DEV_CHECK_ERR(m_DynamicDescrSetAllocator.GetAllocatedPoolCount() == 0, "All allocated dynamic descriptor set pools must have been released at this point"); + auto* pDeviceVkImpl = m_pDevice.RawPtr(); + auto VkCmdPool = m_CmdPool.Release(); pDeviceVkImpl->SafeReleaseDeviceObject(std::move(VkCmdPool), ~Uint64{0}); @@ -754,7 +755,7 @@ namespace Diligent if(GetNumCommandsInCtx() != 0) { LOG_ERROR_MESSAGE(m_bIsDeferred ? - "There are outstanding commands in the deferred device context when finishing the frame. This is an error and may cause unpredicted behaviour. Close all deferred contexts and execute them before finishing the frame" : + "There are outstanding commands in deferred device context #", m_ContextId, " when finishing the frame. This is an error and may cause unpredicted behaviour. Close all deferred contexts and execute them before finishing the frame" : "There are outstanding commands in the immediate device context when finishing the frame. This is an error and may cause unpredicted behaviour. Call Flush() to submit all commands for execution before finishing the frame"); } @@ -787,13 +788,11 @@ namespace Diligent void DeviceContextVkImpl::Flush() { -#ifdef DEVELOPMENT if (m_bIsDeferred) { - LOG_ERROR("Flush() should only be called for immediate contexts"); + LOG_ERROR_MESSAGE("Flush() should only be called for immediate contexts"); return; } -#endif VkSubmitInfo SubmitInfo = {}; SubmitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; @@ -1405,7 +1404,7 @@ namespace Diligent { if (m_bIsDeferred) { - LOG_ERROR("Only immediate context can execute command list"); + LOG_ERROR_MESSAGE("Only immediate context can execute command list"); return; } -- cgit v1.2.3