diff options
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
6 files changed, 16 insertions, 3 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h index 9bc54e82..7c87e5fb 100644 --- a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h @@ -134,9 +134,6 @@ private: void CommitViewports(); void CommitScissorRects(); -#if 0 - friend class SwapChainVkImpl; -#endif inline void EnsureVkCmdBuffer(); inline void DisposeVkCmdBuffer(); @@ -171,8 +168,10 @@ private: FixedBlockMemoryAllocator m_CmdListAllocator; const Uint32 m_ContextId; #endif + VulkanUtilities::VulkanCommandBufferPool m_CmdPool; + // Semaphores are not owned by the command context std::vector<VkSemaphore> m_WaitSemaphores; std::vector<VkPipelineStageFlags> m_WaitDstStageMasks; std::vector<VkSemaphore> m_SignalSemaphores; diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBufferPool.h b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBufferPool.h index 22429fe8..d898bae2 100644 --- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBufferPool.h +++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/VulkanCommandBufferPool.h @@ -45,6 +45,8 @@ namespace VulkanUtilities VkCommandBuffer GetCommandBuffer(uint64_t LastCompletedFence, const char* DebugName = ""); void DisposeCommandBuffer(VkCommandBuffer CmdBuffer, uint64_t FenceValue); + + CommandPoolWrapper&& Release(); private: // Shared point to logical device must be defined before the command pool diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp index 0297f4a3..32e8116e 100644 --- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp @@ -84,6 +84,9 @@ namespace Diligent Flush(); } + + auto VkCmdPool = m_CmdPool.Release(); + m_pDevice.RawPtr<RenderDeviceVkImpl>()->SafeReleaseVkObject(std::move(VkCmdPool)); } IMPLEMENT_QUERY_INTERFACE( DeviceContextVkImpl, IID_DeviceContextVk, TDeviceContextBase ) diff --git a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp index 6d370ca0..3d77fa07 100644 --- a/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/RenderDeviceVkImpl.cpp @@ -406,6 +406,7 @@ template void RenderDeviceVkImpl::SafeReleaseVkObject<VkFramebuffer> (VulkanUt template void RenderDeviceVkImpl::SafeReleaseVkObject<VkDescriptorPool> (VulkanUtilities::DescriptorPoolWrapper &&Object); template void RenderDeviceVkImpl::SafeReleaseVkObject<VkDescriptorSetLayout>(VulkanUtilities::DescriptorSetLayoutWrapper &&Object); template void RenderDeviceVkImpl::SafeReleaseVkObject<VkSemaphore> (VulkanUtilities::SemaphoreWrapper &&Object); +template void RenderDeviceVkImpl::SafeReleaseVkObject<VkCommandPool> (VulkanUtilities::CommandPoolWrapper &&Object); void RenderDeviceVkImpl::DiscardStaleVkObjects(Uint64 CmdListNumber, Uint64 FenceValue) diff --git a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp index 03722eb8..cb00e700 100644 --- a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp @@ -321,6 +321,7 @@ SwapChainVkImpl::~SwapChainVkImpl() if(m_VkSwapChain != VK_NULL_HANDLE) { auto *pDeviceVkImpl = m_pRenderDevice.RawPtr<RenderDeviceVkImpl>(); + pDeviceVkImpl->IdleGPU(true); vkDestroySwapchainKHR(pDeviceVkImpl->GetVkDevice(), m_VkSwapChain, NULL); } } diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanCommandBufferPool.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanCommandBufferPool.cpp index d94a83f3..b5ec40b0 100644 --- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanCommandBufferPool.cpp +++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/VulkanCommandBufferPool.cpp @@ -112,4 +112,11 @@ namespace VulkanUtilities // executed the command buffer m_DiscardedCmdBuffers.emplace_back(FenceValue, CmdBuffer); } + + CommandPoolWrapper&& VulkanCommandBufferPool::Release() + { + m_LogicalDevice.reset(); + m_DiscardedCmdBuffers.clear(); + return std::move(m_CmdPool); + } } |
