shader: accept readfirstlane of a proven wave-uniform VGPR in the mesh frontend #3439
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3439"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T09:04:19Z.
Part of #3416
Branch
shader-mesh-udiv-uniform(f7b77587,f74eacc8), based on main41babe6e.git merge-treewith main184b15dbis clean.What changes
The native mesh frontend refused any
v_readfirstlane_b32whose source was not one of its tracked lane or group values. That blocks the 32-bit unsigned division expansion over root constants:v_cvt_f32_u32,v_rcp_f32,v_mul_f32,v_cvt_u32_f32, thenv_readfirstlane_b32and a scalar refinement.In
src/gfx1013_direct_mesh.inl(line numbers at the branch head)::109-110 records the SGPRs that hold root constants as wave-uniform at entry.
:914 adds
s_sub_i32ands_mul_hi_u32to the scalar ALU list. Both go through the sharedalu.arithmetic.:1118-1152, VALU arm: the result is recorded as wave-uniform (:1149-1152) when the write meets all of these (:1142-1144):
v_mac_f32/v_fmac_f32, the old destination is also uniform;A later write to the VGPR replaces the value that
readfirstlanereads, so the proof no longer applies.The
v_readfirstlane_b32gate itself (:1031) is unchanged.Evidence
On this head, release build:
Result:
native_direct_meshPassed.src/gfx1013_direct_mesh.inlandtests/native_direct_mesh_check.pyare identical on41babe6eand184b15db.Tests:
uniform-udivis accepted. Each of these is refused at thereadfirstlane:varying-udivoverwritten-udivvarying-accumulatorvarying-pair-highsdwa-uniform-sourcepartial-exec-writeMutation on this head:
if (uniform_result) {(:1149) changed toif (false && uniform_result) {.uniform-udivthen fails withnative compute +0x28: unsupported mesh instruction or EXEC state: v_readfirstlane_b32. After the revert the test passes.Mutation on the previous revision (9aa6e57c on main
212d4b5f, same changed lines), not repeated on this head:uniform_result=full_exec && sourceschanged touniform_result=sources.partial-exec-writethen fails: the read at +0x24 is accepted, and the run stops later withnative compute +0x38: unbound numeric SGPR s18.partial-exec-writewrites v6 and reads it inside thes_cbranch_execzblock, then restores the saved EXEC at the branch target. It does not widen EXEC inside the block.Not covered
uniform-udivasserts only that lowering succeeds and the export is present. It does not check the quotient value.readfirstlane. Those conditions were not mutated.v_ceil_f32is in the VALU arm but in none of the source-count lists, so its result is never recorded as uniform (by reading).full_exec || exec_skip, :1031) also accepts a read inside a lane-skip block. No case here covers a read after EXEC is widened inside the skip.shader-mesh-exec-widenrefuses that widening.CI
On main
184b15dbtheprCTest preset filter does not matchnative_direct_mesh, soBuild and test on Windowsdoes not exercise this change.Interactions with other open mesh branches
By
git merge-treeat the current heads, two textual conflicts:tests/native_direct_mesh_check.py, end ofmain(), withtests-mesh-refusal-coverage(0feac9c2). Keep both blocks. This block starts with its ownlayout.write_text('mesh1 128 3 1 2 128 64\nconstants 21 0 1').src/gfx1013_direct_mesh.inl, the scalar ALU name list, withshader-mesh-udiv-ops(ddd77faf). That branch addss_max_u32and this one addss_sub_i32 || s_mul_hi_u32. The resolution is the union of both additions.No textual conflict with
shader-mesh-exec-widen,shader-mesh-exchange-nosaveormesh57-profile-mismatch-part. The combinations were not built at the current heads.