From b3f162746d1b1bdd7c8ea093554a4c8a360536f2 Mon Sep 17 00:00:00 2001 From: ipavlin98 Date: Mon, 2 Nov 2026 10:53:06 +0300 Subject: [PATCH] Clear the swapchain's stale mark before reading the surface so a resize during the build is not lost The mark used to be cleared after the swapchain was built, which dropped a resize that arrived meanwhile. The switch to fullscreen at start lands there on the window thread, and the driver does not report the swapchain as out of date. --- runtime/gfx_present.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/runtime/gfx_present.c b/runtime/gfx_present.c index 9b5afbbf..2cff8e29 100644 --- a/runtime/gfx_present.c +++ b/runtime/gfx_present.c @@ -295,8 +295,7 @@ static void free_capture(void) { g_cap_valid = 0; } -// Returns 1 with a usable swapchain, 0 when the window has no area (minimised). Called with g_pl held. -static int create_swapchain(void) { +static int build_swapchain(void) { flip_locked(); // the acquired image goes out before its swapchain is replaced VkCtx *c = vk_ctx(); VkSurfaceCapabilitiesKHR caps; @@ -364,10 +363,19 @@ static int create_swapchain(void) { } free_capture(); vk_queue_unlock(); - plat_xchg32(&g_dirty, 0); return 1; } +// Returns 1 with a usable swapchain, 0 when the window has no area (minimised). Called with g_pl held. The stale mark +// goes before the surface is read: a resize during the build keeps it. The switch to fullscreen at start lands there +// on the window thread, and the driver does not report the swapchain as out of date. +static int create_swapchain(void) { + plat_xchg32(&g_dirty, 0); + if (build_swapchain()) return 1; + plat_xchg32(&g_dirty, 1); + return 0; +} + static void sync_barrier(VkCommandBuffer cb, VkImage img, VkImageLayout from, VkImageLayout to, VkPipelineStageFlags2 s0, VkAccessFlags2 a0, VkPipelineStageFlags2 s1, VkAccessFlags2 a1) { VkImageMemoryBarrier2 b = {.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2, .srcStageMask = s0, .srcAccessMask = a0,