Commit 172d7bc
committed
Preserve cached core frame across CMD_EVENT_REINIT (frontend + Metal)
command_event_reinit tears the video driver down via
video_driver_free, which nulls video_st->frame_cache_data (the
pointer was borrowed from the core's own framebuffer and isn't
guaranteed to stay live across the driver swap). The new driver
then comes up with no cached frame to replay, so reinits triggered
from inside the menu (e.g. toggling video_hdr_mode between HDR10
and scRGB on Metal) leave the paused-core background missing until
the user F1-cycles back through the core.
Snapshot the cached frame into a static buffer before reinit,
restore the pointer into video_st->frame_cache_data afterwards, and
call video_driver_cached_frame() to push it through the new
driver's frame callback. The static buffer is realloc'd on demand
and reused across reinits so there's no leak — the core's next real
frame will simply overwrite the frame_cache_data pointer at its
leisure.
In the Metal driver, additionally latch a _frameEverUploaded flag
so that on frame==NULL calls before the first real frame lands
(e.g. in the one-or-two-frame window before the cached replay
completes), we can also fall back to reading
video_st->frame_cache_data directly from inside renderFrame. The
two paths overlap cleanly: the frontend snapshot keeps the cache
pointer valid across reinit, and the driver-side latch guards the
transient.
Fixes paused-core background disappearing after HDR mode toggle on
Metal; harmless elsewhere because other drivers either don't
rebuild their internal frame texture on reinit (keeping content
across the swap by accident) or already have equivalent workarounds.
Files
command.c : snapshot-and-replay around video_driver_reinit.
gfx/drivers/metal.m : _frameEverUploaded latch + cached-frame
fallback in renderFrame.1 parent 42f3a3c commit 172d7bc
2 files changed
Lines changed: 100 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2440 | 2440 | | |
2441 | 2441 | | |
2442 | 2442 | | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
| 2452 | + | |
| 2453 | + | |
| 2454 | + | |
| 2455 | + | |
| 2456 | + | |
| 2457 | + | |
| 2458 | + | |
| 2459 | + | |
| 2460 | + | |
| 2461 | + | |
| 2462 | + | |
| 2463 | + | |
| 2464 | + | |
| 2465 | + | |
| 2466 | + | |
| 2467 | + | |
| 2468 | + | |
| 2469 | + | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
| 2474 | + | |
| 2475 | + | |
| 2476 | + | |
| 2477 | + | |
| 2478 | + | |
| 2479 | + | |
| 2480 | + | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
| 2487 | + | |
| 2488 | + | |
| 2489 | + | |
2443 | 2490 | | |
2444 | 2491 | | |
| 2492 | + | |
| 2493 | + | |
| 2494 | + | |
| 2495 | + | |
| 2496 | + | |
| 2497 | + | |
| 2498 | + | |
| 2499 | + | |
| 2500 | + | |
| 2501 | + | |
| 2502 | + | |
| 2503 | + | |
| 2504 | + | |
| 2505 | + | |
| 2506 | + | |
2445 | 2507 | | |
2446 | 2508 | | |
2447 | 2509 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3235 | 3235 | | |
3236 | 3236 | | |
3237 | 3237 | | |
| 3238 | + | |
| 3239 | + | |
| 3240 | + | |
| 3241 | + | |
| 3242 | + | |
| 3243 | + | |
| 3244 | + | |
| 3245 | + | |
| 3246 | + | |
| 3247 | + | |
| 3248 | + | |
| 3249 | + | |
3238 | 3250 | | |
3239 | 3251 | | |
3240 | 3252 | | |
| |||
3540 | 3552 | | |
3541 | 3553 | | |
3542 | 3554 | | |
3543 | | - | |
| 3555 | + | |
3544 | 3556 | | |
| 3557 | + | |
| 3558 | + | |
| 3559 | + | |
| 3560 | + | |
| 3561 | + | |
| 3562 | + | |
| 3563 | + | |
| 3564 | + | |
| 3565 | + | |
| 3566 | + | |
| 3567 | + | |
| 3568 | + | |
| 3569 | + | |
| 3570 | + | |
| 3571 | + | |
| 3572 | + | |
| 3573 | + | |
| 3574 | + | |
| 3575 | + | |
| 3576 | + | |
| 3577 | + | |
| 3578 | + | |
| 3579 | + | |
| 3580 | + | |
| 3581 | + | |
3545 | 3582 | | |
3546 | 3583 | | |
3547 | 3584 | | |
| |||
0 commit comments