shader: lower gfx1013 cube coordinate instructions in pixel_aot #295
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/299"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Its3rr0rsWRLD on 2026-11-21T21:18:04Z.
Change
pixel_aotrejected the cube-map coordinate instructionsv_cubeid_f32,v_cubesc_f32,v_cubetc_f32andv_cubema_f32, which shaders use before sampling a cube map. This lowers all four following LLVM'sConstantFoldAMDGCNCubeIntrinsic(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_f32returns twice the signed major coordinate. Each result is computed inline from the three operands, with source modifiers andclamphandled 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_binaryfixture list at the same position. Whichever lands second, I will rebase and keep both lines.Verification
Commit
d311159plus this change, Windows 10 Enterprise 26H2 build 26300.9974, MSVC 14.51.36231, Windows SDK 10.0.26100.0 DXC.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.debug_errors=0andmax_absolute_error=0. Each test runs 46 draws with this change and 40 ond311159; the six extra draws are the six cube directions.tests/pixel_aot_check.py binarypasses with the program added to the binary fixtures: LLVM 15.0.6llvm-mcandllvm-objcopy, disassembled throughlibLLVM-17.soandlibLLVM-18.soon 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.pyandtests/bidi_controls_check.pypass.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_mismatchand 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 ond311159rejects the program at its firstv_cubeid_f32.Not measured here: NaN coordinates, which are not drawn, and cube-map sampling itself, which the translator does not support yet.
Checklist
AI-assisted: yes. Written with Claude Opus 5.5; verified on the hardware listed above.