shader: lower gfx1013 32-bit integer min, max and med3 in pixel_aot #303
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/308"
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 alexander-src on 2026-11-21T21:41:23Z.
Change
Lower all 14 gfx1013 32-bit integer minimum, maximum, and median instruction forms in
tools/pixel_aot.py:v_min_i32,v_max_i32,v_min_u32, andv_max_u32in both_e32and_e64encodings (8 forms).v_min3_i32,v_max3_i32,v_med3_i32,v_min3_u32,v_max3_u32, andv_med3_u32(6 forms).Operands are reinterpreted via
asint(i32) orasuint(u32), evaluated with HLSLmin/max(storing the threemed3operands once into anint3/uint3local before takingmax(min(x, y), min(max(x, y), z))), and written back to vector registers withasfloat. Float source modifiers (-,|x|,abs(...)),clamp, pending sample overwrites, unresolved loads, and whole-quad mode are rejected.Add control, binary assembly/disassembly, and D3D12 draw fixtures in
tests/pixel_aot_check.py, plus documentation indocs/experiments.md.Verification
Commit
4f0811con Linux x86_64 (Python 3.14, LLVM 23.1, g++):python3 -B tests/pixel_aot_check.py binary llvm-mc llvm-objcopy libLLVM.so: passed (assembles all 4 new fixtures covering all 14 forms forgfx1013, extracts, disassembles, lowers, and matches source lowering).g++ -std=c++17 -O2 -Wall -Wextra -Werror) of all 4 generated shader bodies against the Python reference across exact binary16 inputs ((-2.0, 1.0),(-2.0, -1.0),(-2.0, -1.0, 1.0),(0.5, -0.5, 4.0)plusmed3ties): all 14 forms matched.main:tools/pixel_aot.py: rejectedv_min_i32_e32(Unsupported instruction 21) andv_min3_i32(Unsupported instruction 22).python3 -B tests/docs_links_check.py,tests/bidi_controls_check.py,tests/rdna2_tools_check.py(26 ran, 1 skipped withoutLLVM_LIB), and the 5 non-iced_x86checks intests/form_coverage_check.py: all passed.offscreen_check.exeD3D12 draws locally because this environment is Linux without MSVC/DXC/Windows;check_int_minmax_draws()will execute under the Windows CI job.Evidence and follow-up
All fixtures are synthetic AMDGPU assembly programs authored inline in
tests/pixel_aot_check.pyunder the repository's MIT license. Test inputs are exact normal binary16 floats whose 32-bit patterns reverse order across signed, unsigned, and floating-point comparisons, so every winning bit pattern survivesexport16without precision loss. Semantics follow the AMD RDNA Shader ISA reference.This shares the
int_operand()helper with #306; whichever merges second will need a small rebase. It does not overlap with #169 (f32min3/max3/med3) or #232 (bitwise/shift/conversion).Checklist
AI-assisted: yes.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T21:58:50Z.
At
4f0811cthe merge conflicts are indocs/experiments.md,tests/pixel_aot_check.py. Keep the integer extrema cases alongside existing pixel coverage and shareint_operandwith the adjacent comparison work.Imported from R0Y00/Xbox2Windows. Originally posted by alexander-src on 2026-11-21T22:19:49Z.
Rebased onto
main(6ee2406) in8f24058, preserving all landed scalar64,v_cvt_f32_f16, andfmaak/fmamktests and docs alongside the integer min/max/med3 cases. Updatedint_operand()to delegate toscalar_u32()identically to #306 and #310 so whichever lands second stays an easy rebase.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T02:56:26Z.
A test merge of
8f24058against main conflicts intests/pixel_aot_check.py. The integer comparisons in #306 have now landed. Reuse theirint_operandand retain both the comparison and extrema fixtures. Please refresh the branch and rerun the relevant fixture and Windows CI.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T03:08:19Z.
Please update only #308 first, using the integer operand handling that landed in #306. The earlier request to refresh #310 can wait until #308 lands; that way the shared helper and draw list only need reconciling once per branch.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T04:04:05Z.
I merged main into this branch and resolved the conflicts in the pixel lowerer and its test driver. On
9105a0d, ctest --preset dev --no-tests=error -R ^pixel_aot_ passed on hardware (53.40 s) and WARP (11.10 s). Auto-merge is enabled while CI runs. No rebase is needed from you.