Shaders: lower compute thread-group info and s_get_waveid_in_workgroup #551
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!551
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-551"
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?
@kilvynsilveira-tech on GitHub · 2026-11-24 04:49 UTC · original
kilvynsilveira-tech:shader-group-info-coverage→main· +399 −4 · 3 files · 1 commits · openLower 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)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 #1686.@KoLolX3 on GitHub · 2026-11-24 05:33 UTC · original
Check on Linux, not Windows: pass. Head
f96ce2927merged ontomaind2a4bae1f(clean merge).core,formats,game,loader,pe,pipeline,shader): PR94 passed, 7 failed,main92 passed, 7 failed.cargo xwin check --workspace --target x86_64-pc-windows-msvc, coversvictory-gpu,victory-hleand the app): PR ok,mainok.main168.mainhere as well (not this PR): 7 tests invictory-loaderandvictory-pethat parse their own test binary as a PE image, which is an ELF file on Linux.victory-gpu/victory-hletests and the game itself.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.
@catminou4 on GitHub · 2026-11-24 12:36 UTC · original
Triage note: overlaps #521 (
model the compute thread-group info SGPR's wave count), which merges cleanly with main. This PR (#551, compute group info + wave id in workgroup + more) is broader in scope but hasmergeable=falseagainst current main. If #521 lands first, this one needs a rebase and a scope check that the remaining pieces (wave id, group info beyond the wave count) are still distinct.@kilvynsilveira-tech on GitHub · 2026-11-24 15:01 UTC · original
Rebased onto current \main\ (\fe310e) and updated the new tests to pass \Some(&st)\ to
esource::track.
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:
@Calvix2k on GitHub · 2026-11-24 22:18 UTC · original
Overlap with #1686: this PR also lowers pixel sample coverage via
dx.op.coverage; #1686 does that part alone with a coverage-mask readback test and is already rebased onto70564ae. The compute group-info/wave-id lowering here is separate and may still be useful. Suggest splitting the coverage part out (or dropping it in favour of #1686) so the two do not compete.@Marvisak on GitHub · 2026-11-25 00:25 UTC · original · edited 2026-11-26 03:20 UTC
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
crates/victory-shader/src/emit/lower.rs,Input::GroupInfonow builds theTG_SIZESGPR asfirst_wavefront << 31 | wave_index << 6 | wave_count. That matches the public layout in LLVM AMDGPUUsage and the way Mesa ACO extracts the subgroup id (bits 6-11).s_get_waveid_in_workgroupreturns the same wave index through the newwave_id()helper, whichMergedWaveInfonow shares, and it is refused outside compute and mesh. The readback test invalu_tests.rscovers a partial wave64 wave and checks all 32 bits.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
@Calvix2k on GitHub · 2026-11-25 00:41 UTC · original
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.
@kilvynsilveira-tech on GitHub · 2026-11-26 02:19 UTC · original
Rebased onto latest
main(63bcca4->b97b7bb) and incorporated the review feedback and several improvements:SampleCoveragein favour of #1686 (thanks @Calvix2k for the heads-up) so this PR stays focused on computeGroupInfo(TG_SIZE_EN) ands_get_waveid_in_workgroup.TG_SIZE_ENhardware field layout: in addition to the masked 6-bit wave count (threads.div_ceil(wave) & 0x3F, bits5:0) and wave index (flattenedThreadIdInGroup >> log2(wave), bits11:6), bit31(first_wavefront,w == 0) is now populated too ({first_wavefront, 14'b0, wave_id[10:0], wave_count[5:0]}), so full-width reads,first_wavechecks,s_bfe_u32/s_and_b32extractions, and values carried across phis/copies all match the console register layout.s_get_waveid_in_workgrouppolish: handlesnulldestination without emitting dead instructions, and coversHwStage::Msas well asPs/Vsrefusals.emit/mod.rssoemit/lower.rsstays below the 512 KiBxtask policylimit, and addedemit::valu_tests::compute_group_info_and_waveid_in_workgroup_match_the_groupto verify per-threadTG_SIZEands_get_waveid_in_workgroupreadback across a[8, 4, 3]96-thread group in bothwave32andwave64on SM 6.6 / WARP).Verified locally:
cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: cleancargo run -p xtask --locked -- policy:191 files okdxil.dllcontainer & hash validation passing on all emittedCs(wave32/wave64) andMsshaders.@fuzeofficlal on GitHub · 2026-11-26 17:05 UTC · original · requested changes
Verified
b97b7bb6f5ed7229944ebbee0f020049e4819986merged cleanly onto63bcca43on Windows 11 with an RTX 5090, WARP,dxil.dll, andVICTORY_D3D12_DEBUG=1(xtask policy:191 files ok;cargo clippydefault &--all-featuresclean;emit::tests::18/18,emit::valu_tests36/36,emit::census_tests1/1passed;emit/lower.rs=522,146B,523,467B combined with#2084).Blocking issue:
TG_SIZE_ENwave-ID bit position does not match the RDNA2 CS layout (crates/victory-shader/src/emit/lower.rs:1497-1513)Input::GroupInfocurrently packs the wave index into bits[16:6](w << 6), citing LLVM AMDGPUUsage (Initial Kernel Execution State). However:COMPUTE_PGM_RSRC2.TG_SIZE_ENas:[5:0]:wave_count[17:6]:ordered_append_term(11/12-bit ordered-append counter — not wave ID)[24:20]: wave ID within workgroup (first_wavein bit31)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
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 on GitHub · 2026-11-26 19:50 UTC · original · approved these changes
LGTM — verified on RTX 5090 and
VICTORY_WARP=1(Windows / D3D12) againstorigin/main(63bcca4).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).
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.