shader: lower gfx1013 cube coordinate instructions in pixel_aot #295

Merged
Its3rr0rsWRLD merged 1 commit from upstream-pr/299 into main 2026-11-21 21:27:19 +00:00
Its3rr0rsWRLD commented 2026-11-21 21:18:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Its3rr0rsWRLD on 2026-11-21T21:18:04Z.


Change

pixel_aot rejected the cube-map coordinate instructions v_cubeid_f32, v_cubesc_f32, v_cubetc_f32 and v_cubema_f32, which shaders use before sampling a cube map. This lowers all four following LLVM's ConstantFoldAMDGCNCubeIntrinsic (llvm/lib/Analysis/ConstantFolding.cpp, release/15.x): the major axis is z if |z| is at least |x| and |y|, otherwise y if |y| is at least |x|, otherwise x; a face is negative only for a nonzero, non-NaN negative coordinate; v_cubema_f32 returns twice the signed major coordinate. Each result is computed inline from the three operands, with source modifiers and clamp handled like the other arithmetic. Independent problem: it widens the arithmetic the pixel translator accepts.

Overlap: #288, #292, #293 and #297 also edit these files. This branch merges cleanly with #292, #293 and #297. With #288 it conflicts on one line: both append a program to the check_binary fixture list at the same position. Whichever lands second, I will rebase and keep both lines.

Verification

Commit d311159 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.
  • Every draw reports debug_errors=0 and max_absolute_error=0. Each test runs 46 draws with this change and 40 on d311159; the six extra draws are the six cube directions.
  • 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 (no shared LLVM 15 library was available). Unchanged main passes the same check with both libraries. The Ubuntu CI job runs it with LLVM 15.
  • tests/docs_links_check.py and tests/bidi_controls_check.py pass.

Evidence and follow-up

The fixture is synthetic. One shader evaluates all four operations on the direction in constant words 3 to 5, and it is drawn for six directions: (2, -2, 1) and (-1.5, 0.25, -1.5) for the y/x and z/x ties, (-3, 1, 2), (0, 0, -0), (1, 0.5, -0.25) and (0.25, 1, 0.5). Together they select all six faces; (0, 0, -0) selects face 4 because -0 is not negative, and exports -0 for the major axis. The reference is a direct Python transcription of the LLVM function, and every expected value is exact after the half export. Negative controls, one per direction, each must report pixel_mismatch and does: the other axis winning a tie (twice), -0 treated as negative, an unsigned major axis, and a coordinate with the wrong sign. The controls also check the inline lowering and refuse a missing operand. The translator on d311159 rejects the program at its first v_cubeid_f32.

Not measured here: NaN coordinates, which are not drawn, and cube-map sampling itself, which the translator does not support yet.

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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6534511395 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/299). Originally posted by [Its3rr0rsWRLD](https://github.com/Its3rr0rsWRLD) on 2026-11-21T21:18:04Z. --- ## Change `pixel_aot` rejected the cube-map coordinate instructions `v_cubeid_f32`, `v_cubesc_f32`, `v_cubetc_f32` and `v_cubema_f32`, which shaders use before sampling a cube map. This lowers all four following LLVM's `ConstantFoldAMDGCNCubeIntrinsic` (`llvm/lib/Analysis/ConstantFolding.cpp`, release/15.x): the major axis is z if |z| is at least |x| and |y|, otherwise y if |y| is at least |x|, otherwise x; a face is negative only for a nonzero, non-NaN negative coordinate; `v_cubema_f32` returns twice the signed major coordinate. Each result is computed inline from the three operands, with source modifiers and `clamp` handled like the other arithmetic. Independent problem: it widens the arithmetic the pixel translator accepts. Overlap: #288, #292, #293 and #297 also edit these files. This branch merges cleanly with #292, #293 and #297. With #288 it conflicts on one line: both append a program to the `check_binary` fixture list at the same position. Whichever lands second, I will rebase and keep both lines. ## Verification Commit d311159 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. - Every draw reports `debug_errors=0` and `max_absolute_error=0`. Each test runs 46 draws with this change and 40 on d311159; the six extra draws are the six cube directions. - `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 (no shared LLVM 15 library was available). Unchanged main passes the same check with both libraries. The Ubuntu CI job runs it with LLVM 15. - `tests/docs_links_check.py` and `tests/bidi_controls_check.py` pass. ## Evidence and follow-up The fixture is synthetic. One shader evaluates all four operations on the direction in constant words 3 to 5, and it is drawn for six directions: (2, -2, 1) and (-1.5, 0.25, -1.5) for the y/x and z/x ties, (-3, 1, 2), (0, 0, -0), (1, 0.5, -0.25) and (0.25, 1, 0.5). Together they select all six faces; (0, 0, -0) selects face 4 because -0 is not negative, and exports -0 for the major axis. The reference is a direct Python transcription of the LLVM function, and every expected value is exact after the half export. Negative controls, one per direction, each must report `pixel_mismatch` and does: the other axis winning a tie (twice), -0 treated as negative, an unsigned major axis, and a coordinate with the wrong sign. The controls also check the inline lowering and refuse a missing operand. The translator on d311159 rejects the program at its first `v_cubeid_f32`. Not measured here: NaN coordinates, which are not drawn, and cube-map sampling itself, which the translator does not support yet. ## 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.
upstream-sync closed this pull request 2026-11-24 06:42:18 +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!295
No description provided.