shader: draw the s_movk_i32 sign extension in pixel_aot #337

Merged
Its3rr0rsWRLD merged 1 commit from upstream-pr/342 into main 2026-11-21 22:56:22 +00:00
Its3rr0rsWRLD commented 2026-11-21 22:46:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Its3rr0rsWRLD on 2026-11-21T22:46:05Z.


Change

This adds tests only; the translator is unchanged. pixel_aot already lowers s_movk_i32 by sign-extending its 16-bit immediate and folding the result (tools/pixel_aot.py, the s_mov_b32|s_movk_i32 branch). No fixture used the instruction, so the sign extension was never checked on a GPU and SOPK had no covered form. This adds one draw that exports the extension.

Verification

Commit b860dd5 plus this change, Windows 10 Enterprise 26H2 build 26300.9974, MSVC 14.51.36231, Windows SDK 10.0.26100.0 DXC.

ctest --preset dev --no-tests=error -R '^pixel_aot_' -V
  • pixel_aot_hardware: Passed on NVIDIA GeForce RTX 4070 Ti (10de:2782), driver 32.0.16.1088.
  • pixel_aot_warp: Passed on WARP 10.0.26100.9818.
  • Each test runs 55 draws with this change and 54 on b860dd5. Every draw reports debug_errors=0 and max_absolute_error=0.
  • tests/pixel_aot_check.py binary passes with the program added to the binary fixtures: LLVM 15.0.6 llvm-mc and llvm-objcopy, disassembled through libLLVM-17.so and libLLVM-18.so on Linux. LLVM prints s_movk_i32 s48, 0x8000 and s_bfe_u32 s49, s48, 0x80018 exactly as written. The controls, tests/docs_links_check.py and tests/bidi_controls_check.py pass.

Evidence and follow-up

The program uses only instructions already on main:

  1. It moves 0x8000 and 0x7fff with s_movk_i32.
  2. s_bfe_u32 extracts bytes 1 and 3 of each result.
  3. v_cvt_f32_f16 widens each byte as a binary16 subnormal, and a multiply by 2^24 turns it into the exact integer.

With sign extension the draw exports 255, 128, 127 and 0. Two wrong references each report pixel_mismatch: zero extension, which gives 0 for byte 3 of 0x8000, and treating 0x7fff as negative, which gives 255 for its byte 3.

This branch merges cleanly with #288, #293, #324, #329, #334, #337 and #340.

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 README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted: yes. Written with Claude Opus 5.5; verified on the hardware listed above.

🤖 Generated with Claude Code

https://claude.ai/code/session_01X1EBSe6YfE2ivQChRsx1hc

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6535389751 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/342). Originally posted by [Its3rr0rsWRLD](https://github.com/Its3rr0rsWRLD) on 2026-11-21T22:46:05Z. --- ## Change This adds tests only; the translator is unchanged. `pixel_aot` already lowers `s_movk_i32` by sign-extending its 16-bit immediate and folding the result (`tools/pixel_aot.py`, the `s_mov_b32|s_movk_i32` branch). No fixture used the instruction, so the sign extension was never checked on a GPU and SOPK had no covered form. This adds one draw that exports the extension. ## Verification Commit b860dd5 plus this change, Windows 10 Enterprise 26H2 build 26300.9974, MSVC 14.51.36231, Windows SDK 10.0.26100.0 DXC. ```powershell ctest --preset dev --no-tests=error -R '^pixel_aot_' -V ``` - `pixel_aot_hardware`: Passed on NVIDIA GeForce RTX 4070 Ti (10de:2782), driver 32.0.16.1088. - `pixel_aot_warp`: Passed on WARP 10.0.26100.9818. - Each test runs 55 draws with this change and 54 on b860dd5. Every draw reports `debug_errors=0` and `max_absolute_error=0`. - `tests/pixel_aot_check.py binary` passes with the program added to the binary fixtures: LLVM 15.0.6 `llvm-mc` and `llvm-objcopy`, disassembled through `libLLVM-17.so` and `libLLVM-18.so` on Linux. LLVM prints `s_movk_i32 s48, 0x8000` and `s_bfe_u32 s49, s48, 0x80018` exactly as written. The controls, `tests/docs_links_check.py` and `tests/bidi_controls_check.py` pass. ## Evidence and follow-up The program uses only instructions already on `main`: 1. It moves 0x8000 and 0x7fff with `s_movk_i32`. 2. `s_bfe_u32` extracts bytes 1 and 3 of each result. 3. `v_cvt_f32_f16` widens each byte as a binary16 subnormal, and a multiply by 2^24 turns it into the exact integer. With sign extension the draw exports 255, 128, 127 and 0. Two wrong references each report `pixel_mismatch`: zero extension, which gives 0 for byte 3 of 0x8000, and treating 0x7fff as negative, which gives 255 for its byte 3. This branch merges cleanly with #288, #293, #324, #329, #334, #337 and #340. ## 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 README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted: yes. Written with Claude Opus 5.5; verified on the hardware listed above. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01X1EBSe6YfE2ivQChRsx1hc
upstream-sync closed this pull request 2026-11-24 06:42:32 +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!337
No description provided.