From db65f107689f853141fd2cf4cb7b6b55b24aff3e Mon Sep 17 00:00:00 2001 From: Ribbit Date: Wed, 8 Oct 2025 04:01:24 +0200 Subject: [vk] Unify RAII in Vulkan (#2679) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR consolidates Vulkan RAII on video_core/vulkan_common/vulkan_wrapper.h’s vk::Handle and remove the unused duplicate src/video_core/vulkan_common/vulkan_raii.h, reducing confusion and maintenance. Swapchain now uses RAII‑managed per‑image semaphores and clears them in Destroy(), providing correct present synchronization and automatic cleanup. Expected result: simpler lifetimes, fewer leak risks, and more stable presentation with negligible overhead. Co-authored-by: Ribbit Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2679 Reviewed-by: MaranBr Reviewed-by: CamilleLaVey Co-authored-by: Ribbit Co-committed-by: Ribbit --- src/video_core/vulkan_common/vulkan_wrapper.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'src/video_core/vulkan_common/vulkan_wrapper.cpp') diff --git a/src/video_core/vulkan_common/vulkan_wrapper.cpp b/src/video_core/vulkan_common/vulkan_wrapper.cpp index 949b91499d..b77d01711a 100644 --- a/src/video_core/vulkan_common/vulkan_wrapper.cpp +++ b/src/video_core/vulkan_common/vulkan_wrapper.cpp @@ -12,7 +12,6 @@ #include "common/common_types.h" #include "common/logging/log.h" -#include "common/settings.h" #include "video_core/vulkan_common/vk_enum_string_helper.h" #include "video_core/vulkan_common/vma.h" #include "video_core/vulkan_common/vulkan_wrapper.h" @@ -311,10 +310,7 @@ const char* Exception::what() const noexcept { } void Destroy(VkInstance instance, const InstanceDispatch& dld) noexcept { - // FIXME: A double free occurs here if RAII is enabled. - if (!Settings::values.enable_raii.GetValue()) { - dld.vkDestroyInstance(instance, nullptr); - } + dld.vkDestroyInstance(instance, nullptr); } void Destroy(VkDevice device, const InstanceDispatch& dld) noexcept { @@ -417,10 +413,7 @@ void Destroy(VkInstance instance, VkDebugReportCallbackEXT handle, } void Destroy(VkInstance instance, VkSurfaceKHR handle, const InstanceDispatch& dld) noexcept { - // FIXME: A double free occurs here if RAII is enabled. - if (!Settings::values.enable_raii.GetValue()) { - dld.vkDestroySurfaceKHR(instance, handle, nullptr); - } + dld.vkDestroySurfaceKHR(instance, handle, nullptr); } VkResult Free(VkDevice device, VkDescriptorPool handle, Span sets, -- cgit v1.2.3