dxil/shader: dominator-scoped LDS range bounds coalescing and split-reciprocal format_load #181
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ReTerryDavis--ReVIctory!181
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-180"
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?
@Zalthor on GitHub · 2026-12-05 21:33 UTC · original
Zalthor:shader/lds-range-bounds-and-format-load→main· +959 −201 · 8 files · 1 commits · openSummary
Cuts DXIL instruction count and shader bounds/conversion overhead without disabling safety checks:
crates/victory-dxil/src/bitcode.rs,opt.rs,opt_tests.rs,crates/victory-shader/src/emit/shader.rs,lds_gs.rs,tests.rs):IntRange { max, may_one }) and dominator-scopedFacts::max_upropagation in DXILopt.rsto fold provably in-bounds integer comparisons and eliminate redundant LDS guard branches safely.Op::Phiincoming operands with&Facts::default()so loop-body branch guards cannot leak across loop backedges, uses DXIL opcodes135(WaveAllBitCount,0..=w) and136(WavePrefixBitCount,0..=w-1) for wave bit-count bounds, respects operandint_bitsinCountbits(31), and uses checkedu128arithmetic forflattenedThreadIdInGroup(96).ds_read/ds_writebounds checks and simplifies dword indexing viadword_index().int_range_*unit tests inopt_tests.rsandlds_b128_coalesced_read_and_write_lower_and_validateinlower/tests.rs(verifyinglds_blocks = 2shrinks DXIL below the clampedlds_blocks = 1fallback).norm_f32_splitforformat_load(crates/victory-shader/src/emit/lower/memory.rs):UNORM/SNORM(1..=16-bit) integer division sequences informat_loadwith bit-exact IEEE-754 split-reciprocal multiplies (norm_f32_split), exhaustively tested over all normalized codes (split_reciprocal_is_bit_exact_for_all_normalized_codes).TRANSLATOR_VERSIONincrates/victory-shader/src/lib.rs.Verification
origin/mainca49e25, post-review):cargo clippy --workspace --all-targets --locked -- -D warningsandcargo clippy --workspace --all-targets --all-features --locked -- -D warningspass (0warnings).--all-features -- --test-threads=1tests pass acrossvictory-dxil(27 passed; 0 failed),victory-shader(270 passed; 0 failed; 2 ignored; 55 filtered out+5 passed; 0 failedrunnable non-SM-6.6valu_tests/intersect_tests; the remaining SM 6.6 tests require a newer D3D12 runtime than Win10 LTSC inbox), andxtask(9 passed; 0 failed).victory.exe translate --validate --list+VICTORY_SHADER_CENSUS, RDNA 4 Wave64):25,889 / 25,889shaders emitted and validated cleanly bydxil.dll(0validation errors).25,887common shaders):84,791,842 -> 81,140,547total DXIL instructions (-3,651,295,-4.31%):arith -2,619,151 (-7.59%),select -593,213 (-6.58%),bitcast -349,898 (-3.13%),cast -127,697 (-4.86%),blocks -15,514 (-0.50%)-12.15%(8,765shrank), Vertex-10.02%, Compute-3.50%, Pixel-0.64%.builtin:cruise,VICTORY_GPU_TIMINGS=1,VICTORY_FSR_FRAMEGEN=0real frames only):VICTORY_LDS_BOUNDS=0while remaining 100% bounds-safe:[compute 87bf9e3f2bf2f052](-271 op / -84 blk):0.142 -> 0.090 ms(cruise_back),0.230vs0.290 msunsafeLDS0(spawn_idle)[compute f8425d3c03df62a0](-400 op / -32 blk):0.213 -> 0.180 ms(spawn_idle),0.204 -> 0.158 ms(cruise_out)[mesh fd08d25a8c755b78, pixel 11f05e25425baf60](-500 op):0.257 -> 0.205 ms(spawn_idle)[mesh 244ca58c13650317, pixel 73644c6a0b7b5b35](-1,083 op):0.150 -> 0.090 ms(cruise_back)4e9c5f8d61to19fdb32159View 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.