shader: lower gfx1030 comparison sample gradients #2740

Merged
stan495 merged 2 commits from upstream-pr/2748 into main 2026-11-26 07:12:47 +00:00
stan495 commented 2026-11-26 05:44:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-26T05:44:20Z.


Summary

Lower gfx1030 image_sample_c_d, image_sample_c_d_o, image_sample_c_d_g16, and image_sample_c_d_o_g16 to SampleCmpGrad. This subset accepts a two-mip 2D R32_FLOAT view, red dmask:0x1, a normalized point-comparison sampler and contiguous address operands. Gradients must be statically known and normal or zero in the input precision. G16 places U in the low half and V in the high half of each slope word. The offset forms accept a known packed signed XY displacement. Dynamic slopes, unwaited reads, unsupported sampler states and instruction LOD clamps remain refused.

Follows #1568, which is already on main. Physical GPU readbacks for all four forms (and comparison LOD bias) have now been reproduced on AMD Radeon RX 7900 XTX and AMD Radeon(TM) Graphics with the D3D12 debug layer enabled (see below).

Verification

Tested clean head 72f443fb13a9d47f421b2e20d02bec89a292aee6.

python3 -B tests/pixel_compare_grad_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 llc-15
python3 -B tests/pixel_compare_grad_check.py glsl glslangValidator spirv-val spirv-dis
python3 -B tests/pixel_compare_lod_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1
python3 -B tests/pixel_sample_clamp_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 llc-15

All four commands passed. The new binary check exercised LLVM code generation, assembly, disassembly and the synthetic-container CLI for all four forms. The translated HLSL was also compiled and drawn through the WARP fixture below.

. .\tools\dev.ps1
$root = (Get-Location).Path
$env:TEMP = "$root/out"
$env:TMP = $env:TEMP
cmake --preset dev -DINTAKE_PYTHON=<python-with-dev-requirements>
cmake --build --preset dev --target offscreen_check --parallel 6
ctest --preset dev --no-tests=error -j 1 -R '^pixel_aot_(compare_(grad|lod_(level|bias)|sample|gather)_(warp|hardware)|sample_(gradient|coarse_gradient)_(warp|hardware)|sample_clamp_(controls|compile|warp|hardware)|title_load.*warp)$' -V --output-junit "$root/out/grad-72f443fb.xml"
python -B tools/form_coverage.py out/grad-72f443fb.xml --records out/build/dev/form_coverage --json out/grad-72f443fb-coverage.json --gaps gfx1030
python -B tools/run_checks_parallel.py tests/docs_links_check.py tests/bidi_controls_check.py tests/form_coverage_check.py tests/pixel_compare_grad_check.py

CTest: 17 passed, 0 failed, 2 capability skips. Windows 11 build 26300.9974, WARP 10.0.26100.9818, Intel Arc B390 driver 32.0.101.8509, D3D12 debug layer unavailable. All four forms matched the CPU reference on WARP at 8x8 and 16x16. Zeroing the gradient for image_sample_c_d first changed pixel (2,0) from (1,0.578125,0.5,1) to (0,0.578125,0.5,1) in the 8x8 case. The WARP record counts all four forms; the targeted suite covers 27/111 gfx1030 MIMG forms, not the main-branch total. All four standalone Python checks passed.

Arc B390 reported SampleCmpGradientAndBiasSupported unavailable, skipping pixel_aot_compare_grad_hardware and pixel_aot_compare_lod_bias_hardware.

Physical GPU verification on 72f443fb13a9d47f421b2e20d02bec89a292aee6 (AMD)

Built clean head 72f443fb13a9d47f421b2e20d02bec89a292aee6 on Windows 11 build 10.0.26200.9974 with MSVC 19.44.35228.0, DXC 1.8.2502.11, and Python 3.12.10 (out/pe-env). D3D12 debug layer was enabled on all adapters (debug_errors=0 debug_warnings=0).

. .\tools\dev.ps1
$env:TMP = (Resolve-Path ..\..\out\t).Path
$env:TEMP = $env:TMP
$dxc = (Get-Command dxc -ErrorAction Stop).Source
python -B tests/pixel_compare_grad_check.py compile $dxc
python -B tools/run_checks_parallel.py tests/docs_links_check.py tests/bidi_controls_check.py tests/form_coverage_check.py tests/pixel_compare_grad_check.py
cmake --preset dev "-DINTAKE_PYTHON=$py"
cmake --build --preset dev --target offscreen_check --parallel 8

$env:XBOX2WINDOWS_ADAPTER = '7900 XTX'
ctest --preset dev --no-tests=error -j 1 -R '^pixel_aot_(compare_(grad|lod_(level|bias)|sample|gather)_(warp|hardware)|sample_(gradient|coarse_gradient)_(warp|hardware)|sample_clamp_(controls|compile|warp|hardware)|title_load.*warp)$' -V --output-junit "$(Resolve-Path out)/grad-72f443fb-7900xtx.xml"
python -B tools/form_coverage.py out/grad-72f443fb-7900xtx.xml --records out/build/dev/form_coverage --json out/grad-72f443fb-7900xtx-coverage.json --gaps gfx1030

$env:XBOX2WINDOWS_ADAPTER = 'Radeon(TM) Graphics'
ctest --preset dev --no-tests=error -j 1 -R '^pixel_aot_compare_(grad|lod_bias)_hardware$' -V
  • Standalone Python checks: compile and all 4 parallel checks (docs_links_check.py, bidi_controls_check.py, form_coverage_check.py, pixel_compare_grad_check.py) passed. (binary and glsl checks were not rerun here as LLVM 15 and glslang/spirv-tools are not installed on this Windows host; both passed in the Linux run above.)
  • AMD Radeon RX 7900 XTX (1002:744c, driver 32.0.32029.2010) + WARP (10.0.26100.9818): 19 passed, 0 failed, 0 capability skips (pixel_aot_compare_grad_hardware passed in 10.59 s, pixel_aot_compare_lod_bias_hardware passed in 5.62 s, pixel_aot_compare_grad_warp passed in 5.45 s). Targeted coverage from this run: 49/1863 gfx1030 forms (27/111 MIMG forms).
  • AMD Radeon(TM) Graphics (1002:164e, driver 32.0.21045.29003): 2 passed, 0 failed, 0 capability skips (pixel_aot_compare_grad_hardware passed in 7.75 s, pixel_aot_compare_lod_bias_hardware passed in 5.69 s).
  • Readback & first mutation mismatch: On both physical AMD GPUs and WARP, all four forms (image_sample_c_d, image_sample_c_d_o, image_sample_c_d_g16, image_sample_c_d_o_g16) matched the CPU reference at 8x8 and 16x16 (mismatches=0, debug_errors=0 debug_warnings=0). Zeroing the gradient for image_sample_c_d in the 8x8 case first differed at x=2 y=0: expected=1,0.578125,0.5,1 actual=0,0.578125,0.5,1 (mismatches=21).

git diff --check and the local merge simulation passed against upstream 1ec01d7037d30fbdc383d48dceb43ad8c48e0f0b. Merge simulation is separate from the tests above.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6620378468 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2748). Originally posted by [stan495](https://github.com/stan495) on 2026-11-26T05:44:20Z. --- ## Summary Lower gfx1030 `image_sample_c_d`, `image_sample_c_d_o`, `image_sample_c_d_g16`, and `image_sample_c_d_o_g16` to `SampleCmpGrad`. This subset accepts a two-mip 2D `R32_FLOAT` view, red `dmask:0x1`, a normalized point-comparison sampler and contiguous address operands. Gradients must be statically known and normal or zero in the input precision. G16 places U in the low half and V in the high half of each slope word. The offset forms accept a known packed signed XY displacement. Dynamic slopes, unwaited reads, unsupported sampler states and instruction LOD clamps remain refused. Follows #1568, which is already on main. Physical GPU readbacks for all four forms (and comparison LOD bias) have now been reproduced on AMD Radeon RX 7900 XTX and AMD Radeon(TM) Graphics with the D3D12 debug layer enabled (see below). ## Verification Tested clean head `72f443fb13a9d47f421b2e20d02bec89a292aee6`. ```sh python3 -B tests/pixel_compare_grad_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 llc-15 python3 -B tests/pixel_compare_grad_check.py glsl glslangValidator spirv-val spirv-dis python3 -B tests/pixel_compare_lod_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 python3 -B tests/pixel_sample_clamp_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 llc-15 ``` All four commands passed. The new binary check exercised LLVM code generation, assembly, disassembly and the synthetic-container CLI for all four forms. The translated HLSL was also compiled and drawn through the WARP fixture below. ```powershell . .\tools\dev.ps1 $root = (Get-Location).Path $env:TEMP = "$root/out" $env:TMP = $env:TEMP cmake --preset dev -DINTAKE_PYTHON=<python-with-dev-requirements> cmake --build --preset dev --target offscreen_check --parallel 6 ctest --preset dev --no-tests=error -j 1 -R '^pixel_aot_(compare_(grad|lod_(level|bias)|sample|gather)_(warp|hardware)|sample_(gradient|coarse_gradient)_(warp|hardware)|sample_clamp_(controls|compile|warp|hardware)|title_load.*warp)$' -V --output-junit "$root/out/grad-72f443fb.xml" python -B tools/form_coverage.py out/grad-72f443fb.xml --records out/build/dev/form_coverage --json out/grad-72f443fb-coverage.json --gaps gfx1030 python -B tools/run_checks_parallel.py tests/docs_links_check.py tests/bidi_controls_check.py tests/form_coverage_check.py tests/pixel_compare_grad_check.py ``` CTest: 17 passed, 0 failed, 2 capability skips. Windows 11 build `26300.9974`, WARP `10.0.26100.9818`, Intel Arc B390 driver `32.0.101.8509`, D3D12 debug layer unavailable. All four forms matched the CPU reference on WARP at 8x8 and 16x16. Zeroing the gradient for `image_sample_c_d` first changed pixel `(2,0)` from `(1,0.578125,0.5,1)` to `(0,0.578125,0.5,1)` in the 8x8 case. The WARP record counts all four forms; the targeted suite covers 27/111 gfx1030 MIMG forms, not the main-branch total. All four standalone Python checks passed. Arc B390 reported `SampleCmpGradientAndBiasSupported` unavailable, skipping `pixel_aot_compare_grad_hardware` and `pixel_aot_compare_lod_bias_hardware`. ### Physical GPU verification on `72f443fb13a9d47f421b2e20d02bec89a292aee6` (AMD) Built clean head `72f443fb13a9d47f421b2e20d02bec89a292aee6` on Windows 11 build `10.0.26200.9974` with MSVC `19.44.35228.0`, DXC `1.8.2502.11`, and Python `3.12.10` (`out/pe-env`). D3D12 debug layer was **enabled** on all adapters (`debug_errors=0 debug_warnings=0`). ```powershell . .\tools\dev.ps1 $env:TMP = (Resolve-Path ..\..\out\t).Path $env:TEMP = $env:TMP $dxc = (Get-Command dxc -ErrorAction Stop).Source python -B tests/pixel_compare_grad_check.py compile $dxc python -B tools/run_checks_parallel.py tests/docs_links_check.py tests/bidi_controls_check.py tests/form_coverage_check.py tests/pixel_compare_grad_check.py cmake --preset dev "-DINTAKE_PYTHON=$py" cmake --build --preset dev --target offscreen_check --parallel 8 $env:XBOX2WINDOWS_ADAPTER = '7900 XTX' ctest --preset dev --no-tests=error -j 1 -R '^pixel_aot_(compare_(grad|lod_(level|bias)|sample|gather)_(warp|hardware)|sample_(gradient|coarse_gradient)_(warp|hardware)|sample_clamp_(controls|compile|warp|hardware)|title_load.*warp)$' -V --output-junit "$(Resolve-Path out)/grad-72f443fb-7900xtx.xml" python -B tools/form_coverage.py out/grad-72f443fb-7900xtx.xml --records out/build/dev/form_coverage --json out/grad-72f443fb-7900xtx-coverage.json --gaps gfx1030 $env:XBOX2WINDOWS_ADAPTER = 'Radeon(TM) Graphics' ctest --preset dev --no-tests=error -j 1 -R '^pixel_aot_compare_(grad|lod_bias)_hardware$' -V ``` - **Standalone Python checks**: `compile` and all 4 parallel checks (`docs_links_check.py`, `bidi_controls_check.py`, `form_coverage_check.py`, `pixel_compare_grad_check.py`) passed. (`binary` and `glsl` checks were not rerun here as LLVM 15 and glslang/spirv-tools are not installed on this Windows host; both passed in the Linux run above.) - **AMD Radeon RX 7900 XTX (`1002:744c`, driver `32.0.32029.2010`) + WARP (`10.0.26100.9818`)**: **19 passed, 0 failed, 0 capability skips** (`pixel_aot_compare_grad_hardware` passed in `10.59 s`, `pixel_aot_compare_lod_bias_hardware` passed in `5.62 s`, `pixel_aot_compare_grad_warp` passed in `5.45 s`). Targeted coverage from this run: **49/1863 gfx1030 forms (27/111 MIMG forms)**. - **AMD Radeon(TM) Graphics (`1002:164e`, driver `32.0.21045.29003`)**: **2 passed, 0 failed, 0 capability skips** (`pixel_aot_compare_grad_hardware` passed in `7.75 s`, `pixel_aot_compare_lod_bias_hardware` passed in `5.69 s`). - **Readback & first mutation mismatch**: On both physical AMD GPUs and WARP, all four forms (`image_sample_c_d`, `image_sample_c_d_o`, `image_sample_c_d_g16`, `image_sample_c_d_o_g16`) matched the CPU reference at 8x8 and 16x16 (`mismatches=0`, `debug_errors=0 debug_warnings=0`). Zeroing the gradient for `image_sample_c_d` in the 8x8 case first differed at `x=2 y=0`: `expected=1,0.578125,0.5,1 actual=0,0.578125,0.5,1` (`mismatches=21`). `git diff --check` and the local merge simulation passed against upstream `1ec01d7037d30fbdc383d48dceb43ad8c48e0f0b`. Merge simulation is separate from the tests above.
upstream-sync closed this pull request 2026-11-26 08:01:46 +00:00
tedin7 commented 2026-11-26 08:01:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T07:12:08Z.

Review: COMMENTED


Review of head c3cf49ff (after update with main).

  • Lowering of image_sample_c_d, _d_o, _d_g16, _d_o_g16 to SampleCmpGrad reads correct: address width, operand order, static-gradient and normal-or-zero guards, G16 low/high split, refusal of dynamic slopes.
  • Siblings checked: LOD/bias path shares the sampler checks; implicit-derivative path unchanged. New CTest pixel_aot_compare_grad_{warp,hardware} added next to the sample/lod ones, CI workflow lists the new checks and installs glslang-tools.
  • Commands run: git diff --check origin/main...HEAD, tests/docs_links_check.py, tests/bidi_controls_check.py, tests/pixel_compare_grad_check.py glsl ... all pass.
  • Note: swapping the dvdx/dudy slope order in the lowering is NOT caught by the glsl mode of the Linux check; only the draw test (WARP readback) can guard that.
  • Win2025 dev+release 12/12 on this head (see receipt comment).

No blocking findings.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6069889629 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2748#pullrequestreview-6069889629). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T07:12:08Z. **Review:** COMMENTED --- Review of head c3cf49ff (after update with main). - Lowering of `image_sample_c_d`, `_d_o`, `_d_g16`, `_d_o_g16` to `SampleCmpGrad` reads correct: address width, operand order, static-gradient and normal-or-zero guards, G16 low/high split, refusal of dynamic slopes. - Siblings checked: LOD/bias path shares the sampler checks; implicit-derivative path unchanged. New CTest `pixel_aot_compare_grad_{warp,hardware}` added next to the sample/lod ones, CI workflow lists the new checks and installs glslang-tools. - Commands run: `git diff --check origin/main...HEAD`, `tests/docs_links_check.py`, `tests/bidi_controls_check.py`, `tests/pixel_compare_grad_check.py glsl ...` all pass. - Note: swapping the dvdx/dudy slope order in the lowering is NOT caught by the `glsl` mode of the Linux check; only the draw test (WARP readback) can guard that. - Win2025 dev+release 12/12 on this head (see receipt comment). No blocking findings. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 08:01:54 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T07:12:07Z.


Win2025 WARP receipt for head c3cf49ff after updating with main.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit c3cf49ff20491ec95097c5bbcc875a8f14b23c73:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target offscreen_check -- -j 2): 22.07s (configure 1.82s)
    • Test (ctest --preset dev -R '^pixel_aot_(compare_(grad|lod_(level|bias)|sample)_(warp|hardware)|sample_(gradient|coarse_gradient)_(warp|hardware))$' --parallel 6 --no-tests=error --output-on-failure): 12/12 passed (6.09s: pixel_aot_compare_lod_level_warp 1.89s, pixel_aot_compare_lod_bias_warp 1.94s, pixel_aot_sample_coarse_gradient_warp 3.02s, pixel_aot_compare_sample_warp 3.03s, pixel_aot_sample_gradient_warp 3.03s, pixel_aot_compare_sample_hardware 3.08s, pixel_aot_compare_lod_level_hardware 1.99s, pixel_aot_compare_lod_bias_hardware 1.97s, pixel_aot_sample_gradient_hardware 2.75s, pixel_aot_sample_coarse_gradient_hardware 2.80s, pixel_aot_compare_grad_hardware 2.85s, pixel_aot_compare_grad_warp 2.87s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target offscreen_check -- -j 2): 43.15s (configure 1.81s)
    • Test (ctest --preset release -R '^pixel_aot_(compare_(grad|lod_(level|bias)|sample)_(warp|hardware)|sample_(gradient|coarse_gradient)_(warp|hardware))$' --parallel 6 --no-tests=error --output-on-failure): 12/12 passed (5.62s: pixel_aot_compare_lod_bias_hardware 1.75s, pixel_aot_compare_lod_level_hardware 1.80s, pixel_aot_compare_lod_bias_warp 1.82s, pixel_aot_sample_gradient_warp 2.76s, pixel_aot_sample_coarse_gradient_warp 2.82s, pixel_aot_compare_sample_warp 2.83s, pixel_aot_compare_lod_level_warp 1.79s, pixel_aot_compare_sample_hardware 2.67s, pixel_aot_sample_gradient_hardware 2.71s, pixel_aot_sample_coarse_gradient_hardware 2.53s, pixel_aot_compare_grad_hardware 2.66s, pixel_aot_compare_grad_warp 2.67s)
  • Windows Python checks: tests/pixel_compare_grad_check.py ok (0.5s), tests/pixel_compare_lod_check.py ok (0.5s), tests/pixel_sample_gradient_check.py ok (0.5s)
  • sccache: 52/58 hits; wall 81.5s

Tests run include pixel_aot_compare_grad_warp/hardware (the new one) plus the lod/sample/gradient siblings.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7185202107 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2748#issuecomment-7185202107). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T07:12:07Z. --- Win2025 WARP receipt for head c3cf49ff after updating with main. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `c3cf49ff20491ec95097c5bbcc875a8f14b23c73`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target offscreen_check -- -j 2`): `22.07s` (configure `1.82s`) - Test (`ctest --preset dev -R '^pixel_aot_(compare_(grad|lod_(level|bias)|sample)_(warp|hardware)|sample_(gradient|coarse_gradient)_(warp|hardware))$' --parallel 6 --no-tests=error --output-on-failure`): **12/12 passed** (`6.09s`: `pixel_aot_compare_lod_level_warp` `1.89s`, `pixel_aot_compare_lod_bias_warp` `1.94s`, `pixel_aot_sample_coarse_gradient_warp` `3.02s`, `pixel_aot_compare_sample_warp` `3.03s`, `pixel_aot_sample_gradient_warp` `3.03s`, `pixel_aot_compare_sample_hardware` `3.08s`, `pixel_aot_compare_lod_level_hardware` `1.99s`, `pixel_aot_compare_lod_bias_hardware` `1.97s`, `pixel_aot_sample_gradient_hardware` `2.75s`, `pixel_aot_sample_coarse_gradient_hardware` `2.80s`, `pixel_aot_compare_grad_hardware` `2.85s`, `pixel_aot_compare_grad_warp` `2.87s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target offscreen_check -- -j 2`): `43.15s` (configure `1.81s`) - Test (`ctest --preset release -R '^pixel_aot_(compare_(grad|lod_(level|bias)|sample)_(warp|hardware)|sample_(gradient|coarse_gradient)_(warp|hardware))$' --parallel 6 --no-tests=error --output-on-failure`): **12/12 passed** (`5.62s`: `pixel_aot_compare_lod_bias_hardware` `1.75s`, `pixel_aot_compare_lod_level_hardware` `1.80s`, `pixel_aot_compare_lod_bias_warp` `1.82s`, `pixel_aot_sample_gradient_warp` `2.76s`, `pixel_aot_sample_coarse_gradient_warp` `2.82s`, `pixel_aot_compare_sample_warp` `2.83s`, `pixel_aot_compare_lod_level_warp` `1.79s`, `pixel_aot_compare_sample_hardware` `2.67s`, `pixel_aot_sample_gradient_hardware` `2.71s`, `pixel_aot_sample_coarse_gradient_hardware` `2.53s`, `pixel_aot_compare_grad_hardware` `2.66s`, `pixel_aot_compare_grad_warp` `2.67s`) - **Windows Python checks**: `tests/pixel_compare_grad_check.py` ok (`0.5s`), `tests/pixel_compare_lod_check.py` ok (`0.5s`), `tests/pixel_sample_gradient_check.py` ok (`0.5s`) - `sccache`: 52/58 hits; wall `81.5s` Tests run include pixel_aot_compare_grad_warp/hardware (the new one) plus the lod/sample/gradient siblings. AI-assisted; commands listed were executed locally.
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!2740
No description provided.