summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp')
-rw-r--r--Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp52
1 files changed, 47 insertions, 5 deletions
diff --git a/Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp b/Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp
index 537c21c514..202c3f6777 100644
--- a/Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp
+++ b/Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp
@@ -73,7 +73,7 @@ void CommandBufferManager::DestroyCommandPool()
if (m_command_pool)
{
vkDestroyCommandPool(g_vulkan_context->GetDevice(), m_command_pool, nullptr);
- m_command_pool = nullptr;
+ m_command_pool = VK_NULL_HANDLE;
}
}
@@ -141,8 +141,8 @@ void CommandBufferManager::DestroyCommandBuffers()
for (FrameResources& resources : m_frame_resources)
{
- for (const auto& it : resources.cleanup_resources)
- it.destroy_callback(device, it.object);
+ for (auto& it : resources.cleanup_resources)
+ it();
resources.cleanup_resources.clear();
if (resources.fence != VK_NULL_HANDLE)
@@ -385,8 +385,8 @@ void CommandBufferManager::OnCommandBufferExecuted(size_t index)
iter.second.second(resources.fence);
// Clean up all objects pending destruction on this command buffer
- for (const auto& it : resources.cleanup_resources)
- it.destroy_callback(g_vulkan_context->GetDevice(), it.object);
+ for (auto& it : resources.cleanup_resources)
+ it();
resources.cleanup_resources.clear();
}
@@ -446,6 +446,48 @@ void CommandBufferManager::ExecuteCommandBuffer(bool submit_off_thread, bool wai
WaitForFence(pending_fence);
}
+void CommandBufferManager::DeferBufferDestruction(VkBuffer object)
+{
+ FrameResources& resources = m_frame_resources[m_current_frame];
+ resources.cleanup_resources.push_back(
+ [object]() { vkDestroyBuffer(g_vulkan_context->GetDevice(), object, nullptr); });
+}
+
+void CommandBufferManager::DeferBufferViewDestruction(VkBufferView object)
+{
+ FrameResources& resources = m_frame_resources[m_current_frame];
+ resources.cleanup_resources.push_back(
+ [object]() { vkDestroyBufferView(g_vulkan_context->GetDevice(), object, nullptr); });
+}
+
+void CommandBufferManager::DeferDeviceMemoryDestruction(VkDeviceMemory object)
+{
+ FrameResources& resources = m_frame_resources[m_current_frame];
+ resources.cleanup_resources.push_back(
+ [object]() { vkFreeMemory(g_vulkan_context->GetDevice(), object, nullptr); });
+}
+
+void CommandBufferManager::DeferFramebufferDestruction(VkFramebuffer object)
+{
+ FrameResources& resources = m_frame_resources[m_current_frame];
+ resources.cleanup_resources.push_back(
+ [object]() { vkDestroyFramebuffer(g_vulkan_context->GetDevice(), object, nullptr); });
+}
+
+void CommandBufferManager::DeferImageDestruction(VkImage object)
+{
+ FrameResources& resources = m_frame_resources[m_current_frame];
+ resources.cleanup_resources.push_back(
+ [object]() { vkDestroyImage(g_vulkan_context->GetDevice(), object, nullptr); });
+}
+
+void CommandBufferManager::DeferImageViewDestruction(VkImageView object)
+{
+ FrameResources& resources = m_frame_resources[m_current_frame];
+ resources.cleanup_resources.push_back(
+ [object]() { vkDestroyImageView(g_vulkan_context->GetDevice(), object, nullptr); });
+}
+
void CommandBufferManager::AddFencePointCallback(
const void* key, const CommandBufferQueuedCallback& queued_callback,
const CommandBufferExecutedCallback& executed_callback)