GPU: copy shader-written water/ocean textures back into title memory (VICTORY_TEXTURE_BACK) #2573

Open
github-bot wants to merge 1 commit from github-bot/gh-2573 into main AGit
Owner

@⁠Bebrik229 on GitHub · 2026-11-25 16:05 UTC · original
Bebrik229:gpu/texback → main · +301 −2 · 5 files · 1 commits · open

…(VICTORY_TEXTURE_BACK)

GPU: copy shader-written water/ocean textures back into title memory (VICTORY_TEXTURE_BACK)

Fixes #2248

Summary

Ports texture GPU-to-CPU copy-back from Geckomacabre/vx-layer@eee5667d so textures written by compute shaders via unordered access (UAV) and read directly on the CPU are tiled back into title memory after execution.

Root Cause

In GTA VI (Gone Fishing / Follow the plane boat mission), the shallow-water / ocean passes (WaterSimMgr:CS_CompositeSimDataIntoOutputTexture0101, water_compressed_simulation_rendertarget:CS_MinMax_*) write 256x256 R32_FLOAT (f41), 256x256 R32G32_FLOAT (f16), 64x64 f16, and 128x128 R16G16_UINT (f36) textures through compute UAVs. On the console (unified memory), CPU buoyancy reads those texels directly from memory. On PC, shader writes remained in the host DEFAULT texture copy while title RAM stayed empty/stale, causing boats to drop immediately upon physics handoff with "Engine destroyed".

(Note: ShallowWaterSim:CS_ResolveHeightLookUps / u11 buffer readback was independently confirmed working beforehand via live readback probing and is not the missing piece.)

Changes
crates/victory-gpu/src/texback.rs:
Parses VICTORY_TEXTURE_BACK (default "256x256f41,256x256f16,64x64f16,128x128f36", "0" or empty disables).
Records CopyTextureRegion into a READBACK buffer when a command list closes, and tiles subresources back into title RAM via victory_formats::texture::Layout::tile + host::copy_mapped(..., true) after submission completes.
crates/victory-gpu/src/draw.rs, host.rs, lib.rs, resource.rs:
Tracks UAV texture writes in readable(), adds Host::read_back_buffer, schedules textures_back() in HostList::close(), runs texback::land() in Host::execute before bottom-of-pipe writes, and exposes resource::texture_kind / title_texture.
Verification
cargo xtask policy: passed (asset policy: 185 files ok).
cargo test -p victory-gpu --lib -- --test-threads=1: 193 passed, 1 ignored, including new texback::tests::parse_kinds_handles_default_disable_and_custom_lists and zero regressions (3 unrelated pre-existing tests dynamic_slots_are_held_until_released, a_texture_written_in_one_format_reads_in_another_through_a_placed_view, and lists_share_a_table_and_copies_keep_their_views fail identically on unmodified origin/main 67e8ae14 on this RTX 5070).
Live game run: Verified end-to-end with the same texback port on RTX 5070 12 GB (Windows 11, --console series-s, Gone Fishing / Follow the plane) — boat stays afloat on the water surface and drives normally instead of sinking with "Engine destroyed" (matching independent confirmations on fxceless/victory-fork#863 on RTX 3070 / 4070 SUPER / 5090).
Credits
Original texback design & implementation: Geckomacabre/vx-layer@eee5667d
Community diagnosis & confirmations: fxceless/victory-fork#863 (CuteBooty, KaV3R, Mishkile, sawetco)

**@⁠Bebrik229** on GitHub · 2026-11-25 16:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/2573) `Bebrik229:gpu/texback` → `main` · +301 −2 · 5 files · 1 commits · open …(VICTORY_TEXTURE_BACK) GPU: copy shader-written water/ocean textures back into title memory (VICTORY_TEXTURE_BACK) Fixes #2248 Summary Ports texture GPU-to-CPU copy-back from Geckomacabre/vx-layer@eee5667d so textures written by compute shaders via unordered access (UAV) and read directly on the CPU are tiled back into title memory after execution. Root Cause In GTA VI (Gone Fishing / Follow the plane boat mission), the shallow-water / ocean passes (WaterSimMgr:CS_CompositeSimDataIntoOutputTexture0101, water_compressed_simulation_rendertarget:CS_MinMax_*) write 256x256 R32_FLOAT (f41), 256x256 R32G32_FLOAT (f16), 64x64 f16, and 128x128 R16G16_UINT (f36) textures through compute UAVs. On the console (unified memory), CPU buoyancy reads those texels directly from memory. On PC, shader writes remained in the host DEFAULT texture copy while title RAM stayed empty/stale, causing boats to drop immediately upon physics handoff with "Engine destroyed". (Note: ShallowWaterSim:CS_ResolveHeightLookUps / u11 buffer readback was independently confirmed working beforehand via live readback probing and is not the missing piece.) Changes crates/victory-gpu/src/texback.rs: Parses VICTORY_TEXTURE_BACK (default "256x256f41,256x256f16,64x64f16,128x128f36", "0" or empty disables). Records CopyTextureRegion into a READBACK buffer when a command list closes, and tiles subresources back into title RAM via victory_formats::texture::Layout::tile + host::copy_mapped(..., true) after submission completes. crates/victory-gpu/src/draw.rs, host.rs, lib.rs, resource.rs: Tracks UAV texture writes in readable(), adds Host::read_back_buffer, schedules textures_back() in HostList::close(), runs texback::land() in Host::execute before bottom-of-pipe writes, and exposes resource::texture_kind / title_texture. Verification cargo xtask policy: passed (asset policy: 185 files ok). cargo test -p victory-gpu --lib -- --test-threads=1: 193 passed, 1 ignored, including new texback::tests::parse_kinds_handles_default_disable_and_custom_lists and zero regressions (3 unrelated pre-existing tests dynamic_slots_are_held_until_released, a_texture_written_in_one_format_reads_in_another_through_a_placed_view, and lists_share_a_table_and_copies_keep_their_views fail identically on unmodified origin/main 67e8ae14 on this RTX 5070). Live game run: Verified end-to-end with the same texback port on RTX 5070 12 GB (Windows 11, --console series-s, Gone Fishing / Follow the plane) — boat stays afloat on the water surface and drives normally instead of sinking with "Engine destroyed" (matching independent confirmations on fxceless/victory-fork#863 on RTX 3070 / 4070 SUPER / 5090). Credits Original texback design & implementation: Geckomacabre/vx-layer@eee5667d Community diagnosis & confirmations: fxceless/victory-fork#863 (CuteBooty, KaV3R, Mishkile, sawetco)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:09:34 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:15 UTC · original

Automated triage for the maintainers.

Needs work. The problem is real: title memory does not see what compute shaders write to a texture through unordered access, and the copy path here (read-back buffer, then Layout::tile, then copy_mapped into title memory) is a reasonable building block. It merges cleanly and CI (check) passes. What stops it as is:

  • Selection by hard-coded kind. texback::wanted copies back every texture whose (width, height, format) matches the VICTORY_TEXTURE_BACK list, and the default list (256x256f41,256x256f16,64x64f16,128x128f36) is tuned to one title's water pass. Any other texture of those kinds is copied back as well, and a texture of a different size that the CPU reads is not. The rule should depend on something general, for example textures written through UAVs that have title memory the CPU touches, or every UAV-written texture with title memory, measured for cost. A default list of one title's texture kinds should not ship as built-in behaviour.
  • Ordering with CPU writes. texback::land reads the whole title range, tiles the GPU texels over it, and writes it all back after the submission. Bytes the title wrote in that range while the list ran are overwritten. Please say why that cannot happen, or limit the write to what the GPU wrote, as the buffer copy-back in host.rs does.
  • Host and title formats. record copies the host texture's subresources and tiles them with the title layout from resource::title_texture. When the host format or mip/array layout differs from the title's (format conversions, twins), the bytes will not match. Please skip those textures or convert them, and add a test that tiles a known pattern back.
  • Provenance. The module says it is based on Geckomacabre/vx-layer (eee5667d). A maintainer needs to know that code's licence and whether it may be copied here.
  • The only test covers env parsing. A host test that writes a UAV texture in a list and checks the title bytes afterwards would show the path works.

Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 22:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/2573#issuecomment-7176144175) <!-- victory-triage v1 head=85dfb0fdff4f8c312dac9f6b3a968e3967610904 verdict=needs-work at=2026-11-25T22:15:45Z --> Automated triage for the maintainers. **Needs work.** The problem is real: title memory does not see what compute shaders write to a texture through unordered access, and the copy path here (read-back buffer, then `Layout::tile`, then `copy_mapped` into title memory) is a reasonable building block. It merges cleanly and CI (`check`) passes. What stops it as is: - **Selection by hard-coded kind.** `texback::wanted` copies back every texture whose (width, height, format) matches the `VICTORY_TEXTURE_BACK` list, and the default list (`256x256f41,256x256f16,64x64f16,128x128f36`) is tuned to one title's water pass. Any other texture of those kinds is copied back as well, and a texture of a different size that the CPU reads is not. The rule should depend on something general, for example textures written through UAVs that have title memory the CPU touches, or every UAV-written texture with title memory, measured for cost. A default list of one title's texture kinds should not ship as built-in behaviour. - **Ordering with CPU writes.** `texback::land` reads the whole title range, tiles the GPU texels over it, and writes it all back after the submission. Bytes the title wrote in that range while the list ran are overwritten. Please say why that cannot happen, or limit the write to what the GPU wrote, as the buffer copy-back in `host.rs` does. - **Host and title formats.** `record` copies the host texture's subresources and tiles them with the title layout from `resource::title_texture`. When the host format or mip/array layout differs from the title's (format conversions, twins), the bytes will not match. Please skip those textures or convert them, and add a test that tiles a known pattern back. - **Provenance.** The module says it is based on `Geckomacabre/vx-layer` (`eee5667d`). A maintainer needs to know that code's licence and whether it may be copied here. - The only test covers env parsing. A host test that writes a UAV texture in a list and checks the title bytes afterwards would show the path works. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2573/head:github-bot/gh-2573'
git switch 'github-bot/gh-2573'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2573'
git switch 'github-bot/gh-2573'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2573'
git switch 'github-bot/gh-2573'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2573'
git switch 'main'
git merge --squash 'github-bot/gh-2573'
git switch 'main'
git merge --ff-only 'github-bot/gh-2573'
git switch 'main'
git merge 'github-bot/gh-2573'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
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
github/Marvisak--VIctory!2573
No description provided.