shader: lower gfx1013 floating-point ceiling #266

Merged
lambirou merged 2 commits from upstream-pr/270 into main 2026-11-21 21:25:58 +00:00
lambirou commented 2026-11-21 19:52:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-21T19:52:57Z.


Change

Lower v_ceil_f32 to HLSL ceil for the gfx1013 straight-line pixel path. The e32 and e64 encodings use the existing floating-point operand and output handling. A ceiling write into a pending texture sample destination is rejected before vmcnt(0).

Related work in #258 covers v_trunc_f32. Both patches touch the floating-point ALU dispatch in tools/pixel_aot.py and can be reviewed independently.

Verification

Tested commit 275043a92b144d00663ad041c1c5b68c8d2e5ff3 on 7233cecc0efea32e0dba55c3d2e66227b09b8a86 using Windows 11 build 26300.10075, MSVC 14.44.35207 and Windows SDK DXC 10.0.26100.0.

.\tools\dev.ps1
cmake --preset dev
cmake --build --preset dev
ctest --preset dev --no-tests=error -R '^pixel_aot_(warp|hardware)$' --output-junit "$PWD/out/shader-ceil.xml" -V
.\out\pe-env\Scripts\python.exe -B tools/form_coverage.py out/shader-ceil.xml --json out/shader-ceil.json
ctest --preset dev --no-tests=error -E '_hardware$' --output-junit "$PWD/out/shader-ceil-regression.xml"
.\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py
.\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py
  • Both pixel tests passed on Microsoft Basic Render Driver (WARP 10.0.26100.10068) and AMD Radeon RX 9060 XT (driver 32.0.32029.2010). The debug layer was unavailable. The targeted tests had no skips.
  • The coverage report includes both ceiling encodings and counts 59 of 1,968 gfx1013 forms. The Windows regression suite passed 94 tests with two WARP capability skips (bvh_wave64_warp and wave_shuffle_warp). Both Python checks passed.
  • The binary suite passed with LLVM 23.1.5 for Windows. It assembles gfx1013 programs, disassembles them and checks that both input paths emit identical HLSL.
  • git diff --check origin/main HEAD passed.
$llvmBin = (Resolve-Path out/llvm-check/ucrt64/bin).Path
.\out\pe-env\Scripts\python.exe -B tests/pixel_aot_check.py binary "$llvmBin\llvm-mc.exe" "$llvmBin\llvm-objcopy.exe" "$llvmBin\libLLVM-23.dll"

Evidence and follow-up

The original MIT-licensed fixture uses synthetic shader source and constants and checks the four rendered channels against a Python reference. It covers negative and positive fractions, integral inputs, signed zero and e64 absolute value, negation and clamp. Before the lowering change, the fixture stopped at Unsupported instruction 20: v_ceil_f32_e32 v12, s44. The ceiling-to-floor control reports pixel_mismatch, and the early destination write is rejected. The experiment and its reproduction commands are in docs/experiments.md. AMD RDNA 2 ISA reference

Checklist

  • This pull request covers one reviewable behavior.
  • I included the verification commands and observed results.
  • The fixture includes negative controls.
  • I updated the relevant experiment documentation.
  • The patch contains only source, tests and documentation.

This contribution was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6533643156 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/270). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-21T19:52:57Z. --- ## Change Lower `v_ceil_f32` to HLSL `ceil` for the gfx1013 straight-line pixel path. The e32 and e64 encodings use the existing floating-point operand and output handling. A ceiling write into a pending texture sample destination is rejected before `vmcnt(0)`. Related work in #258 covers `v_trunc_f32`. Both patches touch the floating-point ALU dispatch in `tools/pixel_aot.py` and can be reviewed independently. ## Verification Tested commit `275043a92b144d00663ad041c1c5b68c8d2e5ff3` on `7233cecc0efea32e0dba55c3d2e66227b09b8a86` using Windows 11 build 26300.10075, MSVC 14.44.35207 and Windows SDK DXC 10.0.26100.0. ```powershell .\tools\dev.ps1 cmake --preset dev cmake --build --preset dev ctest --preset dev --no-tests=error -R '^pixel_aot_(warp|hardware)$' --output-junit "$PWD/out/shader-ceil.xml" -V .\out\pe-env\Scripts\python.exe -B tools/form_coverage.py out/shader-ceil.xml --json out/shader-ceil.json ctest --preset dev --no-tests=error -E '_hardware$' --output-junit "$PWD/out/shader-ceil-regression.xml" .\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py .\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py ``` - Both pixel tests passed on Microsoft Basic Render Driver (WARP 10.0.26100.10068) and AMD Radeon RX 9060 XT (driver 32.0.32029.2010). The debug layer was unavailable. The targeted tests had no skips. - The coverage report includes both ceiling encodings and counts 59 of 1,968 gfx1013 forms. The Windows regression suite passed 94 tests with two WARP capability skips (`bvh_wave64_warp` and `wave_shuffle_warp`). Both Python checks passed. - The binary suite passed with LLVM 23.1.5 for Windows. It assembles gfx1013 programs, disassembles them and checks that both input paths emit identical HLSL. - `git diff --check origin/main HEAD` passed. ```powershell $llvmBin = (Resolve-Path out/llvm-check/ucrt64/bin).Path .\out\pe-env\Scripts\python.exe -B tests/pixel_aot_check.py binary "$llvmBin\llvm-mc.exe" "$llvmBin\llvm-objcopy.exe" "$llvmBin\libLLVM-23.dll" ``` ## Evidence and follow-up The original MIT-licensed fixture uses synthetic shader source and constants and checks the four rendered channels against a Python reference. It covers negative and positive fractions, integral inputs, signed zero and e64 absolute value, negation and clamp. Before the lowering change, the fixture stopped at `Unsupported instruction 20: v_ceil_f32_e32 v12, s44`. The ceiling-to-floor control reports `pixel_mismatch`, and the early destination write is rejected. The experiment and its reproduction commands are in `docs/experiments.md`. [AMD RDNA 2 ISA reference](https://docs.amd.com/v/u/en-US/rdna2-shader-instruction-set-architecture) ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the verification commands and observed results. - [x] The fixture includes negative controls. - [x] I updated the relevant experiment documentation. - [x] The patch contains only source, tests and documentation. This contribution was AI-assisted.
upstream-sync closed this pull request 2026-11-24 06:42:09 +00:00
R0Y00 commented 2026-11-24 06:47:59 +00:00 (Migrated from github.com)

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


275043a conflicts in tests/pixel_aot_check.py and tools/pixel_aot.py. #273 now supplies the pending-sample destination guard for the whole arithmetic path. Please retain that guard and fract32 while adding ceil, then rerun the pixel and LLVM checks.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7068775930 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/270#issuecomment-7068775930). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-21T20:28:18Z. --- `275043a` conflicts in `tests/pixel_aot_check.py` and `tools/pixel_aot.py`. #273 now supplies the pending-sample destination guard for the whole arithmetic path. Please retain that guard and `fract32` while adding `ceil`, then rerun the pixel and LLVM checks.
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!266
No description provided.