mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-25 14:05:57 +00:00
The sync-ahead check counts every frame as if the GPU were behind, and compares bytes as well as written pages
Whether the game writes what the GPU still reads does not depend on this machine's timing, so check mode now takes the late wait's value at every frame wait (the frames where the GPU really was behind are counted apart). The set's bytes are copied at the snap: a written page counts its changed bytes too, and the mirror sync copies are narrowed to the bytes the frame binds from the mirror (class bound), since a page written only outside them races nothing it reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1ab3856fdd
commit
f5fbe9df15
6 files changed
+173
-61
No files matched your search
@@ -541,9 +541,10 @@ NVN_API(nvnSyncWait) {
|
||||
const GfxBackend *b = gfx_backend();
|
||||
uint64_t want = s->fence, lag = s->fence;
|
||||
// Only the game's per-frame wait lags, and not a poll (timeout 0).
|
||||
int mode = timeout && c->x[30] == frame_wait_lr() ? sync_mode() : 0;
|
||||
int mode = timeout && c->x[30] == frame_wait_lr() ? sync_mode() : 0, behind = b->fence_done() < want;
|
||||
if (mode == 2) vk_ahead_frame_entry();
|
||||
if (mode && b->fence_done() < want) {
|
||||
// check: every frame as if the GPU were behind (the question is what the game writes, not this machine's timing)
|
||||
if (mode == 2 || (mode && behind)) {
|
||||
uint64_t p0 = __atomic_load_n(&pa_fence[0], __ATOMIC_ACQUIRE);
|
||||
uint64_t p1 = __atomic_load_n(&pa_fence[1], __ATOMIC_ACQUIRE);
|
||||
if (want <= p0 && want > p1) lag = p1;
|
||||
@@ -560,7 +561,7 @@ NVN_API(nvnSyncWait) {
|
||||
vk_mem_shadow_fence(); // a shadow sync that read the old guard finishes before the game writes again
|
||||
}
|
||||
if (b->fence_done() >= want) {
|
||||
if (mode == 2) vk_ahead_frame_lag(s->fence, lag);
|
||||
if (mode == 2) vk_ahead_frame_lag(s->fence, lag, behind);
|
||||
b->cpu_synced(want == s->fence ? s->fence : b->fence_done());
|
||||
if (mode == 2) vk_ahead_frame_done(1);
|
||||
ret_x(c, NVN_SYNC_WAIT_RESULT_ALREADY_SIGNALED);
|
||||
@@ -571,7 +572,7 @@ NVN_API(nvnSyncWait) {
|
||||
NVN_BLOCKING();
|
||||
ok = b->fence_wait(want, timeout);
|
||||
}
|
||||
if (mode == 2) vk_ahead_frame_lag(s->fence, lag);
|
||||
if (mode == 2) vk_ahead_frame_lag(s->fence, lag, behind);
|
||||
if (ok) b->cpu_synced(want == s->fence ? s->fence : b->fence_done());
|
||||
if (mode == 2) vk_ahead_frame_done(ok);
|
||||
ret_x(c, ok ? NVN_SYNC_WAIT_RESULT_CONDITION_SATISFIED : NVN_SYNC_WAIT_RESULT_TIMEOUT_EXPIRED);
|
||||
|
||||
Reference in new issue
Block a user