From 861a30a6cdeb7fd6a856a55c3dad5d896da6f333 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sat, 2 Apr 2016 11:06:39 +0200 Subject: [PATCH] Fix an assortment of minor resource leaks, make vulkan validator happier. --- GPU/Vulkan/DrawEngineVulkan.cpp | 1 + GPU/Vulkan/FramebufferVulkan.cpp | 2 ++ GPU/Vulkan/PipelineManagerVulkan.cpp | 10 ++++++++-- GPU/Vulkan/TextureCacheVulkan.cpp | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index b27920edc9..c0e6806e75 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -211,6 +211,7 @@ DrawEngineVulkan::~DrawEngineVulkan() { } delete[] uvScale; vkDestroyPipelineLayout(vulkan_->GetDevice(), pipelineLayout_, nullptr); + vkDestroyDescriptorSetLayout(vulkan_->GetDevice(), descriptorSetLayout_, nullptr); } void DrawEngineVulkan::BeginFrame() { diff --git a/GPU/Vulkan/FramebufferVulkan.cpp b/GPU/Vulkan/FramebufferVulkan.cpp index f10e9c5613..3926644394 100644 --- a/GPU/Vulkan/FramebufferVulkan.cpp +++ b/GPU/Vulkan/FramebufferVulkan.cpp @@ -193,6 +193,8 @@ FramebufferManagerVulkan::FramebufferManagerVulkan(VulkanContext *vulkan) : } FramebufferManagerVulkan::~FramebufferManagerVulkan() { + delete[] convBuf_; + vulkan_->Delete().QueueDeleteRenderPass(rpLoadColorLoadDepth_); vulkan_->Delete().QueueDeleteRenderPass(rpClearColorLoadDepth_); vulkan_->Delete().QueueDeleteRenderPass(rpClearColorClearDepth_); diff --git a/GPU/Vulkan/PipelineManagerVulkan.cpp b/GPU/Vulkan/PipelineManagerVulkan.cpp index 84ee2961e6..f787079dbf 100644 --- a/GPU/Vulkan/PipelineManagerVulkan.cpp +++ b/GPU/Vulkan/PipelineManagerVulkan.cpp @@ -20,7 +20,8 @@ void PipelineManagerVulkan::Clear() { // This should kill off all the shaders at once. // This could also be an opportunity to store the whole cache to disk. Will need to also // store the keys. - for (auto iter : pipelines_) { + for (auto &iter : pipelines_) { + vulkan_->Delete().QueueDeletePipeline(iter.second->pipeline); delete iter.second; } pipelines_.clear(); @@ -98,6 +99,10 @@ static int SetupVertexAttribsPretransformed(VkVertexInputAttributeDescription at return count; } +static bool UsesBlendConstant(int factor) { + return factor == VK_BLEND_FACTOR_CONSTANT_ALPHA || factor == VK_BLEND_FACTOR_CONSTANT_COLOR; +} + static VulkanPipeline *CreateVulkanPipeline(VkDevice device, VkPipelineCache pipelineCache, VkPipelineLayout layout, VkRenderPass renderPass, const VulkanPipelineRasterStateKey &key, const VertexDecoder *vtxDec, VulkanVertexShader *vs, VulkanFragmentShader *fs, bool useHwTransform) { @@ -142,7 +147,8 @@ static VulkanPipeline *CreateVulkanPipeline(VkDevice device, VkPipelineCache pip VkDynamicState dynamicStates[8]; int numDyn = 0; - if (key.blendEnable) { + if (key.blendEnable && + (UsesBlendConstant(key.srcAlpha) || UsesBlendConstant(key.srcColor) || UsesBlendConstant(key.destAlpha) || UsesBlendConstant(key.destColor))) { dynamicStates[numDyn++] = VK_DYNAMIC_STATE_BLEND_CONSTANTS; } dynamicStates[numDyn++] = VK_DYNAMIC_STATE_SCISSOR; diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index 004d00e897..1856862031 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -150,6 +150,7 @@ TextureCacheVulkan::TextureCacheVulkan(VulkanContext *vulkan) TextureCacheVulkan::~TextureCacheVulkan() { Clear(true); allocator_->Destroy(); + delete allocator_; } void TextureCacheVulkan::DownloadFramebufferForClut(u32 clutAddr, u32 bytes) {