perf(shader): mark SLOT_MEMORY directory loads pure and add global-buffer SRV CSE (#276) #396
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/396"
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 Androtim/MiniVI. Originally posted by Androtim on 2026-12-03T13:45:07Z.
Summary
Ports two GPL-3.0 DXIL bitcode optimization passes into
victory-shadercleanly and title-neutrally:Pure
SLOT_MEMORYpage-directory loads — ported fromlobomfz/VIctory-xmemPR #166 (fd19a20, GPL-3.0):Module::pure_loads: HashSet<u32>andModule::mark_pure(&mut self, v: V)incrates/victory-shader/src/emit/bitcode.rs.classandhas_effectincrates/victory-shader/src/emit/bitcode/opt.rsto treat marked pure calls asEffect::Pure.SLOT_MEMORYpage-directoryrawBufferLoad.f32result (entry) viaself.s.m.mark_pure(entry)insideLower::memory_entry(crates/victory-shader/src/emit/lower.rs), so conditional fault stores toSLOT_FAULTSdo not break CSE across consecutive lookups of the same(lo, hi)page.Global-buffer-aware
RawBufferSRV CSE (DOM_LOADS = 128) — ported fromReTerryDavis/ReVIctorycommit40b5f9c(building onlobomfz/VIctory-xmemfd19a20, GPL-3.0):pub const DOM_LOADS: u32 = 128(enabled by default inMODULE,ALL, andDEFAULT = 255, matching MiniVI'sDEFAULT = ALLconvention;VICTORY_SHADER_OPT=127opts out ofDOM_LOADS, and63opts out of bothWIDEandDOM_LOADS).Key::BufferRead(usize, u32, Vec<V>),raw_srv_key(forRawBufferSRVs,kind == 11),is_global_buffer_write(allowing non-aliasing LDS, private, mesh/primitive output ops includingemitIndices, texture writes, and threadgroup-only barriers), andsrv_memory_regionsincrates/victory-shader/src/emit/bitcode/opt.rs.srv_memory_regionsas a dataflow fixpoint over reachable blocks in RPO so cross-loop SRV CSE is preserved when loop back-edges have no global buffer writes/barriers, while strictly invalidating on UAV/global buffer stores, atomics, and device/group-UAV barriers (m & 6 != 0).Refs #276
Change Map
crates/victory-shader/src/emit/bitcode.rs—Module::pure_loads,Module::mark_purecrates/victory-shader/src/emit/lower.rs—self.s.m.mark_pure(entry)inLower::memory_entrycrates/victory-shader/src/emit/bitcode/opt.rs—DOM_LOADS = 128,Key::BufferRead,pure_loadshandling,is_global_buffer_write, fixpointsrv_memory_regions,raw_srv_key,mergeupdates, and 5 unit tests (a_read_marked_pure_is_reused_past_a_store_on_a_branch,raw_srv_reuse_requires_dominance_and_an_unbroken_memory_region,raw_srv_reuse_across_non_aliasing_writes_and_group_barriers,raw_srv_reuse_invalidated_by_uav_writes_atomics_and_device_barriers,pure_slot_memory_and_srv_cse_emit_valid_dxil_containers)crates/victory-shader/src/emit/lower_tests.rs— 2 end-to-end lowering +dxil.dllvalidation tests (slot_memory_pure_load_reuses_directory_across_fault_branch_and_validates,raw_srv_cse_in_lowered_shader_preserves_lds_write_and_invalidates_on_uav_store)crates/victory-shader/src/emit/mod.rs—shader_opt()docs (255,DOM_LOADS = 128,127,63) andthe_clean_up_switch_parses_or_runs_every_passVerification
cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --locked -- -D warnings— passed (0 warnings)cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --all-features --locked -- -D warnings— passed (0 warnings)cargo +1.98.1-x86_64-pc-windows-gnu test -p xtask --locked—8 passed; 0 failedcargo +1.98.1-x86_64-pc-windows-gnu xtask policy—asset policy: 351 files okcargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader --lib -- --test-threads=1 bitcode::opt::tests the_clean_up_switch slot_memory_pure_load raw_srv_cse_in_lowered_shader—21 passed; 0 failed(all 7 new positive/negative tests pass, includingdxil.dllcontainer validation)cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader --lib -- --test-threads=1—414 passed; 3 failed; 6 ignoredlocally against Windows SDK10.0.22000.0dxil.dll(the 3 failures —first_half_values_render_on_hardware_and_warp,rectangles_are_drawn_whole,the_rectangle_stage_is_a_geometry_shader— are pre-existing PSV0 mismatches on10.0.22000.0reproduced in unmodified baseline407 passed; 3 failed; 6 ignored; verified in full onwindows-latestCI below)Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-03T14:01:54Z.
Triage (
7e615e6a, CIcheckPASS):+903/-17acrossbitcode.rs,bitcode/opt.rs,lower.rs,lower_tests.rs,mod.rs): pureSLOT_MEMORYdirectory loads + global-buffer-awareRawBufferSRV CSE (DOM_LOADS = 128,DEFAULT = 255, opt-out viaVICTORY_SHADER_OPT=127; automatic translator/cache-key isolation viavictory-gpu/build.rs+shader_opt()). Note file overlap inbitcode/opt.rswith#314.#282) (aliasing/barrier soundness inis_global_buffer_write&srv_memory_regions) + Gate 3 cold-cache plain--releaseA/B (0DXIL errors /0DRED) +--features diagnosticsvisual PNG verification.