GPU: spill oversized host root signatures' user data to root CBVs #644
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!644
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/644/head"
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?
@nathanbzrr on GitHub · 2026-11-24 06:06 UTC · original
nathanbzrr:gpu/root-signature-user-data-cbv-spill→main· +1119 −14 · 2 files · 1 commits · closed without mergingSummary
Host D3D12 hard-caps root signatures at 64 DWORDs.
HostPipeline::newemits a separateD3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTSparameter for every shader stage (VS/MS+PS, up to 32+ DWORDs each) plus per-stage 2-DWORD root CBVs/SRVs. Any pipeline whose combined per-stage user data and root descriptors exceeds 64 DWORDs failsD3D12SerializeVersionedRootSignatureand drops all draws using that pipeline, even though the DXIL shaders bindb0, space 0as a normal CBV that accepts both root 32-bit constants and root CBVs identically.Changes (
crates/victory-gpu/src/pipeline/host.rs,crates/victory-gpu/src/draw.rs)Stage::user_data: Option<(u32, u32)>withOption<UserDataBind>(Constants { param, dwords }orCbv { param, dwords }).root_param_cost,root_signature_cost, andfit_root_signature:UserDataBind::Constants(dwords > 2) toD3D12_ROOT_PARAMETER_TYPE_CBV(b0, space 0,D3D12_ROOT_DESCRIPTOR_FLAG_DATA_STATIC, preservingShaderVisibility), reducing each stage's cost fromdwordsto 2 DWORDs.(ParameterType, ShaderRegister, RegisterSpace)CBV/SRV/UAVroot descriptors across stages into a singleD3D12_SHADER_VISIBILITY_ALLparameter and remaps all stage parameter indices (never merging descriptor tables orb0user data).fit_root_signaturebefore serializing the root signature inHostPipeline::new.State::bind(returningboolchecked byprepare_for,dispatch, and theDISPATCHarm ofexecute_indirect) to uploadUserDataBind::Cbvvalues into 256-byte-alignedHostList::scratchmemory and bind them viaSetComputeRootConstantBufferView/SetGraphicsRootConstantBufferView.Verification
Isolated verification on branch
gpu/root-signature-user-data-cbv-spill(6fa53a5):rustfmt --edition 2024 --config skip_children=true --check crates/victory-gpu/src/pipeline/host.rs crates/victory-gpu/src/draw.rs(passed)cargo test -p victory-gpu -- --test-threads=1(51 passed, 0 failed, 1 ignored; includes 6fit_*unit tests,host_oversized_graphics_root_signatures_serialize_after_fit, andspilled_user_data_cbv_executes_distinct_dispatches_on_host)VICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics -- --test-threads=1(53 passed, 0 failed, 1 ignored; zero D3D12 debug layer errors)cargo clippy -p victory-gpu --all-targets(0 warnings inpipeline/host.rsanddraw.rs; 1 pre-existing warning athost.rs:267)cargo xtask policy(151 files ok)No game files. AI-assisted; reviewed and verified with the tests above.
@nathanbzrr on GitHub · 2026-11-24 21:36 UTC · original
Rebased onto
origin/main(ffe310e, new headb106bcd), resolving the conflict incrates/victory-gpu/src/draw.rs:prepare_for(if !self.bind(list, p, false) { return false; },#681null vertex-buffer unbinding,#654diagnostics) andbind(...) -> bool(#336self.table_faileddrop check).#644UserDataBind::Constants/UserDataBind::Cbvhandling insidebind, returningfalsewhenlist.scratch(bytes)returnsNone.Re-verified on Windows MSVC (
cargo clippy+cargo test --workspace --locked):cargo clippy --workspace --all-targets --locked -- -D warnings: cleancargo clippy --workspace --all-targets --all-features --locked -- -D warnings: cleancargo test --workspace --locked: 350 passed, 0 failed, 6 ignored (victory-gpu: 58 passed, 0 failed, 1 ignored;xtask: 4 passed includingrepository_passes_policy)@nathanbzrr on GitHub · 2026-11-24 22:17 UTC · original
Rebased onto
origin/main(70564ae, new head4eb145b):crates/victory-gpu/src/draw.rspreservingorigin/main'sprepare_for/execute_indirectdiagnostics (NOT_RUN),describememory details,root_uavs,view_addresses,memory/memory_dirtybinding, androotspage-table setup alongsideUserDataBind::{Constants, Cbv}handling.crates/victory-gpu/src/pipeline/host.rs(fit_root_signature) to also remapstage.root_uavs,stage.memory,stage.memory_dirty, andstage.view_addresses(so shared cross-stage root UAVs andMEMORY_SPACEdescriptors deduplicate and remap accurately).pipeline::host::tests::fit_phase2_deduplicates_uavs_and_memory_paramscoveringroot_uavs/memory/memory_dirty/view_addressesPhase 2 deduplication, and updatedHostShader/Stage/HostPipelineliterals indraw::tests::spilled_user_data_cbv_executes_distinct_dispatches_on_host.Verified on
4eb145b(Windows MSVC):rustfmt --edition 2024 --check crates/victory-gpu/src/pipeline/host.rs crates/victory-gpu/src/draw.rs: all#644hunks clean (only pre-existingorigin/mainformatting diffs remain).cargo clippy --workspace --all-targets --locked -- -D warnings: clean.cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: clean.cargo test --workspace --locked:485 passed, 0 failed, 7 ignored(victory-gpu:87 passed, 0 failed, 1 ignored;xtask:4 passed).@Marvisak on GitHub · 2026-11-25 01:16 UTC · original · edited 2026-11-25 06:21 UTC
Automated triage for the maintainers.
Merge candidate.
fit_root_signatureincrates/victory-gpu/src/pipeline/host.rskeeps host root signatures within D3D12's 64-DWORD limit by turning the largest per-stage user-data root constants into a root CBV at the sameb0register, then, if still over, merging identical root views across stages and remapping every stage index and theview_markspair;State::bindindraw.rsuploads spilled user data toHostList::scratch(256-byte aligned) and binds it as a root CBV. I checked the cost model (constants 1 per DWORD, root views 2, tables 1), that merging is safe becausebindreads root views from the pipeline-wide title roots so every stage binds the same address for a slot, and that all index fields (root_uavs,memory,memory_dirty,view_addresses,marks) are remapped. Minor: theassert_eq!(values.len(), dwords as usize)in theCbvarm can never fail and could go.Thanks for the rebase. It now merges cleanly with
mainand the earlier conflict inpipeline/host.rsis resolved, so this is the first content review.CI: passing (
check).Generated by Claude Code
@nathanbzrr on GitHub · 2026-11-25 03:19 UTC · original
Rebased onto
origin/main(940d32f, new head226e9fc):crates/victory-gpu/src/pipeline/host.rsandcrates/victory-gpu/src/draw.rs, preservingorigin/main's alignedGraphicsState::elements,aniso_point_mip_supported,view_marksroot-parameter pair (HostPipeline.marks),readable(..., marked), and earlyexecute_indirectpipeline-drop check.fit_root_signatureto takemarks: &mut Option<(u32, u32)>so Phase 1 includes the 4-DWORDview_marks/view_writesparameters in the budget and Phase 2 remapsmarksindices alongsidestageswhen deduplicating shared root descriptors.pipeline::host::tests::fit_accounts_for_and_remaps_view_marksand updateddraw::tests::spilled_user_data_cbv_executes_distinct_dispatches_on_hostforview_marks/marks.pipeline/host.rsanddraw.rs.Verified on
226e9fc(Windows MSVC):cargo run -p xtask -- policy --staged:asset policy: 2 files okcargo clippy --workspace --all-targets -- -D warnings&--all-features: cleancargo test -p victory-gpu --locked: 153 passed, 0 failed, 2 ignored (--all-features: 156 passed, 0 failed, 2 ignored)cargo test --workspace --locked: 0 failures across all workspace crates@nathanbzrr on GitHub · 2026-11-25 21:51 UTC · original
Rebased onto
origin/main(61bfc77, new head4b3d5a2):crates/victory-gpu/src/draw.rs, keepingorigin/main'splaced_unordered_textures_write_and_read_back_through_placed_viewsandexplicit_and_placed_rgba8_textures_at_one_address_share_compute_writes(61bfc77) alongsidespilled_user_data_cbv_executes_distinct_dispatches_on_host.assert_eq!(values.len(), dwords as usize)inState::bind'sUserDataBind::Cbvarm per the triage note.Verified on
4b3d5a2(Windows MSVC):cargo run -p xtask -- policy:asset policy: 182 files okcargo clippy -p victory-gpu --all-targets --locked -- -D warnings&--all-features: cleancargo test -p victory-gpu --lib --locked -- draw::tests --test-threads=1: 14 passed, 0 failedcargo test -p victory-gpu --lib --locked -- pipeline::host::tests --test-threads=1: 11 passed, 0 failedVICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --lib --locked -- spilled_user_data_cbv_executes_distinct_dispatches_on_host --test-threads=1: 1 passed, 0 failed@Marvisak on GitHub · 2026-11-25 22:11 UTC · original
Automated triage for the maintainers, second look (a review against current
main, with builds and tests where they could change the verdict).Closing because nothing shows that a title pipeline reaches this case.
mainlogs "host root signature refused" whenever it happens, and that line is in none of more than a hundred recent title runs (thousands of pipelines each), while other refusals do show up there; the tests here are synthetic. Against that, the change rewrites how user data is bound for every pipeline and merges root parameters across stages. If a refusal turns up in a run, a fix can be written against that pipeline.If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.
Pull request closed