From d3b9ae45cfc4f98305bf8a749e50e46fa0a93caa Mon Sep 17 00:00:00 2001 From: Nick Fisher Date: Wed, 16 Apr 2025 13:35:40 +0800 Subject: [PATCH] (Windows) properly destroy swapchain and don't un-set current unless the swapchain being destroyed is the current swapchain --- .../native/src/windows/vulkan/vulkan_platform.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/thermion_dart/native/src/windows/vulkan/vulkan_platform.cpp b/thermion_dart/native/src/windows/vulkan/vulkan_platform.cpp index cbb57c46..1ca8dc6e 100644 --- a/thermion_dart/native/src/windows/vulkan/vulkan_platform.cpp +++ b/thermion_dart/native/src/windows/vulkan/vulkan_platform.cpp @@ -25,10 +25,11 @@ namespace thermion::windows::vulkan { TVulkanPlatform::TVulkanPlatform() { _customization.gpu.index = 0; + TRACE("Set GPU index to 1"); } TVulkanPlatform::~TVulkanPlatform() { - std::cerr << "Destroyed Vulkan platform" << std::endl; + TRACE("Destroyed Vulkan platform"); } filament::backend::VulkanPlatform::Customization TVulkanPlatform::getCustomization() const noexcept { @@ -39,14 +40,17 @@ filament::backend::VulkanPlatform::SwapChainPtr TVulkanPlatform::createSwapChain VkExtent2D extent) { std::lock_guard lock(mutex); current = filament::backend::VulkanPlatform::createSwapChain(nativeWindow, flags, extent); - std::cerr << "Created swap chain with flags " << flags << std::endl; + TRACE("Created swap chain with flags %d", flags); return current; } void TVulkanPlatform::destroy(filament::backend::VulkanPlatform::SwapChainPtr handle) { std::lock_guard lock(mutex); - current = nullptr; - std::cerr << "Destroyed swap chain" << std::endl; + filament::backend::VulkanPlatform::destroy(handle); + if(handle == current) { + current = nullptr; + } + TRACE("Destroyed swap chain"); } VkResult TVulkanPlatform::present(SwapChainPtr handle, uint32_t index, VkSemaphore finishedDrawing) {