Skip to content

Commit 04ca4a4

Browse files
committed
Fix fullscreen menu flash when we do a context reset/fullscreen toggle
1 parent f6a1210 commit 04ca4a4

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

command.c

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2529,6 +2529,59 @@ void command_event_reinit(const int flags)
25292529
video_st->frame_cache_width = cached_snapshot_w;
25302530
video_st->frame_cache_height = cached_snapshot_h;
25312531
video_st->frame_cache_pitch = cached_snapshot_p;
2532+
2533+
#ifdef HAVE_MENU
2534+
/* If the menu is alive across the reinit, the runloop's
2535+
* pre-frame menu work (driver_ctx->render +
2536+
* set_texture_enable) doesn't get a chance to run before
2537+
* the cached_frame() replay below. Two consequences if we
2538+
* don't reproduce that work here:
2539+
*
2540+
* 1. The new video driver instance starts with its
2541+
* menu-texture flag (D3D11_ST_FLAG_MENU_ENABLE,
2542+
* GL2_FLAG_MENU_TEXTURE_ENABLE, etc.) cleared, so the
2543+
* replay frame falls into the driver's "else if
2544+
* (statistics_show)" branch and draws OSD stats on the
2545+
* bare core framebuffer instead of the menu overlay.
2546+
*
2547+
* 2. Menu drivers like ozone cache layout/font dimensions
2548+
* keyed on the previous viewport size and only
2549+
* recompute them when their render() callback notices a
2550+
* width/height change. If we replay before render()
2551+
* runs, the menu draws at the old (windowed) scale into
2552+
* the new (fullscreen) viewport, so fonts and widgets
2553+
* appear undersized for one frame until the next
2554+
* runloop iteration corrects them.
2555+
*
2556+
* Mirroring the runloop's pre-frame menu sequence here --
2557+
* render with the new dimensions, then raise the
2558+
* texture-enable flag -- keeps the snapshot replay
2559+
* visually consistent with subsequent frames.
2560+
*
2561+
* Gated on a valid snapshot: without one we won't be
2562+
* pushing a replay frame anyway, and calling render() on a
2563+
* freshly-(re)initialised menu driver before the runloop
2564+
* has had a chance to populate it can leave it in a
2565+
* partially-computed state for the next real frame
2566+
* (e.g. ozone clears OZONE_FLAG_NEED_COMPUTE after a
2567+
* premature render). */
2568+
if (menu_st->flags & MENU_ST_FLAG_ALIVE)
2569+
{
2570+
if ( menu_st->driver_ctx
2571+
&& menu_st->driver_ctx->render)
2572+
menu_st->driver_ctx->render(
2573+
menu_st->userdata,
2574+
video_st->width,
2575+
video_st->height,
2576+
false);
2577+
2578+
if ( video_st->poke
2579+
&& video_st->poke->set_texture_enable)
2580+
video_st->poke->set_texture_enable(video_st->data,
2581+
true, false);
2582+
}
2583+
#endif
2584+
25322585
video_driver_cached_frame();
25332586
}
25342587

0 commit comments

Comments
 (0)