shader: lower composite s_waitcnt forms in pixel_aot #659
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/665"
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 Holastor on 2026-11-22T18:30:16Z.
Summary
Support arbitrary counter combinations in
s_waitcnt(vmcnt,lgkmcnt,expcntin any order) as well as raw0/0x0forms intools/pixel_aot.py, and synchronizetools/scan_unsupported_shaders.pypattern matching.Background & Motivation
In the GFX10 (RDNA 2) ISA,
s_waitcntencodes up to three hardware counters:vmcnt(Vector Memory Counter, 6-bit: 0..63)lgkmcnt(LDS, GDS, Kcache, Message Counter, 6-bit: 0..63)expcnt(Export Counter, 3-bit: 0..7)Real compiler-generated GFX1013 shader binaries frequently emit composite forms such as:
s_waitcnt vmcnt(7) lgkmcnt(0)s_waitcnt vmcnt(7) lgkmcnt(63)s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)s_waitcnt 0Previously,
pixel_aot.pyonly accepted isolatedlgkmcnt(0)orvmcnt(N)or the exact sequencevmcnt(0) lgkmcnt(0). All composite sequences were rejected, causings_waitcntto be the #1 blocker across the entire 8,145 shader census (blocking 7,870 shaders / 96.6% of shaders with 878,578 occurrences).Implementation Details
tools/pixel_aot.py:s_waitcnt <tokens>.vmcnt: 0..63 (raisesValueError("VM wait count exceeds the gfx10 six-bit field")on overflow).lgkmcnt: 0..63 (raisesValueError("LGKM wait count exceeds the gfx10 six-bit field")on overflow).expcnt: 0..7 (raisesValueError("Export wait count exceeds the gfx10 three-bit field")on overflow).has_vm,has_lgkm,has_exp) and malformed tokens cleanly withValueError.lgkmcnt == 0, clearspendingconstant buffer loads. Whenlgkmcnt > 0, preservespendingstate.vmcnt == 0, clearssample_dest. Whenvmcnt > 0, updates outstanding sample windowissue > samples - limit.0and0x0payload, clearing bothsample_destandpending.tools/scan_unsupported_shaders.py:SUPPORTED_INSTRUCTIONS_REGEXto recognize composite sequences ofvmcnt,lgkmcnt,expcntwithin their respective valid bounds, as well as0/0x0.tests/pixel_aot_check.py:vmcnt(7) lgkmcnt(0),vmcnt(7) lgkmcnt(63),lgkmcnt(0) vmcnt(0),vmcnt(0) expcnt(0) lgkmcnt(0),0,0x0).lgkmcnt(0)clearspendingand allows reading constant registers;lgkmcnt(63)keepspendingand correctly raisesConstant read before load completion.lgkmcnt(64),expcnt(8)), duplicate tokens (vmcnt(0) vmcnt(1),lgkmcnt(0) lgkmcnt(1)), and malformed tokens (s_waitcnt invalid).tests/rdna2_tools_check.py:is_instruction_supportedchecks to assertTrueon valid composite forms andFalseon out-of-range or malformed forms.Verification
Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-22T19:09:24Z.
Independent Windows run of this PR on physical hardware:
aea3b2d(PR head), built from sourcectest --preset dev --no-tests=error -R '^pixel_aot_' -V: 22/22 passed on hardware and WARP, no skips. The debug layer reporteddebug_errors=0on all 498 draws.I didn't run any mutations.
AI-assisted.