GPU: fix PresentX subresource copy and plane format handling #3257
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!3257
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3257"
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?
@fuzeofficlal on GitHub · 2026-11-26 14:48 UTC · original
fuzeofficlal:fix/gpu-present-formats-subresource→main· +491 −13 · 1 files · 1 commits · openSummary
Fixes three D3D12 contract and rendering bugs in
Host::present_with_compositor(crates/victory-gpu/src/host.rs) when presenting valid D3D12.X textures:present_with_compositorcalledCopyResource(&back, texture), which violates D3D12's matching-dimensions rule whenever the presented texture hasMipLevels > 1orDepthOrArraySize > 1(the DXGI swap-chain back buffer always has 1 mip and 1 slice). This emitted D3D12 Debug Layer error#944on hardware and WARP and aborted the process (0xc0000409) on retail WARP. Switching toCopyTextureRegionof subresource0matchescapture::read_back/capture::probeand presents mip 0 slice 0 cleanly.UNORM/SNORMtargets intoFLOAT/UNORMswap chains:swap_formatmapsR16G16B16A16_UNORMandR16G16B16A16_SNORMtoR16G16B16A16_FLOAT(andR8G8B8A8_SNORMtoR8G8B8A8_UNORM). Previously, single-plane presents raw-copied UNORM bits directly into the float swap chain (turning[1.0, 0.5, 0.0, 1.0]into half-floatNaNs[0xffff, 0x7fff, 0x0000, 0xffff]), and multi-plane presents created anR16G16B16A16_FLOATSRV overR16G16B16A16_UNORM, which either produced0x7fffNaNs on castable textures or triggered permanent device removal (DXGI_ERROR_INVALID_CALL = 0x887A0001, Debug Layer#28/#232) on non-castable textures. Single-plane format-converting targets now route throughCompositor, andcompositor_srv_formatpreserves each typed float/UNORM/SNORM plane's own format for sampling.swap_format(d.Format).unwrap_or(d.Format)passed typeless formats outsideswap_format(such asB8G8R8X8_TYPELESS, produced byresource::host_descforB8G8R8X8_UNORM_SRGBtextures withALLOW_UNORDERED_ACCESS) directly toCreateShaderResourceView, immediately removing the host D3D12 device (0x887A0001) on both retail hardware and WARP.compositor_srv_formatmaps typeless color families to concrete float/UNORM formats and skips unsampleable planes (such as integer formats) instead of issuing an invalid SRV.Verification
63bcca43:present_single_plane_copies_subresource_zero_of_mipmapped_and_array_texturesaborted (0xc0000409); RTX 5090 + WARP Debug Layer reported D3D12 error#944.present_converts_unorm16_planes_without_nan_or_device_removalread back raw UNORM bits[65535, 32767, 0, 65535](NaN) in single-plane and removed non-castable devices (0x887A0001) in multi-plane.present_composites_typeless_bgrx_overlay_without_device_removalaborted (0xc0000409,0x887A0001device removal).compositor_srv_format_preserves_typed_formats_and_resolves_typelessandpresent_plane_tests) pass on RTX 5090 (default and diagnostics + Debug Layer) and WARP (retail and diagnostics + Debug Layer).victory-gpu --libpasses on RTX 5090 default (230 passed), RTX 5090 diagnostics + Debug Layer serial (247 passed), and WARP diagnostics + Debug Layer serial (247 passed).cargo clippy --workspace --all-targets --locked -- -D warnings,--all-features,git diff --check,rustfmt --edition 2024 --checkon modified hunks, andcargo run --locked -p xtask -- policyall pass.@Dukestar69 on GitHub · 2026-11-26 15:13 UTC · original · approved these changes
Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090 + WARP):
R16G16B16A16_{UNORM,SNORM}->FLOAT,R8G8B8A8_SNORM->UNORM) throughCompositor, resolving typeless/sRGB formats cleanly incompositor_srv_format, and copying subresource 0 viaCopyTextureRegionfor mipmapped/array textures cleanly fixes PresentX format and subresource handling.cargo test -p victory-gpu --lib host::tests:: -- --test-threads=1(RTX 5090): all passed (includingcompositor_srv_format_preserves_typed_formats_and_resolves_typeless).cargo test -p victory-gpu --lib --features diagnostics host::present_plane_tests:: -- --test-threads=1(RTX 5090): 4 passed, 0 failed (includingpresent_composites_typeless_bgrx_overlay_without_device_removal,present_converts_unorm16_planes_without_nan_or_device_removal,present_single_plane_copies_subresource_zero_of_mipmapped_and_array_textures).VICTORY_FORCE_WARP=1 cargo test -p victory-gpu --lib --features diagnostics host::present_plane_tests:: -- --test-threads=1(WARP): 4 passed, 0 failed.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo clippy -p victory-gpu --features diagnostics --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.