reinit: the menu gets vsync after a restart only if vsync is on

When the menu comes up, menu_driver_toggle() gives it vsync "if vsync
is on": it checks the setting first. The end of command_event_reinit()
did the same thing without the check. With vsync off, every driver
restart with the menu up - a fullscreen toggle, a driver or HDR
setting - started the new video driver without vsync, as configured,
and a few frames later switched it on. So the menu ran with a vsync
the user had turned off, where at startup it does not, and the
swapchain the driver had just made was thrown away and made again.

That second swapchain is where a fullscreen toggle went wrong on one
Windows machine (Vulkan, NVIDIA, HDR10, threaded video, vsync off).
Its logs show, each time, a new driver creating its swapchain with
present mode IMMEDIATE, then "Creating swapchain with present mode:
FIFO" right after the input drivers are back, and then either

  [Vulkan] QueuePresent failed (err = -4, result = -4), destroying swapchain.

or nothing more at all, with the run loop and the video thread still
running and the picture no longer changing. At startup, where the
swapchain is made once, the same fullscreen window works.

The check is the one menu_driver_toggle() has: vsync on, scanline sync
off. With vsync on the call is made as before, and asks for the
interval the driver already started with.

Why the driver there answers the rebuilt swapchain the way it does is
not known, and a user with vsync on who changes the swap interval
still rebuilds it. Built here and compiled for Windows with mingw; the
fullscreen toggle itself has not been run on Windows with this.
This commit is contained in:
LibretroAdmin authored and libretroadmin committed 2026-10-03 02:58:58 +02:00
1 parent 2ff3e7b337
commit eb33c4d2e5
1 file changed
+12
+12
View File
@@ -3472,7 +3472,19 @@ void command_event_reinit(const int flags)
&& video_st->poke->show_mouse)
video_st->poke->show_mouse(video_st->data, false);
}
/* The menu runs with vsync if vsync is on - the rule
* menu_driver_toggle() applies when the menu comes up - and only
* then. This used to switch it on whenever the menu was up, whatever
* the setting: with vsync off, every reinit with the menu up (a
* fullscreen toggle, say) started the new driver without vsync, as
* configured, and a few frames later turned it on here, which
* rebuilds the swapchain that had just been made. The menu ran with
* a vsync the user had switched off, unlike at startup, and on at
* least one Windows Vulkan setup the first present after that second
* swapchain failed or left a dead picture. */
if ( (menu_st->flags & MENU_ST_FLAG_ALIVE)
&& settings->bools.video_vsync
&& !settings->bools.video_scanline_sync
&& video_st->current_video->set_nonblock_state)
video_st->current_video->set_nonblock_state(
video_st->data, false,