GPU: copy depth twins directly instead of through a scratch #2737
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!2737
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2737"
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?
@Therecalloftheonion on GitHub · 2026-11-25 19:23 UTC · original
Therecalloftheonion:pr/depth-twin-direct→main· +271 −43 · 1 files · 1 commits · openWhat
Subresources of one format family copy straight between a depth texture and its writable twin instead of through a scratch buffer. D32 twins now exist at all: the previous exact-format check rejected them, so shader writes to D32 depth were dropped. The scratch remains for converted 16-bit planes and is created only when a route needs conversion.
Why
GPU memory: a twin otherwise allocates a full scratch buffer on top of the twin texture. A D32 twin now takes one texture instead of two, and a depth-stencil texture's stencil plane (same format family) no longer goes through the scratch.
Testing
a_d32_twin_copies_directly_and_takes_no_scratch: creates a D32 depth texture and its twin, uploads known texels, performs the real depth-to-color copy, reads it back, checks every texel, and checks the device was not removed. Passes on the RX 6700 XT.cargo test -p victory-gpu --lib: 196 passed.Not tested on NVIDIA; the direct copy relies on DXGI format-family compatibility, as the D3D12 copy rules allow.
@passerbyyhx on GitHub · 2026-11-25 19:59 UTC · original
On
a35eb773,twin::tests::a_d32_twin_copies_directly_and_takes_no_scratchpassed on a GeForce RTX 4090 Laptop GPU (driver 621.14, Windows 11, Rust 1.98.1 MSVC). I ran the unmodified PR head first, then repeated the test with a diagnostic print after the final assertions to confirm it reached readback. The D3D12 device LUID resolved to the NVIDIA adapter. All 16 texels of the generated 4×4 D32 texture matched after the depth-to-color copy. The test recorded one direct copy and no scratch buffer. Both runs used the synthetic fixture and no game files.cargo test --locked --offline -p victory-gpu --lib twin::tests::a_d32_twin_copies_directly_and_takes_no_scratch -- --exact --test-threads=1 --nocaptureTest run and summary assisted by Codex.
@kotekompotek on GitHub · 2026-11-25 20:06 UTC · original
Good win: same-family subresources (D32's R32 plane, D24S8's pieces) now copy texture-to-texture with no scratch - a D32 twin drops a full texture of GPU memory. The scratch is only allocated when a route actually converts (at > 0), and the copy loop splits direct routes from converted ones cleanly. The 'whole subresource for depth-stencil' comment matches D3D12's restriction.
@fuzeofficlal on GitHub · 2026-11-25 20:10 UTC · original
Reviewed and verified
a35eb773(merged cleanly ontomain13f91ca) on Windows 11 (RTX 5090 + WARP).Code review
sameintwin.rs:173toresource::family(df[d].Footprint.Format) == resource::family(td.Format)cleanly enables zero-scratch directCopyTextureRegion(whole-subresource, multi-mip/array safe) forD32_FLOAT/R32_TYPELESS,D16_UNORM, and theR8_TYPELESSstencil plane ofR32G8X24_TYPELESS, while keeping the smaller scratch + compute conversion only for the 16-bit converted depth plane (118..=120) and returningtrueforlist.need_rebind()only when compute conversion runs.#2173):#2737does not guarddd.SampleDesc.Count > 1before callingCreateCommittedResourcewithALLOW_UNORDERED_ACCESS(which D3D12 rejects for multisampled resources). On the flip side,#2173guards MSAA and typed D16/D32 but still allocates a scratch buffer for same-family copies.git merge-treebetween#2737and#2173(as well as#485and#559) is completely conflict-free, so the two compose cleanly.Verification (Windows 11, RTX 5090 + WARP)
--features diagnostics):twin::tests3/3 passed (includinga_d32_twin_copies_directly_and_takes_no_scratch),draw::tests --test-threads=111/11 passed.VICTORY_D3D12_WARP=1,--features diagnostics --lib -- --test-threads=1): 199 passed, 0 failed, 1 ignored.cargo clippy -p victory-gpu --all-targets --locked -- -D warnings(default &--features diagnostics): 0 warnings;cargo xtask policy: 184 files ok.@passerbyyhx on GitHub · 2026-11-25 20:18 UTC · original
I ran the two branches together on a GeForce RTX 4090 Laptop GPU (driver 621.14). Merging #2173 at
cdd11bd2intoa35eb773gave tree017a5f2d88135b5740feeac8dbb7989338b250acwithout conflicts. The original D32 direct-copy and typed-depth tests both passed. A second run with test-only prints confirmed the adapter by LUID and recorded the readbacks.0.2500038and wrote back0xbfff. D32 read0.25and wrote back0x3f400000(0.75).Both synthetic fixtures ran with diagnostics in the same build. No game files were used. Test run and summary assisted by Codex.
@Marvisak on GitHub · 2026-11-25 23:22 UTC · original
Automated triage for the maintainers.
This PR conflicts with the current
mainincrates/victory-gpu/src/twin.rs, which has changed since the PR's base. It will be reviewed once it is rebased ontomain.Generated by Claude Code
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.