GPU: placed copies take the bytes a GPU write leaves in their memory #1725
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!1725
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1725/head"
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?
@Nixitov on GitHub · 2026-11-24 21:24 UTC · original
Nixitov:gpu/placed-copy→main· +939 −11 · 5 files · 2 commits · closed without mergingA texture the title places in its own memory is read through a placed view whose DXGI format differs from the format of the resource that writes it: the fog volumes are written as
R32_UINTthrough a UAV and sampled as the console's packedR9G9B9E5through a placed SRV. The host makes one texture per (address, description), so those are two host textures here, and the reader's copy never receives what the GPU wrote.The console is allowed this because the format lives in the view and the shader packs RGBE by hand; nothing in title memory changes between the write and the read.
Before.
sky_scattering:CS_AerialPerspectiveVolumeswrote the volumes andscattering_transmittance_system:CS_Gather_Classified_0sampled them empty: density 0, transmittance 1.0, and the shader marched to its own 9999-iteration cap. That was 83.99 ms a dispatch, 280-320 ms a frame, 67 % of the GPU frame, and the frame washed white.After. On the first bind of a placed copy that another resource at the same title address writes (same size, texel width and mip count, a different format, a UAV), the reader's list copies the writer's host texture into it through a staging buffer, with the writer's format at one end and the placed copy's at the other, since the host refuses a texture copy between the two families. The writer comes from a by-address map of title textures with host copies, filled at creation and emptied at release. The copy is recorded before the draw or dispatch that reads it, once per list and placed copy, and replaces the upload of title memory that holds none of the bytes.
VICTORY_PLACED_SYNC=0turns it off, and the frame line counts the copies.Same dispatch: 0.2 ms. Five 80x45x64 volumes (1.47 MB each) synced from f42 to f67, the white wash is gone, about 30 ms a frame better, and the texture-upload time in steady state is halved.
Hardening (
83c7bb4). The staged copy took the pair's footprints from a cache keyed by the two host textures' addresses. A released host texture's address comes back for another one and the old footprints then describe the wrong pair — a copy past the buffer's end, or between a format a texture no longer has — which is an invalid command the host answers with device removal (the one DRED stop seen atCopyTextureRegion). The cell now carries the descriptions it was made for and is remade when either differs. Both ends must be single-sample textures of one dimension in the plain layout, with formats the adapter can copy as a texture of that dimension (CheckFeatureSupport) and the same texel size; each end's footprints are taken and must lie in the same places, inside the buffer, or nothing is recorded. Each copy names a box inside both textures' subresource at that mip and uses the host's row sizes for 3D textures. Both host copies and the staging buffer are held across the recording and kept by the list until it is reset.The experiment worth skipping. Making one resource per address instead of one per (address, description) does not work: D3D12 refuses a view of the other format family and the device is removed.
Not covered. Placed UAV views, directly indexed (non-table) reads, and a single pre-change DRED report that named
CopyTextureRegionand was never reproduced once the guards above were in.Tested
RTX 5070, Windows 11 26200.9974, driver 617.14. Base
mainffe310e:cargo build --release -p victory: clean.cargo test --release -p victory-gpu: 52 passed, 1 ignored, includingresource::tests::a_placed_copy_takes_the_bytes_of_its_writer(a write through the R32 UAV read back through the placed copy as the same values) andtexture::tests::a_placed_copy_is_staged_only_between_the_same_texels(the buffer layout's same-texels-only rule).cargo clippy --workspace --all-targets --locked -- -D warnings, with and without--all-features: clean.No game data.
AI-assisted (DeepSeek V4.1 Flash coding agent).
@Marvisak on GitHub · 2026-11-25 01:25 UTC · original
Automated triage for the maintainers. Closing because this change is already in
main, ormainhas since replaced the code it patches.Already in main: a memory written as R32_UINT and sampled as R9G9B9E5 shares one host texture through castable formats, with alias copies where the host cannot cast (resource.rs shared_texture, texture.rs alias_copy,
13bbd6fe).If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
@Marvisak on GitHub · 2026-11-25 01:35 UTC · original
Automated triage for the maintainers.
Needs rebase. This pull request conflicts with
main(conflicting:crates/victory-gpu/src/draw.rs,crates/victory-gpu/src/host.rs,crates/victory-gpu/src/resource.rs,crates/victory-gpu/src/texture.rs). It will be reviewed once it is rebased onto the currentmain.Generated by Claude Code
Pull request closed