victory-shader: fix 32 KiB TGSM guard, f32 wave prefix flag, and DPP/permlane safety #358
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: launcher
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
run report
security: hold
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs gpu test
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/Androtim--MiniVI!358
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-358"
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?
@Androtim on GitHub · 2026-12-02 15:52 UTC · original
Androtim:fix/shader-tgsm-waveprefix-dpp→main· +330 −7 · 4 files · 1 commits · openFixes P1/P2 shader lowering findings #9, #10, and #11 from #282 (related: #276).
Summary
crates/victory-shader/src/emit/lower.rs):self.s.lds_dwords > HOST_LDS_DWORDSunconditionally inLower::run(catchingticket,halves, andexchangeTGSM overflows even whenself.pairs.is_none()).ticketallocation on 1D multiple-of-wave shaders (cs.threads[1] == 1 && cs.threads[2] == 1 && group.is_multiple_of(wave)) already atHOST_LDS_DWORDS(32 KiB) so they use the linear wave base fallback instead of overflowing 32 KiB TGSM, while still catching 2D/3D/unaligned overflows cleanly.crates/victory-shader/src/emit/lower.rs):unsigned = u8::from(!float)(i.e.0forOp::AddF) todx.op.wavePrefixOp.f32instead of hardcoded1. (Bin::Addinbitcode.rsalready emits LLVMfaddwhen operand types arefloat.)crates/victory-shader/src/emit/lower.rs):row_shl/row_shrlaneIndexviaselect(in_row, src, lane)before callingwaveReadLaneAtso out-of-row lanes never pass negative/out-of-range lane indices.all_lane_blocks_nativeinstead ofall_lane_blocksforv_permlane16_b32/v_permlanex16_b32fi:1, rejecting fetch-inactive inside divergent loop latches as well as lane branches.Verification
cargo clippy -p victory-shader --all-targets --locked -- -D warnings(passed)cargo run -p xtask --locked -- policy(325 files ok)cargo test -p victory-shader --lib -- --test-threads=1suites including new regression tests (emit::lower::tests,emit::permlane_tests::permlane_fetch_inactive,emit::wave::tests,emit::wave64_tests,emit::size_tests,emit::waterfall_tests,emit::lds_sub_tests,emit::threading::tests,structure::tests,emit::bitcode::tests,bvh::tests,dxbc::tests,dxil::tests,ir::tests,resource::tests,spill::tests,emit::own_bits::tests,emit::container::tests,emit::cost::tests,emit::atomic_tests)github-bot referenced this pull request2026-12-02 16:06:14 +00:00
@Androtim on GitHub · 2026-12-02 16:08 UTC · original
Automated triage for the maintainers (not an approval).
Verdict:
needs-gpu-test· CI (check):passingReview Summary
CI is passing and all three fixes in
crates/victory-shader/src/emit/lower.rsare clean, tightly scoped, and backed by targeted unit/DXIL-validation tests:ticketfallback (Lower::run,Lowersetup incrates/victory-shader/src/emit/lower.rs):self.s.lds_dwords > HOST_LDS_DWORDSunconditional inLower::runproperly catches TGSM overflows fromhalves,exchange,ticket, and oversized program LDS even whenself.pairs.is_none().ticketallocation only whens.lds_dwords >= HOST_LDS_DWORDSon 1D multiple-of-wave groups (cs.threads[1] == 1 && cs.threads[2] == 1 && group.is_multiple_of(wave)) preserves lowering for full-32 KiB 1D shaders (e.g.,CS_CollectTriangles_Meshlets) while still rejecting 2D/3D/unaligned overflows cleanly.wavePrefixOp.f32signed/unsigned flag (crates/victory-shader/src/emit/lower.rs):u8::from(!float)(0forOp::AddF,1forOp::AddU) todx.op.wavePrefixOp.{sfx}aligns withwaveActiveOpand the DXIL specification.fi:1guard (crates/victory-shader/src/emit/lower.rs):srcviaselect(in_row, src, lane)beforeself.read_lane(x, safe)prevents out-of-range/negativelaneIndexvalues from reachingdx.op.waveReadLaneAtonrow_shl/row_shrboundary lanes.v_permlane16_b32/v_permlanex16_b32fetch_inactivefromall_lane_blockstoall_lane_blocks_nativecloses the gap for divergent loop latches.crates/victory-shader/src/emit/bitcode.rs,lower_tests.rs,permlane_tests.rs):#[cfg(test)]inspection helpers and regression tests cover each fix (including DXIL validation on Windows).Next Step
Because this changes emitted DXIL and shader acceptance rules (32 KiB TGSM/ticket fallback, float wave prefix ops, DPP
waveReadLaneAtclamping, andpermlanefi:1rejection), a local real-GPU smoke test is recommended before merging to confirm no regressions in title shader compilation or rendering.Generated with Antigravity CLI (
agy).View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.