Repository navigation
Shaders: lower compute thread-group info and s_get_waveid_in_workgroup - #551
kilvynsilveira-tech wants to merge 1 commit into
Conversation
|
Check on Linux, not Windows: pass. Head
On: AMD Ryzen 7 5700, 62 GB RAM, Artix Linux 7.3.4-artix1-2, rustc 1.98.1 (the repo's pinned toolchain), cargo-xwin 0.24.1. No game data. Automated check only: the code itself was not reviewed. |
|
Triage note: overlaps #521 ( |
f96ce29 to
9670518
Compare
|
Rebased onto current \main\ (\fe310e) and updated the new tests to pass \Some(&st)\ to Regarding the overlap with #521:
If #521 lands first, I'm happy to rebase again and keep only the distinct pieces. Re-verified after rebasing:
|
|
Overlap with #1686: this PR also lowers pixel sample coverage via |
|
Automated triage for the maintainers. Thanks for rebasing and for dropping the coverage part in favour of #1686. The new head merges cleanly and is now reviewed. In This also covers the wave-count part of #521, so only one of the two should land. Verdict: merge candidate (a recommendation to look, not an approval). CI: passing. Generated by Claude Code |
|
Triage is right: the branch is based on fe310e and crates/victory-shader/src/emit/lower.rs has moved since. I do not have push access to your fork, but the conflict is confined to the lower match arms for the group-info ops; a git rebase origin/main and keeping the new arms alongside the added ones resolves it. Happy to review the rebased head. |
Model the full COMPUTE_PGM_RSRC2.TG_SIZE_EN layout ({first_wavefront, 14'b0, wave_id[10:0], wave_count[5:0]}), lower s_get_waveid_in_workgroup in compute and mesh stages, and share wave_id() with MergedWaveInfo. Drop SampleCoverage in favour of Marvisak#1686.
9670518 to
b97b7bb
Compare
|
Rebased onto latest
Verified locally:
|
fuzeofficlal
left a comment
There was a problem hiding this comment.
Verified b97b7bb6f5ed7229944ebbee0f020049e4819986 merged cleanly onto 63bcca43 on Windows 11 with an RTX 5090, WARP, dxil.dll, and VICTORY_D3D12_DEBUG=1 (xtask policy: 191 files ok; cargo clippy default & --all-features clean; emit::tests:: 18/18, emit::valu_tests 36/36, emit::census_tests 1/1 passed; emit/lower.rs = 522,146 B, 523,467 B combined with #2084).
Blocking issue: TG_SIZE_EN wave-ID bit position does not match the RDNA2 CS layout (crates/victory-shader/src/emit/lower.rs:1497-1513)
Input::GroupInfo currently packs the wave index into bits [16:6] (w << 6), citing LLVM AMDGPUUsage (Initial Kernel Execution State). However:
- AMD RDNA2 ISA §3.12.2 defines
COMPUTE_PGM_RSRC2.TG_SIZE_ENas:- bits
[5:0]:wave_count - bits
[17:6]:ordered_append_term(11/12-bit ordered-append counter — not wave ID) - bits
[24:20]: wave ID within workgroup (first_wavein bit31)
- bits
- For a 96-thread Wave32 workgroup, wave 1 produces
0x0000_0043in this PR versus0x0010_0003under the documented RDNA2 layout (with zero ordered-append term). Becauseemit/valu_tests.rs:2410-2418assertsw << 6, the test mirrors the same assumption.
Please either verify and document if the console ABI places the wave ID at bit 6 on real RDNA2 hardware, or move the wave ID field to bits [24:20] and assert the full SGPR value against the ISA layout.
Additional notes
- Please validate the compute thread-group dimensions before
cs.threads.iter().product::<u32>()(lower.rs:602/:1501-1505) so zero dimensions or overflowing products return a structured lowering error instead of panicking or truncating the 6-bit wave count (& 0x3F). s_get_waveid_in_workgroup(lower.rs:4139-4152) accepts both compute and mesh stages (self.s.threads.is_some()), so updating its error text to mention both (and checkingM0destination rules) would keep diagnostics accurate.
Dukestar69
left a comment
There was a problem hiding this comment.
LGTM — verified on RTX 5090 and VICTORY_WARP=1 (Windows / D3D12) against origin/main (63bcca4).
- Lowering compute thread-group info (
tg_size) ands_get_waveid_in_workgroupvalidates cleanly with DXIL and produces matching wave/group IDs on both RTX 5090 and WARP. cargo test -p victory-shader --lib group_info_and_waveid_in_workgroup -- --test-threads=1: 2 passed, 0 failed on RTX 5090 and 2 passed, 0 failed onVICTORY_WARP=1(group_info_and_waveid_in_workgroup_lower_and_validateandcompute_group_info_and_waveid_in_workgroup_match_the_group).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).
Lower two workgroup wave-identity inputs the emitter previously refused:
COMPUTE_PGM_RSRC2.TG_SIZE_EN): was"the thread-group info SGPR". Now packs the full hardware layout{first_wavefront, 14'b0, ordered_append_term[10:0], wave_count[5:0]}(LLVM AMDGPUUsage, Initial Kernel Execution State):5:0: wave count in the group (threads.div_ceil(wave) & 0x3F, counting partial trailing waves).11:6: wave index in the group (flattenedThreadIdInGroup >> log2(wave)), matching Mesa ACO'stg_sizesubgroup-id extraction (& 0xfc0/s_bfe_u32at offset 6, width 6) when GDS ordered append is disabled.31:first_wavefront(1on wave0,0otherwise).s_get_waveid_in_workgroup: was"a scalar memory read as data". Now writes the same wave index to its destination SGPR in compute and mesh stages (nulldestination is a no-op), and refuses cleanly outside compute and mesh (Ps/Vs).Input::MergedWaveInfonow shares the sameLower::wave_id()helper.(Note: pixel
Input::SampleCoveragewas dropped from this PR in favour of #1686 so the two PRs do not overlap.)Tests (synthetic machine code only;
cargo xtask policypasses)emit::tests::group_info_and_waveid_in_workgroup_lower_and_validate(cross-platform +dxil.dllcontainer/hash validation on Windows): compute inwave32andwave64([96, 1, 1], joined across control flow, plusnulldestination),s_get_waveid_in_workgroupinHwStage::Ms, and clean refusals inHwStage::PsandHwStage::Vs.emit::valu_tests::compute_group_info_and_waveid_in_workgroup_match_the_group: 3D[8, 4, 3](96-thread) compute dispatch in bothwave32(3 waves) andwave64(2 waves, partial trailing wave), verifying all 32 bits ofTG_SIZE(first_wavefront | wave_id << 6 | wave_count) ands_get_waveid_in_workgroupper thread on available SM 6.6 hardware and WARP backends.Validation
cargo clippy --workspace --all-targets --locked -- -D warnings— cleancargo clippy --workspace --all-targets --all-features --locked -- -D warnings— cleancargo run -p xtask --locked -- policy— clean (191 files ok)cargo test -p victory-shader --locked— new tests and non-SM 6.6 suite pass locally (dxil.dllvalidated; live SM 6.6 / WARP dispatch runs in CI and on SM 6.6 hosts; local GPU is RX 580)