GPU: upload the stencil plane with guest textures #2509
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!2509
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2509"
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?
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 15:03 UTC · original
andrewpozdnakov7-jpg:codex1/stencil-upload→main· +271 −14 · 2 files · 2 commits · openA VIctory CopyResource of a CPU-populated depth/stencil texture uploads depth but leaves stencil zero. Stage every compatible plane and use native D3D12 copy footprints. Dirty-span offsets include the start of each guest plane, so a stencil-only CPU write can refresh stencil independently. The console D16S8 layout that needs float depth conversion retains its existing upload path. D3D12 format plane count
The same WARP test submits a normal VIctory CopyResource of a 2 × 2 R32G8X24_TYPELESS texture with two mips and two array slices. It reads both planes back after the copy and after writing one stencil byte in the source.
67e8ae1401+ teste98af1dSix alternating WARP runs reproduced the failure on main and passed on the updated branch. The full serial GPU suite had 199 passes and one ignore with both D3D12 debug flag settings. Strict GPU Clippy in both modes and repository policy passed. The independent RTX 5070 run covers the earlier
88067efhead. AI-assisted. Synthetic data only. RTX 5070 resultCoordination claim
Please preserve the Git author when reapplying the change. If you fold the code or test into another commit, please add this trailer.
Co-authored-by: andrewpozdnakov7-jpg [email protected]
@oni-swr on GitHub · 2026-11-25 15:29 UTC · original
Verification (Windows 11, WARP/CPU only) — head
88067ef31fd4b23c5a3c9ffbc32b65bc8d834e23Tested: the PR head, which is
origin/main940d32fplus the PR commits (merge-base940d32f; clean merge, fast-forward). Windows 11 Pro 10.0.26200, rustc/cargo 1.98.1.VICTORY_D3D12_WARP=1with--features diagnostics(the switch is only honoured with that feature, otherwisehost()would take the default adapter), so the host device is WARP; no physical GPU involved.cargo test -p victory-gpu --locked --features diagnostics --lib copy_resource_uploads_depth -- --test-threads=1texture.rsrestored toorigin/main(test kept)stencil planeleft: [0, 0, 0, 0],right: [7, 11, 13, 17]cargo test -p victory-gpu --locked --features diagnostics --lib -- --test-threads=1cargo clippy -p victory-gpu --all-targets --locked -- -D warnings(also with--features diagnostics)cargo xtask policyasset policy: 182 files okSo the test exercises the bug: on main only plane 0 is detiled and the stencil plane reads back zero; with the PR both planes match the guest bytes.
Diff read: the subresource index is split as D3D12 orders it (mips, then array slices, then planes) via
subresources_per_plane, each plane gets its owntiled[offset..offset+size]slice and its owndetile, and the XOR-swizzle refusal now checks every plane. For single-plane texturesplanes[0].offsetis 0 and the slice is the whole layout, so that path is unchanged; 3D textures keepMipLevelsper plane. No findings. Caveats: the new test returns early ifhost()yields no device, so it only means something where a D3D12 device exists (WARP here); it covers one mip, one slice, 2x2, and not mip chains or array depth-stencil, which the index math also handles but nothing tests. WARP only; real-GPU behaviour untested.AI use: Claude Code (Claude Sonnet 5.5).
@welisonzika14-jpg on GitHub · 2026-11-25 16:06 UTC · original
Machine: RTX 5070, driver 621.24, Windows 11, Rust 1.98.1 (MSVC).
Head:
88067ef(base940d32f). Command:cargo test -p victory-gpu --locked --features diagnostics --lib copy_resource_uploads_depth -- --test-threads=1.VICTORY_D3D12_DEBUG=1: 1 passed.VICTORY_D3D12_WARP=1: 1 passed.940d32f: 141 passed, 2 failed, the same two. So +1 test, no new failure.67e8ae1(conflicts in crates/victory-gpu/src/resource.rs and crates/victory-gpu/src/texture.rs), so a rebase is needed.Written with AI help (Claude/Kiro); the numbers are from runs on my machine.
@Marvisak on GitHub · 2026-11-25 16:16 UTC · original · edited 2026-11-25 18:31 UTC
Automated triage for the maintainers.
texture::staging/Staging::detileincrates/victory-gpu/src/texture.rsnow stage every plane the host format has (D3D12_FEATURE_FORMAT_INFO.PlaneCount), not only plane 0, so a CPU-written stencil plane is uploaded too. Each plane's dirty spans are offset by the start of that plane in the guest layout.What I checked:
victory_formats::texture::Texture).refresh_nowstill useslayout.size, which now covers both planes.The new test in
resource.rsreads both planes back over two mips and two slices, then again after a stencil-only CPU write. The head merges cleanly into currentmain, and CI passes (check). Not covered: real-GPU depth-format differences in plane 0, which this PR does not change.Generated by Claude Code
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 16:41 UTC · original
Updated for
67e8ae1401and kept the new selective upload path. The same WARP test now covers two mips, two array slices and a CPU write to stencil only. Main reads zero from stencil. The updated branch reads all expected depth and stencil values, including 53 after replacing 41 in the last stencil subresource. Six alternating A/B runs, serial GPU 199 passed and 1 ignored in both debug flag settings, strict GPU Clippy in both modes and repository policy. Thanks for the independent test of88067ef.Updated commit
If you fold the change or test into another commit, please preserve the Git author or add this trailer.
Co-authored-by: andrewpozdnakov7-jpg [email protected]
@fuzeofficlal on GitHub · 2026-11-26 18:18 UTC · original · approved these changes
Looks good. Verified merged onto
main(63bcca43) on an RTX 5090 and Microsoft WARP under the D3D12 Debug Layer (VICTORY_D3D12_DEBUG=1):D3D12_FEATURE_FORMAT_INFOforPlaneCount, guarding multi-plane staging withmatching_layout(preserving consoleD16S8's single-plane path), mapping D3D12 subresource indices in mip -> array slice -> plane order, and resizing/offsetting per-plane dirty spans cleanly handle depth/stencil uploads and stencil-only refreshes.cargo xtask policy(191 files ok) andcargo clippy --locked -p victory-gpu --all-targets -- -D warnings(default and--all-features) pass.copy_resource_uploads_depth_and_stencil_from_guest_memoryandtexture::tests::(3/3) pass on both RTX 5090 and WARP underVICTORY_D3D12_DEBUG=1with zero Debug Layer messages.DXGI_FORMAT_R24G8_TYPELESS(44), plus clean staging/copying of single-planeD32_FLOAT(40) and consoleD16S8(118) fallback, on both RTX 5090 and WARP underVICTORY_D3D12_DEBUG=1.#2341onmain.@Dukestar69 on GitHub · 2026-11-26 18:50 UTC · original · approved these changes
LGTM — verified on RTX 5090 (Windows / D3D12) against
origin/main(63bcca4).D3D12_FEATURE_FORMAT_INFOand matching depth element size so D16S8 stays safely on plane 0) cleanly brings stencil data from guest memory to the host texture.cargo test -p victory-gpu --lib resource:: -- --test-threads=1: 19 passed, 0 failed (includingcopy_resource_uploads_depth_and_stencil_from_guest_memory).cargo test -p victory-gpu --lib texture:: -- --test-threads=1: 2 passed, 0 failed.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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.