summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp
diff options
context:
space:
mode:
authorRobin Kertels <robin.kertels@gmail.com>2022-10-01 01:23:10 +0200
committerRobin Kertels <robin.kertels@gmail.com>2022-10-01 01:26:04 +0200
commitfba7d35f94bd4b2e20b8c26be4818a025a0ed5eb (patch)
tree024d665a932121c2e6c61e56fc8da19fd2165b20 /Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp
parented75a58061c14816b001e3fd4511f104ff131c3d (diff)
VideoBackends:Vulkan: Associate descriptor pool with frame rather than command buffer
Diffstat (limited to 'Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp')
-rw-r--r--Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp b/Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp
index f1a1d3e1e4..c8e48dc677 100644
--- a/Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp
+++ b/Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp
@@ -93,7 +93,10 @@ bool CommandBufferManager::CreateCommandBuffers()
LOG_VULKAN_ERROR(res, "vkCreateSemaphore failed: ");
return false;
}
+ }
+ for (VkDescriptorPool& descriptor_pool : m_descriptor_pools)
+ {
// TODO: A better way to choose the number of descriptors.
const std::array<VkDescriptorPoolSize, 5> pool_sizes{{
{VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 500000},
@@ -112,7 +115,7 @@ bool CommandBufferManager::CreateCommandBuffers()
pool_sizes.data(),
};
- res = vkCreateDescriptorPool(device, &pool_create_info, nullptr, &resources.descriptor_pool);
+ res = vkCreateDescriptorPool(device, &pool_create_info, nullptr, &descriptor_pool);
if (res != VK_SUCCESS)
{
LOG_VULKAN_ERROR(res, "vkCreateDescriptorPool failed: ");
@@ -155,9 +158,12 @@ void CommandBufferManager::DestroyCommandBuffers()
if (resources.fence != VK_NULL_HANDLE)
vkDestroyFence(device, resources.fence, nullptr);
+ }
- if (resources.descriptor_pool != VK_NULL_HANDLE)
- vkDestroyDescriptorPool(device, resources.descriptor_pool, nullptr);
+ for (VkDescriptorPool descriptor_pool : m_descriptor_pools)
+ {
+ if (descriptor_pool != VK_NULL_HANDLE)
+ vkDestroyDescriptorPool(device, descriptor_pool, nullptr);
}
vkDestroySemaphore(device, m_present_semaphore, nullptr);
@@ -340,6 +346,12 @@ void CommandBufferManager::SubmitCommandBuffer(bool submit_on_worker_thread,
}
cmd_buffer_index = (cmd_buffer_index + 1) % NUM_COMMAND_BUFFERS;
}
+
+ // Reset the descriptor pool
+ VkResult res =
+ vkResetDescriptorPool(g_vulkan_context->GetDevice(), GetCurrentDescriptorPool(), 0);
+ if (res != VK_SUCCESS)
+ LOG_VULKAN_ERROR(res, "vkResetDescriptorPool failed: ");
}
// Switch to next cmdbuffer.
@@ -457,11 +469,6 @@ void CommandBufferManager::BeginCommandBuffer()
LOG_VULKAN_ERROR(res, "vkBeginCommandBuffer failed: ");
}
- // Also can do the same for the descriptor pools
- res = vkResetDescriptorPool(g_vulkan_context->GetDevice(), resources.descriptor_pool, 0);
- if (res != VK_SUCCESS)
- LOG_VULKAN_ERROR(res, "vkResetDescriptorPool failed: ");
-
// Reset upload command buffer state
resources.init_command_buffer_used = false;
resources.semaphore_used = false;