shader: lower 64-bit scalar bitset forms #709

Merged
lambirou merged 2 commits from upstream-pr/715 into main 2026-11-23 05:01:46 +00:00
lambirou commented 2026-11-22 22:19:35 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-22T22:19:35Z.


Change

Add s_bitset0_b64 and s_bitset1_b64 to pixel_aot. Both forms read the
incoming SGPR pair, mask the source index to six bits and clear or set that bit
while preserving the other 63 bits and SCC. The lowerer reuses the existing
SGPR-pair and 32-bit bitset conventions.

The source-built fixture covers indices 0, 31, 32, 63 and 64 with both initial
SCC values. It exports both result words and SCC. It also carries the exact
all-ones NaN-shaped pair from PR #680 at index 31, where setting the bit must
retain 0xffffffff through the full-width integer readback, and reads the index
from either destination word. A negative reference that applies index 31 to the
high destination word, and a second that re-reads an aliased index after the
destination write, must report pixel_mismatch.

The lowerer overlaps the two b64 forms proposed in PR #680. This branch adds
the boundary, SCC, exact-integer and aliased-index controls to that work. One
implementation should land as the copy of record and the other should follow it
with the complementary tests.

GitHub searches for the two exact mnemonics found no open issue or pull request.
Open PR #620 exercises the adjacent 32-bit SOP1 forms and does not change the
translator.

Verification

The final local commit is 1f22244262, rebased
onto main 787ace7 after the quadmask/bitreplicate PR #716 merged.

python -B tests/pixel_aot_check.py
python -B tests/form_coverage_check.py
ctest --test-dir out/gfx1013-validation/dev -j 1 --no-tests=error -V -R '^pixel_aot_blend_scalar_(warp|hardware)$'
ctest --test-dir out/gfx1013-validation/release -j 1 --no-tests=error -V -R '^pixel_aot_blend_scalar_(warp|hardware)$'

Both development and Release builds passed 2 of 2 on WARP
10.0.26100.10068 and AMD Radeon RX 9060 XT driver 32.0.32029.2010.
All 30 positive draws checked 4,096 pixels, 16,384 channels and bits, with
maximum absolute error 0. All three negative controls mismatched. Windows build
26300.10075, D3D12 debug layer unavailable, no skipped tests. No NVIDIA adapter
was available locally. rwZephyr independently ran the same 1f22244 revision on
Windows 10 22H2 build 19045.6466, MSVC 19.44.35230, DXC 1.8.2502.11 and zero
skips. The RTX 3060 Ti, driver 32.0.16.2124, and in-box WARP 10.0.19041.5794
both passed 30 positive draws and all three expected mismatches. The exact
all-ones case matched 0xffffffff in both words with SCC 0 and 1. Setting only
the reference low word to 0x7fffffff produced expected_bits=7fffffff and
actual_bits=ffffffff at pixel (0, 0) on both adapters.

Release used MSVC 19.52.37029.0, CMAKE_CXX_FLAGS_RELEASE=/O2 /Ob2 /DNDEBUG
and a separate build directory.

Form coverage moved gfx1013 from 142 to 144 of 1,968 forms. gfx1030 moved
from 138 to 140 of 1,863.

The local pixel_aot_check.py binary check could not run because the
downloaded out/llvm-check/ucrt64/bin/llvm-mc.exe exits with
Permission denied before processing its options. An LLVM 23 disassembler
check accepted both instruction encodings, but the full LLVM assembler/object
copy round trip remains for CI or a host where llvm-mc is executable.

Evidence and follow-up

All fixtures are source-written synthetic assembly and constants under the
repository's MIT license. The independent references were TomBox's SOP1
execution cases at 2be7211 and Leonida's scalar validation at 4eb6155d.

AI-assisted: yes.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated the relevant experiment documentation.
  • I did not include game files, dumps, distribution links or secrets.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6548541758 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/715). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-22T22:19:35Z. --- ## Change Add s_bitset0_b64 and s_bitset1_b64 to pixel_aot. Both forms read the incoming SGPR pair, mask the source index to six bits and clear or set that bit while preserving the other 63 bits and SCC. The lowerer reuses the existing SGPR-pair and 32-bit bitset conventions. The source-built fixture covers indices 0, 31, 32, 63 and 64 with both initial SCC values. It exports both result words and SCC. It also carries the exact all-ones NaN-shaped pair from PR #680 at index 31, where setting the bit must retain 0xffffffff through the full-width integer readback, and reads the index from either destination word. A negative reference that applies index 31 to the high destination word, and a second that re-reads an aliased index after the destination write, must report pixel_mismatch. The lowerer overlaps the two b64 forms proposed in PR #680. This branch adds the boundary, SCC, exact-integer and aliased-index controls to that work. One implementation should land as the copy of record and the other should follow it with the complementary tests. GitHub searches for the two exact mnemonics found no open issue or pull request. Open PR #620 exercises the adjacent 32-bit SOP1 forms and does not change the translator. ## Verification The final local commit is 1f2224426270470068264a8ea12369bcf857a723, rebased onto main 787ace7 after the quadmask/bitreplicate PR #716 merged. ~~~text python -B tests/pixel_aot_check.py python -B tests/form_coverage_check.py ctest --test-dir out/gfx1013-validation/dev -j 1 --no-tests=error -V -R '^pixel_aot_blend_scalar_(warp|hardware)$' ctest --test-dir out/gfx1013-validation/release -j 1 --no-tests=error -V -R '^pixel_aot_blend_scalar_(warp|hardware)$' ~~~ Both development and Release builds passed 2 of 2 on WARP 10.0.26100.10068 and AMD Radeon RX 9060 XT driver 32.0.32029.2010. All 30 positive draws checked 4,096 pixels, 16,384 channels and bits, with maximum absolute error 0. All three negative controls mismatched. Windows build 26300.10075, D3D12 debug layer unavailable, no skipped tests. No NVIDIA adapter was available locally. rwZephyr independently ran the same 1f22244 revision on Windows 10 22H2 build 19045.6466, MSVC 19.44.35230, DXC 1.8.2502.11 and zero skips. The RTX 3060 Ti, driver 32.0.16.2124, and in-box WARP 10.0.19041.5794 both passed 30 positive draws and all three expected mismatches. The exact all-ones case matched 0xffffffff in both words with SCC 0 and 1. Setting only the reference low word to 0x7fffffff produced expected_bits=7fffffff and actual_bits=ffffffff at pixel (0, 0) on both adapters. Release used MSVC 19.52.37029.0, CMAKE_CXX_FLAGS_RELEASE=/O2 /Ob2 /DNDEBUG and a separate build directory. Form coverage moved gfx1013 from 142 to 144 of 1,968 forms. gfx1030 moved from 138 to 140 of 1,863. The local pixel_aot_check.py binary check could not run because the downloaded out/llvm-check/ucrt64/bin/llvm-mc.exe exits with Permission denied before processing its options. An LLVM 23 disassembler check accepted both instruction encodings, but the full LLVM assembler/object copy round trip remains for CI or a host where llvm-mc is executable. ## Evidence and follow-up All fixtures are source-written synthetic assembly and constants under the repository's MIT license. The independent references were TomBox's SOP1 execution cases at 2be7211 and Leonida's scalar validation at 4eb6155d. AI-assisted: yes. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated the relevant experiment documentation. - [x] I did not include game files, dumps, distribution links or secrets.
upstream-sync closed this pull request 2026-11-24 06:44:28 +00:00
R0Y00 commented 2026-11-24 06:48:49 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T22:36:14Z.


This overlaps #680's two b64 forms. Please coordinate so both branches do not land competing copies. The current fixture uses 0x81020408/0x00010001, which does not cover #680's observed NVIDIA result when setting bit 31 must produce 0xffffffff. Please carry over a full-width integer readback for that exact input, plus an index aliased with the destination pair, and share the result on the same NVIDIA adapter if available. The boundary/SCC controls here are independently useful either way.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7086940981 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/715#issuecomment-7086940981). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-22T22:36:14Z. --- This overlaps #680's two b64 forms. Please coordinate so both branches do not land competing copies. The current fixture uses 0x81020408/0x00010001, which does not cover #680's observed NVIDIA result when setting bit 31 must produce 0xffffffff. Please carry over a full-width integer readback for that exact input, plus an index aliased with the destination pair, and share the result on the same NVIDIA adapter if available. The boundary/SCC controls here are independently useful either way.
lambirou commented 2026-11-24 06:48:49 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-22T22:48:29Z.


I carried the #680 case into this branch and kept the boundary and SCC controls.

  • The fixture now draws the exact all-ones NaN-shaped pair
    (0xFFFFFFFF/0xFFFFFFFF) at index 31 with s_bitset1_b64 and a full-width
    uint4 readback. The expected word stays 0xFFFFFFFF. This is the case that
    previously canonicalised to 0x7fffffff on the NVIDIA driver.
  • The index is now also read from s44 and s45, aliasing either destination
    word, with a negative control for a read-after-write index.
  • 30 positive draws and 3 negative controls pass in development and Release on
    WARP 10.0.26100.10068 and Radeon RX 9060 XT 32.0.32029.2010. No NVIDIA adapter
    is available locally, so I cannot provide the same-adapter comparison.

On coordination, #680 at 33a24a03 has the two b64 lowerings plus a wider
standalone fixture and a binary round trip. This branch keeps one commit and
the two forms only. I can rebase onto #680 or reduce this PR to the additional
controls once you say which implementation should be the copy of record.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7087094198 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/715#issuecomment-7087094198). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-22T22:48:29Z. --- I carried the #680 case into this branch and kept the boundary and SCC controls. - The fixture now draws the exact all-ones NaN-shaped pair (`0xFFFFFFFF`/`0xFFFFFFFF`) at index 31 with `s_bitset1_b64` and a full-width `uint4` readback. The expected word stays `0xFFFFFFFF`. This is the case that previously canonicalised to `0x7fffffff` on the NVIDIA driver. - The index is now also read from `s44` and `s45`, aliasing either destination word, with a negative control for a read-after-write index. - 30 positive draws and 3 negative controls pass in development and Release on WARP 10.0.26100.10068 and Radeon RX 9060 XT 32.0.32029.2010. No NVIDIA adapter is available locally, so I cannot provide the same-adapter comparison. On coordination, #680 at `33a24a03` has the two b64 lowerings plus a wider standalone fixture and a binary round trip. This branch keeps one commit and the two forms only. I can rebase onto #680 or reduce this PR to the additional controls once you say which implementation should be the copy of record.
lambirou commented 2026-11-24 06:48:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-22T22:59:19Z.


Rebased onto 787ace7 after #716 merged and re-ran both GPU suites in
development and Release. The fixture still passes 30 positive draws and 3
negative controls on WARP 10.0.26100.10068 and Radeon RX 9060 XT
32.0.32029.2010. CI is green on 1f22244, including both Windows builds.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7087227035 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/715#issuecomment-7087227035). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-22T22:59:19Z. --- Rebased onto `787ace7` after #716 merged and re-ran both GPU suites in development and Release. The fixture still passes 30 positive draws and 3 negative controls on WARP 10.0.26100.10068 and Radeon RX 9060 XT 32.0.32029.2010. CI is green on `1f22244`, including both Windows builds.
rwZephyr commented 2026-11-24 06:48:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by rwZephyr on 2026-11-22T23:01:23Z.


Independent NVIDIA run for the requested bit-31 and aliased-index cases on 1f2224426270470068264a8ea12369bcf857a723. Windows 10 22H2 build 19045.6466, MSVC 19.44.35230, Windows SDK 10.0.26100.0, DXC 1.8.2502.11, Debug with /MTd. D3D12 debug layer unavailable on both backends.

cmake --preset dev "-DINTAKE_PYTHON=$((Get-Command python).Source)" "-DDXC_EXECUTABLE=$dxc" -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug
cmake --build --preset dev --parallel 4 --target offscreen_check
$env:XBOX2WINDOWS_ADAPTER = 'RTX 3060 Ti'
ctest --preset dev --no-tests=error -V -R '^pixel_aot_blend_scalar_(hardware|warp)$'
  • Hardware: RTX 3060 Ti (10de:2414), driver 621.24 (32.0.16.2124 via DXGI). Passed.
  • Software: In-box WARP (1414:008c), driver 10.0.19041.5794. Passed.
  • Skipped: Zero.

Calling check_scalar_bitset64_draw directly on each adapter confirmed 30 positive draws at 4,096 pixels each and all three expected mismatches. This includes both SCC values and index aliasing through each half of the destination pair.

For the exact 0xffffffff/0xffffffff input at index 31, both result words matched 0xffffffff with SCC 0 and 1. As a separate diagnostic I set only the expected low word to 0x7fffffff, then ran offscreen_check <hardware|warp> --check-pixel-case <shader> <case>. At pixel (0, 0), channel 0 printed expected_bits=7fffffff actual_bits=ffffffff for both SCC values on both adapters.

AI-assisted. All reported tests ran locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7087252833 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/715#issuecomment-7087252833). Originally posted by [rwZephyr](https://github.com/rwZephyr) on 2026-11-22T23:01:23Z. --- Independent NVIDIA run for the requested bit-31 and aliased-index cases on `1f2224426270470068264a8ea12369bcf857a723`. Windows 10 22H2 build `19045.6466`, MSVC `19.44.35230`, Windows SDK `10.0.26100.0`, DXC `1.8.2502.11`, Debug with `/MTd`. D3D12 debug layer unavailable on both backends. ```powershell cmake --preset dev "-DINTAKE_PYTHON=$((Get-Command python).Source)" "-DDXC_EXECUTABLE=$dxc" -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug cmake --build --preset dev --parallel 4 --target offscreen_check $env:XBOX2WINDOWS_ADAPTER = 'RTX 3060 Ti' ctest --preset dev --no-tests=error -V -R '^pixel_aot_blend_scalar_(hardware|warp)$' ``` - **Hardware:** RTX 3060 Ti (`10de:2414`), driver `621.24` (`32.0.16.2124` via DXGI). Passed. - **Software:** In-box WARP (`1414:008c`), driver `10.0.19041.5794`. Passed. - **Skipped:** Zero. Calling `check_scalar_bitset64_draw` directly on each adapter confirmed 30 positive draws at 4,096 pixels each and all three expected mismatches. This includes both SCC values and index aliasing through each half of the destination pair. For the exact `0xffffffff/0xffffffff` input at index 31, both result words matched `0xffffffff` with SCC 0 and 1. As a separate diagnostic I set only the expected low word to `0x7fffffff`, then ran `offscreen_check <hardware|warp> --check-pixel-case <shader> <case>`. At pixel `(0, 0)`, channel 0 printed `expected_bits=7fffffff actual_bits=ffffffff` for both SCC values on both adapters. AI-assisted. All reported tests ran locally.
lambirou commented 2026-11-24 06:48:50 +00:00 (Migrated from github.com)

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


Thanks for the independent run on exactly 1f22244. This closes the NVIDIA
observation requested in the first review. I recorded the RTX 3060 Ti and
in-box WARP results, including the 0x7fffffff diagnostic, in the PR
description. The commit under test is unchanged.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7087306216 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/715#issuecomment-7087306216). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-22T23:05:33Z. --- Thanks for the independent run on exactly `1f22244`. This closes the NVIDIA observation requested in the first review. I recorded the RTX 3060 Ti and in-box WARP results, including the `0x7fffffff` diagnostic, in the PR description. The commit under test is unchanged.
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!709
No description provided.