mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-19 20:25:57 +00:00
Merge pull request #1275: with sync_ahead the game waits for a GPU result it reads once and takes depth queries one frame older, so Link no longer gets gloom on clean ground and shrine reflections no longer go out (ipavlin98)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
4c4f3b150f
12 files changed
+100
-6
No files matched your search
@@ -44,6 +44,8 @@ GPU semantics behind the graphics rows: [maxwell.md](../maxwell.md). The method
|
||||
| frame counter wanders 50-60 | two 60 Hz clocks (vsync event and present acquire) drifting apart | whether both follow one display tick |
|
||||
| a 30 Hz thread runs at 27 Hz, slow cutscenes | host sleep overshoot: Windows waitable timers wake 0.3-0.5 ms late | `TOTK_TRACE=sched` sleep asked versus took |
|
||||
| 20 fps after a scheduler change | a yield back-off that starts too early | yield handling against the console's |
|
||||
| in the Depths Link takes gloom damage and wears the gloom haze while standing on clean ground, some runs only; only with `sync_ahead = 1` | the game read a GPU result of the frame it was told is done before the GPU wrote it: its one-pixel readbacks go through a buffer per request, which then holds zeros or an answer from the ring's last round (fixed: `vk_memory.c` `vk_mem_shadow_read` waits at the invalidate) | `sync_ahead = 0`; the exit line `mem: the game waited for a GPU write it reads` |
|
||||
| in shrines the lamps' reflections on the floor go out for single frames, every other frame at some camera angles; only with `sync_ahead = 1`, more with DLAA (the GPU runs further behind) | the game reads its depth query results two frames later and refuses them unless their frame number is exactly the counter - 2; with sync_ahead it is the counter - 3 on frames where the GPU is behind (fixed: patch set `qstamp` in `recomp/patches-v143.txt` also takes the counter - 3) | `sync_ahead = 0`; a `--capture` run with `TOTK_SYNC_AHEAD` on, counting one-frame drops in floor regions |
|
||||
| climbing or movement wrong only above some fps | game code that assumes a fixed step count per frame | compare at 30, 60 and the failing rate |
|
||||
|
||||
## Threads and crashes
|
||||
|
||||
@@ -90,7 +90,7 @@ Every guest thread is a host thread. TotK assumes Horizon's scheduler: three app
|
||||
- Memory pools. Apple's unified memory let MacNativeGames use the game's pools zero-copy. The back end imports the pools as host memory (`VK_EXT_external_memory_host`). On a discrete GPU, pools bound as buffers are mirrored in device-local memory and the pages the CPU wrote (write watch, above) are uploaded before a replay; idle pool regions are made read-only so the write-watch queries skip them (`vk_memory.c`). GPU-rendered textures are written back when the CPU reads them: on a pool invalidate, on a CPU copy, and for small targets once the CPU waits for a fence (`vk_texture.c`).
|
||||
- Replay thread. `TOTK_REPLAY_ASYNC=1` moves the replay off the submitting thread onto a queue at most one frame behind the game; reads of GPU results wait for the newest writer instead of draining the queue (`vk_backend.c`). It is off by default. Where the game waits for the GPU it overlaps the replay with the game threads (a GTX 1650 in the Depths, issue #88), a gain measured only there; while it was the default, a GTX 1660 Ti at the 60 fps cap with the GPU at 26 % reported uneven motion (#659). It adds up to a frame of latency; `replay_async = 1` turns it on.
|
||||
- Chunked replay. A large submission is recorded in chunks by several threads (`TOTK_REPLAY_WORKERS`, 0 by default: the sequential replay; 4 is a good value from 8 logical processors) and the chunks go to the queue in order (`vk_exec.c`). A sequential scan keeps a copy of the queue state where each chunk starts and lists what a chunk would otherwise learn from the chunks before it: inline uniform updates, conditions, contact shadow marches, uniform drops. It also makes render targets live in replay order and notes the op, since a chunk can sample a storage before the chunk that renders it got there or after the scan went past a later target there: a chunk's texture slots resolve as of its own op, and the chunks after a texture with no entry yet wait for the chunk that makes it. DLSS's decisions (the G-buffer, the light target, the end of the scene, the scaling pass) are the scan's too, and its copy of the lit scene and its evaluation are records of the chunk that holds the op; a chunk's draws are jittered while they come before the scan's end of the scene. The evaluation waits until the chunks before it are recorded, as it reads what their draws noted (the camera block, the jitter, the per-object motion list, which chunks add to under one lock), and the chunks after it wait for it, as they sample its output. `TOTK_REPLAY_STATE_CHECK=1` compares the state after the last chunk with the scan's.
|
||||
- Frame ahead. `TOTK_SYNC_AHEAD=1` (`sync_ahead`, off by default) makes the one `nvnSyncWait` per frame that waits for the frame presented last wait for the frame before it, so the game builds the next frame while the GPU still runs the previous one (`nvn_api_core.c`, `nvnSyncWait`). The game then writes memory that in-flight work still reads. This is safe only with shadow storage (`vk_memory.c`, the CPU-visible pools are host-visible copies of guest memory, on by default on Linux and Wine, `shadow = 1` (`TOTK_SHADOW=1`) on native Windows; without it the switch is ignored): a CPU write reaches the GPU only through the shadow copy made before each submit (`vk_mem_shadow_sync`), and a copy that would overwrite bytes an unfinished submission reads is queued as a GPU copy in the prologue command buffer of the part submitted next (`vk_mem_shadow_prologue`, `TOTK_SHADOW_DEFER=1`, the default with the feature) or, with `=0`, waited for on the replay thread (`shadow_reader_wait`). Only that one wait lags (identified by its call site, known for 1.1.0, 1.2.1 and 1.4.3); results the game reads back from the GPU after it can be a frame old. The fence write-back of small render targets (`vk_texture.c`, `write_back_n`) does not wait for the GPU with `TOTK_WB_EAGER=1` (`wb_eager`, the default, but only while frame-ahead is in effect: with `sync_ahead` off or refused the setting does nothing and the write-back reads the image when it runs): `vk_sync_submit` has `vk_texture_eager_record` copy the targets that value rendered into staging buffers inside the same command buffer, so once the value has passed the write-back only copies from staging into the target's storage. Only a target that was written back within the last 64 timeline values is copied (the first write-back of a target takes the blocking path), and the staging of a target past that window, no longer wanted or released goes through the deferred free (`vk_defer_buffer_until`). A snapshot is used only when its value is the one that last rendered the target, nothing recorded a write to the image since (`wr_fence`) and the GPU has finished it; otherwise the write-back reads the image as before, and the exit line `vk: wb_eager:` counts the reasons. With frame-ahead in effect the exit line `vk: fence write-backs waited for the GPU` counts the write-backs that waited for a copy and the time they waited, for every value of the setting. `check` also reads the old way and compares.
|
||||
- Frame ahead. `TOTK_SYNC_AHEAD=1` (`sync_ahead`, off by default) makes the one `nvnSyncWait` per frame that waits for the frame presented last wait for the frame before it, so the game builds the next frame while the GPU still runs the previous one (`nvn_api_core.c`, `nvnSyncWait`). The game then writes memory that in-flight work still reads. This is safe only with shadow storage (`vk_memory.c`, the CPU-visible pools are host-visible copies of guest memory, on by default on Linux and Wine, `shadow = 1` (`TOTK_SHADOW=1`) on native Windows; without it the switch is ignored): a CPU write reaches the GPU only through the shadow copy made before each submit (`vk_mem_shadow_sync`), and a copy that would overwrite bytes an unfinished submission reads is queued as a GPU copy in the prologue command buffer of the part submitted next (`vk_mem_shadow_prologue`, `TOTK_SHADOW_DEFER=1`, the default with the feature) or, with `=0`, waited for on the replay thread (`shadow_reader_wait`). Only that one wait lags (identified by its call site, known for 1.1.0, 1.2.1 and 1.4.3). GPU writes into pool storage come back with their fence, so a buffer the game reads back every frame after that wait holds the result of the frame before; a buffer it has not read lately holds none, and its `nvnMemoryPoolInvalidateMappedRange` waits for the write (`vk_mem_shadow_read`): TotK reads single pixels through a buffer per request, and in the Depths zeros in one of them put Link in gloom. The exit line `mem: the game waited for a GPU write it reads` counts these waits and their time. On 1.4.3 the patch set `qstamp` (`recomp/patches-v143.txt`) lets the game take its depth query results one frame older; it follows the switch and is off when the switch is refused. The fence write-back of small render targets (`vk_texture.c`, `write_back_n`) does not wait for the GPU with `TOTK_WB_EAGER=1` (`wb_eager`, the default, but only while frame-ahead is in effect: with `sync_ahead` off or refused the setting does nothing and the write-back reads the image when it runs): `vk_sync_submit` has `vk_texture_eager_record` copy the targets that value rendered into staging buffers inside the same command buffer, so once the value has passed the write-back only copies from staging into the target's storage. Only a target that was written back within the last 64 timeline values is copied (the first write-back of a target takes the blocking path), and the staging of a target past that window, no longer wanted or released goes through the deferred free (`vk_defer_buffer_until`). A snapshot is used only when its value is the one that last rendered the target, nothing recorded a write to the image since (`wr_fence`) and the GPU has finished it; otherwise the write-back reads the image as before, and the exit line `vk: wb_eager:` counts the reasons. With frame-ahead in effect the exit line `vk: fence write-backs waited for the GPU` counts the write-backs that waited for a copy and the time they waited, for every value of the setting. `check` also reads the old way and compares.
|
||||
- Recorder thread. The Vulkan calls the replay makes into its command buffer are made by a thread of their own (`vk_rec.c`, after Savage Wind Recomp and LAS Recomp): each `vkCmd*` copies its arguments into a packet of a ring and the recorder makes the calls in order; calls into other command buffers are made at once; the recorder also ends the command buffer, and the submit waits until it has. In the town on an RX 9070 the replay takes 17% less time on the submitting thread. It is off by default on AMD GPUs, where the driver loses the device or hangs the GPU at startup with it (`TOTK_VK_RECORDER=1` forces it on, `=0` makes every call on the submitting thread).
|
||||
- Uniform snapshot. The game rewrites per-object uniform blocks on other threads soon after it submits the frame
|
||||
that reads them, while the replay still records it. At the start of a submission's replay every uniform range it
|
||||
|
||||
@@ -30,6 +30,7 @@ If a PR touches this code, confirm the fix still holds.
|
||||
| lime silhouettes in grass; rectangles in the sky | a target outside the output map must keep its texel; zero-filling it wiped the half-res depth | `vk_pipeline.c` `target_wmask` |
|
||||
| stale grass maps in the far terrain for a second after a hit | write-back of a texture the CPU had rewritten | `vk_texture.c` `write_back` |
|
||||
| cut grass stays standing; fire does not spread (#132) | CPU reads of GPU-rendered textures without an invalidate | `vk_texture.c` `vk_texture_write_back_small`, `nvn_ext.c` `nvn_pool_invalidate` |
|
||||
| gloom damage on clean ground in the Depths with `sync_ahead` | the game read a one-request pixel buffer before the GPU of the frame in flight wrote it | `vk_memory.c` `vk_mem_shadow_read`, from `nvn_ext.c` `nvn_pool_invalidate` |
|
||||
| cloud and fog volumes empty for the session | a one-shot draw skipped instead of waiting for its pipeline | `vk_exec_draw.c` `prepare_draw` |
|
||||
| tile rectangles | storage buffers bound by Ryujinx first-use order, not the c0 slot | `vk_exec_draw.c` `ssbo_slot` |
|
||||
| black dialog background and loading map | 3D targets rejected, the grading LUT never written | `vk_exec.c` `resolve_target` |
|
||||
|
||||
@@ -1185,6 +1185,21 @@ set report TOTK_REPORT_GUARD 1
|
||||
site report main a22d8 2a010571 2a010571 37f80341 # orr w17, w11, w1, lsl #1; tbnz w1, #31, 0xa2340
|
||||
site report main a2310 531f7821 530f7c24 531f7821 35000184 # lsr w4, w1, #15; lsl w1, w1, #1; cbnz w4, 0xa2340
|
||||
|
||||
# Depth query results one frame older (TOTK_SYNC_AHEAD). A compute pass at the start of each frame samples the scene
|
||||
# depth for the world queries and writes their results, with the frame number of the request, into a 23232-byte
|
||||
# CPU-cached buffer that main+0x6e1220 invalidates and reads two frames later. It takes the results as this frame's
|
||||
# (bit 2 of obj+0x10) only when the number at buffer +0x58e4 is exactly the frame counter (obj+0x14) - 2. With
|
||||
# sync_ahead the game's frame wait covers the frame before, so on frames where the GPU runs behind the number read is
|
||||
# the counter - 3 (the frame after it has not come back yet) and the results were refused: in shrines the reflections
|
||||
# of the lamps on the floor went out on those frames, every other frame where the GPU was slow, which looked like
|
||||
# flicker at some camera angles. The set also accepts the counter - 3: d = counter - 2 - number, unsigned d <= 1.
|
||||
# Waiting for that frame when the buffer is invalidated (vk_memory.c vk_mem_shadow_read) also ends the flicker, but
|
||||
# gives back the frame rate sync_ahead brings (63 against 86 fps on a field macro at 4K).
|
||||
# w11 is loaded again on both paths at 0x6e1340 before any read; x8, the number's address, stays for 0x6e1420.
|
||||
set qstamp TOTK_SYNC_AHEAD 0
|
||||
site qstamp main 6e1320 6b0b015f 4b0b014b 7100057f # cmp w10, w11 -> sub w11, w10, w11; cmp w11, #1
|
||||
site qstamp main 6e1324 540000c1 540000c8 # b.ne 0x6e133c -> b.hi 0x6e133c
|
||||
|
||||
# Function-entry hooks (FN_ENTER, runtime/cpu.h): only these functions check g_fnprof on entry, the others carry no
|
||||
# hook. main+0x585bd0 sets the render size (runtime/resolution.c SET_RENDER_SIZE): res_fn_hit takes the renderer from
|
||||
# the game's own call at start, so a DLSS mode can change while the game runs.
|
||||
|
||||
@@ -52,6 +52,9 @@ uint64_t nvn_sync_ahead_guard(void);
|
||||
int nvn_sync_ahead_on(void); // 1 when the frame-ahead wait is in effect: TOTK_SYNC_AHEAD on and not refused (no shadow storage, no known wait site)
|
||||
int vk_mem_shadow_on(void); // vk_memory.c: 1 with shadow storage on (valid once the Vulkan back end is up)
|
||||
void vk_mem_shadow_fence(void); // vk_memory.c: returns once every shadow sync that read the old guard is done
|
||||
// vk_memory.c: the game is about to read [addr, addr+size) of pool storage; waits for a GPU write into it that the game
|
||||
// was told is done, unless the range still holds the result of the write before
|
||||
void vk_mem_shadow_read(uint64_t addr, uint64_t size);
|
||||
void gfx_replay_wait_value(uint64_t v); // vk_backend.c: the replay thread submitted value v
|
||||
uint64_t nvn_fence_last(void); // fence value of the newest submit (0 before the first)
|
||||
int nvn_depth_minus_w(void); // 1 after DeviceSetDepthMode(NEAR_IS_MINUS_W), else 0
|
||||
|
||||
@@ -481,7 +481,8 @@ NVN_API(nvnQueueFenceSync) {
|
||||
// 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 (about 11 ms from the submit), and the wait sets the frame time. With the switch on, that wait, and only that
|
||||
// one, waits for the frame before it instead. What the game reads back of GPU results after the wait can then be a
|
||||
// frame old. The game's CPU writes to memory the GPU still reads reach the GPU only through shadow copies, which are
|
||||
// frame old; a buffer that holds no older result is waited for when the game invalidates it (vk_memory.c
|
||||
// vk_mem_shadow_read). The game's CPU writes to memory the GPU still reads reach the GPU only through shadow copies, which are
|
||||
// queued for the GPU or wait (nvn_sync_ahead_guard). The wait still lasts until the replay thread submitted the asked
|
||||
// value, so no copy of that value itself picks up those writes. pa_fence: the newest fence at the latest present and
|
||||
// the one before, present thread only for writes. pa_guard: the newest value the game was told is done early.
|
||||
@@ -510,6 +511,9 @@ static int sync_ahead(void) {
|
||||
"GPU as before");
|
||||
on = 0;
|
||||
}
|
||||
// The depth query patch (set qstamp, patches-v143.txt) is switched by TOTK_SYNC_AHEAD too: a refused switch
|
||||
// leaves the game's own frame number check, as with the switch off.
|
||||
if (!on) rt_patch_switch(rt_patch_set("qstamp"), 0);
|
||||
if (on) rt_log("nvn: TOTK_SYNC_AHEAD: a wait for the frame presented last waits for the frame before it");
|
||||
}
|
||||
return on;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
void nvn_pool_invalidate(const pool_t *p, uint64_t off, uint64_t size) {
|
||||
if (!p->mem || nvn_gpu_only((uintptr_t)p->mem) || off >= p->size || !size) return;
|
||||
if (size > p->size - off) size = p->size - off;
|
||||
vk_mem_shadow_read((uintptr_t)p->mem + off, size);
|
||||
gfx_backend()->guest_read((uintptr_t)p->mem + off, size);
|
||||
}
|
||||
|
||||
|
||||
@@ -304,6 +304,7 @@ void vk_mem_shadow_sync(uint64_t fence); // fence: the value of the part about
|
||||
// vk_mem_mirror_prologue's copies, which read the shadow.
|
||||
int vk_mem_shadow_deferred(void);
|
||||
void vk_mem_shadow_prologue(VkCommandBuffer cb, uint64_t fence);
|
||||
void vk_mem_shadow_read_log(void); // at exit, with TOTK_SYNC_AHEAD: the run total of vk_mem_shadow_read's waits
|
||||
void vk_mem_gpu_pending(uint64_t addr, uint64_t size);
|
||||
void vk_gpu_written(uint64_t addr, uint64_t size);
|
||||
int vk_mem_flush_add_probe(void); // --probe-vkexec: the flush range list; 0 or the number of the failed check
|
||||
|
||||
@@ -339,6 +339,7 @@ void gfx_exit_log(void) {
|
||||
static int32_t done;
|
||||
rec_check_log();
|
||||
vk_texture_eager_log();
|
||||
vk_mem_shadow_read_log();
|
||||
if (gfx_replay_async() && r_started && !plat_xchg32(&done, 1)) replay_log(game_frames, 1);
|
||||
}
|
||||
|
||||
|
||||
+63
-3
@@ -1303,6 +1303,65 @@ void vk_mem_shadow_fence(void) {
|
||||
plat_mutex_unlock(&shadow_lock);
|
||||
}
|
||||
|
||||
// TOTK_SYNC_AHEAD, nvnMemoryPoolInvalidateMappedRange: the game is about to read [addr, addr+size) of what the GPU
|
||||
// writes into pool storage. While the guard is not done, a write into the range that is still pending can belong to a
|
||||
// value the game was told is done, and its bytes come back only with that value's fence (vk_gpu_written). A range the
|
||||
// game reads again and again (its depth queries and visibility maps: one buffer written every frame or every few)
|
||||
// then still holds the result of the write before, and the game gets that one, a sample late: what the switch trades
|
||||
// for the frame in flight. A range it has not read lately holds no such result. TotK reads single pixels back
|
||||
// (main+0x407ed8 on 1.4.3) through a 64-byte buffer per request, taken in turn from rings of 64 to 256 and read once,
|
||||
// right after the frame wait: read early, the pixel is 0 0 0 0 in a buffer never used, and the answer to another
|
||||
// request, about 27 s old, once the ring came round. In the Depths the zeros put Link in gloom where there is none. So
|
||||
// a range with a pending write that is not known waits for the guard here. Known: the game invalidated this very
|
||||
// range within the last SREAD_AGE fence values (about 30 frames), when it held a result or was waited for.
|
||||
#define SREAD_N 64
|
||||
#define SREAD_AGE 64
|
||||
typedef struct { uint64_t addr, size, at; } SRead;
|
||||
static SRead sread[SREAD_N]; // shadow_lock: the ranges the game invalidated last, with the value issued then
|
||||
static uint64_t s_read_waits, s_read_ticks; // shadow_lock: since the last log
|
||||
static uint64_t r_read_waits, r_read_ticks, r_read_max; // shadow_lock: over the run (vk_mem_shadow_read_log)
|
||||
|
||||
void vk_mem_shadow_read(uint64_t addr, uint64_t size) {
|
||||
if (!shadow_on || !size || !nvn_sync_ahead_guard()) return;
|
||||
plat_mutex_lock(&shadow_lock);
|
||||
uint64_t now = vk_sync_issued();
|
||||
SRead *e = &sread[0]; // the range's entry, else the oldest
|
||||
for (int i = 0; i < SREAD_N; i++) {
|
||||
if (sread[i].addr == addr && sread[i].size == size) { e = &sread[i]; break; }
|
||||
if (sread[i].at < e->at) e = &sread[i];
|
||||
}
|
||||
int known = e->addr == addr && e->size == size && e->at + SREAD_AGE >= now, pending = 0;
|
||||
for (int i = 0; i < nspend && !pending; i++) pending = spend[i].lo < addr + size && spend[i].hi > addr;
|
||||
uint64_t g = nvn_sync_ahead_guard(), wait = pending && !known && g > vk_sync_fence_done() ? g : 0;
|
||||
// A pending write of a value the game was not told is done, in a range not known: the game reads ahead of its own
|
||||
// wait and the range stays unknown.
|
||||
if (known || !pending || wait) *e = (SRead){addr, size, now};
|
||||
plat_mutex_unlock(&shadow_lock);
|
||||
if (!wait) return;
|
||||
uint64_t t0 = qpc();
|
||||
{
|
||||
NVN_BLOCKING();
|
||||
vk_sync_fence_wait(wait, UINT64_MAX);
|
||||
}
|
||||
uint64_t dt = qpc() - t0;
|
||||
plat_mutex_lock(&shadow_lock);
|
||||
s_read_waits++, s_read_ticks += dt;
|
||||
r_read_waits++, r_read_ticks += dt;
|
||||
if (dt > r_read_max) r_read_max = dt;
|
||||
plat_mutex_unlock(&shadow_lock);
|
||||
}
|
||||
|
||||
// The run total of the waits above, once at exit, while frame-ahead is in effect: without TOTK_TRACE=perf the shadow
|
||||
// log lines come only at frames 600 and 1800.
|
||||
void vk_mem_shadow_read_log(void) {
|
||||
static int32_t done;
|
||||
if (!shadow_on || !nvn_sync_ahead_on() || plat_xchg32(&done, 1)) return;
|
||||
plat_mutex_lock(&shadow_lock);
|
||||
rt_log("mem: the game waited for a GPU write it reads %llu times, %.1f ms in all, longest %.2f ms",
|
||||
(unsigned long long)r_read_waits, qpc_ms(r_read_ticks), qpc_ms(r_read_max));
|
||||
plat_mutex_unlock(&shadow_lock);
|
||||
}
|
||||
|
||||
int vk_mem_shadow_on(void) { return shadow_on; }
|
||||
|
||||
void vk_mem_shadow_sync(uint64_t fence) {
|
||||
@@ -1408,10 +1467,11 @@ static void shadow_log(uint64_t frame) {
|
||||
qpc_ms(s_ticks), nspend);
|
||||
if (defer_on || s_waits) // only with TOTK_SYNC_AHEAD: the shadow log of everyone else stays as it was
|
||||
rt_log("mem: shadow deferred (%s): %llu pools, %.1f MiB in %llu copies; replay waited for a reader %llu times, "
|
||||
"%.2f ms", defer_on ? "on" : "off", (unsigned long long)s_defer_pools, s_defer_bytes / 1048576.0,
|
||||
(unsigned long long)s_defer_copies, (unsigned long long)s_waits, qpc_ms(s_wait_ticks));
|
||||
"%.2f ms; the game waited for a GPU write it reads %llu times, %.2f ms", defer_on ? "on" : "off",
|
||||
(unsigned long long)s_defer_pools, s_defer_bytes / 1048576.0, (unsigned long long)s_defer_copies,
|
||||
(unsigned long long)s_waits, qpc_ms(s_wait_ticks), (unsigned long long)s_read_waits, qpc_ms(s_read_ticks));
|
||||
s_syncs = s_queries = s_copied = s_untracked = s_wb_bytes = s_ticks = 0;
|
||||
s_defer_pools = s_defer_bytes = s_defer_copies = s_wait_ticks = s_waits = 0;
|
||||
s_defer_pools = s_defer_bytes = s_defer_copies = s_wait_ticks = s_waits = s_read_waits = s_read_ticks = 0;
|
||||
plat_mutex_unlock(&shadow_lock);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,10 @@ static int cfg_bool(const char *name) { assert(!strcmp(name, "TOTK_SYNC_AHEAD"))
|
||||
static int vk_mem_shadow_on(void) { return shadow; }
|
||||
static uint64_t nvn_fence_last(void) { return last; }
|
||||
static void rt_log(const char *format, ...) { (void)format; }
|
||||
// The patch table: set qstamp exists on 1.4.3 only and starts as TOTK_SYNC_AHEAD says (runtime/patches.c).
|
||||
static int qstamp_on;
|
||||
static int rt_patch_set(const char *name) { return !strcmp(name, "qstamp") && rt_game_version == 143 ? 20 : -1; }
|
||||
static void rt_patch_switch(int set, int on) { if (set == 20) qstamp_on = on; else assert(set == -1); }
|
||||
static void gfx_replay_wait_value(uint64_t value) { replay_value = value; replay_calls++; }
|
||||
static void vk_mem_shadow_fence(void) {
|
||||
assert(nvn_sync_ahead_guard() >= replay_value);
|
||||
@@ -59,10 +63,12 @@ int main(int argc, char **argv) {
|
||||
uint64_t site = rt_game_version == 110 ? 0x7000b39aa4ull : rt_game_version == 121 ? 0x7000b23dfcull :
|
||||
rt_game_version == 143 ? 0x70002db99cull : 0;
|
||||
assert(frame_wait_lr() == site);
|
||||
qstamp_on = rt_game_version == 143 && enabled;
|
||||
last = 20; nvn_sync_ahead_present();
|
||||
last = 40; nvn_sync_ahead_present();
|
||||
assert(pa_fence[0] == (enabled && shadow && supported ? 40 : 0));
|
||||
assert(pa_fence[1] == (enabled && shadow && supported ? 20 : 0));
|
||||
assert(qstamp_on == (rt_game_version == 143 && enabled && shadow)); // a refused switch leaves the game's check
|
||||
int relaxed_cases = 0, polls = 0, other_waits = 0;
|
||||
for (int i = 0; i < 100000; i++) {
|
||||
sync_t sync = {.fenced = random_word() % 2, .fence = random_word() % 65};
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@
|
||||
# Let the game build the next frame while the GPU still draws the previous one, 0 or 1. Default: off. Each frame the
|
||||
# game waits once for the GPU to finish the frame it presented last; with 1 that wait covers the frame before it
|
||||
# instead. On Great Sky Island (Linux, RX 9070 XT) with shadow_defer = 1 this took about 73 to 100 fps. Costs one more
|
||||
# frame of input delay, and frame times vary more from frame to frame than with 0. GPU results the game reads back after that wait, for example occlusion queries, can be a frame old.
|
||||
# frame of input delay, and frame times vary more from frame to frame than with 0. GPU results the game reads back every frame after that wait, for example its depth queries, can be a frame old; a result it reads only once is waited for.
|
||||
# Works on 1.1.0, 1.2.1 and 1.4.3. Needs shadow storage (shadow below), which is on by default on Linux and
|
||||
# Wine and needs shadow = 1 on native Windows; without it the setting is ignored and the log says so.
|
||||
# sync_ahead = 0
|
||||
|
||||
Reference in new issue
Block a user