Fix memory leak for depth and stencil buffer in Vulkan backend 17/318917/1
authorRichard Huang <r.huang@samsung.com>
Fri, 31 Jan 2025 11:36:08 +0000 (11:36 +0000)
committerRichard Huang <r.huang@samsung.com>
Fri, 31 Jan 2025 11:36:08 +0000 (11:36 +0000)
Change-Id: Iba74096c4ff2e1213a293a5fffcd8ee9b96ab7dd

dali/internal/graphics/vulkan-impl/vulkan-image-impl.cpp
dali/internal/graphics/vulkan-impl/vulkan-image-impl.h
dali/internal/graphics/vulkan-impl/vulkan-swapchain-impl.cpp

index 470d1bd919aada7159cac0f85a2a0d2294000046..5a34b9bd515ec27c2ea0638df5aa6ebbbb2a8fbf 100644 (file)
@@ -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));
index 0703f122a3c41f1a39aef840ccbfab7cd7f41a10..dbaf037bb6c4a87c849d0137c8c57d3d76dac960 100644 (file)
@@ -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
index 93c3264b0ea0ddd0bcd87cfe292ed5ccd9045fdd..6df00820dac1cdf3f4d7f78dc7f30ef29249cb9b 100644 (file)
@@ -198,6 +198,11 @@ void Swapchain::CreateVkSwapchain(
 
 void Swapchain::Destroy()
 {
+  if(mDepthStencilBuffer)
+  {
+    mDepthStencilBuffer->Destroy();
+  }
+
   if(mSwapchainKHR)
   {
     auto device    = mGraphicsDevice.GetLogicalDevice();