Repository navigation
Conversation
|
Code review and RTX 5090 + WARP + DXIL + release benchmark verification at head
Clean and well-tested; LGTM. |
|
Automated triage for the maintainers. Merge candidate. Both requested changes are in
The fast path gives CI: passing. Generated by Claude Code |
…s, O(1) valu16 reject, and zero-alloc buffer/mask helpers
Speed up emit::lower hot paths across all shaders with 100% bit-identical DXIL:
- emit/lower/tables.rs: DenseMap<T> (Vec<Option<T>> indexed by Value.0)
for vals, floats, and phi_at, plus FxMap/FxSet for internal lookup maps.
- Lower::get: defer st.masks/st.highs SipHash lookups into the Missing/None
mask_ok fallback instead of running them on every operand read.
- Lower::valu16: fast-reject !name.ends_with("16") && name != "v_cvt_f16_f32"
before scanning the 44 16-bit opcode names on every 32-bit VALU op.
- Lower::inst: defer effect substring scans (contains("store"/"atomic"))
to Err(why); gate mask_ok checks on Encoding.
- Lower::run / round16: skip round16 RPO/dataflow when no s_round_mode or
s_setreg* exists; gate round16_after on Sopp|Sopk; hoist !discards.is_empty()
and sections.contains_key(&b) outside instruction loops.
- reads_mask_as_data / Lower::buffer: eliminate per-call Vec<&Operand> and
String replace("_format_d16_") heap allocations.
Measured (--release bench_lower_hot_paths, median of 3 runs, 2,821-inst CS):
- emit::lower: 2,053.6 -> 1,115.0 us/run (1.84x, -45.7%)
- Identical DXIL: 15,632 B, FNV-1a 0x8b22c9b628d798d0 before and after.
Assisted-by: T3 Code (Antigravity, gemini-4-neon)
1569277 to
08efa8e
Compare
|
Addressed both triage items in
Verified green on AI-assisted: T3 Code (Antigravity, gemini-4-neon) |
Dukestar69
left a comment
There was a problem hiding this comment.
Tested locally merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + dxil.dll):
cargo test -p victory-shader emit::lower::tests: 33 passed, 0 failed.cargo test -p victory-shader emit::tests -- --test-threads=1: 17 passed, 0 failed.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 192 files ok.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
fuzeofficlal
left a comment
There was a problem hiding this comment.
The dense Value tables, lazy get() mask checks, valu16 fast-reject, deferred effect scan, round16 fast path, and zero-alloc reads_mask_as_data/buffer helpers preserve the local semantics I checked, and emit/lower.rs stays under the 512 KiB policy limit (522,251 bytes).
One gap remains in the "100% bit-identical DXIL across all shaders" claim: read_phis switched to FxSet, and live_edges() seeds its LIFO work stack from self.read_phis.iter(). Because Known caps tracked conditions at MAX_KNOWN = 4 (dropping the oldest condition on overflow) while seen prunes subsets (d.get().iter().all(|c| known.get().contains(c))), changing read_phis iteration order can alter traversal order and potentially yield a different conservative live-edge set in fill_phis(). The 2,821-instruction benchmark is straight-line and does not exercise this path. Could you compare base and head DXIL on a branch-heavy phi case with a missing incoming value (or qualify the claim accordingly)?
Verified locally on Windows 11 x64 (RTX 5090 + WARP + dxil.dll, 08efa8e0):
cargo run --locked -p xtask -- policy: passed (192 files ok)cargo clippy -p victory-shader --all-targets --locked -- -D warnings(default and--all-features): cleanemit::lower::tables::tests: 1 passed, 0 failed (1 ignored bench)emit::lower::tests: 33 passed, 0 failedemit::tests -- --test-threads=1(RTX 5090 andVICTORY_WARP=1): 17 passed, 0 failed on both
Summary
Optimizes hot lowering paths in
crates/victory-shader/src/emit/lower.rsacross all shaders while emitting 100% bit-identical DXIL (and keepinglower.rsbelow the 512 KiBxtask policylimit by placing helper tables and tests incrates/victory-shader/src/emit/lower/tables.rs):Valuetables &FxMap/FxSet(emit/lower/tables.rs): replaces SipHashHashMaps forvals,floats, andphi_atwithDenseMap<T>(Vec<Option<T>>indexed byValue.0), and usesFxMap/FxSetfor internal pure-lookup maps/sets (leavingdef_block/Shaders: replace HashMap/linear scans in Lower with O(1) dense Vec tables #2210,user_at/Shaders: cache USER_DATA CBV rows and extracted dwords in Lower::user_at #2207, sub-dword stores/Shaders: use atomicCompareExchange CAS loop for buffer_store_byte and buffer_store_short #2208,memory/Shaders: guard memory_dirty atomics with test-before-or and coalesce page-table loads (FIND-12) #2167,counters, anduser_readsuntouched).is_maskcheck inLower::get(): defers the twost.masks/st.highsSipHash lookups into theMissing/Nonemask_okfallback instead of executing them unconditionally on every operand read.Lower::valu16(): skips scanning all 44 16-bit opcode names on every 32-bit VALU op when!name.ends_with("16") && name != "v_cvt_f16_f32".effectscan & encoding-gated checks inLower::inst(): movescontains("store")/contains("atomic")into theErr(why)arm only, and gatesmask_okstring checks onEncoding.round16,discards, andsectionschecks: skipsround16RPO/dataflow when nos_round_mode/s_setreg*exists, gatesround16_afteronSopp | Sopk, and hoists!discards.is_empty()andsections.contains_key(&b)outside per-instruction loops.reads_mask_as_data()&Lower::buffer(): borrows&[Operand]directly instead of collectingVec<&Operand>, and matchesformat_d16_*suffixes directly instead of allocatingname.replace("_format_d16_", "_format_")per buffer instruction.Measured (
--release bench_lower_hot_paths, median of 3 runs, 2,821-inst CS on63bcca4)emit::lower: 2,053.6 → 1,115.0 µs/run (1.84×, -45.7%)15,632 B, FNV-1a0x8b22c9b628d798d0before and after.Verification
emit::lower::tables::tests::dense_map_and_round16_fast_path_behave_identically.windows-latestMSVC + WARP SM 6.6 CI (clippy,xtask policy192 files ok, full workspace tests): https://github.com/RVZO6/VIctory/actions/runs/45730729035Not run: the title; any hardware GPU.
AI-assisted: T3 Code (Antigravity, gemini-4-neon).