GPU: copy shader-written water/ocean textures back into title memory (VICTORY_TEXTURE_BACK) #2573
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2573
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@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
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)
@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, 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
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.