GPU: hash shaders once in pipeline::shader() and cache SFI0 atomics64 on Translated #2211
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!2211
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2211"
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?
@RVZO6 on GitHub · 2026-11-25 08:00 UTC · original
RVZO6:rvzo/pipeline-startup-fast→main· +73 −19 · 2 files · 1 commits · openDuring startup pipeline creation (~60,000+ pipelines in the world), pipeline registration, key hashing, and library tracking perform avoidable allocations, double hashing, and lock contention:
pipeline::shader()computes BLAKE3 twice and allocatesArc<Shader>while holding theSHADERSmutex.GraphicsState::describe()builds intermediateString/Vec<String>allocations on everymake::key()andlibrary::name()call.library::USEDacquires a global mutex on every early-pipeline lookup and stores full 32-byteStringkeys in bothUSEDandCREATED.dxil_atomics64re-parses the DXIL container on every host pipeline creation instead of caching the result onTranslated.Claimed on #1633 (
https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7155570873).The change
crates/victory-gpu/src/pipeline.rs:shader()and allocateArc<Shader>outside theSHADERSmutex on misses (re-checking under the lock before inserting).dxil_atomics64once insidewith_resources()and cacheatomics64: boolonTranslated.shader_deduplicates_and_matches_blake3_prefixanddxil_atomics64_reads_sfi0_flags.crates/victory-gpu/src/pipeline/host.rs&crates/victory-gpu/src/pipeline/make.rs:GraphicsState::write_description()+Blake3Writerformake::key()andlibrary::name_with(), preserving byte-for-byte identical keys and library names.write_description_matches_legacy_describe_and_blake3.crates/victory-gpu/src/pipeline/library.rs:name_with()streaming the state description directly into BLAKE3 with identical length-prefixed layout.early-pipelines.txtkeys into a lock-freeOnceLock<KeySet>(EARLY_BEFORE) and store canonical 32-hex keys as compactu128values (with exact string fallback for non-canonical lines) in bothEARLY_BEFOREandCREATED.parse_key_u128_accepts_only_canonical_32_hex,created_deduplicates_hex_and_non_hex_keys, andearly_before_lock_free_lookup_handles_hex_and_non_hex.Not a duplicate of
#2192(#1509) replacesmake.rs's FIFO queue with a shader/PSO dependency DAG; it does not removeshader()double-hashing, streamGraphicsStatedescriptions, moveearly-pipelines.txtto lock-freeOnceLock<KeySet>, or cacheatomics64.#2179decoupleslibrary::pipeline()loads fromsave()via a second library handle, and#2180skips rewritinghost-pipelines.binwhen onlyearly-pipelines.txtchanged; both are orthogonal to key hashing andEARLY_BEFORE/CREATEDstorage.Tested
windows-latestMSVC + Windows WARP SM 6.6 CI run45570823602(Clippyclean,Clippy, diagnostics buildclean,Tests:731 passed; 0 failed; 10 ignored,victory-gpu:153 passed; 0 failed; 2 ignored+1 passed,xtask:6 passed; 0 failed):pipeline::tests::shader_deduplicates_and_matches_blake3_prefix ... okpipeline::tests::dxil_atomics64_reads_sfi0_flags ... okpipeline::host::tests::write_description_matches_legacy_describe_and_blake3 ... okpipeline::library::tests::parse_key_u128_accepts_only_canonical_32_hex ... okpipeline::library::tests::created_deduplicates_hex_and_non_hex_keys ... okpipeline::library::tests::early_before_lock_free_lookup_handles_hex_and_non_hex ... okNot run: the title; any hardware GPU. The title was not used in these tests.
AI-assisted: T3 Code (Antigravity, gemini-4-neon)
@Marvisak on GitHub · 2026-11-25 13:29 UTC · original · edited 2026-11-25 18:43 UTC
Automated triage for the maintainers.
Merge candidate. The PR is now small.
pipeline::shader()incrates/victory-gpu/src/pipeline.rshashes the container once and passes the hash toShader::with_hash. On a miss it builds theArc<Shader>outside theSHADERSlock and usesor_insertwhen it takes the lock again, so the first entry inserted is kept.with_resourcescomputesdxil_atomics64once and stores it inTranslated::atomics64.HostPipelinecreation inpipeline/host.rsreads that flag and no longer parses the DXIL container for each pipeline. The flag test (0x1040_0000inSFI0) is unchanged.Translatedis only built inwith_resources, so the new field cannot be left unset. The gain is small and not measured, but the change carries no risk.On your reply: thanks for splitting it. Dropping the
DebugStrContentescaper and theKeySetrewrite resolves the earlier concern about library and early-list keys.CI:
checkpassing.Generated by Claude Code
@RVZO6 on GitHub · 2026-11-25 17:43 UTC · original
Rebased cleanly onto
13f91caand split per triage feedback:GraphicsStateDebugStrContentescaper andKeySet/EARLY_BEFORErewrite (~740 lines removed).2 files changed, +73/-19):blake3::hash(bytes)inpipeline::shader()instead of re-hashing insideShader::new, and allocateArc<Shader>outside theSHADERSlock.dxil_atomics64(&host.dxil)once insidewith_resources()and cacheatomics64: boolonTranslatedinstead of re-parsing the DXIL container on everyHostPipelinecreation.windows-latestMSVC + WARP SM 6.6 CI (both clippy-D warningsprofiles,xtask6/6,victory-gpu+victory-shaderall green): https://github.com/RVZO6/VIctory/actions/runs/45666985023@catminou4 on GitHub · 2026-11-25 08:03 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.
60k-pipeline startup allocation storm eliminated, double-buffered... — startup perf; pairs with #2192's async scheduling and #2211's own scope. Big win if it holds.
@DenRakEiw on GitHub · 2026-11-25 08:03 UTC · original · approved these changes
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC):cargo test -p victory-gpu --lib pipeline::— 21 passed, 0 failed on RTX 5090 (includingshader_deduplicates_and_matches_blake3_prefix)cargo clippy -p victory-gpu --all-targets— 0 warningscargo xtask policy— ok (183 files ok)Clean elimination of the startup pipeline allocation storm, double BLAKE3 hashing, and
USEDlock contention. Looks great.AI-assisted (Gemini 4 Neon).
@Xvania7 on GitHub · 2026-11-25 08:52 UTC · original · approved these changes
Verified locally merged onto
main(940d32f, Windows 10 x64, NVIDIA GeForce RTX 5060, Rust MSVC):cargo test -p victory-gpu --lib -- --test-threads=1 pipeline::— 21 passed, 0 failedcargo clippy -p victory-gpu --all-targets -- -D warnings— 0 warningscargo xtask policy— ok (182 files ok)Synthetic tests only; no game data.
@fuzeofficlal on GitHub · 2026-11-26 02:20 UTC · original · reviewed
Tested merged against current
main(63bcca43) on Windows 11. Althoughgit merge-treereports zero text conflicts andcargo check -p victory-gpu --libcompiles, merging into currentmainbreaks test compilation (error[E0063]) under both default and--features diagnostics:pub(crate) atomics64: booltopipeline::Translatedbreaks 3 newerTranslated { ... }initializers added onmainsince13f91caee:crates/victory-gpu/src/draw.rs:3408(default &diagnostics)crates/victory-gpu/src/pipeline/depth_bounds_test.rs:58(default &diagnostics)crates/victory-gpu/src/pipeline/placed_uav_tests.rs:82(--features diagnostics)mainupdating those three test initializers (note: #2974 also introducesatomics64onTranslatedwith those three call sites updated).@smaxxey on GitHub · 2026-11-26 10:53 UTC · original
Heads-up before this lands: merged onto current
main(63bcca4), the library still builds but the tests no longer compile. Git merges the branch without conflicts. The triage's point thatTranslatedis only built inwith_resourcesheld when it was written, but two test initializers reachedmainsince then and don't set the new field:They come from
e976344(#2155) and842b0cb(#158). On the merge,cargo check -p victory-gpu --libpasses andcargo check -p victory-gpu --lib --testsfails, so CI would turn red after merging. At this branch's own head (ab5ac96) both pass. Settingatomics64in those two initializers after a rebase should be all it needs.Found by merging locally (Windows 11, Rust 1.98.1, no game files). Tested with Claude Code's help.
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.