shader: lower compute DPP16 row_shr for OR and ADD #1877
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1884"
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 roansystemlabs on 2026-11-24T20:04:44Z.
Refs #1543.
Change
This is the
row_shrslice claimed in https://github.com/R0Y00/Xbox2Windows/issues/1543#issuecomment-7141031950, the next one after #1613 and separate from thev_mbcnt(#1782),v_readlane(#1858) ands_bcnt1(#1872) slices. It touchestools/compute_store_aot.py(one new branch next to thequad_permone), a new test file, its CTest entries, the CI lists,docs/experiments.mdand the DPP16 row ofREADME.md.v_or_b32_dppandv_add_nc_u32_dppwithrow_shr:1torow_shr:15, VGPR operands androw_mask:0xf bank_mask:0xfare lowered for gfx1013.SV_GroupThreadID.x, src0 staged in group-shared memory, no wave intrinsics, so the result does not depend on the desktop wave width. Rows are 16 logical lanes; lanexreads lanex - n.BOUND_CTRLis set (the operation still runs:0 | src1,0 + src1) and keeps its old destination when it is not. WithoutBOUND_CTRLthe old destination must be a known word, otherwise the translation is refused (Unverified DPP16 operand).DPP_ROW_SR: "if ((n&0xf) >= cntl[3:0]) pix[n].srca = pix[n - cntl[3:0]].srca, else use bound_cntl"), printed pages 267–268; the archived copy is the one linked in #669 (SHA-25622aec03f2706dba2e148ffde1f3a25d5cdd42c71a96f95240aeb48d995d44795). The manual does not say what is written; LLVM 15AMDGPUModifierSyntaxgives the value: withbound_ctrl:1, "accessing data from an invalid lane will return zero", andGCNDPPCombinerelies on the operation running with that zero.bound_ctrl:0andbound_ctrl:1both assemble to the same encoding with bit 19 of the DPP dword set, and the disassembler printsbound_ctrl:1. The lowering accepts both spellings; the binary mode checks that the two encodings are identical.compute_store_aotdraws since #2168, the CTest entries setFORM_COVERAGE_RECORD, and after every check has passed the test writes the opcodes of the accepted fixture there (12 forms, includingv_or_b32_dppandv_add_nc_u32_dpp). Without the variable it writes nothing. I checked the record file; I did not runtools/form_coverage.pyon a JUnit file.quad_perm). Still refused:row_shl,row_ror,row_share,row_xmask,row_mirror,row_half_mirror,row_bcast,wave_shr,fi:1, partial row or bank masks, an SGPR source, other opcodes (v_xor_b32_dpp,v_sub_nc_u32_dpp,v_add_f32_dpp,v_mov_b32_dpp), shifts 0 and 16, gfx1030, groups of 8 and 2D groups. Each has a control incontrols().Verification
Commit
b06d9688, rebased ontomainat214ed093. Windows 11 Home build 26200, MSVC 19.44 (VS 2022 Build Tools,vcvars64 -vcvars_ver=14.44), Ninja, DXC from Windows SDK 10.0.26100.0, Python 3.12, D3D12 debug layer enabled.compared_words=320 mismatches=0,debug_errors=0 debug_warnings=0compared_words=320 mismatches=0,debug_errors=0 debug_warnings=0No capability skips. The test prints the adapter and driver lines in the CTest log. The existing
compute_store_aot_dpp_(warp|hardware)(quad_perm) passed in every run. Earlier versions of this branch, on older bases, gave the same lines in eight more dev runs and four more release runs.On an earlier base (
330df7f0),ctest --preset dev --no-tests=error -R '^compute_store_aot_'ran 106 tests: 105 passed andcompute_store_aot_guard_read_hardwarehit its 45 s timeout with every readback line so far atmismatches=0. Run alone afterwards it passed in 40.9 s. It does not use DPP, so this change does not reach it: onmain(305d284f) without this branch it took 43.9 s and 35.5 s on the same machine, close to its 45 s limit independently of this change. Onb3e9fad4the full set ran 142 tests and all passed (compute_store_aot_guard_read_hardwarein 33.4 s).LLVM 15 round trip, reported separately from the GPU runs. Locally I have LLVM 15.0.7 as the clang 15 integrated assembler,
llvm-objcopyandLLVM-C.dll, not a standalonellvm-mc:For each shift the program is assembled with both
bound_ctrlspellings, the two.textsections must be identical, the four decoded DPP lines must equal the source text, each DPP dword is checked field by field (src0v1orv7;DPP_CTRL0x111, 0x118, 0x11f;FI0;BOUND_CTRLset on the twobound_ctrllines only; masks 0xff), and the decoded program must translate exactly as the text. The new file is added to the Ubuntu LLVM 15 job and to the platform-independent Python list; I did not run those jobs.With
main's translator,tests/compute_dpp_row_shr_check.pyfails at the firstrow_shrline withUnsupported compute instruction: v_or_b32_dpp v5, v1, v0 row_shr:8 row_mask:0xf bank_mask:0xf bound_ctrl:1.Also run on
b06d9688: thequad_permandv_mbcntcontrols fromtests/compute_store_check.py,tests/docs_links_check.py,tests/bidi_controls_check.py,git diff --check: all pass.Evidence and follow-up
The fixture is original, written for this test in LLVM 15 spelling and assembled from source; MIT, like the repository. No game files, dumps or captured shaders.
BOUND_CTRL. OR shifts that word and ADD shifts the word XOR0x00a50000, so the two steps stage different words. WithoutBOUND_CTRLthe old destination is the dispatch index XOR a key (0x6b000000for OR,0x6c000000for ADD), so a kept value, a zero and a computed value are all different.word=64 expected=00000010, thread 16, the first lane of the second row, on both adapters and all three shifts (actual8b3fcf50,8b234579,8b06bbb2for shifts 1, 8, 15);BOUND_CTRL:word=1 expected=6b000000 actual=00000000, thread 0.Not covered:
llvm-mc-15.row_shl,row_ror,row_bcast, partial masks and the other cross-lane forms of #1543 stay open for other slices.Checklist
README.md,docs/experiments.md).AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T20:08:38Z.
Review: COMMENTED
Review of
0f2189a8(merge base =origin/main=df40e4bc). Comment only, not an approval.Verdict
No P1 or P2 found. The lowering follows the row-shift rule it cites, the BOUND_CTRL cases are right, and the pure-Python controls catch every mutant I applied. Two P3 notes. Clean-room and title-neutral: the fixture is an original source-built program.
Semantics checked against the diff
row_lane = local.x & 15,inside = row_lane >= shift, source lanelocal.x - shift. Lanes 0..shift-1 of every row (so 16..16+shift-1, 32..., not only the first row) take the out-of-range branch.shift1..15 only; 0 and 16 are refused.0 | src1,0 + src1). Without it the lane keeps its old destination, and the old destination has to be a known word, otherwise the translation is refused (Unverified DPP16 operand). Bothbound_ctrl:0andbound_ctrl:1are accepted.uintadd, as forv_add_nc_u32.row_mask:0xf bank_mask:0xf. A lane guard, 2D groups, group X not divisible by 16, andgfx1030are refused, so every lane in a row is active when the barriers run (no divergentGroupMemoryBarrierWithGroupSync).dpp_stageis sized to the group (groupshared uint dpp_stage[64];for the fixture) and each step gets its owndppN_*names.Mutants (each applied alone to
tools/compute_store_aot.py, run withtests/compute_dpp_row_shr_check.py, then reverted)All 11 are caught:
>=changed to>; row width 15 changed to 31; add lowered as or; no-BOUND_CTRL lane writes 0 instead of the old value; bound sense inverted; shift 0 accepted; the divisible-by-16 check dropped; a lane guard allowed; a partial bank mask accepted; the second barrier removed; the out-of-row source not zeroed.P3
bound_ctrl:0/:1spelling. I ran thebinarymode with LLVM 19 as well and it passes (both spellings still encode alike, DPP_CTRL0x111,0x118,0x11f), so the CI pin to 15 is not hiding a different encoding in newer releases.Commands run (Linux, Python 3.14.8)
python -B tests/compute_dpp_row_shr_check.py: controls and mutant predictions pass.python -B tests/compute_dpp_row_shr_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/x86_64-linux-gnu/libLLVM.so.19.1: passes (LLVM 19, not the 15 that CI uses).python -B tests/rdna2_tools_check.py: OK (skipped=18).python -B tests/docs_links_check.py: Self-test passed. Checked 18 Markdown files and 378 links.python -B tests/bidi_controls_check.py: Self-test passed. Checked 1327 tracked source, script and build/CI files: no bidirectional controls.git diff --check origin/main...HEAD: clean.git merge-treewithorigin/main: clean. All mutations reverted withgit checkout -- ..Not run
compute_store_aot_dpp_row_shr_warpand_hardware(D3D12 dispatch, no Windows or GPU here). The WARP and RTX 3070 tables in the description are the author's. The CPU reference in the fixture is the PR's own, so what Linux checks is that the translation and the reference agree on structure; the ISA reading itself I checked only against the cited rule.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T05:01:25Z.
Review: COMMENTED
Re-review of head
b3e9fad438e2229e7470fee9ebd4968f966c2851(previous review was on0f2189a8). Comment only, not an approval.Verdict
No P1 or P2 found. Clean-room and title-neutral; mergeable.
What changed since
0f2189a8The PR was rebased onto current
main(merge base19e04be9). Comparing the PR-only patch of the old and new head, the only functional delta is the form-coverage record added at the end ofcheck_drawintests/compute_dpp_row_shr_check.py(FORM_COVERAGE_RECORD, written after all dispatches and mutant checks pass, opcodes taken fromprogram(shift)), plus the matchingENVIRONMENTproperty oncompute_store_aot_dpp_row_shr_${adapter}inCMakeLists.txt. This matches the convention used by sibling tests and the unique-test-name requirement oftools/form_coverage.py. The lowering intools/compute_store_aot.py(+30 lines) is unchanged, so my earlier semantics review (row/lane boundaries, BOUND_CTRL, masks, barriers) still holds.Commands executed locally (all on this head)
git diff --stat origin/main...HEAD: 6 files, +358/-2.python3 tests/compute_dpp_row_shr_check.py: pass ("Self-test passed", all refusal controls and both mutants flagged as predicted).python3 tests/docs_links_check.py: 18 Markdown files, 407 links, pass.python3 tests/bidi_controls_check.py: 1482 files, pass.git diff --check origin/main...HEAD: clean.inside = row_lane >= shiftchanged to>in the lowering: the test fails (generated HLSL no longer matches the expected program).git checkout -- ..Not run
No Windows WARP run from me. The D3D12 GPU-readback leg (
compute_store_aot_dpp_row_shr_*) is needed before Ready; it is not exercised by the Linux checks. At review timeBuild and test on WindowsandAssemble and translate gfx1013 fixtureswere still pending; the Linux Python checks job passed.Findings
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-25T05:00:09Z.
Rebased onto
mainat19e04be9; the branch is nowb3e9fad4. The conflicts inCMakeLists.txt,.github/workflows/windows.ymlandREADME.mdare resolved by keeping every entry frommainand adding ours after them. The lowering, docs and fixture are unchanged from0f2189a8.One addition: like the other
compute_store_aotdraws since #2168, the new test writes the opcodes of its accepted fixture toFORM_COVERAGE_RECORDwhen CTest sets it (12 forms, includingv_or_b32_dppandv_add_nc_u32_dpp), and writes nothing when the variable is unset.Rerun on
b3e9fad4, same machine:ctest -R '^compute_store_aot_dpp_', dev twice and release once: 4/4 each time. WARP and RTX 3070, shifts 1, 8 and 15: eachcompared_words=320 mismatches=0 debug_errors=0 debug_warnings=0. The cross-row and zero mutants still fail atword=64 expected=00000010andword=1 expected=6b000000 actual=00000000.ctest --preset dev -R '^compute_store_aot_': 142/142 passed.main, the new test still fails atUnsupported compute instruction: v_or_b32_dpp v5, v1, v0 row_shr:8 row_mask:0xf bank_mask:0xf bound_ctrl:1.docs_links_check.py,bidi_controls_check.pyandgit diff --checkpass.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-25T05:33:52Z.
Review: APPROVED
Verified head
b3e9fad4on Windows x64 (devpreset, MSVC19.44.35228.0, SDK/DXC10.0.26100.0):python -B tests/compute_dpp_row_shr_check.py-> passedctest --preset dev --no-tests=error -R '^compute_store_aot_dpp_row_shr_' -V-> 2/2 passed (compute_store_aot_dpp_row_shr_hardware,compute_store_aot_dpp_row_shr_warp;row_shr:1/8/15, 320 words each, 0 mismatches,cross_rowandzeromutants failed as predicted,debug_errors=0 debug_warnings=0)AMD Radeon RX 7900 XTX(vendor=1002 device=744c, driver32.0.32029.2010)Microsoft Basic Render Driver(vendor=1414 device=008c, driver10.0.26100.9818)Verdict: Approved at
b3e9fad4.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T12:53:00Z.
@roansystemlabs could you rebase this branch onto current
mainand force-push?GitHub reports head
b3e9fad4as conflicting withmain, so it cannot be merged as is.Files that conflict with current
main(4aaea119):.github/workflows/windows.ymlCommands run locally:
Once it is rebased and CI is green it will be re-checked right away.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:31:24Z.
Review: COMMENTED
Review of head
b06d96884fec92780136b993a18f3d78dfe46831.Result: no P1, no P2. Two nits.
CI on this head: Linux Python checks, gfx1013 fixture assembly/translation and Windows build+test all pass (
gh pr checks 1884).Commands run locally (Linux, worktree at the head SHA):
git diff --stat origin/main...HEAD: 6 files, +358/-2 (CMake, CI lists, README row, docs, one lowering branch, one test).python3 -B tests/compute_dpp_row_shr_check.py: "Self-test passed." Controls and both built-in mutants (cross_rowat word 64,zeroat word 1) are caught.python3 tests/docs_links_check.py: 19 files, 459 links, passed.python3 tests/bidi_controls_check.py: 1642 files, none found.git diff --check origin/main...HEAD: clean.tools/compute_store_aot.py, each reverted withgit checkout -- .:row_lane >= shiftchanged torow_lane > shift(boundary off by one): killed, the generated-HLSL assertion incontrols()fails.+instead of|: killed, same assertion.Correctness read (
tools/compute_store_aot.pylines ~2104-2132):xreads lanex - ninside its 16-lane row. Lanes withrow_lane < nget 0 for src0 with BOUND_CTRL (op still runs) and keep the old destination without it. This matches the RDNA 2 DPP16 description.dpp_stagebefore readers finish.Nits:
controls(). The GPU readback comparison is Windows-only (drawmode), andllvm-mc-15is not on this Linux host, so I could not runbinary/drawhere. I did not run the Windows pool. The Windows CI job passing covers the build and CTest registration, but the newcompute_store_aot_dpp_row_shr_*WARP/hardware runs should be confirmed on Win2025 before this is relied on.tools/compute_store_aot.py~2113:slot = "dpp_stage"and the staging text are now duplicated between thequad_permandrow_shrbranches. A small shared helper would shorten both. Not blocking.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-25T13:27:13Z.
Rebased onto current
main(214ed093, a bit past4aaea119) and force-pushed; head is nowb06d9688, still one commit.The only conflict was in
.github/workflows/windows.yml, in the platform-independent Python list on Linux:mainaddedmesh_join_descriptor_check.pyandmesh_loop_census_check.pyat the same spot. I kept both and puttests/compute_dpp_row_shr_check.pyafter them. The LLVM 15 matrix entry merged on its own and keeps the(command, extra_env)tuple format used withtools/run_checks_parallel.py(#2267). The other five files merged cleanly;git range-diff origin/main b3e9fad4 b06d9688shows only context changes in the workflow file.Checked on
b06d9688:On WARP 10.0.26100.9818 and an RTX 3070 (32.0.16.2101), shifts 1, 8 and 15 each give
compared_words=320 mismatches=0 debug_errors=0 debug_warnings=0, and both negative controls fail at the predicted first word (word=64 expected=00000010,word=1 expected=6b000000 actual=00000000). Thequad_permandv_mbcntcontrols intests/compute_store_check.pyalso pass. The hashes in the PR description now point atb06d9688/214ed093.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T19:10:57Z.
Review: COMMENTED
Review of head
59bd1b08(merge of main; same change as the head reviewed earlier).Code and tests look sound, but I am not merging because of a duplicate.
Duplicate: #2496 ("compute DPP16 row_shr OR/ADD lowering") covers the same slice (
v_or_b32_dpp/v_add_nc_u32_dppwithrow_shr, compute path). This PR is the older one and matches the claim in #1543. I leave the choice between the two PRs to @R0Y00. If this one is chosen, I see no technical blocker.What I checked against origin/main (15 commits behind, no conflict):
tools/compute_store_aot.py: the new branch sits next to thequad_permone. The lane-before-row-start rule is correct: with BOUND_CTRL src0 is 0 and the op still runs; without it the old destination is kept and must be a known word, otherwise the translation is refused.compute_store_aot_dpp_row_shr_<adapter>). I could not run the draw part on Linux.Commands run locally (Linux):
python3 -B tests/compute_dpp_row_shr_check.py-> OKpython3 tests/docs_links_check.py-> OKpython3 tests/bidi_controls_check.py-> OKgit diff --check origin/main...HEAD-> clean>=changed to>in the row-start test -> the test fails.|changed to+for OR -> the test fails.AI-assisted; commands listed were executed locally.