From e3c0280310086a3fbe69d9fbc2411068e2a651ba Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sun, 23 Sep 2018 22:43:54 -0700 Subject: Couple updates to processing release queue in Vk backend --- Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h | 4 ++-- Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp | 4 ++-- Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp | 13 +++++-------- 3 files changed, 9 insertions(+), 12 deletions(-) (limited to 'Graphics/GraphicsEngineVulkan') diff --git a/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h b/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h index d326e0f6..4814f359 100644 --- a/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/RenderDeviceVkImpl.h @@ -93,7 +93,7 @@ public: void IdleGPU(bool ReleaseStaleObjects); // pImmediateCtx parameter is only used to make sure the command buffer is submitted from the immediate context // The method returns fence value associated with the submitted command buffer - Uint64 ExecuteCommandBuffer(const VkSubmitInfo &SubmitInfo, class DeviceContextVkImpl* pImmediateCtx, std::vector > >* pSignalFences); + Uint64 ExecuteCommandBuffer(Uint32 QueueIndex, const VkSubmitInfo &SubmitInfo, class DeviceContextVkImpl* pImmediateCtx, std::vector > >* pSignalFences); void AllocateTransientCmdPool(VulkanUtilities::CommandPoolWrapper& CmdPool, VkCommandBuffer& vkCmdBuff, const Char* DebugPoolName = nullptr); void ExecuteAndDisposeTransientCmdBuff(Uint32 QueueIndex, VkCommandBuffer vkCmdBuff, VulkanUtilities::CommandPoolWrapper&& CmdPool); @@ -130,7 +130,7 @@ private: // Parameters: // * SubmittedCmdBuffNumber - submitted command buffer number // * SubmittedFenceValue - fence value associated with the submitted command buffer - void SubmitCommandBuffer(const VkSubmitInfo& SubmitInfo, Uint64& SubmittedCmdBuffNumber, Uint64& SubmittedFenceValue, std::vector > >* pFences); + void SubmitCommandBuffer(Uint32 QueueIndex, const VkSubmitInfo& SubmitInfo, Uint64& SubmittedCmdBuffNumber, Uint64& SubmittedFenceValue, std::vector > >* pFences); std::shared_ptr m_VulkanInstance; std::unique_ptr m_PhysicalDevice; diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp index 9c602b8c..f7d1a054 100644 --- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp @@ -801,7 +801,7 @@ namespace Diligent // Submit command buffer even if there are no commands to release stale resources. //if (SubmitInfo.commandBufferCount != 0 || SubmitInfo.waitSemaphoreCount !=0 || SubmitInfo.signalSemaphoreCount != 0) - m_LastSubmittedFenceValue = pDeviceVkImpl->ExecuteCommandBuffer(SubmitInfo, this, &m_PendingFences); + m_LastSubmittedFenceValue = pDeviceVkImpl->ExecuteCommandBuffer(m_CommandQueueId, SubmitInfo, this, &m_PendingFences); m_WaitSemaphores.clear(); m_WaitDstStageMasks.clear(); @@ -1426,7 +1426,7 @@ namespace Diligent auto pDeviceVkImpl = m_pDevice.RawPtr(); VERIFY_EXPR(m_PendingFences.empty()); auto pDeferredCtxVkImpl = pDeferredCtx.RawPtr(); - auto SubmittedFenceValue = pDeviceVkImpl->ExecuteCommandBuffer(SubmitInfo, this, nullptr); + auto SubmittedFenceValue = pDeviceVkImpl->ExecuteCommandBuffer(m_CommandQueueId, SubmitInfo, this, nullptr); pDeferredCtxVkImpl->m_LastSubmittedFenceValue = SubmittedFenceValue; // Set the bit in the deferred context cmd queue mask corresponding to cmd queue of this context pDeferredCtxVkImpl->m_SubmittedBuffersCmdQueueMask |= Uint64{1} << m_CommandQueueId; diff --git a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp index 6f6770ee..f5947039 100644 --- a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp @@ -264,14 +264,14 @@ void RenderDeviceVkImpl::ExecuteAndDisposeTransientCmdBuff(Uint32 QueueIndex, Vk } -void RenderDeviceVkImpl::SubmitCommandBuffer(const VkSubmitInfo& SubmitInfo, +void RenderDeviceVkImpl::SubmitCommandBuffer(Uint32 QueueIndex, + const VkSubmitInfo& SubmitInfo, Uint64& SubmittedCmdBuffNumber, // Number of the submitted command buffer Uint64& SubmittedFenceValue, // Fence value associated with the submitted command buffer std::vector > >* pFences // List of fences to signal ) { // Submit the command list to the queue - Uint32 QueueIndex = 0; auto CmbBuffInfo = TRenderDeviceBase::SubmitCommandBuffer(QueueIndex, SubmitInfo, true); SubmittedFenceValue = CmbBuffInfo.FenceValue; SubmittedCmdBuffNumber = CmbBuffInfo.CmdBufferNumber; @@ -287,7 +287,7 @@ void RenderDeviceVkImpl::SubmitCommandBuffer(const VkSubmitInfo& SubmitInfo, } } -Uint64 RenderDeviceVkImpl::ExecuteCommandBuffer(const VkSubmitInfo& SubmitInfo, DeviceContextVkImpl* pImmediateCtx, std::vector > >* pSignalFences) +Uint64 RenderDeviceVkImpl::ExecuteCommandBuffer(Uint32 QueueIndex, const VkSubmitInfo& SubmitInfo, DeviceContextVkImpl* pImmediateCtx, std::vector > >* pSignalFences) { // pImmediateCtx parameter is only used to make sure the command buffer is submitted from the immediate context // Stale objects MUST only be discarded when submitting cmd list from the immediate context @@ -295,13 +295,10 @@ Uint64 RenderDeviceVkImpl::ExecuteCommandBuffer(const VkSubmitInfo& SubmitInfo, Uint64 SubmittedFenceValue = 0; Uint64 SubmittedCmdBuffNumber = 0; - SubmitCommandBuffer(SubmitInfo, SubmittedCmdBuffNumber, SubmittedFenceValue, pSignalFences); + SubmitCommandBuffer(QueueIndex, SubmitInfo, SubmittedCmdBuffNumber, SubmittedFenceValue, pSignalFences); - // TODO: rework this - //auto CompletedFenceValue = m_CommandQueues[0].CmdQueue->GetCompletedFenceValue(); - //m_MainDescriptorPool.ReleaseStaleAllocations(CompletedFenceValue); m_MemoryMgr.ShrinkMemory(); - PurgeReleaseQueues(); + PurgeReleaseQueue(QueueIndex); return SubmittedFenceValue; } -- cgit v1.2.3