From a733b946459a7926b803dafed148229871e8e082 Mon Sep 17 00:00:00 2001 From: corne-ac <127402474+corne-ac@users.noreply.github.com> Date: Sat, 7 Nov 2026 22:20:03 +0200 Subject: [PATCH] Keep shadow_snap off by default under Wine until it has been measured there Shadow storage is on by default under Wine as well, and the region snapshots were only measured on a native Linux host. TOTK_SHADOW_SNAP=1 still turns them on under Wine. Co-Authored-By: Claude Opus 5.5 --- docs/settings.md | 2 +- runtime/vk_memory.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/settings.md b/docs/settings.md index 182873fa..9c7feca6 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -124,7 +124,7 @@ Many rows below are developer tools that only act together with another setting | `dyn_delta` (default `1`) | Records only the pipeline dynamic states (cull mode, depth and stencil tests, vertex input, blend enables, equations and write masks, ...) whose values changed since the last draw in the command buffer, also across pipeline changes; `0` records the full set at every change of pipeline state, as before; `ab` alternates with the `ab` blocks. | Fewer commands per pipeline change on the render and recorder threads; a driver that loses dynamic state across pipeline binds would draw with stale state. `TOTK_TRACE=perf` prints the calls and commands per submission. | Caution | | `feedback` | `0` samples a target that an earlier draw of the same pass wrote with no barrier; `restart` ends and restarts the pass behind a full barrier; otherwise the feedback-loop layout is used when the GPU supports it. | `0` brings back the old behaviour that the barrier fixed, so the picture can break in passes that read a target they draw into; `restart` costs extra passes. | Risky | | `flush_span` (default `0`) | `1` copies one span from the lowest to the highest flushed address of a pool, as an older version did. | Copies far more data to the GPU in crowded towns: an estimated 30-50 ms of GPU time per large copy over PCIe 3.0 x8. | Caution | -| `shadow_snap` (default `1`) | Shadow storage (Linux, Wine): `1` syncs the pools from per-submission write-watch snapshots, each 2 MiB region queried at most once per submission and shared with the texture checks; `0` queries each pool at every part of a submission, as before. | `1` cut the replay thread's write tracking from about 4.4 to 1.3 ms a frame on a Steam Deck; `0` is for comparison runs. No effect where shadow storage is off (Windows by default). | Caution | +| `shadow_snap` (default `1`) | Shadow storage (Linux, Wine): `1` syncs the pools from per-submission write-watch snapshots, each 2 MiB region queried at most once per submission and shared with the texture checks; `0` queries each pool at every part of a submission, as before. | `1` cut the replay thread's write tracking from about 4.4 to 1.3 ms a frame on a Steam Deck; `0` is for comparison runs. Under Wine/Proton the default is `0` until it has been measured there; `1` turns it on. No effect where shadow storage is off (Windows by default). | Caution | | `freeze_idle` (default `60`) | Number of submissions a 2 MiB region stays unwritten before it is made read-only; `0` turns the freeze off. | A larger value keeps more regions writable and costs more write tracking; a write to a frozen region costs about 60 microseconds. | Caution | | `gpl_draw_build` (default `1`) | `0` leaves the missing shader libraries of a waiting draw to its background job instead of building them in parallel at once. | Draws whose pipeline is not ready are skipped meanwhile, until the job finishes. | Caution | | `lib_prebuild_keep` (default `0`) | Number of recorded graphics shader library variants that stay in memory after the boot prebuild. | Each kept library costs 140-460 KB of memory; the driver cache already makes a rebuild cheap. | Caution | diff --git a/runtime/vk_memory.c b/runtime/vk_memory.c index 449f6b02..c4cd6065 100644 --- a/runtime/vk_memory.c +++ b/runtime/vk_memory.c @@ -953,7 +953,7 @@ static void shadow_copy(PoolRec *r, uint64_t a, uint64_t b, int i) { s_copied += b - a; } -// TOTK_SHADOW_SNAP (default 1): a pool's sync takes its written pages from the per-submission write-watch snapshots +// TOTK_SHADOW_SNAP (default 1 on a native host, 0 under Wine, where it has not been measured): a pool's sync takes its written pages from the per-submission write-watch snapshots // (snap_regions, shared with the texture checks): each 2 MiB region is queried at most once per guest submission, however // many pools share it and however many parts of the submission touch them. The GPU then reads a pool as of the first // part that syncs it, nearer the submit call, the moment the game means (vk_usnap.c). 0 queries each pool at every @@ -967,9 +967,10 @@ static void shadow_copy_newer(PoolRec *r, uint32_t since); static void shadow_sync_pool(PoolRec *r) { uint64_t lo = r->import_lo, hi = r->import_hi; if (shadow_snap < 0) { - shadow_snap = rt_knob("SHADOW_SNAP", "1"); - rt_log("mem: shadow sync: %s (TOTK_SHADOW_SNAP)", - shadow_snap ? "per-submission region snapshots" : "a query per pool at every part"); + shadow_snap = rt_knob("SHADOW_SNAP", plat_is_wine() ? "0" : "1"); + rt_log("mem: shadow sync: %s (TOTK_SHADOW_SNAP%s)", + shadow_snap ? "per-submission region snapshots" : "a query per pool at every part", + plat_is_wine() ? "; off by default under Wine" : ""); } uint32_t epoch = shadow_snap ? vk_texture_epoch() : 0; uint64_t r0 = lo >> SNAP_SHIFT, r1 = (hi - 1) >> SNAP_SHIFT;