help wanted: GPU translation, part 2 (mesh shaders) #1998
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows#1998
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@denn0x on GitHub · 2026-11-24 22:51 UTC · original
Follow-up to #1760. The source-built slices merged so far (#1913, #1779) cover bounded runtime geometry and multi-primitive lowering. A census of mesh-stage programs from a private corpus (aggregate counts only; about 4,000 distinct programs in the group form: LDS, group barriers, per-lane ranges,
v_readfirstlane) shows which constructs still stop a translation. Each row is a separate piece of work that one person can take with a source-built fixture.Constructs (pick one, say so in a comment)
v_writelane_b32/v_readlane_b32used as spill slots for scalar registers, including saved exec maskspos1): clip and cull distancesSV_ClipDistance/SV_CullDistance; the component count comes from pipeline state.What a contribution needs
Notes
Related: #1760, #1759, #1541, #1543, #1143.
@avt0m4t48 on GitHub · 2026-11-24 23:11 UTC · original
I’ll take item B, the constant-lane scalar spill and reload pattern in the bounded mesh path. The source-built wave64 fixture covers a selected lane outside EXEC and a saved EXEC high word that changes control flow. I’m checking pixel readback before submitting the patch.
@avt0m4t48 on GitHub · 2026-11-24 23:13 UTC · original
I’m releasing my claim on item B so someone else can take it. The source-built CPU and DXIL checks passed locally. Pixel readback is still open.
@R0Y00 on GitHub · 2026-11-24 23:26 UTC · original
Item B is available again. If the source-built spill/reload fixture is shareable, please link the source revision and its CPU/DXIL test commands here so the next contributor can start at the GPU readback. The remaining discriminator is a wave64 case that recovers a selected lane outside EXEC and a saved high word whose removal changes the fenced pixel result. Use the existing bounded mesh draw fixture and report capability skips separately.
@Leyukaka on GitHub · 2026-11-25 00:40 UTC · original
Item F (clip and cull distance exports): what blocks it in the mesh tools, from reading
tools/mesh_entry_aot.pyandtools/mesh_dynamic_aot.pyat5a0b0aa. Nothing was run.prim,pos0andparam0only (mesh_entry_aot.py, the export regex). Any other target raises "Unsupported mesh export".mesh_dynamic_aot.pyinherits that parser throughRuntimeWave(Wave).decode_meshtakes the limits from PSV0 and the code from the DXIL chunk.PA_CL,CLIP_DIST,CULL_DIST,CCDIST,ClipDistanceorCullDistancefinds nothing.PA_CL_VS_OUT_CNTL:CLIP_DIST_ENA_0..7,CULL_DIST_ENA_0..7,VS_OUT_CCDIST0/1_VEC_ENA, plusVS_OUT_MISC_VEC_ENAand theUSE_VTX_*bits. As far as I know, in Mesa's layoutpos1is the misc vector (point size, layer, viewport) when that is enabled, and the distance vectors then move topos2/pos3. Sopos1is not always a distance vector, and any guessed layout is wrong for some mix of enables. I have not checked whether the hardware mandates that numbering.SV_ClipDistanceN/SV_CullDistanceNfields, write the export operands in ascending index order, and refuse unknown or contradictory layouts with the target and reason.AI-assisted.
@akimfomin on GitHub · 2026-11-25 01:11 UTC · original
Item B independent GPU readback on Leyukaka's exact #2127 head
2dc58a8bdf7e. Thanks to avt0m4t48 for the earlier CPU/DXIL work and the requested inactive-lane and high-word controls. PortBridge used that request to prepare an independently generated fixture.With only guest lane 0 active, the source saves
EXEC_LO=1andEXEC_HI=0x100into inactive lanes 8 and 40. LLVM assembled and decoded the three gfx1013 guest Wave64 programs. On RTX 4070 Ti SUPER (driver32.0.16.1714, Win11 build28000), the complete spill drew all 1,024 expected green pixels. Zeroing either word left all 1,024 pixels clear as expected. The stale-pixels-only control kept the good export trace and produced the expected 1,024/1,024 mismatches. D3D12 debug layer was unavailable; the hardware device and fenced readback were verified.The passing cases use inline selectors. A separate source-built case with known SGPR selectors still gets the documented refusal. Exact source, CPU/DXIL reproduction and hardware transcript · PortBridge Test Lab. AI-assisted with Codex.
@tedin7 on GitHub · 2026-11-25 01:23 UTC · original
Picking up Item A (branch on SCC any-lane-active in mesh) with unit + WARP/verification tests.
@tedin7 on GitHub · 2026-11-25 01:40 UTC · original
Picking up Item C (non-spill exec mask restore inside a per-lane range) and Item G (scalar written inside a skipped range and live after it) as two separate PRs with mesh tests.
@tedin7 on GitHub · 2026-11-25 01:43 UTC · original
Also picking up Item D (descriptor identity differing between the two arms of a join) as a separate PR with mesh verification tests.
@R0Y00 on GitHub · 2026-11-25 02:36 UTC · original
Item B landed in #2127 (
498c23cc). The bounded translator now handles the constant-lane spill/reload with EXEC cleared and rejects an unwritten slot or mixed ordinary VGPR use. The final head passed the local CPU model, including both EXEC halves. The independent GPU report remains the reference for the fenced inactive-lane/high-word comparison. Keep runtime-geometry support and the other claimed items separate. Independent readback@roansystemlabs on GitHub · 2026-11-25 05:10 UTC · original
I'd like to take item E, sampler state loaded from a descriptor in the bounded mesh path. If someone already has it in progress, I'll step back and review.
Scope: reuse the opt-in sampler table from #1217/#1237 (s0, space1, 16-byte descriptor stride) for mesh programs in tools/mesh_dynamic_aot.py, where the sampler is loaded with s_load from a heap base plus a constant or bounded offset. Anything else (unbounded index, sampler word changed after the load, mixed static and heap use in one join) stays refused by name.
Evidence: a source-built mesh pipeline assembled with LLVM 15 llvm-mc for gfx1013 that samples one texture through two different heap samplers (distinct address modes and LOD limits), drawn on WARP and an RTX 3070 with fenced pixel readback. Negative controls: swapped sampler entries and the default-sampler shortcut must change the readback; the guard removed must fail.
AI-assisted.
@RavenCurseBurg on GitHub · 2026-11-25 06:59 UTC · original
I'll take the early-exit slice of item H for the bounded two-wave64 mesh lowerers. AMD's RDNA 2 ISA §4.3 says a wave can terminate with S_ENDPGM and the remaining live waves can satisfy later barriers. Both current lowerers require identical barrier-PC lists even though Wave.run already requires each executed path to reach S_ENDPGM.
I'll exercise a common barrier followed by one wave terminating and the other continuing to a later barrier. Two live waves reaching different barrier PCs at the same phase must still be refused. The tests will use a source-built program, an independent two-wave arrival/termination reference and GPU readback; runtime LDS sharing and loops are outside this slice.
AMD RDNA 2 ISA, §4.3
AI-assisted (Codex, GPT-6.2 Astra xhigh).
@R0Y00 on GitHub · 2026-11-25 07:04 UTC · original
The item H early-exit slice is available and distinct from #2220. Please proceed with the existing bounded two-wave64 profile. Keep the common first barrier, then let one wave terminate while the survivor reaches its next barrier. Include both wave orders, a readback sentinel that detects a missing surviving-wave write, and a refusal when two live waves reach different barrier PCs. Please include the exact LLVM 15 assembly and WARP/hardware test commands in the PR, with capability skips reported separately.
@RavenCurseBurg on GitHub · 2026-11-25 07:14 UTC · original
I also reproduced a separate input-path blocker while assembling the early-retirement fixture. #2241 can use a shared final S_ENDPGM. Giving the retiring wave its own reachable S_ENDPGM produces the same mesh exports at the wave-model entry point, but the normal stage-13 container extractor refuses the program before either CLI reaches the model. This is the mesh-stage exclusion noted in #721.
I’ll take the bounded two-exit mesh-container follow-up. I’ll check the two decoded exits under gfx1013 wave64, preserve the reachability and instruction-boundary checks, and run a real allocation/position/primitive-export fixture through both CLI entry points and a device readback. An incorrectly tagged compute program, an unreachable alternate path and additional exits will remain controls. I’ll keep it separate from #2241.
@RavenCurseBurg on GitHub · 2026-11-25 07:42 UTC · original
#2241 now covers both requested retirement orders at
5bd2ea09. In the 320-byte reverse-order fixture, wave 0 allocates 68 vertices, writes vertices 0–63, and terminates. Wave 1 traverses the later barrier and supplies vertices 64–67. Both host evaluation orders yield the same barrier traces ([172] and [172, 184]) and primitive indices. The second primitive reads vertex 67.The static and runtime CLI results matched all 1,024 pixels on WARP and a physical D3D12 adapter. Keeping vertex 67 at vertex 2’s position instead removes exactly 528 pixels on each adapter. Both live-wave mismatch refusals are still exercised. The PR description now includes the exact LLVM 15 and draw commands.
@roansystemlabs on GitHub · 2026-11-25 08:31 UTC · original
I'd like to take item F, the clip and cull distance exports, in the bounded mesh path. If someone already has it in progress, I'll step back and review.
Following the analysis above, the export alone can't say which position export carries the distances, so the first slice takes the PA_CL_VS_OUT_CNTL word as an explicit input of the lowerer instead of guessing a layout.
First slice (one PR):
Evidence: source-built mesh programs assembled with LLVM 15 for gfx1013 that export a position plus clip and cull distances, drawn on WARP and an RTX 3070 with fenced pixel readback. A triangle crossing a clip plane must lose exactly the pixels where the interpolated distance is negative, and a primitive whose cull distances are all negative must disappear while its neighbour stays. On current main the same programs stop at "Unsupported mesh export". Negative controls: clip and cull components swapped, CCDIST0 and CCDIST1 swapped, one enabled component dropped, and the guard removed must each fail. Not tested: AMD or Intel GPUs and console hardware.
AI-assisted.
@NiiRoZz on GitHub · 2026-11-25 08:51 UTC · original
I'd like to take the census part of item I: separating the loop-specific first refusals from A–H.
Plan:
tools/mesh_*_aot.pyat a namedmainrevision over mesh-stage programs from a private corpus, in a mode that records the first refusal and, separately, every refusal inside a loop body.exec, loop-carried scalars, trip count constant or data-dependent), and which construct stops each first, split into "already one of A–H" and "loop-specific".No lowering change in this slice. If the census isolates a loop shape that is small and unclaimed, I'll propose it here before starting.
AI-assisted (Claude Code).
@R0Y00 on GitHub · 2026-11-25 09:01 UTC · original
These are separate claims and can proceed in parallel. For item F, use the explicit state word and keep the slot 57 lookup separate. Please pin the public register table and export-order references. Test clipping a partly visible triangle separately from culling a whole primitive, and keep the two-vector swap and unsupported state controls.
For item I, start with the aggregate census at a named revision. Count each program once by its first refusal, with separate totals for loop-local observations, and distinguish an observed back edge from a proved loop trip count. Start with a minimal source-built example for each distinct refusal that affects the ordering of fixes. Keep the private corpus, its code and raw logs local.
@NiiRoZz on GitHub · 2026-11-25 10:06 UTC · original
Item I, census part. Counts only; the corpus, its code and the raw logs stay local.
Short version. At the revisions below, no program of this corpus is stopped by a loop: every program with a back-edge is refused before its first loop, by both bounded lowerers. So loop-specific refusals still cannot be separated from A-H by running the lowerers. What can be measured is the static shape of the loops and what stands in front of them.
Method
tools/mesh_entry_aot.py(lower, 128 zero geometry words) andtools/mesh_dynamic_aot.py(enumerate_variants, 128 run-time words), once per program, each program counted once by its first refusal.mainc4309205, and the lowerer sources ofmain77a204d6(#2276). The tables are identical at both. Between #2151 and #2276 both lowerers raisedTypeErroron every program, so nothing can be measured there.llvm-mcfor gfx1013 wave64, not the LLVM C library (not available on the machine used).s_cbranch_scc1 65533). The census reads it signed. The lowerers do not: a decoded back-edge raisesKeyErrorinstead of "Expected a forward mesh branch" (separate small fix, PR to follow).Coverage
One local extraction of one build. The 309 excluded containers are not de-duplicated and may hold loops.
Loops (CONFIRMED, static)
s_cbranch_scc0/s_cbranch_scc1/s_cbranch_execnz/s_cbranch_vcczFirst refusal (CONFIRMED)
As decoded, both lowerers:
Unsupported scalar instruction s_setreg_imm32_b324,274 of 4,458 programs (95.9%) stop at the flat-scratch setup: two
s_setreg_imm32_b32writes toHW_REG_FLAT_SCR_LOandHW_REG_FLAT_SCR_HI, the second and third instructions of every one of them. That is none of A-H. None of the 4,458 programs holds ascratch_*,flat_*orglobal_*instruction or ans_getreg_b32, so nothing in them observes the write.tools/pixel_aot.pyandtools/compute_store_aot.pyalready accept an unobserved whole-register write of these two registers; the mesh lowerers do not.With those two writes replaced by
s_nop(the census does this itself; nothing else is skipped), entry lowerer, dynamic lowerer in brackets where it differs:Unknown descriptor table or offsetScalar ALU requires concrete operandsScalar not written on this wave (skipped range) is usedKeyErrorats_load_dwordx4: an SGPR the entry state does not define (an exception, not a named refusal)Unsupported scalar instruction s_bitset1_b32Unproven runtime geometry word(dynamic only)s_sub_i32,s_brev_b32,KeyErrorats_mov_b32,IndexErroratv_nop, undefined branch predicate)All 836 programs with loops are still refused before their first loop.
A-H or loop-specific
Reproducing without the corpus
The script and a check with one hand-assembled loop per shape (14 programs, 14 category-boundary mutants, loop-free and barrier-outside controls) are ready as a PR.
What I would propose next
FLAT_SCR_LO/HI; refuse the program if it holds anyscratch_*orflat_*instruction or ans_getreg_b32of those registers). I found no open issue or PR for it. I can take it if nobody has it.AI-assisted (Claude Code).
@Leyukaka on GitHub · 2026-11-25 18:36 UTC · original
@NiiRoZz, about the flat-scratch setup in the mesh lowerers from your census comment above (the two
s_setreg_imm32_b32writes toHW_REG_FLAT_SCR_LO/HI, first refusal for 4,274 of 4,458 programs). You offered to take it if nobody had it. Do you still plan to take it? If not, I can.The rule would be the one you described, the same as
compute_store_aot.py(pixel_aot.pyaccepts the same write): accept a whole-register immediate write toFLAT_SCR_LO/HI, and refuse the program, by a scan of the whole decoded text and not only the executed path, if it holds anyscratch_*orflat_*instruction or ans_getreg_b32of those registers. A field write and thes_setreg_b32form stay refused. Each refusal case gets a negative control. If you are already on it, ignore this.AI-assisted.
@Leyukaka on GitHub · 2026-11-25 18:48 UTC · original
No reply to my question above and no PR or update on the mesh flat-scratch setup since the census comment, so I'm taking it. @NiiRoZz, if you already have work on it, say so and I'll hand it back and review instead.
Scope, as described above:
tools/mesh_entry_aot.py,tools/mesh_dynamic_aot.py), accept a whole-register immediates_setreg_imm32_b32write toHW_REG_FLAT_SCR_LO/HI.scratch_*orflat_*instruction or ans_getreg_b32of those registers.s_setreg_b32form stay refused.AI-assisted.