Shaders: build Halves def/phi table lazily as a compact Vec<Def> in io::raise #2784
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!2784
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2784"
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 20:23 UTC · original
RVZO6:rvzo/io-lazy-defs→main· +186 −65 · 1 files · 1 commits · openClaimed in #1633: #1633
Summary
io::raiseincrates/victory-shader/src/io.rs(+186/-65, including test and benchmark) previously built two full-program SipHashHashMaps (defsandphis) unconditionally on every shader, even thoughHalvesis only ever used on pixel-shaderv_interp_p2_f32/v_interp_p2_f16instructions (100% wasted work on every vertex, compute, and mesh shader, and on pixel shaders withoutv_interp_p2_*).Changes (100% identical
Iooutput):Vec<Def>(enum Def { None, Phi(u32, u32), Inst(u32, u32) }) lazily insideHalveson the firstv_interp_p2_*instruction.inputsdirectly intoIowithout cloning, passing&io.inputstobarycentric_of.Measured on
13f91ca(--release io::tests::bench_io_raise, median of 3×200 runs, 4,000 instructions)13f91ca)v_interp_p2_*)180.0 µs/run7.9 µs/runv_interp_p1/p2pairs)195.2 µs/run44.6 µs/runNot a duplicate of
Halves/defs+phisconstruction inio.rs.Verification
windows-latestMSVC + WARP SM 6.6 CI (both clippy-D warningsprofiles,xtaskpolicy 6/6,victory-shader272/272 including newhalves_defs_are_lazy_and_match_phi_and_inst_defs): https://github.com/RVZO6/VIctory/actions/runs/45693633259AI-assisted: T3 Code (Antigravity, gemini-4-neon)
@kotekompotek on GitHub · 2026-11-25 20:40 UTC · original
Lazy Halves construction removes the upfront defs+phis HashMaps from every io::raise call - a real win since most programs never query halves at all. Moving them behind a build-on-first-use keeps the lookup semantics identical.
@oni-swr on GitHub · 2026-11-25 20:57 UTC · original
Independent WARP/CPU verification of head
09c4783f3bab56bc3af74fd4adf8d5c0d132cd5fmerged cleanly ontoorigin/main13f91caee25f2fdf2c062be5f7a27f058e51cbca.Environment: Windows 11 x64, WARP/CPU only (
VICTORY_WARP=1,VICTORY_D3D12_WARP=1), no physical GPU, no game files; Windows SDK 10.0.26100.0 x64dxil.dll1.8.2502.11.Tests (
cargo test --no-fail-fast): victory-shader: 268 passed, 3 failed, 4 ignored (baseline 267 passed, 3 failed, 3 ignored; +1 new test, +1 ignored benchmark). victory-shader baseline onorigin/main: 267 passed, 3 failed, 3 ignored; the 3 failures (synthetic_tests::a_mask_joined_with_data_at_a_uniform_loop_is_its_number,gathers_at_a_level_match_the_hardware,permutes_read_the_lane_named_and_zero_from_lanes_left_out) fail identically onorigin/mainunder WARP, so they are not caused by this PR.Negative control: mapping phis to
Def::Instinensure_defsmakeshalves_defs_are_lazy_and_match_phi_and_inst_defsfail; restored afterwards. The existing interpolation tests (7) still pass.Clippy:
cargo clippy -p <affected crates> --all-targets -- -D warningsclean (exit 0).fmt:
cargo fmt --checkis not clean onorigin/mainitself (891 diff hunks across many files); this PR: 894 hunks (+3 vs main, in the touched file).Review: The dense
Vec<Def>is equivalent to the two HashMaps (SSA values have one definition) and out-of-range ids resolve toDef::None, as the old map lookups missed; behaviour is preserved. Diff contains no game files, dumps, shader names or retail hashes.AI disclosure: this verification was done by Claude Code (Claude Sonnet 5.5).
@fuzeofficlal on GitHub · 2026-11-25 21:13 UTC · original
Reviewed and benchmarked
09c4783fon Windows 11 (RTX 5090 + WARP + Windows SDK10.0.26100.0dxil.dll) againstmain(13f91ca).Code review
HashMaps with a lazily constructed compactVec<Def>(ensure_defs()only onv_interp_p2_f32/v_interp_p2_f16pair()calls) and movinginputsdirectly intoIois cleanly equivalent: out-of-range / input IDs returnDef::Nonevia.get(), matching priordefs.get() == None && phis.get() == None.Verification & same-machine
--releasebenchmark (rustc 1.98.1MSVC)io::tests: 5/5 passed (includinghalves_defs_are_lazy_and_match_phi_and_inst_defs); WARP +dxil.dllfullvictory-shader --features host: 268 passed, 0 failed (skipping only the 3 hardware-onlysynthetic_tests); RTX 5090 +dxil.dll: 255 passed, 0 failed (0 regressions).cargo clippy --locked -p victory-shader --all-targets -- -D warnings(default &--features host): 0 warnings;cargo xtask policy: 184 files ok.io::tests::bench_io_raise(--release, 3-run median × 200 iters, 4,000 insts, vs13f91ca):cs(nov_interp_p2_*):198.3 µs/run->3.5 µs/run(56.7× / -98.2%)ps_16interp(16 interp pairs):204.7 µs/run->13.3 µs/run(15.4× / -93.5%)git merge-treeagainst13f91ca,#2664, and the full 4-way merge#2784 + #2785 + #2786 + #2787.@Marvisak on GitHub · 2026-11-25 23:24 UTC · original
Automated triage for the maintainers.
In
io::raise(crates/victory-shader/src/io.rs), the two whole-programdefs/phisHashMaps were built for every shader. They are replaced by a denseVec<Def>insideHalves, built only on the firstv_interp_p2_*, andinputsis moved intoIoinstead of cloned. I comparedHalves::joinedandHalves::siteswith the old lookups: each SSA value has one definition, and an unknown id resolves toDef::Nonejust as a missing map entry did, so the output is the same. The gain is per-shader translation time (about 0.2 ms each on a large synthetic program). A maintainer may want the ignoredbench_io_raisetest, which only prints timings, left out. CI passes.This is a recommendation for a maintainer to look, not an approval.
Generated by Claude Code
@Dukestar69 on GitHub · 2026-11-26 03:09 UTC · original · approved these changes
Tested merged onto
origin/main(63bcca4) on Windows 11 x64:cargo test -p victory-shader --lib io::tests: 5 passed, 0 failed, 1 ignored (including newhalves_defs_are_lazy_and_match_phi_and_inst_defs).cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@fuzeofficlal on GitHub · 2026-11-27 00:53 UTC · original · approved these changes
LGTM — the lazy
Vec<Def>table inHalvesis clean and semantically equivalent to the previousHashMapimplementation for SSA programs fromir::build: out-of-range lookups and holes from eliminated phis safely resolve toDef::None,u32indices avoidu16truncation,io::tests(5/5),clippy(--all-targetsand--all-features), andxtask policyall pass, with no regressions acrossvictory-shader.Two small non-blocking notes:
rustfmt --edition 2024 --check crates/victory-shader/src/io.rsflags wrapping on threeassert!lines in the newhalves_defs_are_lazy_and_match_phi_and_inst_defstest (io.rs:844,:851,:856).Programwith a sparseValue(u32::MAX)definition to the publicio::raiseAPI,max_vinensure_defswould attempt to allocateu32::MAX + 1entries (not reachable viair::build).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.