shader: lower s_not_b32, s_brev_b32 and s_bfe_i32 in the mesh frontend #3710
No reviewers
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!3710
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3708"
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?
@mumba17 on GitHub · 2026-12-01 07:56 UTC · original
mumba17:shader/mesh-salu-not-bfe-brev→main· +41 −1 · 2 files · 2 commits · merged 2026-12-02 02:13 UTCRefs #3643, #3705, #2413.
Problem
The C++ mesh frontend (
lower_mesh,src/gfx1013_direct_mesh.inl) refusess_not_b32,s_brev_b32ands_bfe_i32withunsupported mesh instruction or EXEC state. The shared scalar ALU (DirectCompute::arithmetic) already lowers all three. On a native Mesh86 capture they are among the most common first refusals.Change
All three join
s_bfe_u32ands_min_u32on the existing branch that hands scalar ops to the shared ALU. The EXEC and VCC destination refusals in that branch apply unchanged. SCC follows the shared lowering:s_not_b32ands_bfe_i32set it from the result, ands_brev_b32leaves it alone.Census
Capture. A native Mesh86 run on
main1c634037:run_preset.py --console x --gpu nvidia --set translate=false, withX2W_REFUSE_FIXED_MESH=1andX2W_NATIVE_MESH86=1, 600 s from a saved profile. It recorded 2,873.m86requests, 1,569 of them distinct by content.Translation. Each distinct request went through
compile_dxil <dxc> <cache> gfx1013-container-ms-texture-heap req_<key>.m86 <out>.cso. These are counts only; request bytes stay local.main(built with #3708, which changes none of these counts)First refusals that this PR changes:
s_not_b32s_bfe_i32s_brev_b32v_rcp_iflag_f32v_cmpx_ne_u32graphics register undefined on an incoming pathv_ashrrev_i32Most of the 555 programs freed here now stop at
v_rcp_iflag_f32. That is the next wall, and I'll take it as a separate PR.Tests
tests/native_direct_mesh_check.py, ons20 = s_movk_i32 0xfffe(-2), with the result reaching the exported X position throughv_and_b32:scalar-not:xor i32 -2, -1.scalar-brev:dx.op.unary.i32(30, -2).scalar-bfe-i32: anashrof -2 followed by the shl/ashr sign extension, with nolshrof -2.scalar-not-exec:s_not_b32 exec_lo.scalar-brev-vcc:s_brev_b32 vcc_lo.scalar-not-vcc-hi:s_not_b32 vcc_hi.native_direct_meshfails atscalar-notwithunsupported mesh instruction or EXEC state: s_not_b32.ctest -R "native_|mesh|gfx1013" -E "hardware|_warp": 786/788 pass. The two failures,native_compute_implicit_lod_controlsandnative_wave_virtual_derivative_controls, are local only. The SDK 10.0.26100 validator here supports DXIL 1.7, and both tests emit 1.8 metadata. Neither touches the mesh frontend.Environment: Windows 11 build 26300, RTX 3090, MSVC 14.44, DXC from SDK 10.0.26100.
AI-assisted.
🤖 Generated with Claude Code
s_bitset1_b32, then stop at a scalar loop #3705s_bitset1_b32, then stop at a scalar loop #3705@lukaslw-lab on GitHub · 2026-12-01 08:07 UTC · original · approved these changes
Reviewed
9886eb8eby reading the diff; not built or run.Verdict: approve. The three ops join the branch that already hands
s_bfe_u32ands_min_u32to the shared scalar ALU, which lowers all three, and the EXEC and VCC destination refusals apply. No MUST.s_brev_b32as SCC-preserving (gfx1013_direct_compute.inl:3808), and its lowering at:5425does not write SCC.s_not_b32ands_bfe_i32are SCC writers (:3782,:3791, lowered at:5772and:5697). Two cases would pin the behaviour the PR body states:s_cmpbefores_brev_b32, then ans_cselect_b32after it;s_cbranch_scc0afters_not_b32.0x80004(8 bits from bit 4).exec_lo,vcc_loandvcc_hias their names say.scalar-bfe-i32pattern requires theashrand the shl/ashr sign extension and rejects anlshrof -2, so it separates the signed form froms_bfe_u32.Tests:
scalar-not,scalar-brevandscalar-bfe-i32prove each op reaches the exported X throughv_and_b32. The three refusals pin the destination checks. CI rannative_direct_meshin theprpreset and passed at this head.@mumba17 on GitHub · 2026-12-01 08:33 UTC · original
Thanks @lukaslw-lab. SHOULD addressed in
a6602c75, with the two cases you suggested. Both start froms_movk_i32 s20, 0xfffeands_cmp_eq_u32 s20, 0, run the op, thens_cselect_b32 s21, 1, 0, ands21reaches the exported X:scalar-brev-keeps-scc(s_brev_b32 s22, s20): theselecttests the compare's ownicmp eq i32 -2, 0, so SCC passes through unchanged.scalar-not-sets-scc(s_not_b32 s22, s20): theselecttestsicmp ne (xor -2, -1), 0, so SCC comes from the result.AI-assisted.
s_bitset1_b32, then stop at a scalar loop #3705s_bitset1_b32, then stop at a scalar loop #3705@lukaslw-lab on GitHub · 2026-12-01 18:02 UTC · original · approved these changes
Reviewed
a6602c75by reading the diff; not built or run.Verdict: approve.
a6602c75closes the SCC point from our earlier review. No MUST, no open points.0xbf068014=s_cmp_eq_u32 s20, 0(SOPC op 6),0x85158081=s_cselect_b32 s21, 1, 0(SOP2 op 10),0xbe960b14/0xbe960714=s_brev_b32/s_not_b32 s22, s20(SOP1 op 11 / 7).scalar-brev-keeps-sccrequires the select to test the zext of the compare's ownicmp eq i32 -2, 0, so a brev that rewrote SCC would fail it.scalar-not-sets-sccrequires the test to come fromicmp ne (xor -2, -1), 0, so a not that kept the compare's SCC would fail it. Both tie the pick to the exported X throughassert_position_x.Tests: the two new cases reach the SCC handling of the shared scalar ALU through the
gfx1013_direct_mesh.inl:1830branch.native_direct_meshis in theprpreset filter, and CI ran it green at this head.github-bot referenced this pull request2026-12-01 22:37:57 +00:00