GPU: clear unused RTFormats slots and clamp NumRenderTargets #3164
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!3164
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@fuzeofficlal on GitHub · 2026-11-26 10:40 UTC · original
fuzeofficlal:fix/gpu-rt-format-array-unused-slots→main· +279 −1 · 1 files · 1 commits · openSummary
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_policy@Dukestar69 on GitHub · 2026-11-26 10:47 UTC · original · approved these changes
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).
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.