shader: accept v_sub_co_u32, v_subrev_co_u32 and v_and_or_b32 in the mesh frontend (Part of #2413) #3659
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3659"
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 SimSalabimse on 2026-11-30T22:09:54Z.
Part of #2413.
The native mesh frontend already accepts
v_sub_nc_u32andv_subrev_nc_u32since #3537. This adds the three integer ops next to them that it still refuses:v_sub_co_u32(VOP3)v_subrev_co_u32(VOP3)v_and_or_b32(VOP3)All three go through the existing
arithmetic()lowering, so the change insrc/gfx1013_direct_mesh.inlis one whitelist line.tests/mesh57_integer_alu_check.cpp(registered asmesh57_integer_alu) decodes synthetic gfx1013 words for the five ops with the repo decoder and checks the expected result of each form:v_sub_nc_u32/v_subrev_nc_u32: VOP2, VOP3, VOP3 with clamp, SDWA dword and DPP forms, including0 - 1 == 0xFFFFFFFFwrap and the unsigned clamp to 0.v_sub_co_u32/v_subrev_co_u32: VOP3 result plus borrow bit.v_and_or_b32: VOP3(a & b) | c.Left out:
v_sub_co_ci_u32,v_subrev_co_ci_u32).Checks:
-std=c++17 -Wall -Werror=narrowing) and passes.mesh57_*12/12.Why: on the Windows test PC, the derived slot 57 mesh walk (fork branch, see the draft linked from #3541) got through translation further than before and was refused in native compute translation at an unsupported
v_sub_nc_u32. That branch was older than #3537. This PR keeps the subtract coverage in the test and adds the remaining siblings, so the next run does not stop one instruction later.AI-assisted (Cursor)
Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-12-01T09:35:22Z.
Tested on the Windows test PC at head
3df4c9d8, dev preset, withctest -R mesh(excluding the real-device audio tests): 202/202 passed, includingnative_direct_mesh(the DXC test),startup_mesh57_real_shape, and the newmesh57_integer_alu.It merges cleanly with current main
a061032f. Stock main with the same filter is also 207/207.AI-Assisted
Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-01T19:04:24Z.
Review: COMMENTED
Reviewed
3df4c9d8by reading the diff; not built or run.Verdict: comment. The one-line allowlist change is right. The three ops reach lowerings that already exist:
v_and_or_b32is({0} & {1}) | {2}(gfx1013_compute_alu.inl:8), and the two carry-out subtracts go throughcarry_destination(gfx1013_compute_native.cpp:577), whose lowering refuses clamp, neg, DPP and scale. But the PR's only test never runs that code, so nothing pins it. No MUST. I'd approve once a translator case is in.tests/mesh57_integer_alu_check.cppdecodes the words with the repo decoder. It then checks them against its ownlower()(a C++ copy of the expected arithmetic) and against a text search ofgfx1013_direct_mesh.inlfor the names. It never callslower_mesh, so the DXIL for the three new ops, and the borrow write to VCC or an SDST pair, are untested.mesh57_integer_aluis also not in theprpreset filter, so CI did not run it. A few cases intests/native_direct_mesh_check.pywould cover this, in the style of the other mesh allowlist PRs on #3703 (#3704, #3709). Each would follow the result to the exported X withassert_position_x:v_and_or_b32,v_sub_co_u32with its borrow in VCC feeding av_cndmask_b32, andv_subrev_co_u32with operands swapped.carry_destinationwrites the lane bit to 106, and the meshafter_graphics_write(106)clears the numeric VCC words. So a later SALU or SAVEEXEC use of VCC refuses instead of reading a stale compare mask.v_add_co_ci_u32, which is already accepted.Tests:
mesh57_integer_aluproves the decoder names and widths for the five ops, and that the names appear in the mesh source. It does not reach the translator. CI is green, but it did not include this test.Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-12-02T12:13:18Z.
Merged main and resolved the opcode allowlist conflict in
src/gfx1013_direct_mesh.inl.v_and_or_b32was already covered by the upstreamv-and-or-b32case, so I left that one as is. I added av_sub_co_u32case that follows the VCC borrow intov_cndmask_b32, and a swappedv_subrev_co_u32case.mesh57_integer_aluis now in theprpreset.Windows test PC, head
1acfe7a1, dev/pr presets:cmake --preset devcmake --build --preset pr --target mesh57_integer_alu_check compile_dxil(andstartup_indirect_draw_indexed/offscreen_checkfor the nearby suite)ctest --preset pr --no-tests=error -R '^(mesh57_integer_alu|native_direct_mesh)$' -V:mesh57_integer_alupassed.native_direct_meshfailed in the existinginteger-row/float-rowloop withnative compute +0x34: unmapped graphics export. Current main7c9f2639fails the same way in that same loop, so this isn't from the merge. With that loop skipped locally (not committed),v-sub-co-u32-vcc-cndmaskandv-subrev-co-u32-swappedboth passed, and the rest ofnative_direct_meshpassed.ctest --preset dev -R mesh57 -E 'startup_audio_(output|pacing|provider)': 48/64 passed after the first binaries were built. The other 16 were thestartup_mesh57_*_{warp,hardware}tests, which neededoffscreen_check. After building that target those 16 all passed.AI-Assisted
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T19:30:25Z.
Review: COMMENTED
I reviewed
0860f882and ran independent Windows/MSVC Debugctest --preset dev --no-tests=error --output-on-failure -j 1 -R '^(mesh57_integer_alu|native_direct_mesh)$'(2/2). The fixtures pin both carry-out subtract forms and the mesh frontend's acceptance. The trial merge into23986134still conflicts inCMakePresets.jsononly. Please retainmesh57_integer_alutogether with the Mesh86 material coverage now on main, then rerun CI.Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-12-02T20:25:32Z.
Reply to https://github.com/R0Y00/Xbox2Windows/pull/3659#pullrequestreview-6157478782:
Merged current
maininto this branch. The only conflict wasCMakePresets.json: I kept themesh57_integer_alubuild target and test selection alongside main's Mesh86 entries. I resolved only that file; the rest merged cleanly.Run on the Windows test PC (Debug build of the merged head, GPU tests one at a time):
mesh57_integer_alu,native_direct_mesh,startup_mesh57_*andnative_mesh_*: 37 of 37 pass. The previous merge of main had passed the full-R meshselection (233 of 233).AI-Assisted
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T22:01:40Z.
Review: APPROVED
Reviewed the updated lowering and fixtures. The added translator cases exercise the borrow bit through VCC into
v_cndmaskand cover the reversed operand order. On Windows I verified a clean trial merge withmainatc3a85433, builtmesh57_integer_alu_checkandcompile_dxilfrom4818a90b, and ranctest --preset dev --no-tests=error -j 1 --output-on-failure -R '^(mesh57_integer_alu|native_direct_mesh)$'(2 passed). I also checked that the PR CI selection retains the integer ALU and Mesh86 fixtures. Windows, Linux Python, and gfx1013 fixture CI are green on this head.