Lower gfx1013 add, mul, sqrt, rsq, floor and fract in pixel shader translation #120

Merged
PrivacyOnion merged 1 commit from upstream-pr/121 into main 2026-11-21 17:57:46 +00:00
PrivacyOnion commented 2026-11-21 16:36:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by PrivacyOnion on 2026-11-21T16:36:26Z.


Change

Extends tools/pixel_aot.py to lower v_add_f32, v_mul_f32, v_sqrt_f32, v_rsq_f32, v_floor_f32 and v_fract_f32 (_e32 and _e64, including optional clamp) into precise float HLSL expressions (+, *, sqrt, rsqrt, floor, frac).

tests/pixel_aot_check.py adds a shaping() program and shaping_case() CPU reference that exercise all six new instructions with bound constant buffer parameters across the 8x8 UNORM ramp, checks LLVM 15 exp mrt0 comma formatting and arity rejection controls, includes shaping() in the gfx1013 binary round-trip check, and verifies D3D12 readback and constant corruption rejection on both hardware and WARP.

Verification

Built and verified at 734d09b on Windows 11 with VS Build Tools 2022 17.14 (MSVC 19.44.35228.0), Windows SDK 10.0.26100.0, Python 3.12, on NVIDIA GeForce RTX 5070 (vendor=10de device=2f04, driver 32.0.16.1664, debug_layer=enabled) and Microsoft Basic Render Driver (WARP, vendor=1414 device=008c, driver 10.0.26100.9818, debug_layer=enabled):

ctest --preset dev -R '^pixel_aot_' --no-tests=error -V
  • pixel_aot_hardware: passed (pixels=4096 channels=16384 max_absolute_error=0 across all 6 draws, debug_errors=0 debug_warnings=0, negative controls rejected).
  • pixel_aot_warp: passed (pixels=4096 channels=16384 max_absolute_error=0 across all 6 draws, debug_errors=0 debug_warnings=0, negative controls rejected).

Evidence and follow-up

All test inputs are synthetic gfx1013 assembly programs and CPU-computed binary16 round-toward-zero reference cases generated at test time.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6531508175 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/121). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-21T16:36:26Z. --- ## Change Extends `tools/pixel_aot.py` to lower `v_add_f32`, `v_mul_f32`, `v_sqrt_f32`, `v_rsq_f32`, `v_floor_f32` and `v_fract_f32` (`_e32` and `_e64`, including optional `clamp`) into `precise float` HLSL expressions (`+`, `*`, `sqrt`, `rsqrt`, `floor`, `frac`). `tests/pixel_aot_check.py` adds a `shaping()` program and `shaping_case()` CPU reference that exercise all six new instructions with bound constant buffer parameters across the 8x8 UNORM ramp, checks LLVM 15 `exp mrt0` comma formatting and arity rejection controls, includes `shaping()` in the `gfx1013` binary round-trip check, and verifies D3D12 readback and constant corruption rejection on both hardware and WARP. ## Verification Built and verified at `734d09b` on Windows 11 with VS Build Tools 2022 17.14 (`MSVC 19.44.35228.0`), Windows SDK `10.0.26100.0`, Python `3.12`, on `NVIDIA GeForce RTX 5070` (`vendor=10de device=2f04`, driver `32.0.16.1664`, `debug_layer=enabled`) and `Microsoft Basic Render Driver` (`WARP`, `vendor=1414 device=008c`, driver `10.0.26100.9818`, `debug_layer=enabled`): ```powershell ctest --preset dev -R '^pixel_aot_' --no-tests=error -V ``` - `pixel_aot_hardware`: passed (`pixels=4096 channels=16384 max_absolute_error=0` across all 6 draws, `debug_errors=0 debug_warnings=0`, negative controls rejected). - `pixel_aot_warp`: passed (`pixels=4096 channels=16384 max_absolute_error=0` across all 6 draws, `debug_errors=0 debug_warnings=0`, negative controls rejected). ## Evidence and follow-up All test inputs are synthetic `gfx1013` assembly programs and CPU-computed binary16 round-toward-zero reference cases generated at test time.
upstream-sync closed this pull request 2026-11-24 06:41:24 +00:00
R0Y00 commented 2026-11-24 06:47:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T17:18:27Z.


The six-instruction fixture looks good. GitHub now reports conflicts with main. Please keep the current select, absolute and dual-texture controls when reconciling pixel_aot_check.py and run the assembled and rendered fixtures. #144 can follow this PR.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7066376367 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/121#issuecomment-7066376367). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-21T17:18:27Z. --- The six-instruction fixture looks good. GitHub now reports conflicts with main. Please keep the current select, absolute and dual-texture controls when reconciling pixel_aot_check.py and run the assembled and rendered fixtures. #144 can follow this PR.
PrivacyOnion commented 2026-11-24 06:47:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by PrivacyOnion on 2026-11-21T17:39:53Z.


Rebased onto main, keeping the select, absolute_value, and dual_program (forward, reverse, reuse, swapped bindings, and swapped weights) controls alongside shaping and shaping_case. Verified pixel_aot_hardware and pixel_aot_warp:

1/2 Test #72: pixel_aot_hardware ...............   Passed    8.64 sec
2/2 Test #74: pixel_aot_warp ...................   Passed    1.31 sec
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7066651145 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/121#issuecomment-7066651145). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-21T17:39:53Z. --- Rebased onto `main`, keeping the `select`, `absolute_value`, and `dual_program` (`forward`, `reverse`, `reuse`, swapped bindings, and swapped weights) controls alongside `shaping` and `shaping_case`. Verified `pixel_aot_hardware` and `pixel_aot_warp`: ```text 1/2 Test #72: pixel_aot_hardware ............... Passed 8.64 sec 2/2 Test #74: pixel_aot_warp ................... Passed 1.31 sec ```
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!120
No description provided.