startup: clear the lane-mask mark when gfx2hlsl overwrites an SGPR #2114
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2122"
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 denn0x on 2026-11-25T00:53:50Z.
Part of #1723. Related: #2023 (item L, a lane mask derived from descriptor data, relies on the same mask tracking; this does not lower it)
Stage.masksintools/startup/gfx2hlsl.pyrecords the SGPRs that hold a lane mask, and a scalar logic op with a mask source is lowered as a mask op, so its result is reduced to the lane's bit. Only the generic scalar path cleared the mark on an ordinary write. Afterv_cmp_eq_u32_e64 s6, v0, v1ands_buffer_load_dword s6, s[16:19], 0x0, the instructions_or_b32 s8, s6, s7was emitted ass8 = (s6 | s7) & 1;, which cuts the loaded word to bit 0. The stale mark would also make the lane-mask refusals, such as the one for scalar bit tests, refuse a register that no longer holds a mask (not tested here).Now:
set_sclears the mark on every write, after the uniformity of the new value is judged (#1931), so the readfirstlane proof still sees a source register as it was before the write.v_cmp*_e64,s_and_saveexec,s_*_wrexec, a copy ofexec_lo,s_cselect_b64, the mask logic ops) mark the register again after the write.s_loadclears the mark on its destination registers, including the forms that only record a descriptor symbol.New test
tests/startup_gfx2hlsl_mask_overwrite_check.py, registered asstartup_gfx2hlsl_mask_overwrite_controlsinCMakeLists.txt,AGENTS.mdand the Python job, and described indocs/experiments.md. It overwrites a compare result withs_buffer_load,s_load(through a root pointer, and of a descriptor) ors_cselect_b32, then evaluates the following OR on a buffer word. Controls: without the overwrite the OR stays a mask OR, and a compare, saveexec, wrexec, exec copy,s_cselect_b64or class compare after a load marks the register again.Verification (branch head
7ebe57e7onmain246a875d, Windows 11 Pro 10.0.26300, Python 3.13):python -B tests/startup_gfx2hlsl_mask_overwrite_check.py-> exit 0 (mask overwrite: loads and selects clear the mask mark; mask writers mark again). Onmainthe same test reportsFAILED: 7 check(s).tests/startup_gfx2hlsl_*_check.py(includingstartup_gfx2hlsl_readfirstlane_uniform_check.py),tests/startup_translator_check.py,tests/docs_links_check.pyandtests/startup_tools_lint_check.py tools/startup-> 33 scripts, all exit 0.git diff --check main..HEAD-> clean.AI-assisted.