shader: lower compute v_writelane_b32 on known words #1897
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1904"
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 henriazz10 on 2026-11-24T20:43:57Z.
Change
Refs #1543. This is the
v_writelane_b32 vD, sS, laneslice claimed in https://github.com/R0Y00/Xbox2Windows/issues/1543#issuecomment-7142817082. It builds on thev_mbcntslice (#1782) and touches onlytools/compute_store_aot.py, its test,CMakeLists.txtanddocs/experiments.md.v_writelane_b32 vD, sS, lanewrites the known scalar wordsSinto lanelaneofvD(ignoringexec), leaving other lanes atold_vD:wave_size=32,laneis masked to 5 bits:((gindex & 31u) == (lane & 31u)) ? sS : old_vD, wheregindexisSV_GroupIndex.wave_size=32,lanemust be a known constant in0..31(since wave64 selectslane[5:0]), and lowers as that constant. Larger groups requirewave_size=32.lane[5:0]), and it was fixed before publishing.s30,s12);s30,s12), or a lane not known to be in0..31withoutwave_size=32(35literal,35in an SGPR, or a loaded constant word);vD(v40);s_and_saveexec_b32up to theexecrestore);wave_size=32;vDabovev255(v256).Verification
Commit
d2b55bd8, rebased onto8c82879f. Windows 11 build 26300, VS 2019 Build Tools 16.11 (MSVC 14.29), DXC 1.8.2502.11, Python 3.12, debug layer enabled.offscreen_checkwas built from an earliermain; this PR does not change it.compared_words=320 mismatches=0,debug_errors=0compared_words=320 mismatches=0,debug_errors=0The LLVM 15 round trip in Docker (
x2w-llvm15) exited 0:writelane_binary()decodes the assembled fixture back to the samev_writelane_b32lines and requires the same translation.Negative control. With
tools/compute_store_aot.pyreverted tomain,writelane_controls()fails withValueError: Unsupported compute instruction: v_writelane_b32 v4, s4, 3.Evidence
The fixture is source-built in LLVM 15 spelling. It runs one group of 64 threads (two wave32 waves) with
wave_size=32. Each thread starts withv4 = tid.x + 1, then twov_writelane_b32instructions write0x11223344into lane 3 (SGPRs4and inline constant3) and0x55667788into lane 31 (literal0x55667788and SGPRs5). Both waves receive the writes, and all 320 words are compared against a Python reference.wave_size=32(including lane35masked to3), 32 threads withoutwave_size=32(with lane3), and all rejection conditions (including lane35literal/SGPR and a loaded constant-word lane withoutwave_size=32).gindexwithout& 31: word 35;& 31;!=for==;0.Checklist
docs/experiments.md).AI-assisted. Gemini 4 Hydrogen (Antigravity CLI) wrote the change and ran the checks; Claude Code reviewed it.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T20:49:32Z.
Review: COMMENTED
Review of #1904 at head
d2b55bd862(tier TIER_D_ISOLATED_SHADER_OPS). No P1/P2 findings.Commands run locally:
Mutations on tools/compute_store_aot.py (each reverted with git checkout -- .):
0 <= lane <= 31widened to<= 63: tests/compute_store_check.py controls fail (rc=1, "Expected rejection: Unverified writelane lane")==flipped to!=in the emitted select: controls fail (rc=1, exact HLSL assertion)Notes: the draw test also checks four wrong reference outputs and three HLSL mutations against the renderer, which covers the lane mask, the compare and the old-value path. CMake registration matches the sibling tests.
AI-assisted; commands listed were executed locally.