Vulkan: Fix minor vulkan resource leak if inflight frames isn't max.

This commit is contained in:
Henrik Rydgård 2020-03-08 17:03:58 +01:00
parent 1712563817
commit b0b9e24d4e
2 changed files with 4 additions and 2 deletions

View File

@ -113,7 +113,8 @@ VulkanRenderManager::VulkanRenderManager(VulkanContext *vulkan) : vulkan_(vulkan
res = vkCreateSemaphore(vulkan_->GetDevice(), &semaphoreCreateInfo, nullptr, &renderingCompleteSemaphore_);
assert(res == VK_SUCCESS);
for (int i = 0; i < vulkan_->GetInflightFrames(); i++) {
inflightFramesAtStart_ = vulkan_->GetInflightFrames();
for (int i = 0; i < inflightFramesAtStart_; i++) {
VkCommandPoolCreateInfo cmd_pool_info = { VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO };
cmd_pool_info.queueFamilyIndex = vulkan_->GetGraphicsQueueFamilyIndex();
cmd_pool_info.flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT | VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
@ -298,7 +299,7 @@ VulkanRenderManager::~VulkanRenderManager() {
VkDevice device = vulkan_->GetDevice();
vkDestroySemaphore(device, acquireSemaphore_, nullptr);
vkDestroySemaphore(device, renderingCompleteSemaphore_, nullptr);
for (int i = 0; i < vulkan_->GetInflightFrames(); i++) {
for (int i = 0; i < inflightFramesAtStart_; i++) {
vkFreeCommandBuffers(device, frameData_[i].cmdPoolInit, 1, &frameData_[i].initCmd);
vkFreeCommandBuffers(device, frameData_[i].cmdPoolMain, 1, &frameData_[i].mainCmd);
vkDestroyCommandPool(device, frameData_[i].cmdPoolInit, nullptr);

View File

@ -307,6 +307,7 @@ private:
FrameData frameData_[VulkanContext::MAX_INFLIGHT_FRAMES];
int newInflightFrames_ = -1;
int inflightFramesAtStart_ = 0;
// Submission time state
int curWidth_ = -1;