Split wave32 geometry: refuse prefix counts over a mask #44
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!44
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/44/head"
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?
@grahamster2 on GitHub · 2026-11-22 20:31 UTC · original
grahamster2:fix/wave32-mask-prefix-count→main· +137 −3 · 3 files · 1 commits · merged 2026-11-22 21:33 UTCSummary
The split wave32 form of a logical wave64 (geometry mode on adapters without 64-lane waves, e.g. NVIDIA, since #14) gives each native half only its own word of EXEC, VCC and
v_cmpresults.geometry_wave32_hazardsrefuses the cross-half operations, but it had no rule forv_mbcnt_lo/hiover a mask. For lanes 32..63,v_mbcnt_loofexec_lo/vcc_lo/ av_cmpSGPR pair then counts 0 instead of the active lanes of 0..31, so a compaction index or prefix count is silently wrong.v_mbcnt_*whose SRC0 is not an inline constant or literal is now a hazard ("prefix count over a whole-wave mask"). The lane-index idiom (v_mbcntof -1) stays accepted.v_cmpinto an SGPR pair is a mask too, ingeometry_wave32_hazardsand inmesh_wave's taint. Sos_bcnt/s_ff1/s_flbitof one of its 32-bit words, and ans_cmpof such a word that a branch reads, are refused like the 64-bit forms.Emission is unchanged.
Test
gpu_geometry_wave32_prefix_count_over_a_mask: an ES computes VCC (lanes withlane & 3 != 0) ands[10:11](lanes below 40), thenv_mbcntover VCC, overs[10:11]and over EXEC afters_and_saveexec, and stores the three counts. It runs the compute pass only (runner::dispatch), so an adapter without mesh shaders can run it too. If the split translation is refused, the test passes. If it translates, the output must equal a CPU wave64 reference. The native translation must always succeed, and on a wave64 adapter it also runs and is checked against the reference.Before the fix, on both an RTX 3080 (wave 32) and a Radeon RDNA2 iGPU (forced to the split form), lanes 0..31 were right and lanes 32..63 counted only their own half, e.g. got / want for [VCC, s[10:11], EXEC]:
After the fix, it passes on both, and the native wave64 run on the iGPU matches the CPU reference.
geometry_wave32_rejects_cross_half_operationsand a newmesh_waveunit test cover the new rules.cargo test --workspace --release --no-fail-faston the RTX 3080 withXCL_SAMPLE_RPFset to a retailshaders.rpf: lib 328 passed, 0 failed.gpu_pso_e2egives 4 / 6, the same 2 mesh failures as onmain(wave64 MS on a 32-lane adapter, #39 / #42).retail_es_gs_voxelize_geometry_modeandretail_gs_pipeline_through_the_hookstill pass, and the first of them uses the split path there. All 195 ES+GS pairs of that pack passgeometry_wave32_hazardsbefore and after, so the new rule refuses no retail program.Open question
The
v_mbcntrule refuses any non-constant SRC0, including an SGPR that only holds a constant. That fails closed like the other rules. A taint-based version is possible if you'd prefer it. #39 will need the same check for the mesh path, so this rule would apply there too.@ivall on GitHub · 2026-11-22 21:33 UTC · original
Thanks, merged! On an RX 9070 (native wave64) all tests pass,
gpu_pso_e2etoo with a retailshaders.rpf(6 / 6). It changes nothing there, as expected. Thev_mbcnttable is a nice catch.