fix(gpu): skip converting twin copy routes when depth converter is unavailable #3360
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3360"
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?
Imported from Marvisak/VIctory. Originally posted by reeledMarek on 2026-11-26T20:25:43Z.
Summary
r.depth.is_some()) andconverter()returnsNone,Twin::copypreviously skipped the compute conversion pass but still ran the secondCopyTextureRegionpass from the unwritten scratch offset (r.depthorr.twin) into the destination texture, corrupting it with uninitialized scratch bytes.copy_withhelper), skipping routes that require conversion when no converter is available and returningfalseearly without transitions or incrementingCOPIESif no active routes remain.copy_skips_converting_routes_when_converter_is_missing.Verification
cargo clippy -p victory-gpu --all-targets --target x86_64-pc-windows-msvc --locked -- -D warningscargo test -p xtask --lockedImported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T20:28:07Z.
Review: APPROVED
LGTM — verified on RTX 5090 (Windows / D3D12) against
origin/main(63bcca4).converter()is unavailable avoids copying unconverted scratch bytes into the destination texture or emitting unnecessary transitions.cargo test -p victory-gpu --lib twin:: -- --test-threads=1: 3 passed, 0 failed (includingcopy_skips_converting_routes_when_converter_is_missing).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).
Imported from Marvisak/VIctory. Originally posted by passerbyyhx on 2026-11-26T21:34:54Z.
I exercised the mixed route when the depth converter returns
Noneon Windows D3D12, using an RTX 4090 Laptop and Microsoft WARP. The 4×2 fixture creates the resource through the production format mapping. Console formats 118/119/120 all produced an R32 depth footprint (DXGI 39) requiring conversion from the R16 twin and an R8 stencil footprint (DXGI 60) that can copy directly.On
66ea2630each adapter passed 12 readback cases: three formats × two shader-resource flag settings × both copy directions. Stencil transferred, both depth surfaces retained their respective initial bytes, and each case checked all four plane payloads before and after queue completion. The fixture seeded scratch with0xA5.On parent
63bcca43with only the converter-injection seam, both adapters transferred stencil but overwrote destination depth with0xA5. This reproduced for both directions and both flag settings on format 118 (eight failing cases total). Parent readbacks for 119/120 were not needed to establish that control. This is an injected converter-unavailable condition with one mip, one slice and one sample.Portable head fixture.
AI-assisted with Codex.
Imported from Marvisak/VIctory. Originally posted by passerbyyhx on 2026-11-26T22:01:03Z.
I followed up on the mixed-copy readback with both source and destination starting outside their copy states. Host depth started in
DEPTH_WRITEand both twin planes inUNORDERED_ACCESS. All runs required a live D3D12 debug info queue.On the updated fixture, each adapter (RTX 4090 Laptop and Microsoft WARP) passed all 12 combinations of console format 118/119/120, shader-resource flag and copy direction. Every copy emitted the two expected texture transitions, for the stencil twin and host texture. The depth twin stayed in UAV state. After the fence, stencil matched the source byte-for-byte, both depth payloads retained their seeds, and the copy counter advanced once. The debug queue had zero warnings and errors at list close and after GPU completion in these cases. The earlier host-initialization diagnostic was drained separately.
With the same fixture source and converter-injection seam on parent
63bcca43c6a00a758510398fa43096ce7e4f7df0, all eight format-118 controls again transferred stencil and overwrote destination depth with scratch0xA5. The parent requested a third transition on the depth twin. Coverage is forTwin::copy_with, one mip and injected converter absence. The wrapper state machines intwin::routeandHostList::preludewere outside this run.AI-assisted with Codex.
Imported from Marvisak/VIctory. Originally posted by passerbyyhx on 2026-11-26T22:33:05Z.
I ran the missing-depth-converter case through both callers of
Twin::copyat66ea26305170b091bf05e27f770f8f310329066a. The same-listtwin::routeand the submission-timeHostList::preludeeach copied the two stencil mips in both directions and preserved the independently seeded host and twin depth bytes. The RTX 4090 Laptop (621.14) and Microsoft WARP returned the same data.Each case used a single-sample format-118 texture with 4×2 and 2×1 mips. Host stencil started with
41 42 43 44 45 46 47 48and61 62. Twin stencil started withc1 c2 c3 c4 c5 c6 c7 c8ande1 e2. We checked all eight plane/mip payloads before and after the copy. The route cases incremented the copy counter while recording. The prelude cases first incremented it at submission. Every case finished with exactly one copy and one injected converter miss.The submission prelude restored the host depth texture to
DEPTH_WRITEand both twin textures to UAV. The depth twin had no copy transition. Both callers left the list’s rebind flag clear. A compute pipeline and root UAV bound before routing still produced0xc0decafeafter routing without a rebind.Each adapter had an active D3D12 info queue. All 24 recording and fenced-completion checks per adapter reported zero warnings or errors after host initialization. Both logs captured the existing sampler-heap diagnostic during initialization. This run seeded the authoritative side explicitly, used one array slice, and injected converter absence at lookup. The earlier parent comparison used the single-mip copy fixture. Earlier parent and head comparison
Synthetic test source
AI-assisted with Codex.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T23:39:52Z.
Review: APPROVED
Looks good — cleanly prevents unconverted/mismatched scratch copies when the depth converter pipeline is unavailable while preserving direct non-converting planes.
Checked
crates/victory-gpu/src/twin.rs:409-493alongside its callers intwin.rs:326andhost.rs:1961-1976:get_converter()returnsNone,copy_withreturnsfalseearly without callingmv, recording transitions/copies, modifyingscratch(stays inCOMMON), or incrementingCOPIES.R32G8X24_TYPELESS, where plane 0 converts and plane 1 is a direct copy),activeskips the converting plane (somvand prelude reverse barriers inhost.rs:1961-1976stay balanced), transitionsscratchCOPY_DEST -> COPY_SOURCE -> COMMONwithout compute dispatch, copies the stencil plane cleanly, and returnsfalseso callers do not trigger an unnecessary compute rebind.Verification (
66ea2630):cargo xtask policyandcargo clippy -p victory-gpu(default and--features diagnostics,--tests -- -D warnings): passed.twin::tests::(3/3): passed on both hardware GPU and WARP (--features diagnostics,VICTORY_D3D12_DEBUG=1, zero Debug Layer errors).D16S8(R32G8X24_TYPELESS, plane 0R16_TYPELESSconverting + plane 1R8_TYPELESSdirect) probe callingcopy_with(..., to_depth = true, || None): confirmed on both hardware GPU and WARP (VICTORY_D3D12_DEBUG=1) that plane 0 is never transitioned, stencil bytes (0x5a) copy accurately into depth subresource 1,converted == false, and zero Debug Layer errors occur.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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.