From 09eaac37aec4fad669c479e9d8ae333ec96d8a95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Fri, 19 Jun 2026 11:21:52 -0700 Subject: [PATCH] VK: Added descriptor set cache. (#3770) --- src/renderer_vk.cpp | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/src/renderer_vk.cpp b/src/renderer_vk.cpp index 29887ff37..0353b6f70 100644 --- a/src/renderer_vk.cpp +++ b/src/renderer_vk.cpp @@ -9270,6 +9270,8 @@ VK_DESTROY VkDescriptorSet currentDescriptorSet = VK_NULL_HANDLE; uint32_t currentBindHash = 0; uint32_t descriptorSetCount = 0; + + StateCacheLru descriptorSetCache; VkIndexType currentIndexFormat = VK_INDEX_TYPE_MAX_ENUM; SortKey key; uint16_t view = UINT16_MAX; @@ -9682,14 +9684,21 @@ VK_DESTROY { currentBindHash = bindHash; - currentDescriptorSet = getDescriptorSet( - program - , renderBind - , sbo.buffer - , _render->m_colorPalette - ); + VkDescriptorSet* cached = descriptorSetCache.find(bindHash); + if (NULL == cached) + { + VkDescriptorSet descriptorSet = getDescriptorSet( + program + , renderBind + , sbo.buffer + , _render->m_colorPalette + ); + cached = descriptorSetCache.add(bindHash, descriptorSet, 0); - descriptorSetCount++; + descriptorSetCount++; + } + + currentDescriptorSet = *cached; } vkCmdBindDescriptorSets( @@ -9970,14 +9979,21 @@ VK_DESTROY { currentBindHash = bindHash; - currentDescriptorSet = getDescriptorSet( - program - , renderBind - , sbo.buffer - , _render->m_colorPalette - ); + VkDescriptorSet* cached = descriptorSetCache.find(bindHash); + if (NULL == cached) + { + VkDescriptorSet descriptorSet = getDescriptorSet( + program + , renderBind + , sbo.buffer + , _render->m_colorPalette + ); + cached = descriptorSetCache.add(bindHash, descriptorSet, 0); - descriptorSetCount++; + descriptorSetCount++; + } + + currentDescriptorSet = *cached; } vkCmdBindDescriptorSets(