GPU: clear unused RTFormats slots and clamp NumRenderTargets #3162
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3164"
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 fuzeofficlal on 2026-11-26T10:40:52Z.
Summary
GraphicsState::read(subobject kind 15,D3D12_RT_FORMAT_ARRAY) copied all 8RTFormatsentries and mapped them throughpc_format, but neither clampedNumRenderTargetsto 8 nor cleared unused trailing slots (RTFormats[NumRenderTargets..8]) toDXGI_FORMAT_UNKNOWN.Per D3D12 pipeline state validation:
NumRenderTargetsmust be<= 8, andRTFormats[i]fori >= NumRenderTargetsmust beDXGI_FORMAT_UNKNOWN.When a stream leaves stale formats past
NumRenderTargets(for example after loweringNumRenderTargetsor setting it to0for a depth-only pass) or passesNumRenderTargets > 8, bothCreateGraphicsPipelineStateandID3D12Device2::CreatePipelineStatefail withE_INVALIDARGeven without the debug layer enabled, causingHostPipeline::newto returnNoneand drop every draw using that pipeline. In addition,GraphicsState::describe()includes all 8RTFormatsslots in the pipeline library key.Fix
In
GraphicsState::readfor kind 15 (crates/victory-gpu/src/pipeline/host.rs):NumRenderTargetstoRTFormats.len()(8).RTFormats[..count]throughpc_format(preserving valid sparseDXGI_FORMAT_UNKNOWNentries belowNumRenderTargets).RTFormats[count..]withDXGI_FORMAT_UNKNOWN.Previously valid pipelines already had
NumRenderTargets <= 8andDXGI_FORMAT_UNKNOWNin trailing slots, so existing pipeline library cache keys are unchanged.Verification
Added unit and real D3D12 pipeline-creation regression tests in
crates/victory-gpu/src/pipeline/host.rs:rt_format_array_clears_unused_slots_and_clamps_count: verifies trailing slot clearing, canonicaldescribe()keys, preservation of sparse activeDXGI_FORMAT_UNKNOWNslots, and clampingNumRenderTargets > 8.host_pipeline_accepts_stream_with_trailing_rt_formats: verifiesHostPipeline::newsucceeds with zero D3D12 debug layer errors for trailing formats pastNumRenderTargets,NumRenderTargets = 0with stale slot 0 (including thestream_pipeline/CreatePipelineStatepath when depth bounds are supported), andNumRenderTargets > 8. Confirmed both tests fail onmain(CreateGraphicsPipelineStaterejects the PSO even withoutVICTORY_D3D12_DEBUG=1) and pass after the fix.Ran:
cargo test -p victory-gpu --lib --locked -- --test-threads=1(RTX 5090 default, RTX 5090--features diagnostics+VICTORY_D3D12_DEBUG=1, andVICTORY_D3D12_WARP=1+--features diagnostics+VICTORY_D3D12_DEBUG=1)cargo clippy --workspace --all-targets --locked -- -D warnings(default and--all-features)cargo test -p xtask --locked policy::tests::repository_passes_policyImported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T10:47:04Z.
Review: APPROVED
Verified on RTX 5090 against
origin/main(63bcca4):cargo test -p victory-gpu --lib pipeline:: -- --test-threads=1: 25/25 passed (includinghost_pipeline_accepts_stream_with_trailing_rt_formatsandrt_format_array_clears_unused_slots_and_clamps_count).cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Cleanly zeroes unused
RTFormatsentries and clampsNumRenderTargetsto 8.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by Jackster on 2026-11-26T23:02:16Z.
Windows 11,
63bcca4+ this PR, Radeon RX 7900 XTX:cargo test -p victory-gpu --lib: 233 passed / 0 failed / 1 ignored (unpatched63bcca4here: 231; +2).cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.rt_format_array_clears_unused_slots_and_clamps_countandhost_pipeline_accepts_stream_with_trailing_rt_formatsboth pass. Synthetic only. AI-assisted.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.