Port water texture readback and guard against stale writes #999

Manually merged
github merged 2 commits from gh-pr/999/head into gh-pr/999/base 2026-11-26 03:55:32 +00:00
Owner

@⁠cxy0072019-sketch on GitHub · 2026-11-25 15:33 UTC · original
cxy0072019-sketch:fix/water-texture-readback → main · +383 −6 · 6 files · 2 commits · merged 2026-11-25 21:09 UTC

Summary

Port Geckomacabre/vx-layer@eee5667d to victory-fork. In Gone Fishing, the game's CPU physics reads water height and displacement from textures written by the GPU. Copying those textures back after the submission completes gives the boat its buoyancy after the cutscene. Enable with VICTORY_TEXTURE_BACK=1.

Track the texture allocation through submission and skip the copy if that memory was replaced or remapped, or if the texture was released. Include these destinations in the late submission's pending write ranges. The regression test covers invalidation without discarding unrelated allocations.

Refs #863. The original patch is preserved as a separate commit with its authorship.

Validation

  • Clean PR branch on Windows: cargo test --locked -p victory-gpu --lib -- --test-threads=1 returned 171 passed, 5 ignored. cargo build --locked --profile diag -p victory --features diagnostics and the victory --version smoke test passed.
  • Previous 720p Series S renderer with this backport, Windows Sandbox and RTX 5070 Ti: in two runs, the boat remained afloat under player control and the objective advanced from Follow the plane to Collect the package. The unpatched local renderer failed after handing off control. Water surface artifacts remain. The gameplay verification used the local renderer branch, while the clean PR branch verification covers the build and GPU tests above.
**@⁠cxy0072019-sketch** on GitHub · 2026-11-25 15:33 UTC · [original](https://github.com/fxceless/victory-fork/pull/999) `cxy0072019-sketch:fix/water-texture-readback` → `main` · +383 −6 · 6 files · 2 commits · merged 2026-11-25 21:09 UTC ## Summary Port Geckomacabre/vx-layer@eee5667d to victory-fork. In Gone Fishing, the game's CPU physics reads water height and displacement from textures written by the GPU. Copying those textures back after the submission completes gives the boat its buoyancy after the cutscene. Enable with `VICTORY_TEXTURE_BACK=1`. Track the texture allocation through submission and skip the copy if that memory was replaced or remapped, or if the texture was released. Include these destinations in the late submission's pending write ranges. The regression test covers invalidation without discarding unrelated allocations. Refs #863. The [original patch](https://github.com/Geckomacabre/vx-layer/commit/eee5667d) is preserved as a separate commit with its authorship. ## Validation - Clean PR branch on Windows: `cargo test --locked -p victory-gpu --lib -- --test-threads=1` returned 171 passed, 5 ignored. `cargo build --locked --profile diag -p victory --features diagnostics` and the `victory --version` smoke test passed. - Previous 720p Series S renderer with this backport, Windows Sandbox and RTX 5070 Ti: in two runs, the boat remained afloat under player control and the objective advanced from **Follow the plane** to **Collect the package**. The unpatched local renderer failed after handing off control. Water surface artifacts remain. The gameplay verification used the local renderer branch, while the clean PR branch verification covers the build and GPU tests above.
On the console the CPU and the GPU share memory, so what a compute pass
stores into a texture is there for the CPU. Here it stayed in the host copy.
The title's ocean wave passes write a 256x256 height map (R32_FLOAT) and a
displacement map (R32G32_FLOAT) that its CPU code samples (run rw1, with
VICTORY_READ_WATCH=1: about 30 code addresses), which is what boats float on:
they read memory nothing wrote and sank, and the first boat mission failed.

For textures of the kinds in VICTORY_TEXTURE_BACK (by default those the read
watch found the title reading: 256x256 f41 and f16, 64x64 f16, 128x128 f36),
a list whose shaders write one copies it into a read-back buffer when it
closes; once the list has run the texels are tiled into the texture's title
memory in the console's layout (victory_formats Layout::tile).
VICTORY_TEXTURE_BACK=0: none.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 53c561bf92b60e60fb4a53f1c99bc89051ad94b4)
(cherry picked from commit 9d488c72255c6c8b148af26a54a672297d1fe16f)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:55:31 +00:00
github manually merged commit 04df435087 into gh-pr/999/base 2026-11-26 03:55:32 +00:00
Author
Owner

@⁠iGoldenNinja on GitHub · 2026-11-25 16:18 UTC · original

I tested a related allocation-lifetime guard on an RTX 5080. One case that may be worth adding to this PR's regression tests is a later command list naming an old texture after a new buffer takes the same guest base. The old texture can still be alive. Tracking which resource owns the address at creation lets the renderer reject a new readback for that retired owner. The test passed in our port of the allocation checks from this PR. Guard and regression tests

On native Windows 11 Pro 25H2 build 26200.9974, RTX 5080 16 GB / 617.14, Ryzen 9 5900X and Series X settings, the guarded revision kept the boat and both occupants afloat with only the 64×64 RG32F and 128×128 RG16_UINT outputs copied back. The package objective appeared while the controller was idle. Throttle then produced twin wakes, and steering changed the boat's heading against the bridge. At least 1,024 and 256 full-plane writes completed, respectively. No stale rejection was logged during gameplay. The unit test is the evidence for that case. Pinned native report

**@⁠iGoldenNinja** on GitHub · 2026-11-25 16:18 UTC · [original](https://github.com/fxceless/victory-fork/pull/999#issuecomment-7167776793) I tested a related allocation-lifetime guard on an RTX 5080. One case that may be worth adding to this PR's regression tests is a later command list naming an old texture after a new buffer takes the same guest base. The old texture can still be alive. Tracking which resource owns the address at creation lets the renderer reject a new readback for that retired owner. The test passed in our port of the allocation checks from this PR. [Guard and regression tests](https://github.com/iGoldenNinja/victory-fork/commit/b97bb825e6d2f7dda59c7c7acc95501b97e2cb00) On native Windows 11 Pro 25H2 build 26200.9974, RTX 5080 16 GB / 617.14, Ryzen 9 5900X and Series X settings, the guarded revision kept the boat and both occupants afloat with only the 64×64 RG32F and 128×128 RG16_UINT outputs copied back. The package objective appeared while the controller was idle. Throttle then produced twin wakes, and steering changed the boat's heading against the bridge. At least 1,024 and 256 full-plane writes completed, respectively. No stale rejection was logged during gameplay. The unit test is the evidence for that case. [Pinned native report](https://github.com/iGoldenNinja/victory-fork/blob/9a6f178c628015fe1c552e33f4a5c1d5cc30bbcb/docs/water-readback-allocation-lifetime.md)
Author
Owner

@⁠SkillIssueXO on GitHub · 2026-11-25 17:12 UTC · original · edited 2026-11-25 17:31 UTC

Independent Series X test on an RTX 5070 Ti with 465b94f, paired waves from #854, and #999 at 04df435. Both runs used copies of the same local checkpoint with the structure builder off.

  • All four readback formats with VICTORY_LATE_WAIT=3 logged 896 landed copies before a DXGI_ERROR_DEVICE_HUNG after three deferred submissions.
  • With VICTORY_LATE_WAIT=0, the boat cutscene ran farther and logged 6,528 landed copies. The game then exited with 0xc0000005, reading null in VCRUNTIME140.dll+0x1c45a from title code. Available system commit was above 20 GiB. These were single runs and the logs establish two failure signatures.
  • The retry restricted to 256x256f41,256x256f16 reached the handoff. Black water patches remained. In the synchronous run, frame 1871 already shows the patches in the 2560×1440 RGBA16F scene target before final upscale.

Follow-up on the smaller formats. I tested ca8829f with the allocation ownership guard from b97bb825, paired waves, and VICTORY_LATE_WAIT=0. Both Series X replays logged the parsed list [(64, 64, 16), (128, 128, 36)] and completed water readbacks. They reached the boat cutscene, then hit the same null 16-byte read at VCRUNTIME140.dll+0x1c45a, with the first two title return offsets +0x3de6491 and +0x3de2054. The last reported cumulative copy counts were 1,024 and 1,280. Around 21 GiB of system commit remained free in both runs.

The second replay enabled the indirect lighting dispatch split. The lighting shader bound and black patches remained visible during the cutscene. This run did not record the requested or submitted group counts. The explicit kind list and completed copies distinguish these runs from the launcher parse issue in #1037.

AI-assisted analysis. Aggregate measurements only.

**@⁠SkillIssueXO** on GitHub · 2026-11-25 17:12 UTC · [original](https://github.com/fxceless/victory-fork/pull/999#issuecomment-7169160638) · edited 2026-11-25 17:31 UTC Independent Series X test on an RTX 5070 Ti with `465b94f`, paired waves from #854, and #999 at `04df435`. Both runs used copies of the same local checkpoint with the structure builder off. - All four readback formats with `VICTORY_LATE_WAIT=3` logged 896 landed copies before a `DXGI_ERROR_DEVICE_HUNG` after three deferred submissions. - With `VICTORY_LATE_WAIT=0`, the boat cutscene ran farther and logged 6,528 landed copies. The game then exited with `0xc0000005`, reading null in `VCRUNTIME140.dll+0x1c45a` from title code. Available system commit was above 20 GiB. These were single runs and the logs establish two failure signatures. - The retry restricted to `256x256f41,256x256f16` reached the handoff. Black water patches remained. In the synchronous run, frame 1871 already shows the patches in the 2560×1440 RGBA16F scene target before final upscale. **Follow-up on the smaller formats.** I tested `ca8829f` with the allocation ownership guard from `b97bb825`, paired waves, and `VICTORY_LATE_WAIT=0`. Both Series X replays logged the parsed list `[(64, 64, 16), (128, 128, 36)]` and completed water readbacks. They reached the boat cutscene, then hit the same null 16-byte read at `VCRUNTIME140.dll+0x1c45a`, with the first two title return offsets `+0x3de6491` and `+0x3de2054`. The last reported cumulative copy counts were 1,024 and 1,280. Around 21 GiB of system commit remained free in both runs. The second replay enabled the indirect lighting dispatch split. The lighting shader bound and black patches remained visible during the cutscene. This run did not record the requested or submitted group counts. The explicit kind list and completed copies distinguish these runs from the launcher parse issue in #1037. AI-assisted analysis. Aggregate measurements only.
Author
Owner

@⁠DuarttBR on GitHub · 2026-11-25 21:35 UTC · original

Independent test on an RTX 3080 10 GB (Ampere, GA102). The other reports here are on Blackwell cards (RTX 5070 Ti, 5080), so this adds a different architecture.

Machine: driver 617.42, Ryzen 9 5900X, 32 GB RAM, Windows 11 Pro (build 26300), Series X profile at 1080p (VICTORY_RESOLUTION=1920x1080).

Tree: soldsawn/victory-nvidia-8gb at 7b7b952 (fork ca8829f plus community PRs), with this PR (895c0b8, 04df435) cherry-picked on top, clean. VICTORY_TEXTURE_BACK=1; the log shows kinds=[(256, 256, 41), (256, 256, 16), (64, 64, 16), (128, 128, 36)].

Before (same build, TEXTURE_BACK unset): the water did not load and the player could run along the bottom, underwater.

After: the water behaves, and I played most of the boat mission ("Gone Fishing") before the game stopped in the binoculars cutscene. That stop is a separate problem, an int3 that looks like a read of memory nobody wrote; details in #1049 (it is a different address from the access violation reported there).

One build, one long session (about 14 minutes). I did not compare frame times with and without the readback.

AI-assisted (Claude Code). Measured on my own machine. No game files or captures attached.

**@⁠DuarttBR** on GitHub · 2026-11-25 21:35 UTC · [original](https://github.com/fxceless/victory-fork/pull/999#issuecomment-7175288037) Independent test on an RTX 3080 10 GB (Ampere, GA102). The other reports here are on Blackwell cards (RTX 5070 Ti, 5080), so this adds a different architecture. **Machine:** driver 617.42, Ryzen 9 5900X, 32 GB RAM, Windows 11 Pro (build 26300), Series X profile at 1080p (`VICTORY_RESOLUTION=1920x1080`). **Tree:** `soldsawn/victory-nvidia-8gb` at `7b7b952` (fork `ca8829f` plus community PRs), with this PR (`895c0b8`, `04df435`) cherry-picked on top, clean. `VICTORY_TEXTURE_BACK=1`; the log shows `kinds=[(256, 256, 41), (256, 256, 16), (64, 64, 16), (128, 128, 36)]`. **Before** (same build, `TEXTURE_BACK` unset): the water did not load and the player could run along the bottom, underwater. **After:** the water behaves, and I played most of the boat mission ("Gone Fishing") before the game stopped in the binoculars cutscene. That stop is a separate problem, an `int3` that looks like a read of memory nobody wrote; details in #1049 (it is a different address from the access violation reported there). One build, one long session (about 14 minutes). I did not compare frame times with and without the readback. AI-assisted (Claude Code). Measured on my own machine. No game files or captures attached.
Author
Owner

@⁠B0rm0t0s on GitHub · 2026-11-25 22:23 UTC · original

✅ Tested on RTX 5080: water works

VICTORY_TEXTURE_BACK=1 fixes the sinking boats on my machine too.

GPU RTX 5080 16 GB
CPU Ryzen 7 7800X3D
RAM 32 GB DDR5
Commit c36971b
Run 48 min, one session

What works now

  • ✅ Boat floats and starts from standstill
  • ✅ Seaplane lands and taxis into the dock
  • ✅ Got through Gone Fishing to Jason's house
  • ✅ No device removed, no device errors
  • ✅ I closed the game myself, it did not crash

Performance

  • ~6.7 fps average in the open world
  • ~7,800 draws per frame
  • GPU upload heaps: supported and used
🔧 Switches used
Switch Value
VICTORY_ASYNC_SUBMIT 1
VICTORY_QUEUE2 1
VICTORY_INDIRECT_WINDOW 1
VICTORY_TEXTURE_NO_WAIT 1
VICTORY_COPY_PLAIN 1
VICTORY_JOIN_PARTS 1
VICTORY_BACK_OWN_VIEW 1
VICTORY_INDIRECT_GATHER 1
VICTORY_CARD_REHASH_RUNS 1
VICTORY_CARD_WINDOWS_MB 2048
VICTORY_WINDOW_UPLOAD 1
VICTORY_CARD_BUFFERS_MIN_KB 64
VICTORY_CARD_BUFFERS_MB 1280
VICTORY_TEXTURE_BACK 1

Note: 48 minutes with the read-back on ran
clean here, so the device loss in run 276 may
not be caused by the read-back itself.

Thanks for the fix! 🙏

**@⁠B0rm0t0s** on GitHub · 2026-11-25 22:23 UTC · [original](https://github.com/fxceless/victory-fork/pull/999#issuecomment-7176308534) ## ✅ Tested on RTX 5080: water works **`VICTORY_TEXTURE_BACK=1` fixes the sinking boats on my machine too.** | | | |---|---| | **GPU** | RTX 5080 16 GB | | **CPU** | Ryzen 7 7800X3D | | **RAM** | 32 GB DDR5 | | **Commit** | `c36971b` | | **Run** | 48 min, one session | ### What works now - ✅ Boat floats and starts from standstill - ✅ Seaplane lands and taxis into the dock - ✅ Got through *Gone Fishing* to Jason's house - ✅ No device removed, no device errors - ✅ I closed the game myself, it did not crash ### Performance - ~**6.7 fps** average in the open world - ~7,800 draws per frame - GPU upload heaps: supported and used <details> <summary>🔧 Switches used</summary> | Switch | Value | |---|---| | `VICTORY_ASYNC_SUBMIT` | 1 | | `VICTORY_QUEUE2` | 1 | | `VICTORY_INDIRECT_WINDOW` | 1 | | `VICTORY_TEXTURE_NO_WAIT` | 1 | | `VICTORY_COPY_PLAIN` | 1 | | `VICTORY_JOIN_PARTS` | 1 | | `VICTORY_BACK_OWN_VIEW` | 1 | | `VICTORY_INDIRECT_GATHER` | 1 | | `VICTORY_CARD_REHASH_RUNS` | 1 | | `VICTORY_CARD_WINDOWS_MB` | 2048 | | `VICTORY_WINDOW_UPLOAD` | 1 | | `VICTORY_CARD_BUFFERS_MIN_KB` | 64 | | `VICTORY_CARD_BUFFERS_MB` | 1280 | | `VICTORY_TEXTURE_BACK` | 1 | </details> > **Note:** 48 minutes with the read-back on ran > clean here, so the device loss in run 276 may > not be caused by the read-back itself. Thanks for the fix! 🙏
This discussion has been locked. Commenting is limited to contributors.
No description provided.