diff --git a/runtime/gfx_present.c b/runtime/gfx_present.c index 1ab71f68..ea0c72c9 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, diff --git a/runtime/gfx_window_win.c b/runtime/gfx_window_win.c index 51dafe04..71806dd9 100644 --- a/runtime/gfx_window_win.c +++ b/runtime/gfx_window_win.c @@ -333,10 +333,12 @@ static void window_main(void *arg) { outer_size(g_hwnd, cw, ch, &ow, &oh); SetWindowPos(g_hwnd, HWND_BOTTOM, 0, 0, ow, oh, SWP_NOMOVE | SWP_NOACTIVATE | SWP_SHOWWINDOW); if (!background) { + // Pending before the raise: the activation it gets is the first WM_ACTIVATEAPP, which takes the fullscreen + // setting; set after it, fullscreen waited for the next activation and the game started in a window + g_fs_pending = cfg_fullscreen(); raise_window(g_hwnd); // a frontend's player may have no way to reach a window left behind FLASHWINFO fw = {.cbSize = sizeof fw, .hwnd = g_hwnd, .dwFlags = FLASHW_TRAY | FLASHW_TIMERNOFG}; FlashWindowEx(&fw); - g_fs_pending = cfg_fullscreen(); } note_applied(); refresh_rate_update(g_hwnd, 1);