From 5d77c63216f413285a4e0acda37246fbea10b280 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 24 Feb 2018 12:15:22 +0100 Subject: [PATCH] Vulkan: Need to count allocated descsets per frame separately from the map, since tess isn't even in-frame cached. --- GPU/Vulkan/DrawEngineVulkan.cpp | 5 ++++- GPU/Vulkan/DrawEngineVulkan.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index 33b4fc7a9d..56a393f447 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -304,6 +304,7 @@ void DrawEngineVulkan::BeginFrame() { if (frame->descPool != VK_NULL_HANDLE) vkResetDescriptorPool(vulkan_->GetDevice(), frame->descPool, 0); frame->descSets.Clear(); + frame->descCount = 0; descDecimationCounter_ = DESCRIPTORSET_DECIMATION_INTERVAL; } @@ -443,13 +444,14 @@ VkDescriptorSet DrawEngineVulkan::GetOrCreateDescriptorSet(VkImageView imageView return d; } - if (!frame.descPool || frame.descPoolSize < frame.descSets.size() + 1) { + if (!frame.descPool || frame.descPoolSize < frame.descCount + 1) { // Reallocate this desc pool larger, and "wipe" the cache. We might lose a tiny bit of descriptor set reuse but // only for this frame. if (frame.descPool) { DEBUG_LOG(G3D, "Reallocating desc pool from %d to %d", frame.descPoolSize, frame.descPoolSize * 2); vulkan_->Delete().QueueDeleteDescriptorPool(frame.descPool); frame.descSets.Clear(); + frame.descCount = 0; } frame.descPoolSize *= 2; @@ -579,6 +581,7 @@ VkDescriptorSet DrawEngineVulkan::GetOrCreateDescriptorSet(VkImageView imageView if (!tess) // Again, avoid caching when HW tessellation. frame.descSets.Insert(key, desc); + frame.descCount++; return desc; } diff --git a/GPU/Vulkan/DrawEngineVulkan.h b/GPU/Vulkan/DrawEngineVulkan.h index 92d843ac57..673cc4b4f4 100644 --- a/GPU/Vulkan/DrawEngineVulkan.h +++ b/GPU/Vulkan/DrawEngineVulkan.h @@ -232,6 +232,7 @@ private: FrameData() : descSets(512) {} VkDescriptorPool descPool = VK_NULL_HANDLE; + int descCount = 0; int descPoolSize = 256; // We double this before we allocate so we initialize this to half the size we want. VulkanPushBuffer *pushUBO = nullptr;