From 32d4fee95e75f677f49b80556511b02f6b5818f5 Mon Sep 17 00:00:00 2001 From: Patrick Nicolas Date: Tue, 3 Nov 2026 21:06:40 +0100 Subject: [PATCH] Fix warped image when growing the swapchain --- client/scenes/stream.cpp | 17 ++++++++++++----- client/scenes/stream.h | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/client/scenes/stream.cpp b/client/scenes/stream.cpp index c271f2d5..222ceffb 100644 --- a/client/scenes/stream.cpp +++ b/client/scenes/stream.cpp @@ -908,7 +908,7 @@ void scenes::stream::render(const XrFrameState & frame_state) } if (max_width > 0 and max_height > 0) - ensure_foveation_mode(foveation_center.is_cropped(fov, valid_fov), max_width, max_height); + ensure_swapchain(foveation_center.is_cropped(fov, valid_fov), max_width, max_height); session.begin_frame(); @@ -1362,12 +1362,19 @@ void scenes::stream::setup_reprojection_swapchain(uint32_t swapchain_width, uint swapchain.format()); } -void scenes::stream::ensure_foveation_mode(bool cropped, uint32_t width, uint32_t height) +void scenes::stream::ensure_swapchain(bool cropped, uint32_t width, uint32_t height) { - if (!swapchain or foveation_center.needs_swapchain_recreation(cropped)) + if (!swapchain or swapchain.width() < width or swapchain.height() < height or foveation_center.needs_swapchain_recreation(cropped)) { - setup_reprojection_swapchain(width, height, foveation_center.use_meta_swapchain(cropped)); - foveation_center.on_swapchain_recreated(cropped); + try + { + setup_reprojection_swapchain(width, height, foveation_center.use_meta_swapchain(cropped)); + foveation_center.on_swapchain_recreated(cropped); + } + catch (std::exception & e) + { + spdlog::warn("failed to create swapchain"); + } } else { diff --git a/client/scenes/stream.h b/client/scenes/stream.h index fbf734cb..daf7309d 100644 --- a/client/scenes/stream.h +++ b/client/scenes/stream.h @@ -307,7 +307,7 @@ private: void setup(const to_headset::video_stream_description &); void setup_reprojection_swapchain(uint32_t width, uint32_t height, bool foveation); - void ensure_foveation_mode(bool cropped, uint32_t width, uint32_t height); + void ensure_swapchain(bool cropped, uint32_t width, uint32_t height); vk::raii::QueryPool query_pool = nullptr; bool query_pool_filled = false;