Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Vulkan swapchain invalidation issue. #3379

Merged
merged 3 commits into from
Nov 21, 2024

Conversation

mcourteaux
Copy link
Contributor

@mcourteaux mcourteaux commented Nov 21, 2024

Should fix:

The SDL entry code had a bug where the user resizing the window, triggers a window resize event, which calls SDL_SetWindowSize(), which triggers a window size. This loop reverted the window size to the previous size.

To fix the main issue with the Vulkan backend, I clamp the swapchain size to what the driver allows. I set the m_resolution of the swapchain and framebuffer to the actual result after clamping, instead of what the user requests. This way, one of the next frames, when the user's windowing code catches up with the resize, both the requested resolution and the Vulkan-allowed resolution match, and both are again in sync. Additionally, as the view rect passed from the user is still lagging behind in such cases, the VkRenderPassBeginInfo::renderArea is also clamped to the actual resolution of the current framebuffer resolution.

Review from @pezcode would be nice (especially regarding the deleted comment about ignoring m_needToRefreshSwapchain).

CC @MohammedKHC, @LittleCodingFox, @GlaireDaggers.

Many thanks to @GlaireDaggers for some initial investigation, which made fixing this quite a bit easier.


Tested and confirmed to be working on:

  • Linux
  • Android
  • Windows
  • macOS

@bkaradzic bkaradzic merged commit 01af383 into bkaradzic:master Nov 21, 2024
10 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.

2 participants