GPU: copy shader-written water/ocean textures back into title memory (VICTORY_TEXTURE_BACK) #2571
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2573"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
67e8ae14on 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)
[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)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, thencopy_mappedinto title memory) is a reasonable building block. It merges cleanly and CI (check) passes. What stops it as is:texback::wantedcopies back every texture whose (width, height, format) matches theVICTORY_TEXTURE_BACKlist, 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.texback::landreads 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 inhost.rsdoes.recordcopies the host texture's subresources and tiles them with the title layout fromresource::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.Geckomacabre/vx-layer(eee5667d). A maintainer needs to know that code's licence and whether it may be copied here.Generated by Claude Code
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.
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).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.Ticket,texback.rs). It still writes the whole tiled range, so CPU writes made during the list are not handled there either.Geckomacabre/vx-layernow 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).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.