fix(rendering): crash on window resize due to stale swapchain

- Mark swapchain dirty in Application's SDL resize handler (was only done
  in Window::pollEvents which is never called)
- Skip swapchain recreation when window is minimized (0×0 extent violates
  Vulkan spec and crashes vmaCreateImage)
- Guard aspect ratio division by zero when height is 0

Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
This commit is contained in:
Pavel Okhlopkov 2026-04-10 19:51:13 +03:00
parent 759d6046bb
commit e07983b7f6
2 changed files with 7 additions and 1 deletions

View file

@ -720,8 +720,12 @@ void Application::run() {
int newWidth = event.window.data1;
int newHeight = event.window.data2;
window->setSize(newWidth, newHeight);
// Mark swapchain dirty so it gets recreated at the correct size
if (window->getVkContext()) {
window->getVkContext()->markSwapchainDirty();
}
// Vulkan viewport set in command buffer, not globally
if (renderer && renderer->getCamera()) {
if (renderer && renderer->getCamera() && newHeight > 0) {
renderer->getCamera()->setAspectRatio(static_cast<float>(newWidth) / newHeight);
}
// Notify addons so UI layouts can adapt to the new size