shader: cover four scalar leading-bit scan lowerings #681
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/687"
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 Leyukaka on 2026-11-22T20:02:34Z.
Change
This closes four coverage gaps in the scalar leading-bit scan lowering of
tools/pixel_aot.py(s_flbit_i32_b32,s_flbit_i32,s_flbit_i32_b64,s_flbit_i32_i64). Each was a one-line mutation that passed every WARP test onmain. Onlytests/pixel_aot_check.pychanges (13 added, 2 changed lines); the translator does not.s_flbit_i32of0x40000000(result 1)s_flbit_i32_b32of0x00010000(result 15)s_flbit_i32_i64with high word0x40000000(result 1)s_flbitdoes not write SCC, so afters_cmp_lg_u32of two zero words bothb64andi64scans must return0xffffffffwith SCC still false. The new rows are prepended, so the existing mismatch control still reuses its last case.Not covered: a 32-bit hex literal used as the 64-bit source. The translator zero-extends it (except for
s_ashr_i64). I have not checked that against hardware, so this PR does not fix that behavior in a test.Verification
On
bb6ba2f(branch on5748b02), Windows 11 build 26300.9974, MSVC 14.44.35207, Python 3.14, WARP:All 297 tests pass.
Each mutation was applied to
tools/pixel_aot.pyone at a time, and all WARP tests were run. Onmain, all of them passed for each mutation. A control that changed the 64-bit result (63uto62u) was caught bypixel_aot_predicate_rounding_warp, so the run does detect a broken translator. On this branch, each of the four mutations failspixel_aot_predicate_rounding_warp.Checklist
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-22T21:04:57Z.
Thanks for the run on RDNA4, and for checking the ISA entry.
Agreed on the scope: the 32-bit path already had a zero source with SCC seeded false (
(0, 1)), and the 64-bit path did not. The new case rules out anSCC = (source == 0)model on the 64-bit path. It does not show more than that, and it compares the translator against its own reference, not hardware.Folding the seed into
scalar_leading_bit_valueswould save one compile, though the row would still need its draw. I kept a separate draw so the existing rows stay unchanged; I can fold it in, with the row in both widths, if that is preferred.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-22T20:52:59Z.
Verification: #687
shader: cover four scalar leading-bit scan loweringsHead
bb6ba2f7, merged withmain. One file,tests/pixel_aot_check.py, +13/−2. No translatorchange: coverage only.
What it adds
Three rows to
check_scalar_leading_bit_draw:0x40000000— the top bit is clear, the second one set;0x00010000— a single bit near the middle;(0, 0x40000000)— the only set bit sits at bit 62, so the scan has to cross into the highword and skip its top bit.
Plus a separate case that seeds SCC false with
s_cmp_lg_u32before scanning a zero pair, to checkthat
s_flbitdoes not write SCC.Environment
Windows 11 25H2 build 26200.9711, MSVC 19.44.35230, DXC 1.9.2602.17, RX 9070 XT (RDNA4), driver
32.0.32029.2010.
Commands and output
Negative control: I removed the inversion from the
ffbhhelper (31u - firstbithigh(x)becamefirstbithigh(x)) and re-ran^pixel_aot_hardware$:The reserve
The SCC case is not tautological, but its scope is narrower than the comment suggests.
For 32 bits the fixture already had this exact case:
(0, 1)givesword = 0with SCC seeded falseby
s_cmp_eq_u32 s44, s45(0 == 1is false), and the expected result is false. The 64-bit path hadnothing: there
(0, 1)givesword = 0x1_00000000, and(0, 0)seeds SCC true. So animplementation modelling
SCC = (source == 0)passed the 64-bit path before this PR.What the case actually pins down is that model. Slim, but real. Against the ISA:
S_FLBIT_I32_*documents only the destination, with no SCC line, unlike
S_ABS_I32whose entry says "SCC=1 if resultis non-zero". The translator's table (l. 849-850) and its 64-bit path (l. 1654-1666) both leave SCC
alone, which is consistent.
It still says nothing about hardware: it compares the translator against itself. And one row cannot
test the write order if SCC and the destination were both written.
The new 64-bit scan row is the strongest of the three: it is the first case where the top bit of the
high word is zero while a lower bit is set, which is what a naive "scan the high word from the top"
gets wrong.
What I would add
The SCC block pays a
compile_shaderplus a draw for one line. Parameterise the seed(
scalar_leading_bit_values(width, seed="eq"|"lg")) and add the row to the existing case, in 32 bitsas well: the two translator paths are distinct — the SCALAR table for
b32, a dedicated block forb64— so covering both is not redundant, and it removes a compilation.What this does not prove
s_flbit_i32signed variant beyond what the existing rows covered.Merge note: this head, #679 and #683 branch from the same blob (
11f47701) on the same file. Their hunks are disjoint, so no conflict today, but each will need a rebase after the first one lands.AI-assisted; runs executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-22T21:57:42Z.
Yes — fold it in, with the row in both widths. The two translator paths are distinct (the SCALAR table for
b32, the dedicated block forb64), so the 32-bit row is not redundant even though(0, 1)already seeds false there, and dropping onecompile_shaderis worth it.Thanks for stating the reference-vs-hardware limit plainly instead of dressing it up; that is the right way to describe what the case pins down.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-22T22:48:54Z.
Folded in
08f8307. The leading-bit program now seeds SCC withs_cmp_lg_u32, so every row in both widths expects SCC =lo != hiafter the scans. The(0, 0)row, which finds no bit, keeps the false seed throughs_flbit_i32_b32/s_flbit_i32ands_flbit_i32_b64/s_flbit_i32_i64. The separate SCC draw and its compile are removed.The mutation that sets SCC when the 64-bit scan finds no bit still fails
pixel_aot_predicate_rounding_warp.ctest --preset dev --no-tests=error -j 4: 304 of 304 pass on WARP. The branch is rebased on currentmain.AI-assisted.