mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-07 15:31:18 +12:00
Vulkan: Cleanup backbuffer descriptor sets and pool
This commit is contained in:
parent
d4c4c32cf4
commit
44a3c006f6
3 changed files with 16 additions and 4 deletions
|
@ -237,6 +237,7 @@ VKFUNC_DEVICE(vkAllocateDescriptorSets);
|
||||||
VKFUNC_DEVICE(vkFreeDescriptorSets);
|
VKFUNC_DEVICE(vkFreeDescriptorSets);
|
||||||
VKFUNC_DEVICE(vkUpdateDescriptorSets);
|
VKFUNC_DEVICE(vkUpdateDescriptorSets);
|
||||||
VKFUNC_DEVICE(vkCreateDescriptorPool);
|
VKFUNC_DEVICE(vkCreateDescriptorPool);
|
||||||
|
VKFUNC_DEVICE(vkDestroyDescriptorPool);
|
||||||
VKFUNC_DEVICE(vkDestroyDescriptorSetLayout);
|
VKFUNC_DEVICE(vkDestroyDescriptorSetLayout);
|
||||||
|
|
||||||
#undef VKFUNC_INIT
|
#undef VKFUNC_INIT
|
||||||
|
|
|
@ -630,6 +630,17 @@ VulkanRenderer::~VulkanRenderer()
|
||||||
|
|
||||||
vkDestroyPipelineCache(m_logicalDevice, m_pipeline_cache, nullptr);
|
vkDestroyPipelineCache(m_logicalDevice, m_pipeline_cache, nullptr);
|
||||||
|
|
||||||
|
if(!m_backbufferBlitDescriptorSetCache.empty())
|
||||||
|
{
|
||||||
|
std::vector<VkDescriptorSet> 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)
|
for(auto& i : m_backbufferBlitPipelineCache)
|
||||||
{
|
{
|
||||||
|
@ -3019,9 +3030,8 @@ VkDescriptorSet VulkanRenderer::backbufferBlit_createDescriptorSet(VkDescriptorS
|
||||||
hash += (uint64)texViewVk->GetViewRGBA();
|
hash += (uint64)texViewVk->GetViewRGBA();
|
||||||
hash += (uint64)texViewVk->GetDefaultTextureSampler(useLinearTexFilter);
|
hash += (uint64)texViewVk->GetDefaultTextureSampler(useLinearTexFilter);
|
||||||
|
|
||||||
static std::unordered_map<uint64, VkDescriptorSet> s_set_cache;
|
const auto it = m_backbufferBlitDescriptorSetCache.find(hash);
|
||||||
const auto it = s_set_cache.find(hash);
|
if (it != m_backbufferBlitDescriptorSetCache.cend())
|
||||||
if (it != s_set_cache.cend())
|
|
||||||
return it->second;
|
return it->second;
|
||||||
|
|
||||||
VkDescriptorSetAllocateInfo allocInfo = {};
|
VkDescriptorSetAllocateInfo allocInfo = {};
|
||||||
|
@ -3052,7 +3062,7 @@ VkDescriptorSet VulkanRenderer::backbufferBlit_createDescriptorSet(VkDescriptorS
|
||||||
vkUpdateDescriptorSets(m_logicalDevice, 1, &descriptorWrites, 0, nullptr);
|
vkUpdateDescriptorSets(m_logicalDevice, 1, &descriptorWrites, 0, nullptr);
|
||||||
performanceMonitor.vk.numDescriptorSamplerTextures.increment();
|
performanceMonitor.vk.numDescriptorSamplerTextures.increment();
|
||||||
|
|
||||||
s_set_cache[hash] = result;
|
m_backbufferBlitDescriptorSetCache[hash] = result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -583,6 +583,7 @@ private:
|
||||||
std::thread m_pipeline_cache_save_thread;
|
std::thread m_pipeline_cache_save_thread;
|
||||||
VkPipelineCache m_pipeline_cache{ nullptr };
|
VkPipelineCache m_pipeline_cache{ nullptr };
|
||||||
std::unordered_map<uint64, VkPipeline> m_backbufferBlitPipelineCache;
|
std::unordered_map<uint64, VkPipeline> m_backbufferBlitPipelineCache;
|
||||||
|
std::unordered_map<uint64, VkDescriptorSet> m_backbufferBlitDescriptorSetCache;
|
||||||
VkPipelineLayout m_pipelineLayout{nullptr};
|
VkPipelineLayout m_pipelineLayout{nullptr};
|
||||||
VkCommandPool m_commandPool{ nullptr };
|
VkCommandPool m_commandPool{ nullptr };
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue