mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-25 22:15:57 +00:00
Let the game run one frame further ahead of the GPU (TOTK_SYNC_AHEAD, off by default)
Each frame the game waits in one nvnSyncWait (1.2.1 lr 0x7000b23dfc) for the frame it presented last. On the Switch that work is long done by then; here it is still in the replay and on the GPU, and on Great Sky Island the wait is about 4.6 ms of a 13 ms frame. With TOTK_SYNC_AHEAD=1 that one wait waits for the frame before it instead, once the replay thread submitted the asked value, so the game builds the next frame while the GPU runs the last one. The game then writes guest memory that GPU work still in flight reads. Shadow storage makes that safe: a shadow update of a pool with a reader in flight is queued and copied by the GPU in the next part's prologue, in queue order, instead of memcpy'd under that reader (TOTK_SHADOW_DEFER=1, the default with the switch; 0 makes the replay thread wait for the reader instead). The guard is read under the shadow lock and the wait takes that lock once after raising it, so no sync that read the old guard is still copying when the game writes again. The switch needs shadow storage (Linux and Wine by default, TOTK_SHADOW=1 on native Windows) and the 1.2.1 call site; otherwise it stays off with a log line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
71d8b0cc61
commit
4624bf8076
11 files changed
+282
-18
No files matched your search
@@ -713,6 +713,7 @@ NVN_API(nvnQueuePresentTexture) {
|
||||
const tex_t *t = (const tex_t *)o->tex[idx];
|
||||
uint64_t period = present_period(o), now = kern_now_ns();
|
||||
uint64_t slot = now + pace(&o->pace, now, period);
|
||||
nvn_sync_ahead_present();
|
||||
gfx_backend()->present(t, o->crop, slot);
|
||||
o->ticket[idx] = o->presents;
|
||||
o->avail[idx] = cfg_bool("TOTK_FRAME_QUEUE") ? slot : slot + period;
|
||||
|
||||
Reference in new issue
Block a user