Fix release of Vulkan resources
This commit is contained in:
@@ -79,11 +79,21 @@ namespace openVulkanoCpp::Vulkan
|
||||
{
|
||||
device.freeCommandBuffers(cmdPools[i], 1, &cmdBuffers[i]);
|
||||
device.destroyCommandPool(cmdPools[i]);
|
||||
device.destroy(semaphores[i]);
|
||||
}
|
||||
cmdPools = nullptr;
|
||||
cmdBuffers = nullptr;
|
||||
semaphores = nullptr;
|
||||
device.destroyDescriptorPool(descriptorPool);
|
||||
allocations.clear();
|
||||
lastAllocation = nullptr;
|
||||
toFree.clear();
|
||||
recycleBuffers.clear();
|
||||
descriptorSetLayoutCache.clear();
|
||||
shaders.clear();
|
||||
cmdBuffers = nullptr;
|
||||
cmdPools = nullptr;
|
||||
transferQueue = nullptr;
|
||||
device = nullptr;
|
||||
}
|
||||
|
||||
@@ -311,18 +321,18 @@ namespace openVulkanoCpp::Vulkan
|
||||
MemoryAllocation* alloc = new MemoryAllocation(size, type, device);
|
||||
const vk::MemoryAllocateInfo allocInfo = { size, type };
|
||||
alloc->memory = device.allocateMemory(allocInfo);
|
||||
if (addToCache) allocations.push_back(alloc);
|
||||
if (addToCache) allocations.emplace_back(alloc);
|
||||
return alloc;
|
||||
}
|
||||
|
||||
MemoryAllocation* ResourceManager::GetFreeMemoryAllocation(size_t size, uint32_t type, bool createIfAllFull)
|
||||
{
|
||||
MemoryAllocation* alloc = nullptr;
|
||||
for (MemoryAllocation* allocation : allocations)
|
||||
for (auto& allocation : allocations)
|
||||
{
|
||||
if (allocation->type == type && allocation->FreeSpace() >= size)
|
||||
{
|
||||
alloc = allocation;
|
||||
alloc = allocation.get();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user