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.
Should fix:
3242
3227, but properly. (I left the
vkDeviceWaitIdle
in to be sure).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, theVkRenderPassBeginInfo::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: