There is a memory leak

This commit is contained in:
Dynamitos
2023-11-30 11:51:53 +01:00
parent d1475d506e
commit 1493627ceb
20 changed files with 91 additions and 102 deletions
+9 -5
View File
@@ -62,12 +62,10 @@ void DescriptorLayout::create()
PipelineLayout::~PipelineLayout()
{
if (layoutHandle != VK_NULL_HANDLE)
{
vkDestroyPipelineLayout(graphics->getDevice(), layoutHandle, nullptr);
}
}
Map<uint32, VkPipelineLayout> cachedLayouts;
void PipelineLayout::create()
{
vulkanDescriptorLayouts.resize(descriptorSetLayouts.size());
@@ -105,7 +103,14 @@ void PipelineLayout::create()
layoutHash = CRC::Calculate(createInfo.pPushConstantRanges, sizeof(VkPushConstantRange) * createInfo.pushConstantRangeCount, CRC::CRC_32());
layoutHash = CRC::Calculate(createInfo.pSetLayouts, sizeof(VkDescriptorSetLayout) * createInfo.setLayoutCount, CRC::CRC_32(), layoutHash);
if (cachedLayouts.contains(layoutHash))
{
layoutHandle = cachedLayouts[layoutHash];
return;
}
VK_CHECK(vkCreatePipelineLayout(graphics->getDevice(), &createInfo, nullptr, &layoutHandle));
cachedLayouts[layoutHash] = layoutHandle;
}
void PipelineLayout::reset()
@@ -391,7 +396,6 @@ Gfx::PDescriptorSet DescriptorPool::allocateDescriptorSet()
{
//If it hasnt been initialized, allocate it
VK_CHECK(vkAllocateDescriptorSets(graphics->getDevice(), &allocInfo, &cachedHandles[setIndex]->setHandle));
std::cout << "New descriptor " << cachedHandles[setIndex]->setHandle << std::endl;
}
cachedHandles[setIndex]->allocate();