fixing dangling pointer in vulkan's command pools

This commit is contained in:
2025-03-03 10:31:55 +01:00
parent 8abb2b710c
commit b1102874e6
2 changed files with 11 additions and 7 deletions

View File

@@ -250,7 +250,10 @@ void VulkanDestroyDevice(PulseDevice device)
VulkanDestroyDescriptorSetPoolManager(&vulkan_device->descriptor_set_pool_manager);
VulkanDestroyDescriptorSetLayoutManager(&vulkan_device->descriptor_set_layout_manager);
for(uint32_t i = 0; i < vulkan_device->cmd_pools_size; i++)
vulkan_device->vkDestroyCommandPool(vulkan_device->device, vulkan_device->cmd_pools[i].pool, PULSE_NULLPTR);
{
vulkan_device->vkDestroyCommandPool(vulkan_device->device, vulkan_device->cmd_pools[i]->pool, PULSE_NULLPTR);
free(vulkan_device->cmd_pools[i]);
}
vmaDestroyAllocator(vulkan_device->allocator);
vulkan_device->vkDestroyDevice(vulkan_device->device, PULSE_NULLPTR);
if(PULSE_IS_BACKEND_HIGH_LEVEL_DEBUG(device->backend))
@@ -271,13 +274,14 @@ VulkanCommandPool* VulkanRequestCmdPoolFromDevice(PulseDevice device, VulkanQueu
for(uint32_t i = 0; i < vulkan_device->cmd_pools_size; i++)
{
if(thread_id == vulkan_device->cmd_pools[i].thread_id && queue_type == vulkan_device->cmd_pools[i].queue_type)
return &vulkan_device->cmd_pools[i];
if(thread_id == vulkan_device->cmd_pools[i]->thread_id && queue_type == vulkan_device->cmd_pools[i]->queue_type)
return vulkan_device->cmd_pools[i];
}
vulkan_device->cmd_pools_size++;
vulkan_device->cmd_pools = (VulkanCommandPool*)realloc(vulkan_device->cmd_pools, vulkan_device->cmd_pools_size * sizeof(VulkanCommandPool));
if(!VulkanInitCommandPool(device, &vulkan_device->cmd_pools[vulkan_device->cmd_pools_size - 1], queue_type))
vulkan_device->cmd_pools = (VulkanCommandPool**)realloc(vulkan_device->cmd_pools, vulkan_device->cmd_pools_size * sizeof(VulkanCommandPool*));
vulkan_device->cmd_pools[vulkan_device->cmd_pools_size - 1] = (VulkanCommandPool*)calloc(1, sizeof(VulkanCommandPool));
if(!VulkanInitCommandPool(device, vulkan_device->cmd_pools[vulkan_device->cmd_pools_size - 1], queue_type))
return PULSE_NULLPTR;
return &vulkan_device->cmd_pools[vulkan_device->cmd_pools_size - 1];
return vulkan_device->cmd_pools[vulkan_device->cmd_pools_size - 1];
}

View File

@@ -27,7 +27,7 @@ typedef struct VulkanDevice
VulkanDescriptorSetPoolManager descriptor_set_pool_manager;
VulkanDescriptorSetLayoutManager descriptor_set_layout_manager;
VulkanCommandPool* cmd_pools;
VulkanCommandPool** cmd_pools;
uint32_t cmd_pools_size;
struct VulkanQueue* queues[VULKAN_QUEUE_END_ENUM];