Repository navigation
shader: accept any zero VGPR in the mesh group-index exchange - #3537
Conversation
The native mesh frontend matched the group-index exchange only when the zero-address VGPR was v0. The real slot 57 shape uses v6. Read the VGPR from the first v_mov_b32_e32 and rebuild the second move and both DS address fields, then clear the selected VGPR instead of v0. Add a source-built 85-word real-shape fixture with the v6 exchange, a formatted heap read through v_readfirstlane_b32, three DS writes and reads, five barriers, GS_ALLOC_REQ and pos0/prim exports. compile_dxil produces a 4,828-byte MS and a 2,386-byte PS. A mismatched zero VGPR (v5 with DS fields still naming v6) is refused. This tranche covers the compiler shape; the direct-heap runtime profile and the draw/readback remain for the next one.
The real title request stores counts from a formatted load without a proven unsigned bound, so the native frontend refused the count exchange. Clamp the two loaded counts to the layout maxima before setMeshOutputCounts; the real request now passes the exchange and stops later on an undefined incoming VGPR. The source-built real-shape test exercises the clamp path and reports the larger 4,876-byte MS.
|
The Linux Python check fails in |
|
Next blocker on the captured title request: the compiler stops at |
A real slot 57 request defines its position VGPRs under a partial EXEC mask and exports them after an LDS branch. The default merge still refuses that shape. X2W_MESH57_PARTIAL_ZERO=1 keeps the last partial value for mesh reads and exports and materializes a missing merge edge as zero. With the opt-in, one captured title request compiles to a 12,680-byte MS and a 2,310-byte PS; without it the same request refuses at graphics register undefined. The source-built real-shape test exercises the opt-in and keeps the wrong-zero-VGPR control refused. The default behavior is unchanged.
X2W_MESH_DUMP_LAYOUT=1 prints the guest-root SGPR, root parameter, constant count and resource-heap SGPR used by a raw mesh translation. This is the mapping needed to author a Mesh57Profile from a captured request.
Accept v_sub_nc_u32, v_subrev_nc_u32, v_add_co_ci_u32, s_cmpk_lg_i32 and s_lshl2_add_u32 in the mesh lowerer, reusing the shared ALU implementations. On twelve captured live slot 57 requests, four depth-only requests already compiled; the new forms move the remaining multi-byte requests past their first ALU refusal. The next stops are heap-slot provenance, v_readfirstlane, a raw root descriptor and an unmapped export target.
The mesh raw root-buffer path now accepts root_stride_one_high with the 0x31016fac byte-count format, and allows OFFEN to carry a nonzero immediate offset. The live request 314407020a96f733 moves from +0x330 to its next refusal at +0x614, a resource-heap descriptor load.
|
Linux is red on |
lukaslw-lab
left a comment
There was a problem hiding this comment.
Reviewed f3590da0 (draft) by reading the diff; not built or run.
Verdict: comment. No MUST in what I read. The draft needs splitting and tests that tell the opt-in apart from the default before it is ready.
- SHOULD Split it. The title covers the zero-VGPR exchange, but the eight commits also carry the count clamp, the
X2W_MESH57_PARTIAL_ZEROheuristic,X2W_MESH_DUMP_LAYOUT, a wider mesh ALU subset (s_lshl2_add_u32,s_cmpk_lg_i32,v_sub_nc_u32,v_subrev_nc_u32,v_add_co_ci_u32), the OFFEN root V# change and CBV/past-table slots. The body does not mention the last three. The zero-VGPR change, the clamp and the CBV slots each stand alone. - SHOULD The opt-in has no test that shows what it does.
real.m57compiles withoutX2W_MESH57_PARTIAL_ZEROtoo (tests/startup_mesh57_real_shape_check.py:66-94), so the opt-in step would pass if the switch did nothing. Add a source-built shape that is refused by default and accepted with the switch (the+0x46c exp pos0join you described). It also needs a runtime check, because "missing edge = 0" applies to every VGPR (reg>=256) inmerge_edges(src/gfx1013_direct_mesh.inl:255-271), not only the partial writes. - SHOULD Assert the refusal text in the wrong-zero-VGPR control (
:83). Today any refusal passes, not just thezero_vgpr!=5gate. - NIT
src/gfx1013_direct_compute.inl:925drops the zero-immediate check (0x3fff→0x1000) without a test. The offset is added at:933, so I see no wrong read. - NIT
CMakePresets.jsonaddscompile_dxilto theprbuild targets, but no new test is in theprfilter, so CI builds it without using it. - Checked, no finding: the exchange words are read after the
>= 60size check, and the DS fields are rebuilt correctly aroundzero_vgpr.indirect_table_bufferalready resolves slot-17 CBV tokens from location + size. An unbounded range keepspast_tablefalse.
Tests: native_fixed_mesh57_cbv_* proves that a CBV-declared slot reads the same dword and that a UAV-declared slot is still refused. startup_mesh57_real_shape proves the v6 exchange compiles. Nothing covers the clamp, the ALU additions or the OFFEN change. CI ran none of these (not in the Windows pr filter, and the Linux job does not build compile_dxil).
|
Review follow-up on
Split status: the CBV/past-table lot is extracted to #3565. The remaining plan is: zero-VGPR, count clamp, partial-EXEC opt-in, wider ALU, OFFEN root V#, and the layout dump as separate lots; their tests currently share the real-shape harness, so the harness needs sub-case extraction before those branches can stand alone. |
lukaslw-lab
left a comment
There was a problem hiding this comment.
Re-review at 756c58cb (previous: f3590da0), by reading the diff; not built or run.
Verdict: approve. The test gaps from my first pass are closed. The split is under way, so it can follow. No MUST.
- Opt-in:
partialis refused by default at+0x148withgraphics register undefined on an incoming path: 265and accepted withX2W_MESH57_PARTIAL_ZERO=1. The test also requires thephi i32 [ 0, … ], [ 1065353216, … ]and that the export bitcasts that phi, so a switch that did nothing, or zeroed the wrong edge, would now fail. It exercises the generalreg>=256rule inmerge_edges, as I asked. - The wrong-zero-VGPR control asserts the exact
+0x4refusal in both modes. - Clamp, ALU and OFFEN now each have a source-built check that reads the emitted IR through
X2W_DUMP_SHADER_IR: the two count selects feed the counts, thev_add_co_ci_u32refusal comes without a reaching VCC (+0x144 … register 106), and OFFEN offset 16 lands in the address. The new comment atgfx1013_direct_compute.inl:923explains why the0x1000mask is enough: the raw-load decoder refuses IDXEN first. - CI:
startup_mesh57_real_shapeis in theprfilter now, and run 46383882043 passed it, so thecompile_dxilbuild target is no longer unused. - SHOULD (can follow):
f3590da0is still on the branch, although #3565 merged the same change. Itsnative_mesh57.inldiff is byte-identical, and the PR merges cleanly with main5de27d2b, so nothing breaks. A rebase would drop the commit and keep the history honest. The rest of the split (zero-VGPR, clamp, opt-in, ALU, OFFEN, layout dump) is as planned in your reply. - NIT:
X2W_DUMP_SHADER_IRis documented only indocs/experiments/native-fixed-mesh57.md. One line in thecompile_dxilusage text would help anyone outside mesh find it.
756c58c to
e6ee730
Compare
|
Re-review follow-up at
The remaining split (zero-VGPR, clamp, opt-in, ALU, OFFEN, layout dump) is unchanged and can follow. |
lukaslw-lab
left a comment
There was a problem hiding this comment.
Reviewed e6ee7309 by reading the diff; not built or run.
Verdict: approve. The rebase only drops f3590da0 and adds the usage line; the mesh changes are the ones approved at 756c58cb.
- Checked:
git range-difffrom756c58cbtoe6ee7309. Commitsf0b966b8…5a1edb31are identical, and3d4f93b0is identical to756c58cb.f3590da0is gone and its change is on main as #3565 (a7e8298c). The diff anddocs/experiments/native-fixed-mesh57.mdno longer mention the CBV or past-table reads. - Checked:
e6ee7309adds only theX2W_DUMP_SHADER_IR=FILEline to thecompile_dxilusage text (tools/startup/compile_dxil.cpp:1591). It matches the reader at:336and the doc note atnative-fixed-mesh57.md:162. - NIT The PR body still describes the CBV and past-table change and counts the two
_cbvcases in "26/26 (13 variants)". Both now belong to #3565, so the body should drop them so the squash message matches the diff.
Tests: startup_mesh57_real_shape is in the pr filter. CI ran it on this head and every job passed, including the Linux Python job.
#3537 replaced the "mesh count exchange exceeds declared range" refusal with a clamp to the declared output range, but the too-many-primitives case still expected the refusal, so native_direct_mesh failed on main. The case now checks that the vertex and primitive counts are clamped to 3 and 1 and that the clamped values reach setMeshOutputCounts. Co-authored-by: lukaslw-lab <291379150+lukaslw-lab@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Problem
The native mesh frontend refused four shapes from the real slot 57 workload:
Change
v_mov_b32_e32of the group-index exchange and rebuild its DS fields around it.X2W_MESH57_PARTIAL_ZERO=1: keep the last partial value for mesh reads/exports and materialize a missing merge edge as zero. The default path still refuses an unproven partial VGPR.s_buffer_loadcarries no format, filtering or typed element, so the descriptor's memory read as raw dwords is the same value. The submission still resolves each slot's token and refuses anything that is not a buffer SRV or a CBV.Validation
native_fixed_mesh57_*warp+hardware: 26/26 passed (13 variants, including the two new_cbvcases).native_fixed_mesh57_cbv_warp|hardware: the same MS reads the same dword through a table slot declared as a CBV; PSO created and pixels match the SRV variant.native_fixed_mesh57_cbv_uav_warp|hardware: the same slot declared as a UAV is still refused withMS buffer slot outside a verified SRV range.graphics register undefined on an incoming path: 265; withX2W_MESH57_PARTIAL_ZERO=1it compiles to a 12,680-byte MS. Four of the twelve live captures are depth-only and compile (3e8243,0acf7c,30d597,fd8f); with their reviewed profiles they create a native PSO, forward one indirect DispatchMesh and complete a depth readback, locally, without their bytes entering the repository. The partial-EXEC path is a heuristic for lanes the shader has not proven defined, not the final per-VGPR EXEC proof.Limits
The empty-PS depth-only profile,
DispatchMeshand pixel readback for a captured key remain the next tranche; they need the runtime fixture branch, which this PR does not carry. The Linux Python job fails onstartup_triage_run_check.pybecause a source reason is missing fromCOMPUTE_DISPATCH_REASONS; this PR does not touch that tool. Windows and the gfx1013 fixture jobs pass.Refs #2413