From 0df6a7c4052b296007f224e86346824cd5ffffeb Mon Sep 17 00:00:00 2001 From: Richard Huang Date: Fri, 31 Jan 2025 11:36:08 +0000 Subject: [PATCH] Fix memory leak for depth and stencil buffer in Vulkan backend Change-Id: Iba74096c4ff2e1213a293a5fffcd8ee9b96ab7dd --- dali/internal/graphics/vulkan-impl/vulkan-image-impl.cpp | 7 ++++++- dali/internal/graphics/vulkan-impl/vulkan-image-impl.h | 7 ++++++- .../graphics/vulkan-impl/vulkan-swapchain-impl.cpp | 5 +++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/dali/internal/graphics/vulkan-impl/vulkan-image-impl.cpp b/dali/internal/graphics/vulkan-impl/vulkan-image-impl.cpp index 470d1bd91..5a34b9bd5 100644 --- a/dali/internal/graphics/vulkan-impl/vulkan-image-impl.cpp +++ b/dali/internal/graphics/vulkan-impl/vulkan-image-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Samsung Electronics Co., Ltd. + * Copyright (c) 2025 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -78,6 +78,11 @@ Image::Image(Device& graphicsDevice, const vk::ImageCreateInfo& createInfo, vk:: } } +Image::~Image() +{ + Destroy(); +} + void Image::Initialize() { VkAssert(mDevice.GetLogicalDevice().createImage(&mCreateInfo, &mDevice.GetAllocator("IMAGE"), &mImage)); diff --git a/dali/internal/graphics/vulkan-impl/vulkan-image-impl.h b/dali/internal/graphics/vulkan-impl/vulkan-image-impl.h index 0703f122a..dbaf037bb 100644 --- a/dali/internal/graphics/vulkan-impl/vulkan-image-impl.h +++ b/dali/internal/graphics/vulkan-impl/vulkan-image-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_GRAPHICS_VULKAN_IMAGE_IMPL_H /* - * Copyright (c) 2024 Samsung Electronics Co., Ltd. + * Copyright (c) 2025 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,6 +46,11 @@ public: */ Image(Device& graphicsDevice, const vk::ImageCreateInfo& createInfo, vk::Image externalImage = nullptr); + /** + * @brief Destructor + */ + ~Image(); + /** * Second stage initialization: * Creates new VkImage with given specification, it doesn't diff --git a/dali/internal/graphics/vulkan-impl/vulkan-swapchain-impl.cpp b/dali/internal/graphics/vulkan-impl/vulkan-swapchain-impl.cpp index 93c3264b0..6df00820d 100644 --- a/dali/internal/graphics/vulkan-impl/vulkan-swapchain-impl.cpp +++ b/dali/internal/graphics/vulkan-impl/vulkan-swapchain-impl.cpp @@ -198,6 +198,11 @@ void Swapchain::CreateVkSwapchain( void Swapchain::Destroy() { + if(mDepthStencilBuffer) + { + mDepthStencilBuffer->Destroy(); + } + if(mSwapchainKHR) { auto device = mGraphicsDevice.GetLogicalDevice(); -- 2.34.1