Fix issue with freeing resources

This commit is contained in:
Georg Hagen
2024-07-11 13:22:01 +02:00
parent 22cb48be89
commit 313b01db1b
16 changed files with 300 additions and 156 deletions

View File

@@ -12,18 +12,18 @@
namespace OpenVulkano::Vulkan
{
void UniformBuffer::Init(ManagedBuffer* buffer, uint32_t frameOffset, uint32_t frameSize, vk::DescriptorSetLayout* descriptorSetLayout, const DescriptorSetLayoutBinding& binding, uint32_t setId)
void UniformBuffer::Init(ManagedBuffer::Ptr buffer, uint32_t frameOffset, uint32_t frameSize, vk::DescriptorSetLayout* descriptorSetLayout, const DescriptorSetLayoutBinding& binding, uint32_t setId)
{
m_buffer = buffer;
m_buffer = std::move(buffer);
m_frameOffset = frameOffset;
const vk::DescriptorSetAllocateInfo descSetAllocInfo = { ResourceManager::INSTANCE->descriptorPool, 1, descriptorSetLayout };
m_descriptorSet = buffer->allocation->device.allocateDescriptorSets(descSetAllocInfo)[0];
vk::DescriptorBufferInfo bufferInfo = { buffer->buffer, 0, frameSize };
m_descriptorSet = m_buffer->allocation->device.allocateDescriptorSets(descSetAllocInfo)[0];
vk::DescriptorBufferInfo bufferInfo = { m_buffer->buffer, 0, frameSize };
vk::WriteDescriptorSet writeDescriptorSet = { m_descriptorSet, binding.bindingId, 0, 1 };
writeDescriptorSet.descriptorType = static_cast<vk::DescriptorType>(binding.descriptorType);
writeDescriptorSet.pBufferInfo = &bufferInfo;
buffer->allocation->device.updateDescriptorSets(1, &writeDescriptorSet, 0, nullptr);
m_buffer->allocation->device.updateDescriptorSets(1, &writeDescriptorSet, 0, nullptr);
m_setOffset = setId;
m_dynamic = binding.descriptorType == DescriptorSetLayoutBinding::TYPE_UNIFORM_BUFFER_DYNAMIC || binding.descriptorType == DescriptorSetLayoutBinding::TYPE_STORAGE_BUFFER_DYNAMIC;
}