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

Open
Bebrik229 wants to merge 1 commit from upstream-pr/2573 into main
Bebrik229 commented 2026-11-25 16:05:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Bebrik229 on 2026-11-25T16:05:00Z.


…(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)

<!-- greyfinch-sync:Marvisak/VIctory:issue:5494788824 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2573). Originally posted by [Bebrik229](https://github.com/Bebrik229) on 2026-11-25T16:05:00Z. --- …(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)
upstream-sync changed title from [PR #2573] GPU: copy shader-written water/ocean textures back into title memory … to [PR #2573] GPU: copy shader-written water/ocean textures back into title memory (VICTORY_TEXTURE_BACK) 2026-11-25 17:04:40 +00:00
Marvisak commented 2026-11-25 23:06:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:15:56Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176144175 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2573#issuecomment-7176144175). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:15:56Z. --- <!-- 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)_
upipibi commented 2026-11-28 02:10:01 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-28T02:10:01Z.


Some facts for the triage points, from two forks that run this read-back on by default. I read their trees and ran nothing; I don't run the title.

  • It fixes #2248 in long runs. foxhound's findings (RX 7900 XTX, kept in trustno1-coder/VIctory-NVIDIA as docs/findings.md) record the ocean's height and displacement maps as compute-written textures that the title's physics samples on the CPU: "With it the boat stays up through a whole run; without it sank in every one." trustno1-coder/VIctory-NVIDIA ships the same module on by default (crates/victory-gpu/src/texback.rs).
  • A lead for the general rule (point 1). Their module still selects by kind, with the same default list and a shortcut: note admitting it. Its header, though, records how the kinds were found: a read watch (VICTORY_READ_WATCH=1, run rw1) saw about 30 places in the title read those two kinds. A rule of "UAV-written textures whose title memory the title is seen reading" would follow from that. The read-watch code itself isn't in their current tree, so its cost is unknown.
  • Ordering (point 2). Their version adds per-allocation tickets that a remap or resource change invalidates (Ticket, texback.rs). It still writes the whole tiled range, so CPU writes made during the list are not handled there either.
  • Provenance (point 4). Geckomacabre/vx-layer now returns 404, so its licence can't be checked at the source. The forks carrying the code are GPL-3.0(-or-later), but that doesn't establish the original's terms.

AI-assisted (Claude Code, Claude Opus 5.5 read the forks' files and this thread).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7232176376 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2573#issuecomment-7232176376). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-28T02:10:01Z. --- Some facts for the triage points, from two forks that run this read-back on by default. I read their trees and ran nothing; I don't run the title. - **It fixes #2248 in long runs.** foxhound's findings (RX 7900 XTX, kept in trustno1-coder/VIctory-NVIDIA as `docs/findings.md`) record the ocean's height and displacement maps as compute-written textures that the title's physics samples on the CPU: "With it the boat stays up through a whole run; without it sank in every one." trustno1-coder/VIctory-NVIDIA ships the same module on by default (`crates/victory-gpu/src/texback.rs`). - **A lead for the general rule (point 1).** Their module still selects by kind, with the same default list and a `shortcut:` note admitting it. Its header, though, records how the kinds were found: a read watch (`VICTORY_READ_WATCH=1`, run rw1) saw about 30 places in the title read those two kinds. A rule of "UAV-written textures whose title memory the title is seen reading" would follow from that. The read-watch code itself isn't in their current tree, so its cost is unknown. - **Ordering (point 2).** Their version adds per-allocation tickets that a remap or resource change invalidates (`Ticket`, `texback.rs`). It still writes the whole tiled range, so CPU writes made during the list are not handled there either. - **Provenance (point 4).** `Geckomacabre/vx-layer` now returns 404, so its licence can't be checked at the source. The forks carrying the code are GPL-3.0(-or-later), but that doesn't establish the original's terms. AI-assisted (Claude Code, Claude Opus 5.5 read the forks' files and this thread).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2573:upstream-pr/2573'
git switch 'upstream-pr/2573'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2573'
git switch 'upstream-pr/2573'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2573'
git switch 'upstream-pr/2573'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2573'
git switch 'main'
git merge --squash 'upstream-pr/2573'
git switch 'main'
git merge --ff-only 'upstream-pr/2573'
git switch 'main'
git merge 'upstream-pr/2573'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!2571
No description provided.