GPU: hash DXIL shader slices zero-copy in HostPipeline::new #1993
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!1993
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1993"
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-25 02:32 UTC · original
nathanbzrr:gpu/cache-root-signatures→main· +89 −18 · 1 files · 1 commits · openSummary
crates/victory-gpu/src/pipeline/host.rs,HostPipeline::new):code_bytes(Vec<u8>allocations per shader stage) with borrowing&[u8]slices viastage_dxil/stage_bytesand extractedshader_bytecode(Option<&[u8]>) -> D3D12_SHADER_BYTECODE.super::library::name(...)call sites (compute, mesh, and graphics) to hash the borrowed slices directly, keeping pipeline library names unchanged.crates/victory-gpu/src/pipeline/host.rs):stage_bytes_matches_code_bytes_for_pipeline_namesverifying identicalsuper::library::name(...)hashes across compute, mesh, and graphics (including absent stages, empty slices, and rectanglegsbytes).Verification (
72ab576, Windows MSVC)cargo clippy --workspace --all-targets --locked -- -D warnings: passed (0 warnings)cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passed (0 warnings)cargo test -p victory-gpu --lib pipeline --locked: 17 passed, 0 failedcargo test -p victory-gpu --lib pipeline --all-features --locked: 18 passed, 0 failedcargo test --workspace --locked: all workspace crates passed (0 failures;victory-gpu: 144 passed, 0 failed, 2 ignored)cargo run -p xtask -- policy --staged:asset policy: 1 files ok(crates/victory-gpu/src/pipeline/host.rs)@upipibi on GitHub · 2026-11-25 03:00 UTC · original
Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at
0c8f440.victory-shader: 244 passed, 3 failed, 3 ignored. The 3 are #1744's NVIDIA failures onmain(the twostride_testsheap-buffer reads andgathers_at_a_level_match_the_hardware).victory-gpu: 144 passed, 2 failed, with only the two NVIDIA heap-cap failuresmainalso has (dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_views). Same asmainon this hardware. Not run: a title.AI-assisted (Claude Code).
@jeremygold02 on GitHub · 2026-11-25 03:39 UTC · original
Triage verdict — Separate the hash cleanup from the cache performance decision (
0c8f440)Evidence
Checks and limits
Next step
This verification was AI-assisted.
@nathanbzrr on GitHub · 2026-11-25 04:12 UTC · original
@jeremygold02 Thanks for the review! Updated
gpu/cache-root-signatures(headbeecf58, based onorigin/main940d32f) to address the cache eviction, concurrent-miss coalescing, pipeline-name equivalence, and benchmark points:1. Single-flight coalescing & O(1) LRU eviction (
crates/victory-gpu/src/pipeline/host.rs)RootSignatureCachenow usesMutex<RootSignatureCacheState>+Condvarwith an explicitCacheSlot::Creatingin-flight state and an RAIICreatingGuard. Concurrent misses for the same key wait on the in-flight creator and share its(ID3D12RootSignature, Arc<[u8]>)without redundantD3D12SerializeVersionedRootSignature/CreateRootSignaturecalls (andCreatingGuardremoves the slot and notifies waiters if creation fails or unwinds).HashMapwipe atROOT_SIGNATURE_CACHE_CAP = 1024with an intrusiveO(1)LRU doubly-linked list (ReadyEntryindices inVec<Option<ReadyEntry>>) so hot entries survive capacity eviction and evicted COM objects/blobs drop outside the cache mutex.2. Tests &
library::nameequivalencestage_bytes_matches_code_bytes_for_pipeline_names: verifies borrowedstage_bytesslices produce identicalsuper::library::name(...)hashes tocode_bytesacross compute, mesh, and graphics (including absent stages, empty slices, and rectanglegsbytes).root_signature_cache_reuses_com_identity_and_separates_distinct_layouts: verifies exact serialization counts, LRU eviction preserving hot keys over cold ones, andCreatingslot recovery on creator error with a concurrent waiter.root_signature_cache_canonicalizes_concurrent_misses: verifies 4 barrier-synchronized threads per key share COM/blob identity withserializations == 1per cold key.3. Synthetic D3D12 benchmark (
bench_root_signature_cache,--release)Measured on Windows MSVC (
cargo test --release -p victory-gpu --lib pipeline::host::tests::bench_root_signature_cache -- --ignored --nocapture):16.19 ms(serializations=2000) vs cached0.50 ms(serializations=16) — 32.11x15.27 ms(serializations=256) vs cached18.48 ms(serializations=32) — 0.83x (single-flight reduces D3D12 serializations/creations 8x from 256 to 32; remaining threads wait onCondvar+RootSignatureKeyVecconstruction for trivial 2-param descriptors)cap=1024: 256 hot keys touched 5x interleaved with 844 cold keys): uncached14.18 ms(serializations=2124) vs cached14.20 ms(serializations=1100) — 1.00x (halves D3D12 serializations and preserves hot keys across the 1,024 cap while breaking even on elapsed time for synthetic 2-param root signatures)If maintainers prefer landing the zero-copy
stage_bytescleanup inHostPipeline::newas a standalone PR before deciding on the root signature cache, happy to split it out.Verification (
beecf58, Windows MSVC)cargo run -p xtask -- policy --staged:asset policy: 1 files okcargo clippy --workspace --all-targets --locked -- -D warnings&--all-features: cleancargo test -p victory-gpu --lib pipeline --locked: 20 passed, 0 failed, 1 ignored (--all-features&VICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 --features diagnostics -- --test-threads=1: 21 passed, 0 failed, 1 ignored)cargo test --workspace --locked: all crates passed (0 failures;victory-gpu: 147 passed, 0 failed, 3 ignored)@Marvisak on GitHub · 2026-11-25 09:16 UTC · original · edited 2026-11-25 11:22 UTC
Automated triage for the maintainers.
Merge candidate. The root signature cache is gone. The PR is now only the borrowed-slice cleanup in
crates/victory-gpu/src/pipeline/host.rs(HostPipeline::new).stage_dxil/stage_byteshandlibrary::namethe translated DXIL bytes directly instead of copying them throughcode_bytes, andshader_bytecodebuilds the sameD3D12_SHADER_BYTECODEas before. An absent stage still hashes as an empty slice, so pipeline names do not change, and the three call sites (compute, mesh, graphics) match.On your reply: confirmed. The head
72ab576is a single commit with only this change (+89/−18), and it merges cleanly. A small optional point:stage_bytes_matches_code_bytes_for_pipeline_nameskeeps a copy of the removedcode_bytesonly to compare against it, so it could be dropped without losing coverage. CI: passing (check).Generated by Claude Code
@nathanbzrr on GitHub · 2026-11-25 09:29 UTC · original
Addressed the triage feedback (
#issuecomment-7158106934) at72ab576(based cleanly onorigin/main940d32f):stage_bytesDXIL slice cleanup (shader_bytecode,stage_dxil,stage_bytes, and the 3super::library::name(...)call sites inHostPipeline::new) plusstage_bytes_matches_code_bytes_for_pipeline_namesincrates/victory-gpu/src/pipeline/host.rs(+89 / -18 lines).Local Verification (
72ab576, Windows MSVC)cargo clippy --workspace --all-targets --locked -- -D warnings: passed (0 warnings)cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passed (0 warnings)cargo test -p victory-gpu --lib pipeline --locked: 17 passed, 0 failedcargo test -p victory-gpu --lib pipeline --all-features --locked: 18 passed, 0 failedcargo test --workspace --locked: all workspace crates passed, 0 failed (victory-gpu: 144 passed, 2 ignored)cargo run -p xtask -- policy --staged:asset policy: 1 files ok@fuzeofficlal on GitHub · 2026-11-26 01:41 UTC · original
Code review and RTX 5090 + WARP verification at head
72ab576d6f75merged cleanly ontomain(63bcca43c6a0):crates/victory-gpu/src/pipeline/host.rs:595-610, 647-652, 728-733, 871-880):code_bytes()+to_vec()with zero-copystage_bytes(i)/shader_bytecode(stage_dxil(i))feeds the exact same byte slices (&[]for absent stages,t.host.dxil.as_slice()for present stages) intolibrary::nameacross compute, mesh, and graphics pipelines — zero disk pipeline-library cache invalidation, andt.host.dxilborrows cleanly outliveD3D12_SHADER_BYTECODEacrossHostPipeline::new.VICTORY_D3D12_DEBUG=1, Rust 1.98.1):cargo xtask policy:191 files ok;cargo clippy --locked -p victory-gpu --tests -- -D warnings: 0 warningsvictory-gpu -- pipeline::: 24/24 passed on both RTX 5090 and WARP (includingstage_bytes_matches_code_bytes_for_pipeline_names).LGTM.
@catminou4 on GitHub · 2026-11-25 02:48 UTC · original · reviewed
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.
Host root-signature cache + zero-copy DXIL slice hashing — CPU overhead reduction on pipeline creation; hash must cover every byte that affects the PSO.
@fuzeofficlal on GitHub · 2026-11-26 13:32 UTC · original · approved these changes
Reviewed and verified
72ab576dmerged locally ontoorigin/main(63bcca43) on Windows 11 x64 (NVIDIA GeForce RTX 5090 and WARP, Rust1.98.1MSVC, Windows SDK10.0.26100.0dxil.dll; synthetic tests only, no game files).Verification
git merge-treeagainstorigin/main(63bcca43) and combined with#1571: clean.cargo xtask policy(PR head):182 files ok.cargo clippy --locked -p victory-gpu --all-targets -- -D warnings(default and--all-features, PR head, merged, and combined#1993 + #1571): 0 warnings.cargo test --locked -p victory-gpu --lib -- pipeline::— 24 passed, 0 failed (includingstage_bytes_matches_code_bytes_for_pipeline_names).VICTORY_D3D12_DEBUG=1,--features diagnostics):pipeline::— 27 passed, 0 failed on both adapters.#1993 + #1571on63bcca43(RTX 5090,VICTORY_D3D12_DEBUG=1,--features diagnostics): 31 passed, 0 failed.Review Notes
code_bytes()+to_vec()with zero-copystage_dxil/stage_bytesandshader_bytecode(crates/victory-gpu/src/pipeline/host.rs:520-527, 535, 571-576, 639-644, 755-763) feeds identical byte slices (&[]for absent/empty stages,t.host.dxil.as_slice()for present stages) tosuper::library::nameacross compute, mesh, and graphics pipelines, preserving existing disk pipeline-library cache keys byte-for-byte while dropping both the per-stage heap copies and the productionfrom_raw_partsunsafeblock.t.host.dxilslices live insideArc<Shader>'sOnceLockand outliveD3D12_SHADER_BYTECODEacrossHostPipeline::new.Looks good to merge.
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.