WIP: fix(host): host writes that zero imported guest memory mark it; late pages are found when a capture is taken; RX_VK_MEM_CHECK counts where memory sync breaks its rules #1360

Closed
HumanBean wants to merge 6 commits from HumanBean/Longshot:fix/memory-sync into main
Owner

Type: fix · Risk: medium · Tested on: Linux, RTX 3090 · Needs: a Windows build and run; an integrated GPU

Why

"Stale or wrong data after the GPU writes" keeps being fixed one case at a time: each is two of the renderer's tables disagreeing about which copy of a page is newest (guest memory, a capture, a mirror, a shadow). Track B of the renderer rework plan. A design study of vk_memory.cpp found two things to do first, and this pull request does both: close the host writes the renderer is never told about, and count where the sync breaks its own rules on a running game. Stacked on #1309: review the commits after it. See #1034, which fixes the same three writes with its measurement tools; this one is the fix alone, with a check that keeps it fixed.

What changed

The fix

  • host/hos_mem.c discard_pages and FreeMemoryPages, host/hos_svc.c UnmapPhysicalMemory: each zeroed pages the renderer had imported, with no write mark. The renderer's mirrors, capture entries and write-back shadows kept the old bytes, and a write-back could put them back over the zeros. They now write through hos_guest_fill (host/hos.h), which marks after the bytes.
  • Windows changes behaviour here: imported pages are zeroed in place and marked, as on Linux, and no longer go to DiscardVirtualMemory or MEM_RESET under the GPU's mapping. The test also runs before the large-pages early return.
  • Two more unmarked writes found by the audit: nvnTextureReadTexels copying texels into a buffer the game chose (host/nvn_native.c), and the renderer's own guest allocation (host/rx_backend.c).
  • tests/test_host_free_marks.py (new) compiles the real hos_mem.c and checks imported pages read zero and are marked. tests/test_host_guest_writes.py (new) scans host/*.c for a memset/memcpy/memmove into guest memory that no mark follows; 52 sites are allowed, each with its reason (out-parameters, audio, input records, the guest stack).

The late-at-replay fix

  • With the render thread the game captures a submission before the ones ahead of it are recorded, so the capture cannot know their write-backs, and a mirror sync then copied the capture's page over them. memory_take_capture now completes the capture's late list from the write-backs recorded by then (gpu/vk/late_replay.h): takes are in submit order, so every earlier submission is recorded. Such a page keeps the capture's words and takes a GPU word only where a write-back newer than the capture stamped it; it compares no CPU value, so a counter the CPU set back to zero keeps its zero. The argument and its two remaining exposures are above capture_late_at_replay.
  • The generation counter (gen_now and every copy of it) is 64 bits.

The checker

  • RX_VK_MEM_CHECK=1, off unset (gpu/vk/mem_check.h, hooks in vk_memory.cpp and vk_replay.cpp): one flag test a hook when off. On, it counts and logs the first eight of each: a capture taken or marks collected while a recording is open; a take that gets another submission's capture; a mirror sync that copies a capture's page over a newer GPU write not marked late; a sync over words only the GPU writes; live reads by cause; the generation counter's speed. One vk: mem check: line every 600 submits. Nothing aborts.
  • docs/development/memory-check.md (new).

Measurements

Verdict: no change in fps, and no visible bug shown fixed. What the checker can say for certain, over about 160,000 submits through three areas:

  • The ordering rules hold: captures taken or collected with a recording open 0; captures paired to the wrong submission 0 of 168,741.
  • The late-at-replay fix removes its class: candidates of the kind "written back from a mirror since the capture, and not marked late" go from 2,640 to 0, and 2,600 to 5,700 pages a session are found late at the take and merged. Fps with it on and off is the same (Kokiri Forest 62.1 and 63.3 on, 63.9 and 62.5 off; Hyrule Field 92.0 and 90.0, 91.5 and 89.8; the Market 67.8 and 66.8, 68.3 and 68.6).
  • No certain loss: of about 145,000 syncs that copied a CPU page over words the GPU had written, 0 were on a page no CPU write had made dirty.
  • What it cannot say: 50,069 of those syncs replaced a word whose value differed. Each is either a GPU write lost or the game's own reset (it sets counters the GPU fills, the exposure sums among them, back to zero every frame). The bytes cannot tell the two apart. An experiment that kept every such word (a word-by-word sync, not in this branch) doubled the GPU's time (Kokiri Forest 34 fps against 66, GPU 25.3 ms against 11.2), so most are resets and the whole-page copy is right for them.
  • The generation counter ran at 21,000 to 23,000 a second: 32 bits would wrap after about 52 hours. It is 64 bits now.
vk: mem check: ... sync_over_gpu: 0 replaced (a loss or the CPU's reset; 0 on a page no CPU write made dirty), 10275 same (0 unbound), 1 not judged (of 10276 candidates; ... candidates by path: 10276 no write-back, 0 in place, 0 mirror write-back not late); sync_over_gpu_only: 50069 replaced (a loss or the CPU's reset; 0 on a page no CPU write made dirty), 45506 same (10 unbound), 39412 not judged (of 134987 candidates; ...); 18234744 pages synced, 2608 pages late at the replay

With RX_VK_LATE_AT_REPLAY=0: candidates by path: 10316 no write-back, 0 in place, 2640 mirror write-back not late.

Hardware: CachyOS (kernel 7.3.3), RTX 3090 24 GB, NVIDIA 620.70, Ryzen 9 7900X, 32 GB; 2560x1440, no upscaler, Threaded rendering Auto (on). Sessions through the job queue, timing mode for the fps pairs.

Flags and settings

RX_VK_MEM_CHECK (diagnostic, off unset) and RX_VK_LATE_AT_REPLAY (the way back from the late-at-replay fix, on unset), each with its row and its doc.

Testing

Tested: Linux, RTX 3090 (NVIDIA 620.70): two sessions through Kokiri Forest, Hyrule Field and the Market, one with the checker on; the scenes drew with main's draw counts and frame rates, no error line.

Not tested:

  • tests/run_all.py and the three new checks: not run on this PC. test_host_free_marks.py compiles all of hos_mem.c over stand-ins and has never been compiled.
  • Windows: not compiled, not run. The discard change there is argued from how a host-pointer import pins pages.
  • Whether the new marks change any picture: the freed-and-zeroed case was not provoked on purpose.
  • An area change with many pools freed (where the fixed writes run most), long play.

Must be tested:

  • Windows, any GPU: a start, several area changes, ten minutes of play, expecting main's picture and no crash; this is the path whose behaviour changed (Test Farm: @Beanstalk windows nvidia and windows amd: main against this PR, Kokiri Forest, Hyrule Field, the Market, three area changes)
  • A Steam Deck or another integrated GPU: the same.

Risks

What could break: on Windows, imported pages that were discarded are now zeroed in place, which costs a memset and a lock at each region free. A mark that was missing now causes a capture and a mirror sync of the zeroed pages, which is the point, and is new work at an area change.

Turning it off: the checker is off unless set. The fix has no switch; revert the commit.

Compatibility: none: no cache is rebuilt, MKWVK_API_VERSION stays.

Issues

See #1034

Checklist

Everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched).
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main.
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named). Not run on this PC; left to the forge's checks.
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • Numbers from the same PC, scene and settings, at least 2 interleaved runs each, the median reported.
  • Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value.
  • A check under tests/ that reads changed source updated in this PR, not weakened.
  • Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. Built on Linux only here.
  • Docs updated.

🤖 Generated with Claude Code

https://claude.ai/code/session_017vw8dzCsAL3UdW7ft8ptL9

**Type:** fix · **Risk:** medium · **Tested on:** Linux, RTX 3090 · **Needs:** a Windows build and run; an integrated GPU ## Why "Stale or wrong data after the GPU writes" keeps being fixed one case at a time: each is two of the renderer's tables disagreeing about which copy of a page is newest (guest memory, a capture, a mirror, a shadow). Track B of the [renderer rework plan](https://git.magicbean.dev/MagicBeanDev/Longshot/wiki/Renderer-rework-plan). A design study of `vk_memory.cpp` found two things to do first, and this pull request does both: close the host writes the renderer is never told about, and count where the sync breaks its own rules on a running game. Stacked on #1309: review the commits after it. See #1034, which fixes the same three writes with its measurement tools; this one is the fix alone, with a check that keeps it fixed. ## What changed **The fix** - `host/hos_mem.c` `discard_pages` and `FreeMemoryPages`, `host/hos_svc.c` `UnmapPhysicalMemory`: each zeroed pages the renderer had imported, with no write mark. The renderer's mirrors, capture entries and write-back shadows kept the old bytes, and a write-back could put them back over the zeros. They now write through `hos_guest_fill` (`host/hos.h`), which marks after the bytes. - **Windows changes behaviour here:** imported pages are zeroed in place and marked, as on Linux, and no longer go to `DiscardVirtualMemory` or `MEM_RESET` under the GPU's mapping. The test also runs before the large-pages early return. - Two more unmarked writes found by the audit: `nvnTextureReadTexels` copying texels into a buffer the game chose (`host/nvn_native.c`), and the renderer's own guest allocation (`host/rx_backend.c`). - `tests/test_host_free_marks.py` (new) compiles the real `hos_mem.c` and checks imported pages read zero and are marked. `tests/test_host_guest_writes.py` (new) scans `host/*.c` for a `memset`/`memcpy`/`memmove` into guest memory that no mark follows; 52 sites are allowed, each with its reason (out-parameters, audio, input records, the guest stack). **The late-at-replay fix** - With the render thread the game captures a submission before the ones ahead of it are recorded, so the capture cannot know their write-backs, and a mirror sync then copied the capture's page over them. `memory_take_capture` now completes the capture's late list from the write-backs recorded by then (`gpu/vk/late_replay.h`): takes are in submit order, so every earlier submission is recorded. Such a page keeps the capture's words and takes a GPU word only where a write-back newer than the capture stamped it; it compares no CPU value, so a counter the CPU set back to zero keeps its zero. The argument and its two remaining exposures are above `capture_late_at_replay`. - The generation counter (`gen_now` and every copy of it) is 64 bits. **The checker** - `RX_VK_MEM_CHECK=1`, off unset (`gpu/vk/mem_check.h`, hooks in `vk_memory.cpp` and `vk_replay.cpp`): one flag test a hook when off. On, it counts and logs the first eight of each: a capture taken or marks collected while a recording is open; a take that gets another submission's capture; a mirror sync that copies a capture's page over a newer GPU write not marked late; a sync over words only the GPU writes; live reads by cause; the generation counter's speed. One `vk: mem check:` line every 600 submits. Nothing aborts. - `docs/development/memory-check.md` (new). ## Measurements **Verdict:** no change in fps, and no visible bug shown fixed. What the checker can say for certain, over about 160,000 submits through three areas: - **The ordering rules hold:** captures taken or collected with a recording open 0; captures paired to the wrong submission 0 of 168,741. - **The late-at-replay fix removes its class:** candidates of the kind "written back from a mirror since the capture, and not marked late" go from 2,640 to 0, and 2,600 to 5,700 pages a session are found late at the take and merged. Fps with it on and off is the same (Kokiri Forest 62.1 and 63.3 on, 63.9 and 62.5 off; Hyrule Field 92.0 and 90.0, 91.5 and 89.8; the Market 67.8 and 66.8, 68.3 and 68.6). - **No certain loss:** of about 145,000 syncs that copied a CPU page over words the GPU had written, 0 were on a page no CPU write had made dirty. - **What it cannot say:** 50,069 of those syncs replaced a word whose value differed. Each is either a GPU write lost or the game's own reset (it sets counters the GPU fills, the exposure sums among them, back to zero every frame). The bytes cannot tell the two apart. An experiment that kept every such word (a word-by-word sync, not in this branch) doubled the GPU's time (Kokiri Forest 34 fps against 66, GPU 25.3 ms against 11.2), so most are resets and the whole-page copy is right for them. - The generation counter ran at 21,000 to 23,000 a second: 32 bits would wrap after about 52 hours. It is 64 bits now. ``` vk: mem check: ... sync_over_gpu: 0 replaced (a loss or the CPU's reset; 0 on a page no CPU write made dirty), 10275 same (0 unbound), 1 not judged (of 10276 candidates; ... candidates by path: 10276 no write-back, 0 in place, 0 mirror write-back not late); sync_over_gpu_only: 50069 replaced (a loss or the CPU's reset; 0 on a page no CPU write made dirty), 45506 same (10 unbound), 39412 not judged (of 134987 candidates; ...); 18234744 pages synced, 2608 pages late at the replay ``` With `RX_VK_LATE_AT_REPLAY=0`: `candidates by path: 10316 no write-back, 0 in place, 2640 mirror write-back not late`. Hardware: CachyOS (kernel 7.3.3), RTX 3090 24 GB, NVIDIA 620.70, Ryzen 9 7900X, 32 GB; 2560x1440, no upscaler, Threaded rendering Auto (on). Sessions through the job queue, timing mode for the fps pairs. ### Flags and settings `RX_VK_MEM_CHECK` (diagnostic, off unset) and `RX_VK_LATE_AT_REPLAY` (the way back from the late-at-replay fix, on unset), each with its row and its doc. ## Testing **Tested:** Linux, RTX 3090 (NVIDIA 620.70): two sessions through Kokiri Forest, Hyrule Field and the Market, one with the checker on; the scenes drew with main's draw counts and frame rates, no error line. **Not tested:** - `tests/run_all.py` and the three new checks: not run on this PC. `test_host_free_marks.py` compiles all of `hos_mem.c` over stand-ins and has never been compiled. - Windows: not compiled, not run. The discard change there is argued from how a host-pointer import pins pages. - Whether the new marks change any picture: the freed-and-zeroed case was not provoked on purpose. - An area change with many pools freed (where the fixed writes run most), long play. **Must be tested:** - Windows, any GPU: a start, several area changes, ten minutes of play, expecting main's picture and no crash; this is the path whose behaviour changed (Test Farm: `@Beanstalk windows nvidia and windows amd: main against this PR, Kokiri Forest, Hyrule Field, the Market, three area changes`) - A Steam Deck or another integrated GPU: the same. ## Risks **What could break:** on Windows, imported pages that were discarded are now zeroed in place, which costs a memset and a lock at each region free. A mark that was missing now causes a capture and a mirror sync of the zeroed pages, which is the point, and is new work at an area change. **Turning it off:** the checker is off unless set. The fix has no switch; revert the commit. **Compatibility:** none: no cache is rebuilt, `MKWVK_API_VERSION` stays. ## Issues See #1034 ## Checklist ### Everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. - [ ] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). Not run on this PC; left to the forge's checks. - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [x] Numbers from the same PC, scene and settings, at least 2 interleaved runs each, the median reported. - [x] Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value. - [x] A check under `tests/` that reads changed source updated in this PR, not weakened. - [ ] Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. Built on Linux only here. - [x] Docs updated. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_017vw8dzCsAL3UdW7ft8ptL9
refactor(vk): 93 kill switches and the older paths they kept are deleted from the four large renderer files
All checks were successful
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 7s
Guide screenshots / Guide images and local UI source review (pull_request) Successful in 11s
Third-party parts / As their notes say (pull_request) Successful in 14s
CI / Workflow lint (actionlint) (pull_request) Successful in 19s
PR description / Description follows the template (pull_request_target) Successful in 5s
Website / Website on Cloudflare (pull_request_target) Has been skipped
b9805ef295
The renderer rework plan's track F. A kill switch turned off, or back to an older way, something that is on for
every PC; nobody ships with one set, and each kept an old path alive. vk_draw.cpp 32, vk_texture.cpp 21,
vk_replay.cpp 20, vk_memory.cpp 20: the read and the path are gone, the default is the only behaviour, and each name
is a GONE row of gpu/vk/switches.def, so a run that still sets one is told. 26 are kept, each for a reason (a value
set by a tool or named in the README, a default that follows the PC, a young fix's way out).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8dzCsAL3UdW7ft8ptL9
refactor(vk): 18 more kill switches and their older paths are deleted from the smaller renderer files
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 8s
PR description / Description follows the template (pull_request_target) Successful in 13s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 14s
CI / Workflow lint (actionlint) (pull_request) Successful in 20s
Website / Website on Cloudflare (pull_request_target) Has been skipped
Third-party parts / As their notes say (pull_request) Successful in 23s
5742f65ca1
The renderer rework plan's track F, after the four large files (#1309). vk_vma.cpp, vk_main.cpp, vk_temporal.cpp,
vk_xfer.cpp, vk_dlss.cpp, vk_fsr4.cpp, vk_jobs.cpp, vk_reflex.cpp, vk_framegen.cpp, vk_programs.cpp and vk_progcache.cpp
lose the read and the path; each name is a GONE row of gpu/vk/switches.def. 18 are kept: the README or a script
names them, the shader cache's stamp holds them, or they are a way out that measurement runs or a driver still need.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8dzCsAL3UdW7ft8ptL9
feat(host): the host's switches join the table: every HOS_ and LONGSHOT_ name the game reads has a row
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 13s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 15s
CI / Workflow lint (actionlint) (pull_request) Successful in 17s
Third-party parts / As their notes say (pull_request) Successful in 17s
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 5s
2e0743237d
The renderer rework plan's track F. gpu/vk/switches.def gains the host's 216 switches (89 diagnostics, 50 that turn
something off, 23 player settings, 24 numbers, 20 that turn on something nobody ships, 8 that follow the PC), read
once each from the code. The start's report names them when set and says a HOS_ name that is none; a LONGSHOT_ name
that is none is passed over (the launcher and the Builder have their own). The host's three removed HOS_ names become
GONE rows.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8dzCsAL3UdW7ft8ptL9
fix(host): host writes that zero imported guest memory mark it, and RX_VK_MEM_CHECK counts where memory sync breaks its rules
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 7s
PR description / Description follows the template (pull_request_target) Successful in 9s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 9s
CI / Workflow lint (actionlint) (pull_request) Successful in 11s
Third-party parts / As their notes say (pull_request) Successful in 14s
Website / Website on Cloudflare (pull_request_target) Has been skipped
c6cbc08ae7
The renderer rework plan's track B, steps 0 and 1. discard_pages, FreeMemoryPages and UnmapPhysicalMemory zeroed pages
the renderer had imported without a write mark, so its mirrors, captures and shadows kept the old bytes; they, the
texel read-back and the renderer's own guest allocation now write through hos_guest_fill / mark after the bytes, on
Windows as on Linux. tests/test_host_guest_writes.py fails on a bulk host write into guest memory that no mark
follows. RX_VK_MEM_CHECK=1 (off unset) counts captures taken out of order, mirror syncs over newer GPU writes and
GPU-only words, live reads by cause, and how fast the generation counter runs.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8dzCsAL3UdW7ft8ptL9
Author
Owner

Tested in game: Linux, RTX 3090, NVIDIA 620.70: two sessions through Kokiri Forest, Hyrule Field and the Market at 2560x1440, one with RX_VK_MEM_CHECK=1; scenes drew as main, and the checker counted 3,122 syncs over newer GPU writes in 174,600 submits.

Tested in game: Linux, RTX 3090, NVIDIA 620.70: two sessions through Kokiri Forest, Hyrule Field and the Market at 2560x1440, one with RX_VK_MEM_CHECK=1; scenes drew as main, and the checker counted 3,122 syncs over newer GPU writes in 174,600 submits.
Collaborator

Possibly related, for context:

  • issue #432 Idea: guest-memory fixes from the macOS port on Windows and Linux too, once timed (dirty-page atomics, zeroed pages marked, fatal allocation failures) — Open issue includes marking renderer-owned guest zeroing and cross-platform guest-memory fixes.
Possibly related, for context: - issue #432 Idea: guest-memory fixes from the macOS port on Windows and Linux too, once timed (dirty-page atomics, zeroed pages marked, fatal allocation failures) — Open issue includes marking renderer-owned guest zeroing and cross-platform guest-memory fixes.
fix(vk): a capture's pages that a write-back wrote since are found late when the capture is taken, and merged
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 7s
PR description / Description follows the template (pull_request_target) Successful in 10s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 10s
CI / Workflow lint (actionlint) (pull_request) Successful in 10s
Third-party parts / As their notes say (pull_request) Successful in 14s
a313a71902
The renderer rework plan's track B. With the render thread the game captures a submission before the ones ahead of
it are recorded, so capture_make could not know their write-backs: a mirror sync then copied the CPU's stale page
over the GPU's words (57 pages with words lost in one session, counted by RX_VK_MEM_CHECK; 0 with this). The take
completes the late list from the write-backs recorded by then (late_replay.h). RX_VK_MEM_CHECK now judges by
bytes, sparse mirrors included; the generation counter is 64 bits. RX_VK_LATE_AT_REPLAY=0 is the way back.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8dzCsAL3UdW7ft8ptL9
Author
Owner

A caution on the second commit (the late-at-replay fix), from its author. Its evidence was the checker's count of syncs that replaced GPU-written words going from 57 to 0. A later experiment showed that count cannot tell a GPU write wrongly overwritten from a counter the game resets each frame by writing zero: a sync that kept such words (not in this branch) doubled the GPU's time, so most of what the checker called losses were probably resets. The late-at-replay fix showed no fps change, but it is being re-argued against that case before this pull request leaves WIP. The first commit (host writes that zero imported memory now mark it) is not affected.

A caution on the second commit (the late-at-replay fix), from its author. Its evidence was the checker's count of syncs that replaced GPU-written words going from 57 to 0. A later experiment showed that count cannot tell a GPU write wrongly overwritten from a counter the game resets each frame by writing zero: a sync that kept such words (not in this branch) doubled the GPU's time, so most of what the checker called losses were probably resets. The late-at-replay fix showed no fps change, but it is being re-argued against that case before this pull request leaves WIP. The first commit (host writes that zero imported memory now mark it) is not affected.
HumanBean changed title from WIP: fix(host): host writes that zero imported guest memory mark it, and RX_VK_MEM_CHECK counts where memory sync breaks its rules to WIP: fix(host): host writes that zero imported guest memory mark it; late pages are found when a capture is taken; RX_VK_MEM_CHECK counts where memory sync breaks its rules 2026-11-17 08:24:22 +00:00
fix(vk): RX_VK_MEM_CHECK says what it cannot tell: a replaced word is a loss or the CPU's own reset
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 7s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 10s
PR description / Description follows the template (pull_request_target) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Successful in 12s
Third-party parts / As their notes say (pull_request) Successful in 15s
2ee9c904e2
A sync that kept every word the capture left as it was (tried here, never shipped) doubled the GPU's time: the game
sets counters the GPU fills back to zero each frame, and a compare of contents cannot see a write of the same
value. The checker's counts are renamed 'replaced', the one certain case (a page no CPU write made dirty) is
counted apart, and the argument for the late-at-replay fix is written above capture_late_at_replay.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_017vw8dzCsAL3UdW7ft8ptL9
Author
Owner

Folded into #1339, which is now the one pull request for memory (budget and sync). The commits are unchanged apart from being rebased into one stack and carrying the fixes the check suite asked for; nothing was dropped.

Folded into #1339, which is now the one pull request for memory (budget and sync). The commits are unchanged apart from being rebased into one stack and carrying the fixes the check suite asked for; nothing was dropped.
HumanBean closed this pull request 2026-11-17 15:48:19 +00:00
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 7s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 10s
PR description / Description follows the template (pull_request_target) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Successful in 12s
Third-party parts / As their notes say (pull_request) Successful in 15s

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!1360
No description provided.