shader: draw v_exp_f32_e64, v_log_f32_e64 and v_mac_f32_e64 in pixel_aot #723

Merged
rasptum merged 1 commit from upstream-pr/729 into main 2026-11-22 23:54:05 +00:00
rasptum commented 2026-11-22 23:21:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-22T23:21:24Z.


Change

Tests and documentation only. tools/pixel_aot.py is unchanged.

pixel_aot already accepts the VOP3 (e64) encodings of v_exp_f32, v_log_f32 and v_mac_f32, but no fixture translated them, so they were never drawn and did not count as covered. #340 (merged) drew the other accepted e64 forms and left the approximate ones out, because D3D allows exp2 and log2 a last-place error and a raw result has no single binary32 reference.

One program now draws all three, and makes a bitwise comparison valid:

  • For exp and log each input is chosen so that the true result is a small integer. The program then adds 0.5 and takes the floor (v_add_f32_e32, v_floor_f32_e32), which returns the same integer for any result within 0.5 of the true one. This checks the operation and its source modifiers, which are what e64 adds over e32, not last-place accuracy.
  • v_mac_f32_e64 is exact and is compared directly.

A, B, C and D are constants s44 to s47. Two rows are drawn: (-3, -32, 0.25, 4097) and (-4, -8, 0.5, 4097).

Instruction Expected, row 1 Expected, row 2
v_exp_f32_e64 v12, -s44 8 16
v_log_f32_e64 v13, |s45| 5 3
v_mac_f32_e64 v14, -s44, |s45| onto C 96.25 32.5
v_mac_f32_e64 v15, -s47, -s47 onto -16785408 0 (unfused; a fused multiply-add gives 1.0) 0

Negative controls: eight wrong references on the first row, each replacing one channel, must report pixel_mismatch.

Wrong reference Channel Value in the wrong reference Drawn
exp with the negation dropped 0 0 8
natural exponential for exp2 0 20 8
log for exp 0 2 8
natural logarithm for log2 1 3 5
exp for log 1 4294967296 5
mac with the negation dropped 2 -95.75 96.25
mac with the accumulator dropped 2 96 96.25
fused multiply-add 3 1 0

The draws are registered as their own CTest entries, pixel_aot_e64_approx_hardware and pixel_aot_e64_approx_warp (tests/pixel_aot_check.py draw-e64-approx), each with its own FORM_COVERAGE_RECORD, so nothing is added to pixel_aot_hardware. That is 10 draws from one compile and one renderer launch. The program is added to the LLVM 15 round trip, the controls assert that the modifiers reach exp2, log2 and the unfused helper and that v_mac_f32_e64 with an unwritten destination is refused, tests/form_coverage_check.py asserts the three forms, and docs/experiments.md has a paragraph (the sentence there saying the approximate exp and log e64 forms are not drawn is updated).

This advances instruction-form coverage of the pixel translator by three forms on gfx1013 and two on gfx1030.

Verification

Update before opening: rebased onto main at 121fdc3 as d3e2239. On that commit I reran the LLVM 15 round trip, tests/form_coverage_check.py and the full pixel_aot_check.py draw run on WARP (all pass); the hardware and ctest results below are from the commit named there.

The full ctest run below was made at cdb6b0e (this change on main 787ace7). The branch was then rebased onto 7c256c3 (cb49062), which adds only #683 (README and 11 lines of static controls); the two new tests on both backends, the controls, the round trip, form_coverage_check.py, pso_readiness_check.py and docs_links_check.py were rerun there and passed. Windows 10 Pro 22H2 (10.0.19045.6466), Windows SDK 10.0.26100.0 DXC, Debug build, debug layer enabled in every run.

cmake --preset dev
cmake --build --preset dev --target offscreen_check
ctest --preset dev --no-tests=error -R '^pixel_aot_'

24 tests ran. 23 passed, 1 failed, 0 skipped.

Test Adapter Result
pixel_aot_e64_approx_warp Microsoft Basic Render Driver, WARP 10.0.19041.5794 Passed, 0.6 s
pixel_aot_e64_approx_hardware NVIDIA GeForce RTX 3060 (10de:2503), driver 32.0.15.9636 Passed, 1.0 s
the other 11 pixel_aot_*_warp tests WARP 10.0.19041.5794 Passed
10 of the other 11 pixel_aot_*_hardware tests RTX 3060 Passed
pixel_aot_blend_scalar_hardware RTX 3060 Failed. It also fails on untouched main on this machine and this change does not touch it.

In both new tests the two right references report max_absolute_error=0, every draw reports debug_errors=0 debug_warnings=0, and the 8 wrong references each report mismatch.

Other checks, all passed:

  • python -B tests/pixel_aot_check.py binary <llvm-mc> <llvm-objcopy> <LLVM-C.dll> with LLVM 15.0.7. LLVM 15 prints all ten instructions of the program exactly as written for -mcpu=gfx1013.
  • python -B tests/pixel_aot_check.py (controls).
  • The 22 pure-Python checks listed in AGENTS.md.

Evidence and follow-up

Coverage, counted with tools/form_coverage.py from the records of the run above. The baseline is the union of the seven record-writing shader tests run on WARP from a clean copy of 787ace7.

gfx1013 gfx1030 (RDNA2)
main at 787ace7 515 of 1968 510 of 1863
this change 518 of 1968 512 of 1863

The forms added are exactly v_exp_f32_e64, v_log_f32_e64 and v_mac_f32_e64. v_mac_f32 is not in the gfx1030 list, so that list gains two. None is removed. docs/coverage/dashboard.svg is not regenerated here.

What this does not show: last-place accuracy of exp and log on any adapter, inputs outside these two rows (zero, negative arguments to log, infinities, NaN), and what the console computes. The e32 forms keep their existing draws.

Overlap with open pull requests: #340 is merged and does not contain these. The diffs of the open shader pull requests (38 read) were searched for the three form names on added lines; none adds them. This pull request appends one line to the check_binary fixture list, as every open shader pull request does, so a textual conflict there with whichever lands first is expected and trivial.

AI-assisted (Claude Code). The Windows results were measured locally.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6549144811 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/729). Originally posted by [rasptum](https://github.com/rasptum) on 2026-11-22T23:21:24Z. --- ## Change Tests and documentation only. `tools/pixel_aot.py` is unchanged. `pixel_aot` already accepts the VOP3 (e64) encodings of `v_exp_f32`, `v_log_f32` and `v_mac_f32`, but no fixture translated them, so they were never drawn and did not count as covered. #340 (merged) drew the other accepted e64 forms and left the approximate ones out, because D3D allows `exp2` and `log2` a last-place error and a raw result has no single binary32 reference. One program now draws all three, and makes a bitwise comparison valid: - For exp and log each input is chosen so that the true result is a small integer. The program then adds 0.5 and takes the floor (`v_add_f32_e32`, `v_floor_f32_e32`), which returns the same integer for any result within 0.5 of the true one. This checks the operation and its source modifiers, which are what e64 adds over e32, not last-place accuracy. - `v_mac_f32_e64` is exact and is compared directly. A, B, C and D are constants s44 to s47. Two rows are drawn: (-3, -32, 0.25, 4097) and (-4, -8, 0.5, 4097). | Instruction | Expected, row 1 | Expected, row 2 | |---|---|---| | `v_exp_f32_e64 v12, -s44` | 8 | 16 | | `v_log_f32_e64 v13, \|s45\|` | 5 | 3 | | `v_mac_f32_e64 v14, -s44, \|s45\|` onto C | 96.25 | 32.5 | | `v_mac_f32_e64 v15, -s47, -s47` onto -16785408 | 0 (unfused; a fused multiply-add gives 1.0) | 0 | Negative controls: eight wrong references on the first row, each replacing one channel, must report `pixel_mismatch`. | Wrong reference | Channel | Value in the wrong reference | Drawn | |---|---|---|---| | exp with the negation dropped | 0 | 0 | 8 | | natural exponential for exp2 | 0 | 20 | 8 | | log for exp | 0 | 2 | 8 | | natural logarithm for log2 | 1 | 3 | 5 | | exp for log | 1 | 4294967296 | 5 | | mac with the negation dropped | 2 | -95.75 | 96.25 | | mac with the accumulator dropped | 2 | 96 | 96.25 | | fused multiply-add | 3 | 1 | 0 | The draws are registered as their own CTest entries, `pixel_aot_e64_approx_hardware` and `pixel_aot_e64_approx_warp` (`tests/pixel_aot_check.py draw-e64-approx`), each with its own `FORM_COVERAGE_RECORD`, so nothing is added to `pixel_aot_hardware`. That is 10 draws from one compile and one renderer launch. The program is added to the LLVM 15 round trip, the controls assert that the modifiers reach `exp2`, `log2` and the unfused helper and that `v_mac_f32_e64` with an unwritten destination is refused, `tests/form_coverage_check.py` asserts the three forms, and `docs/experiments.md` has a paragraph (the sentence there saying the approximate exp and log e64 forms are not drawn is updated). This advances instruction-form coverage of the pixel translator by three forms on gfx1013 and two on gfx1030. ## Verification Update before opening: rebased onto `main` at 121fdc3 as d3e2239. On that commit I reran the LLVM 15 round trip, `tests/form_coverage_check.py` and the full `pixel_aot_check.py draw` run on WARP (all pass); the hardware and ctest results below are from the commit named there. The full `ctest` run below was made at cdb6b0e (this change on `main` 787ace7). The branch was then rebased onto 7c256c3 (cb49062), which adds only #683 (README and 11 lines of static controls); the two new tests on both backends, the controls, the round trip, `form_coverage_check.py`, `pso_readiness_check.py` and `docs_links_check.py` were rerun there and passed. Windows 10 Pro 22H2 (10.0.19045.6466), Windows SDK 10.0.26100.0 DXC, Debug build, debug layer enabled in every run. ```powershell cmake --preset dev cmake --build --preset dev --target offscreen_check ctest --preset dev --no-tests=error -R '^pixel_aot_' ``` 24 tests ran. 23 passed, 1 failed, 0 skipped. | Test | Adapter | Result | |---|---|---| | `pixel_aot_e64_approx_warp` | Microsoft Basic Render Driver, WARP 10.0.19041.5794 | Passed, 0.6 s | | `pixel_aot_e64_approx_hardware` | NVIDIA GeForce RTX 3060 (10de:2503), driver 32.0.15.9636 | Passed, 1.0 s | | the other 11 `pixel_aot_*_warp` tests | WARP 10.0.19041.5794 | Passed | | 10 of the other 11 `pixel_aot_*_hardware` tests | RTX 3060 | Passed | | `pixel_aot_blend_scalar_hardware` | RTX 3060 | Failed. It also fails on untouched `main` on this machine and this change does not touch it. | In both new tests the two right references report `max_absolute_error=0`, every draw reports `debug_errors=0 debug_warnings=0`, and the 8 wrong references each report `mismatch`. Other checks, all passed: - `python -B tests/pixel_aot_check.py binary <llvm-mc> <llvm-objcopy> <LLVM-C.dll>` with LLVM 15.0.7. LLVM 15 prints all ten instructions of the program exactly as written for `-mcpu=gfx1013`. - `python -B tests/pixel_aot_check.py` (controls). - The 22 pure-Python checks listed in `AGENTS.md`. ## Evidence and follow-up Coverage, counted with `tools/form_coverage.py` from the records of the run above. The baseline is the union of the seven record-writing shader tests run on WARP from a clean copy of 787ace7. | | gfx1013 | gfx1030 (RDNA2) | |---|---|---| | `main` at 787ace7 | 515 of 1968 | 510 of 1863 | | this change | 518 of 1968 | 512 of 1863 | The forms added are exactly `v_exp_f32_e64`, `v_log_f32_e64` and `v_mac_f32_e64`. `v_mac_f32` is not in the gfx1030 list, so that list gains two. None is removed. `docs/coverage/dashboard.svg` is not regenerated here. What this does not show: last-place accuracy of exp and log on any adapter, inputs outside these two rows (zero, negative arguments to log, infinities, NaN), and what the console computes. The e32 forms keep their existing draws. Overlap with open pull requests: #340 is merged and does not contain these. The diffs of the open shader pull requests (38 read) were searched for the three form names on added lines; none adds them. This pull request appends one line to the `check_binary` fixture list, as every open shader pull request does, so a textual conflict there with whichever lands first is expected and trivial. _AI-assisted (Claude Code). The Windows results were measured locally._ 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 06:44: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!723
No description provided.