shader: lower scalar quadmask and bit replication #710

Merged
lambirou merged 1 commit from upstream-pr/716 into main 2026-11-22 22:38:22 +00:00
lambirou commented 2026-11-22 22:19:42 +00:00 (Migrated from github.com)

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


Change

Add s_quadmask_b32, s_quadmask_b64 and s_bitreplicate_b64_b32 to pixel_aot
for numeric SGPR values.

The quad masks take the OR of each four-bit group and set SCC from the complete
result. The b64 result keeps all sixteen quad bits in bits 15:0 and writes zero
to the high word, matching the measured RDNA2 words. Bit replication expands
each source bit into two adjacent bits and preserves SCC. Reads occur before
destination writes, so a destination may overlap the source.

The fixture covers sparse and alternating patterns, zero, the all-set word,
bits 0 and 31, both result words and both incoming SCC values. Negative
references cover AND-within-group, the missing second copy, the wrong source
word, a quad placed in the high destination word and recomputed SCC.

GitHub searches for the three exact mnemonics found no open issue or pull
request.

Verification

The final local commit is b93399de22.

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)$'

The 37-case fixture passed in development and Release on WARP
10.0.26100.10068 and AMD Radeon RX 9060 XT driver 32.0.32029.2010.
Every positive draw matched all 4,096 pixels and 16,384 channels bit for bit,
and every negative control reported pixel_mismatch. Windows build
26300.10075, D3D12 debug layer unavailable, no skipped tests.

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 145 of 1,968 forms. gfx1030 moved
from 138 to 141 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 all three 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

The source-built fixture uses synthetic constants under the repository's MIT
license. The independent semantic reference is Leonida at 4eb6155d, checked
against the RDNA2 scan of the AMD instruction-set reference. TomBox at 2be7211
was also inspected and contained explicit bitset cases, but no direct quadmask
or bitreplicate case at that revision.

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:6548542817 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/716). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-22T22:19:42Z. --- ## Change Add s_quadmask_b32, s_quadmask_b64 and s_bitreplicate_b64_b32 to pixel_aot for numeric SGPR values. The quad masks take the OR of each four-bit group and set SCC from the complete result. The b64 result keeps all sixteen quad bits in bits 15:0 and writes zero to the high word, matching the measured RDNA2 words. Bit replication expands each source bit into two adjacent bits and preserves SCC. Reads occur before destination writes, so a destination may overlap the source. The fixture covers sparse and alternating patterns, zero, the all-set word, bits 0 and 31, both result words and both incoming SCC values. Negative references cover AND-within-group, the missing second copy, the wrong source word, a quad placed in the high destination word and recomputed SCC. GitHub searches for the three exact mnemonics found no open issue or pull request. ## Verification The final local commit is b93399de22d161a85528eb28a40c56096d4906fa. ~~~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)$' ~~~ The 37-case fixture passed in development and Release on WARP 10.0.26100.10068 and AMD Radeon RX 9060 XT driver 32.0.32029.2010. Every positive draw matched all 4,096 pixels and 16,384 channels bit for bit, and every negative control reported pixel_mismatch. Windows build 26300.10075, D3D12 debug layer unavailable, no skipped tests. 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 145 of 1,968 forms. gfx1030 moved from 138 to 141 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 all three 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 The source-built fixture uses synthetic constants under the repository's MIT license. The independent semantic reference is Leonida at 4eb6155d, checked against the RDNA2 scan of the AMD instruction-set reference. TomBox at 2be7211 was also inspected and contained explicit bitset cases, but no direct quadmask or bitreplicate case at that revision. 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
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!710
No description provided.