shader: verify unsigned pixel comparisons on raw bit patterns #610

Merged
lambirou merged 1 commit from upstream-pr/616 into main 2026-11-22 18:04:18 +00:00
lambirou commented 2026-11-22 16:02:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-22T16:02:05Z.


Change

Add a focused follow-up fixture for the integer predicate lowering in #306. The shader exports both operand orders of v_cmp_lt_u32 through v_cndmask_b32, using vcc_lo for e32 and s52 for e64. The three input cases cover the sign boundary, equal words, and a pair whose unsigned order would reverse if a register move quieted the first NaN. The readback checks all four channels of 4,096 pixels per draw. Replacing both comparisons with the signed forms must produce a pixel mismatch.

Verification

Tested commit 11090f5 on base 9b0df70 with Windows 11 build 26300.10075, Windows SDK 10.0.26100.0 and LLVM 23.1.5.

. ./tools/dev.ps1
cmake --preset dev
cmake --build --preset dev --target offscreen_check
ctest --preset dev --no-tests=error -R '^pixel_aot_(warp|hardware)$' --output-junit "$PWD/out/unsigned-less-than-upstream.xml"
$llvm = Join-Path $PWD 'out/llvm-check/ucrt64/bin'
$env:PATH="$llvm;$env:PATH"
./out/pe-env/Scripts/python.exe -B tests/pixel_aot_check.py binary "$llvm/llvm-mc.exe" "$llvm/llvm-objcopy.exe" "$llvm/libLLVM-23.dll"
./out/pe-env/Scripts/python.exe -B tests/docs_links_check.py
./out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.py
git diff --check HEAD^ HEAD
  • Both pixel tests passed on Microsoft Basic Render Driver (WARP 10.0.26100.10068) and AMD Radeon RX 9060 XT (driver 32.0.32029.2010), with zero skips. The signed control mismatched at the first pixel on both adapters. The D3D12 debug layer was unavailable.
  • The LLVM binary round trip, documentation link check, bidirectional-control check and diff check passed.

Evidence and follow-up

The fixture is original synthetic gfx1013 assembly authored in tests/pixel_aot_check.py under the repository's MIT license. The raw inputs enter the constant buffer as 32-bit words, and the expected outputs come from Python unsigned comparisons.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I included a negative control for the new fixture.
  • I updated the experimental documentation.
  • I kept the submission limited to source-built fixtures and documentation.

This patch was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6544541658 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/616). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-22T16:02:05Z. --- ## Change Add a focused follow-up fixture for the integer predicate lowering in #306. The shader exports both operand orders of `v_cmp_lt_u32` through `v_cndmask_b32`, using `vcc_lo` for e32 and `s52` for e64. The three input cases cover the sign boundary, equal words, and a pair whose unsigned order would reverse if a register move quieted the first NaN. The readback checks all four channels of 4,096 pixels per draw. Replacing both comparisons with the signed forms must produce a pixel mismatch. ## Verification Tested commit `11090f5` on base `9b0df70` with Windows 11 build 26300.10075, Windows SDK 10.0.26100.0 and LLVM 23.1.5. ```powershell . ./tools/dev.ps1 cmake --preset dev cmake --build --preset dev --target offscreen_check ctest --preset dev --no-tests=error -R '^pixel_aot_(warp|hardware)$' --output-junit "$PWD/out/unsigned-less-than-upstream.xml" $llvm = Join-Path $PWD 'out/llvm-check/ucrt64/bin' $env:PATH="$llvm;$env:PATH" ./out/pe-env/Scripts/python.exe -B tests/pixel_aot_check.py binary "$llvm/llvm-mc.exe" "$llvm/llvm-objcopy.exe" "$llvm/libLLVM-23.dll" ./out/pe-env/Scripts/python.exe -B tests/docs_links_check.py ./out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.py git diff --check HEAD^ HEAD ``` - Both pixel tests passed on Microsoft Basic Render Driver (WARP 10.0.26100.10068) and AMD Radeon RX 9060 XT (driver 32.0.32029.2010), with zero skips. The signed control mismatched at the first pixel on both adapters. The D3D12 debug layer was unavailable. - The LLVM binary round trip, documentation link check, bidirectional-control check and diff check passed. ## Evidence and follow-up The fixture is original synthetic gfx1013 assembly authored in `tests/pixel_aot_check.py` under the repository's MIT license. The raw inputs enter the constant buffer as 32-bit words, and the expected outputs come from Python unsigned comparisons. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I included a negative control for the new fixture. - [x] I updated the experimental documentation. - [x] I kept the submission limited to source-built fixtures and documentation. This patch was AI-assisted.
upstream-sync closed this pull request 2026-11-24 06:43:57 +00:00
MarlomMedeiros commented 2026-11-24 06:43:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MarlomMedeiros on 2026-11-22T18:11:41Z.

Review: COMMENTED


Community review + independent run on a second-vendor adapter, since the reported hardware is a Radeon RX 9060 XT.

Environment

  • Commit under test: 11090f5 on base 9b0df70
  • Windows 11 build 26300.10075, VS 2026 MSVC 19.52, Ninja, DXC from SDK 10.0.26100
  • ctest --preset dev --no-tests=error -R '^pixel_aot_predicate_rounding_(warp|hardware)$' -V: both passed
  • Hardware: NVIDIA GeForce RTX 5070 (vendor=10de device=2f04), driver 32.0.16.2135, D3D12 debug layer enabled, debug_errors=0 debug_warnings=0, pixels=4096 max_absolute_error=0
  • WARP: Microsoft Basic Render Driver, driver 10.0.26100.10068
  • tests/pixel_aot_check.py controls pass on this commit

Review notes

  • The fixture exports four channels exactly matching the order * 2 broadcast: vcc_lo e32 forward and reverse, then s52 e64 forward and reverse. Sign boundary, equal words and the NaN-payload pair each isolate a distinct failure mode.
  • The case design is sharp: 0x80000000 vs 0x7fffffff yields (0,1) unsigned and (1,0) signed, so the u32 to i32 mutation necessarily reports a mismatch at that case; the 0x7f800002/0x7fc00001 pair orders correctly only when the comparison reads raw bits, so a float-domain implementation fails it without needing a NaN-quieting assumption.
  • The docs paragraph is accurate against the fixture, including the quieting rationale and the 4-channel x 64-texel coverage.
  • Heads-up: base 9b0df70 is ~30 commits behind current main (8f57366); the insertion point near check_unsigned_less_than_draws has been stable, so a rebase should be trivial.

No blockers found.

AI-assisted: yes. All reported checks ran locally on the adapter and driver listed.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6013681690 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/616#pullrequestreview-6013681690). Originally posted by [MarlomMedeiros](https://github.com/MarlomMedeiros) on 2026-11-22T18:11:41Z. **Review:** COMMENTED --- Community review + independent run on a second-vendor adapter, since the reported hardware is a Radeon RX 9060 XT. ## Environment - Commit under test: `11090f5` on base `9b0df70` - Windows 11 build 26300.10075, VS 2026 MSVC 19.52, Ninja, DXC from SDK 10.0.26100 - `ctest --preset dev --no-tests=error -R '^pixel_aot_predicate_rounding_(warp|hardware)$' -V`: **both passed** - Hardware: NVIDIA GeForce RTX 5070 (vendor=10de device=2f04), driver 32.0.16.2135, D3D12 debug layer enabled, `debug_errors=0 debug_warnings=0`, `pixels=4096 max_absolute_error=0` - WARP: Microsoft Basic Render Driver, driver 10.0.26100.10068 - `tests/pixel_aot_check.py` controls pass on this commit ## Review notes - The fixture exports four channels exactly matching the `order * 2` broadcast: `vcc_lo` e32 forward and reverse, then `s52` e64 forward and reverse. Sign boundary, equal words and the NaN-payload pair each isolate a distinct failure mode. - The case design is sharp: `0x80000000` vs `0x7fffffff` yields (0,1) unsigned and (1,0) signed, so the `u32` to `i32` mutation necessarily reports a mismatch at that case; the `0x7f800002`/`0x7fc00001` pair orders correctly only when the comparison reads raw bits, so a float-domain implementation fails it without needing a NaN-quieting assumption. - The docs paragraph is accurate against the fixture, including the quieting rationale and the 4-channel x 64-texel coverage. - Heads-up: base `9b0df70` is ~30 commits behind current `main` (`8f57366`); the insertion point near `check_unsigned_less_than_draws` has been stable, so a rebase should be trivial. No blockers found. AI-assisted: yes. All reported checks ran locally on the adapter and driver listed.
thepatrickworld commented 2026-11-24 06:48:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-22T18:00:35Z.


@lambirou Independent AMD (RDNA4) result on 11090f5. Measurements only, no code change.

Environment

  • Windows 11 25H2, build 26200.9711
  • MSVC 19.44.35230 (toolset 14.44.35207), Windows SDK 10.0.26100.0, DXC 1.9.2602.17
  • AMD Radeon RX 9070 XT, vendor 1002, device 7550, driver 32.0.32029.2010, native wave width 64
  • debug_layer=unavailable (Tools.Graphics.DirectX is NotPresent here)
  • Clean worktree of the PR head 11090f5.

No LLVM with gfx1013 support on this machine, so the binary path described in your verification block was not run. What follows is the D3D12 draw path plus every CTest entry registered in this tree.

Commands

cmake --preset dev
cmake --build --preset dev --parallel 12 --target offscreen_check
set XBOX2WINDOWS_ADAPTER=AMD Radeon RX 9070 XT
ctest --preset dev --no-tests=error -R "^pixel_aot_|^rdna2_tools"

Observed

23 tests, 23 passed, 0 failed, 0 skipped (116.75 s): rdna2_tools_check, then the eleven _hardware suites (pixel_aot, buffer_color, u32_from_f32, attribute, three_way, predicate_rounding, blend_scalar, bfm, e64, integer_nc, rndne) and their eleven _warp counterparts.

On the main draw suite (separate targeted run, same build):

pixel_aot_hardware ... Passed  18.99 sec
pixel_aot_warp ..... Passed   9.61 sec
  • 47 draws on hardware, 46 at pixels=4096 and one at pixels=64, every one max_absolute_error=0 (4 channels per pixel).
  • 47 draws on WARP, same split, max_absolute_error=0.

Why this is worth measuring on this adapter

The fixture covers both operand orders of v_cmp_lt_u32 through v_cndmask_b32, with vcc_lo for e32 and s52 for e64, and one case whose unsigned order would reverse if the first NaN were quieted by a register move. That is a pure integer-predicate path, so an adapter difference would surface as a wrong pixel rather than a compile error. All 16,384 channels per draw matched on both backends.

Limit

The negative control you describe (replacing both comparisons with the signed forms must produce a pixel mismatch) lives in the binary path, which needs LLVM 23.1.5 — not installed here. So this run confirms the draw results and the registered tool checks, not the negative control.

AI-assisted; runs executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7083271721 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/616#issuecomment-7083271721). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-22T18:00:35Z. --- @lambirou **Independent AMD (RDNA4) result on `11090f5`.** Measurements only, no code change. ### Environment - Windows 11 25H2, build **26200.9711** - MSVC **19.44.35230** (toolset 14.44.35207), Windows SDK 10.0.26100.0, DXC **1.9.2602.17** - **AMD Radeon RX 9070 XT**, vendor 1002, device 7550, driver **32.0.32029.2010**, native wave width 64 - `debug_layer=unavailable` (`Tools.Graphics.DirectX` is `NotPresent` here) - Clean worktree of the PR head `11090f5`. No LLVM with gfx1013 support on this machine, so the `binary` path described in your verification block was not run. What follows is the D3D12 draw path plus every CTest entry registered in this tree. ### Commands ``` cmake --preset dev cmake --build --preset dev --parallel 12 --target offscreen_check set XBOX2WINDOWS_ADAPTER=AMD Radeon RX 9070 XT ctest --preset dev --no-tests=error -R "^pixel_aot_|^rdna2_tools" ``` ### Observed **23 tests, 23 passed, 0 failed, 0 skipped** (116.75 s): `rdna2_tools_check`, then the eleven `_hardware` suites (`pixel_aot`, `buffer_color`, `u32_from_f32`, `attribute`, `three_way`, `predicate_rounding`, `blend_scalar`, `bfm`, `e64`, `integer_nc`, `rndne`) and their eleven `_warp` counterparts. On the main draw suite (separate targeted run, same build): ``` pixel_aot_hardware ... Passed 18.99 sec pixel_aot_warp ..... Passed 9.61 sec ``` - **47 draws on hardware**, 46 at `pixels=4096` and one at `pixels=64`, **every one `max_absolute_error=0`** (4 channels per pixel). - **47 draws on WARP**, same split, `max_absolute_error=0`. ### Why this is worth measuring on this adapter The fixture covers both operand orders of `v_cmp_lt_u32` through `v_cndmask_b32`, with `vcc_lo` for e32 and `s52` for e64, and one case whose unsigned order would reverse if the first NaN were quieted by a register move. That is a pure integer-predicate path, so an adapter difference would surface as a wrong pixel rather than a compile error. All 16,384 channels per draw matched on both backends. ### Limit The negative control you describe (replacing both comparisons with the signed forms must produce a pixel mismatch) lives in the `binary` path, which needs LLVM 23.1.5 — not installed here. So this run confirms the draw results and the registered tool checks, not the negative control. _AI-assisted; runs executed locally._
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!610
No description provided.