diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h index 7cfc8aa24..65b801429 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h @@ -237,6 +237,7 @@ VKFUNC_DEVICE(vkAllocateDescriptorSets); VKFUNC_DEVICE(vkFreeDescriptorSets); VKFUNC_DEVICE(vkUpdateDescriptorSets); VKFUNC_DEVICE(vkCreateDescriptorPool); +VKFUNC_DEVICE(vkDestroyDescriptorPool); VKFUNC_DEVICE(vkDestroyDescriptorSetLayout); #undef VKFUNC_INIT diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp index 372fa07c1..ed33a03fc 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp @@ -630,6 +630,17 @@ VulkanRenderer::~VulkanRenderer() vkDestroyPipelineCache(m_logicalDevice, m_pipeline_cache, nullptr); + if(!m_backbufferBlitDescriptorSetCache.empty()) + { + std::vector freeVector; + freeVector.reserve(m_backbufferBlitDescriptorSetCache.size()); + std::transform(m_backbufferBlitDescriptorSetCache.begin(), m_backbufferBlitDescriptorSetCache.end(), std::back_inserter(freeVector), [](auto& i) { + return i.second; + }); + vkFreeDescriptorSets(m_logicalDevice, m_descriptorPool, freeVector.size(), freeVector.data()); + } + + vkDestroyDescriptorPool(m_logicalDevice, m_descriptorPool, nullptr); for(auto& i : m_backbufferBlitPipelineCache) { @@ -3019,9 +3030,8 @@ VkDescriptorSet VulkanRenderer::backbufferBlit_createDescriptorSet(VkDescriptorS hash += (uint64)texViewVk->GetViewRGBA(); hash += (uint64)texViewVk->GetDefaultTextureSampler(useLinearTexFilter); - static std::unordered_map s_set_cache; - const auto it = s_set_cache.find(hash); - if (it != s_set_cache.cend()) + const auto it = m_backbufferBlitDescriptorSetCache.find(hash); + if (it != m_backbufferBlitDescriptorSetCache.cend()) return it->second; VkDescriptorSetAllocateInfo allocInfo = {}; @@ -3052,7 +3062,7 @@ VkDescriptorSet VulkanRenderer::backbufferBlit_createDescriptorSet(VkDescriptorS vkUpdateDescriptorSets(m_logicalDevice, 1, &descriptorWrites, 0, nullptr); performanceMonitor.vk.numDescriptorSamplerTextures.increment(); - s_set_cache[hash] = result; + m_backbufferBlitDescriptorSetCache[hash] = result; return result; } diff --git a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h index 30ebfb010..fe35a8ad4 100644 --- a/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h +++ b/src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.h @@ -583,6 +583,7 @@ class VulkanRenderer : public Renderer std::thread m_pipeline_cache_save_thread; VkPipelineCache m_pipeline_cache{ nullptr }; std::unordered_map m_backbufferBlitPipelineCache; + std::unordered_map m_backbufferBlitDescriptorSetCache; VkPipelineLayout m_pipelineLayout{nullptr}; VkCommandPool m_commandPool{ nullptr };