diff --git a/Common/GPU/Vulkan/VulkanMemory.cpp b/Common/GPU/Vulkan/VulkanMemory.cpp index 9015e0d0ba..b4ee6297a5 100644 --- a/Common/GPU/Vulkan/VulkanMemory.cpp +++ b/Common/GPU/Vulkan/VulkanMemory.cpp @@ -349,9 +349,11 @@ void VulkanPushPool::NextBlock(VkDeviceSize allocationSize) { curBlockIndex_++; while (curBlockIndex_ < blocks_.size()) { Block &block = blocks_[curBlockIndex_]; - if (block.frameIndex == curFrameIndex) { + // Grab the first matching block, or unused block (frameIndex == -1). + if ((block.frameIndex == curFrameIndex || block.frameIndex == -1) && block.size >= allocationSize) { _assert_(block.used == 0); block.used = allocationSize; + block.frameIndex = curFrameIndex; return; } curBlockIndex_++; diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index 91957b923c..ad4a8c2057 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -981,7 +981,7 @@ VKContext::VKContext(VulkanContext *vulkan) // 200 textures per frame was not enough for the UI. dp.maxSets = 4096; - VkBufferUsageFlags usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT; + VkBufferUsageFlags usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT; push_ = new VulkanPushPool(vulkan_, "pushBuffer", 1024 * 1024, usage); for (int i = 0; i < VulkanContext::MAX_INFLIGHT_FRAMES; i++) { @@ -1770,7 +1770,8 @@ uint64_t VKContext::GetNativeObject(NativeObject obj, void *srcObject) { return (uint64_t)curFramebuffer_->GetFB()->GetRTView(); case NativeObject::THIN3D_PIPELINE_LAYOUT: return (uint64_t)pipelineLayout_; - + case NativeObject::PUSH_POOL: + return (uint64_t)push_; default: Crash(); return 0; diff --git a/Common/GPU/thin3d.h b/Common/GPU/thin3d.h index 3013470e95..ae3db6af00 100644 --- a/Common/GPU/thin3d.h +++ b/Common/GPU/thin3d.h @@ -252,6 +252,7 @@ enum class NativeObject { NULL_IMAGEVIEW, NULL_IMAGEVIEW_ARRAY, THIN3D_PIPELINE_LAYOUT, + PUSH_POOL, }; enum FBChannel { diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index ca64ae4e11..a88581759e 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -173,7 +173,7 @@ void DrawEngineVulkan::InitDeviceObjects() { // the null texture. This should be cleaned up... } - pushUBO = new VulkanPushPool(vulkan, "pushUBO", 4 * 1024 * 1024, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT); + pushUBO = (VulkanPushPool *)draw_->GetNativeObject(Draw::NativeObject::PUSH_POOL); pushVertex = new VulkanPushPool(vulkan, "pushVertex", 2 * 1024 * 1024, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT); pushIndex = new VulkanPushPool(vulkan, "pushIndex", 1 * 1024 * 1024, VK_BUFFER_USAGE_INDEX_BUFFER_BIT); @@ -252,11 +252,6 @@ void DrawEngineVulkan::DestroyDeviceObjects() { delete pushIndex; pushIndex = nullptr; } - if (pushUBO) { - pushUBO->Destroy(); - delete pushUBO; - pushUBO = nullptr; - } if (samplerSecondaryNearest_ != VK_NULL_HANDLE) vulkan->Delete().QueueDeleteSampler(samplerSecondaryNearest_); @@ -297,7 +292,7 @@ void DrawEngineVulkan::BeginFrame() { lastPipeline_ = nullptr; - pushUBO->BeginFrame(); + // pushUBO is the thin3d push pool, don't need to BeginFrame again. pushVertex->BeginFrame(); pushIndex->BeginFrame();