From de64acf20511c6d6d71c3456ac0f8fcc16ae6ddc Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sun, 7 Oct 2018 19:31:08 -0700 Subject: Few changes to D3D12 and Vulkan backends to make implementations more consistent --- Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp | 11 +++++++---- Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'Graphics/GraphicsEngineVulkan') diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp index c8222b6a..a29ca27d 100644 --- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp @@ -104,16 +104,20 @@ namespace Diligent { 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 the immediate context being destroyed, which indicates the context has not been Flush()'ed.", " This is unexpected and may result in synchronization errors"); + } if (!m_bIsDeferred) { Flush(); } + // For deferred contexts, m_SubmittedBuffersCmdQueueMask is reset to 0 after every call to FinishFrame(). + // In this case there are no resources to release, so there will be no issues. FinishFrame(); // There must be no stale resources @@ -148,8 +152,6 @@ namespace Diligent void DeviceContextVkImpl::DisposeVkCmdBuffer(Uint32 CmdQueue, VkCommandBuffer vkCmdBuff, Uint64 FenceValue) { VERIFY_EXPR(vkCmdBuff != VK_NULL_HANDLE); - auto& DeviceVkImpl = *m_pDevice.RawPtr(); - auto& ReleaseQueue = DeviceVkImpl.GetReleaseQueue(CmdQueue); class CmdBufferDeleter { public: @@ -186,6 +188,7 @@ namespace Diligent VulkanUtilities::VulkanCommandBufferPool* Pool; }; + auto& ReleaseQueue = m_pDevice.RawPtr()->GetReleaseQueue(CmdQueue); ReleaseQueue.DiscardResource(CmdBufferDeleter{vkCmdBuff, m_CmdPool}, FenceValue); } @@ -749,9 +752,11 @@ namespace Diligent void DeviceContextVkImpl::FinishFrame() { 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 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"); + } if (!m_MappedTextures.empty()) LOG_ERROR_MESSAGE("There are mapped textures in the device context when finishing the frame. All dynamic resources must be used in the same frame in which they are mapped."); @@ -1388,8 +1393,6 @@ namespace Diligent (pDeviceVkImpl, this, vkCmdBuff) ); pCmdListVk->QueryInterface( IID_CommandList, reinterpret_cast(ppCommandList) ); - m_CommandBuffer.SetVkCmdBuffer(VK_NULL_HANDLE); - m_CommandBuffer.Reset(); m_State = ContextState{}; m_DescrSetBindInfo.Reset(); diff --git a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp index a85670fb..b4a98d4d 100644 --- a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp @@ -131,7 +131,8 @@ RenderDeviceVkImpl :: RenderDeviceVkImpl(IReferenceCounters* RenderDeviceVkImpl::~RenderDeviceVkImpl() { - // Explicitly destroy dynamic heap + // Explicitly destroy dynamic heap. This will move resources owned by + // the heap into release queues m_DynamicMemoryManager.Destroy(); // Wait for the GPU to complete all its operations -- cgit v1.2.3