Skip to content

cleanupSwapChain in 17_swap_chain_recreation.cpp was not destroying the previous swapchain#101

Merged
gpx1000 merged 20 commits intoKhronosGroup:mainfrom
lmichaudel:patch-1
Jul 21, 2025
Merged

cleanupSwapChain in 17_swap_chain_recreation.cpp was not destroying the previous swapchain#101
gpx1000 merged 20 commits intoKhronosGroup:mainfrom
lmichaudel:patch-1

Conversation

@lmichaudel
Copy link
Contributor

As the title says, the source code was missing a simple swapChain = nullptr; (that is actually present in the tutorial).
Without this fix the swapChain recreation crashes (Device::createSwapchainKHR: ErrorSurfaceLostKHR).

@gpx1000
Copy link
Contributor

gpx1000 commented Jul 19, 2025

Great find! This might be the explanation behind the resize crash issue in Windows. @SaschaWillems if you have a chance, could you verify if this brilliant find solves resize?

@lmichaudel
Copy link
Contributor Author

lmichaudel commented Jul 19, 2025

I checked all the other cleanup methods and fixed them.
33_vulkan_profiles.cpp was actually already fixed.
EDIT: 34_android.cpp too.

@gpx1000
Copy link
Contributor

gpx1000 commented Jul 19, 2025

Well it's a great find, you're absolutely right those should have been cleaned up. Don't worry about CI failing. That has been having problems; I'm more testing if CI passes Windows.

@gpx1000
Copy link
Contributor

gpx1000 commented Jul 20, 2025

If you sync to the latest then the CI should pass for all build environments.

@SaschaWillems
Copy link
Collaborator

Still crashing for me. This does not address the actual issue, which is this block of code:

                result = presentQueue.presentKHR(presentInfo);
                if (result == vk::Result::eErrorOutOfDateKHR || result == vk::Result::eSuboptimalKHR || framebufferResized) {
                    framebufferResized = false;
                    recreateSwapChain();
                }
                else if (result != vk::Result::eSuccess) {
                    throw std::runtime_error("failed to present swap chain image!");
                }

presentQueue.presentKHR will throw an exception, but there is no exception handing around it.

@gpx1000
Copy link
Contributor

gpx1000 commented Jul 21, 2025

Well, that's sad, I'll leave fixing it on my TODO list. For now, this PR is correct and necessary. LGTM.

@gpx1000 gpx1000 merged commit f7d889f into KhronosGroup:main Jul 21, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments