Changed command buffers to be handled properly as pooled objects

This commit is contained in:
baldurk
2015-12-27 12:48:50 +01:00
parent 290b695a6b
commit b3029b6ddf
3 changed files with 14 additions and 12 deletions
+6
View File
@@ -169,6 +169,12 @@ class VulkanResourceManager : public ResourceManager<WrappedVkRes*, TypedRealHan
// though that the pool isn't going to be destroyed while
// either allocation or freeing happens, so we only need to
// lock against concurrent allocs or deletes of children.
if(record && record->bakedCommands)
{
record->bakedCommands->Delete(this);
record->bakedCommands = NULL;
}
if(record->pool)
{
@@ -239,7 +239,14 @@ VkResult WrappedVulkan::vkAllocateCommandBuffers(
record->bakedCommands = NULL;
record->AddParent(GetRecord(pAllocateInfo->commandPool));
record->pool = GetRecord(pAllocateInfo->commandPool);
record->AddParent(record->pool);
{
record->pool->LockChunks();
record->pool->pooledChildren.push_back(record);
record->pool->UnlockChunks();
}
// we don't serialise this as we never create this command buffer directly.
// Instead we create a command buffer for each baked list that we find.
@@ -103,17 +103,6 @@ void WrappedVulkan::vkFreeCommandBuffers(VkDevice device, VkCommandPool commandP
{
WrappedVkDispRes *wrapped = (WrappedVkDispRes *)GetWrapped(pCommandBuffers[c]);
if(wrapped->record)
{
if(wrapped->record->bakedCommands)
{
wrapped->record->bakedCommands->Delete(GetResourceManager());
wrapped->record->bakedCommands = NULL;
}
wrapped->record->Delete(GetResourceManager());
wrapped->record = NULL;
}
VkCommandBuffer unwrapped = wrapped->real.As<VkCommandBuffer>();
GetResourceManager()->ReleaseWrappedResource(pCommandBuffers[c]);