shader: lower one structured wave64 else arm in pixel_aot masked regions #1364
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1371"
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 MasterDomino on 2026-11-24T09:32:00Z.
Fixes #1315 (Stage B; Stage A is #1328)
pixel_aotmasked regions now accept one structured wave64 else arm:s_andn2_b64 exec, s[a:b], execon the saved pair. This follows the scope R0Y00 approved on #1315.Behaviour (
tools/pixel_aot.py)s_andn2_b64 exec, s[a:b], execnaming the open region's exact saved pair, at most once, for both openers (s_and_saveexec_b64ands_mov_b64 s[a:b], exec+v_cmpx). EXEC becomes saved & ~EXEC, the saved lanes whose condition is false, so the else arm runs on the negated region condition.Else arm reads a register defined only in the then arm).condition ? then : else, with the pre-region value standing in for an arm that did not write it. A register undefined before the region and not written on both reachable arms stays undefined (conditional) after the close, as before.s_cbranch_execzdirectly after the opener must land exactly on the transition. Landing on the close of a region that has a transition is refused at the transition.s_or_b64ors_mov_b64).seen_skipnow allows both arms of the same region to carry a skip. Two regions with skips are still refused.s_andn2_b64writes it from the new EXEC, until an admitted scalar compare redefines it.s_andn2_b32 exec_lostay refused.Tests (
tests/pixel_aot_check.py)Fixture
else_region: the then arm writes v13 and v14. The else arm writes v13 and computes v15 = 0.5 × v14, so it must read v14's pre-region value. v13 merges both arms, v14 only the then arm and v15 only the else arm. It covers both openers, both closes and the skip shapesnone/then/else/both, with the displacements computed from real instruction offsets.check_masked_else_controls:sample16.z, the pre-region v14.s_andn2_b32 exec_loare refused.v_cmpxthen arm, unknown in the else arm (Select condition is not a tracked scalar result), and accepted again afters_cmp_lt_i32redefines it.image_sample,expandv_readfirstlane_b32are refused in the else arm.check_masked_else_draw(runs indraw-exec-regions, so inpixel_aot_exec_regions_{warp,hardware}): 16 programs × thresholds 0.5 / 10 / -1. Three mutants must mismatch:Binary regression: the 16 programs, the 12 with skips through labels, are assembled with LLVM 15, disassembled with offsets, and must lower like the computed offset pairs.
Two existing checks changed because they pinned the old refusal of the transition:
check_masked_mov_close_controls(#1328):s_andn2_b64 exec, s[60:61], execbefore the close is now valid. It now asserts a transition of another pair rejects withUnexpected execution mask else transition. The wave32 copy refusal is kept.check_cmpx_controls: the refused-extra list used the same-pair transition and now usess_andn2_b64 exec, s[58:59], exec.Results
Rebased on
b9c9f624(includes #1337). Windows 11 26H2 (build 26300.9974),devpreset, DXC 1.8.2502.11, Python 3.13.1, LLVM 15.0.7.tests/rdna2_tools_check.py(with LLVM, 1 existing skip),form_coverage_check,shader_census_check,shader_corpus_report_check,pso_readiness_check,docs_links_checkandbidi_controls_checkalso pass.Negative control: with
tools/pixel_aot.pyrestored to main,check_masked_else_controlsfails withInstruction cannot run in a masked region: s_andn2_b64 exec, s[60:61], exec.Not measured
The structural counts on #1315 are shape counts only: 23,603 simple wave64 if/else regions, 15,323 of them with both skips. With #1337 the scan names unbound operands, but it still stops before regions for almost every record, so the number of local records this unblocks is not measured. These draws pin the translator's model on desktop adapters; they are not evidence for gfx1013 hardware.
AI-assisted.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T09:42:05Z.
Review: COMMENTED
Technical peer-review of commit
6b8ad31cea19cd53f844d9586562393603f8fcd4:Verification
git diff --check origin/main...HEAD: clean.tests/docs_links_check.py: passed (16 Markdown files, 303 links).tests/bidi_controls_check.py: passed (1,149 files).tests/pixel_aot_check.py: passed.tests/rdna2_tools_check.py: passed (139 tests, 18 skipped).tests/form_coverage_check.py: passed.--preset dev):offscreen_checkbuilt (24.01s);ctest -R '^pixel_aot_(exec|cmpx)_regions_warp$'2/2 passed (3.63s)./O2(--preset release):offscreen_checkbuilt (35.92s);ctest -R '^pixel_aot_(exec|cmpx)_regions_warp$'2/2 passed (3.50s).tests/pixel_aot_check.py(12.0s),tests/rdna2_tools_check.py(4.4s),tests/form_coverage_check.py(42.6s) passed.Findings (
tools/pixel_aot.py)s_andn2_b64 exec, s[a:b], exec), pre-region vector state restoration,else_undefinedcheck (correctly evaluated beforedifference_update(writes)), dual-arm skip tracking, andclose_regionjoin are clean and well-tested.s_andn2_b64transition (tools/pixel_aot.py:3215-3217), whenregion["skip"] is not None,scalar.conditionalis updated fromregion["scalar_written"], butregion["outstanding"](before_pending, before_samples) is only restored atclose_region(tools/pixel_aot.py:2846-2851). If the skipped then arm executed ans_waitcnt, a wave that skipped the then arm would enter the else arm withpending/sample_destcleared even though it did not run that wait. Restoringpendingandsample_destfromregion["outstanding"]ats_andn2_b64whenregion["skip"] is not Nonewould close that gap.Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T10:02:36Z.
@tedin7 thanks, that gap was real. Before the fix, a then arm with a skip and an
s_waitcnt lgkmcnt(0)let the else arm use a descriptor loaded before the region (s_buffer_load_dword s72, s[68:71], 0x20) although a wave that skipped the then arm never ran that wait. Fixed ine4112744: when the then arm can be skipped, the transition restores the opener's outstanding loads and samples, asclose_regiondoes for a skipped region. New control incheck_masked_else_controls: no skip → accepted; then skip with the wait only in the then arm →Unresolved constant buffer binding; then skip with a wait in both arms → accepted. Without the fix that control fails. Controls, the LLVM 15 binary regression and the 12 region CTests (WARP + RX 9070 XT) pass; the branch still merges cleanly with main.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T10:18:57Z.
Review: COMMENTED
Technical retest at
e41127442c316862c04e0bfaed904518eb0e33e8:Previous finding verified
e4112744restoresregion["outstanding"](pendingandsample_dest) at thes_andn2_b64 exec, s[a:b], exectransition whenregion["skip"] is not None, so ans_waitcntin a skippablethenarm no longer hides pre-region outstanding loads from theelsearm.tests/pixel_aot_check.py(check_masked_else_controls) adds thewaited(True, False)negative control (rejects withUnresolved constant buffer binding) andwaited(True, True)positive control.Checks run
docs_links_check.py,bidi_controls_check.py,pixel_aot_check.py,form_coverage_check.py, andrdna2_tools_check.py(LLVM_MC=llvm-mc-19, 139 tests, 18 skipped) all passed.tests/form_coverage_check.pypassed (44.18s).--preset dev, targetoffscreen_check):ctest -R '^pixel_aot_(exec_regions|cmpx_regions|region_body|region_waits|region_scalar_alu|region_scalar_load)_warp$'6/6 passed (4.61s)./O2(--preset release, targetoffscreen_check):ctest -R '^pixel_aot_(exec_regions|cmpx_regions|region_body|region_waits|region_scalar_alu|region_scalar_load)_warp$'6/6 passed (4.87s).All checks pass cleanly.