shader: lower gfx1030 uniform coarse-gradient sampling #1569

Merged
stan495 merged 1 commit from upstream-pr/1576 into main 2026-11-24 14:45:22 +00:00
stan495 commented 2026-11-24 14:32:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-24T14:32:17Z.


Summary

Lower gfx1030 image_sample_cd, image_sample_cd_o, image_sample_cd_g16, and image_sample_cd_o_g16 for contiguous 2D addresses, dmask:0xf, and statically known finite slopes. The full and packed gradient operands reuse the existing SampleGrad lowering. Identical slope words across lanes make the coarse lane selection immaterial to this profile. The tests reject dynamic slopes and non-finite operands. Native lane selection for varying slopes is outside the profile.

Refs #1507

Verification

Tested clean head 0479b8dece5fe54196605ae106c76199e8287fba on 5042ab7514a4f5715795da44f5899b437c40d8d5.

. .\tools\dev.ps1
$root = (Get-Location).Path
cmake --preset dev -DINTAKE_PYTHON=<python.exe>
cmake --build --preset dev --target offscreen_check
$env:TEMP = "$root/out"
$env:TMP = $env:TEMP
ctest --preset dev --no-tests=error -R '^pixel_aot_(sample_(coarse_gradient|gradient|offset|lod)|compare_sample)_(warp|hardware)$' -V --output-junit "$root/out/coarse-0479b8de.xml"
python -B tools/form_coverage.py out/coarse-0479b8de.xml --records out/build/dev/form_coverage --json out/coarse-0479b8de.coverage.json
python -B tests/form_coverage_check.py
python -B tests/docs_links_check.py
python -B tests/bidi_controls_check.py

CTest reported 10 passes, 0 failures and 0 skips. Both coarse-gradient records contain all four forms. The tests check two-mip and four-mip textures and a spatial ramp against the expected readback. Zeroing the slopes first changed (0,0) from green to red. Channel 0 was expected 0 and read 1. Zeroing the signed offset also changed the first pixel. The translator rejects a gradient loaded from a constant buffer as Coarse gradients require statically known slopes.

Windows 11 build 26300.9974, Intel Arc B390 driver 32.0.101.8509, Microsoft WARP 10.0.26100.9818. The debug layer was unavailable.

python3 -B tests/pixel_sample_gradient_check.py binary-coarse llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 llc-15
python3 -B tests/pixel_sample_gradient_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 llc-15

Both LLVM 15 checks passed. The four coarse forms assembled, disassembled and translated through the synthetic-container CLI. git diff --check and git merge-tree --write-tree passed against be484d0f12aa6e7d6e755cbded6068dd7172a1f4, including a simulation landing #1565 and #1568 first.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6584142093 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1576). Originally posted by [stan495](https://github.com/stan495) on 2026-11-24T14:32:17Z. --- ## Summary Lower gfx1030 `image_sample_cd`, `image_sample_cd_o`, `image_sample_cd_g16`, and `image_sample_cd_o_g16` for contiguous 2D addresses, `dmask:0xf`, and statically known finite slopes. The full and packed gradient operands reuse the existing `SampleGrad` lowering. Identical slope words across lanes make the coarse lane selection immaterial to this profile. The tests reject dynamic slopes and non-finite operands. Native lane selection for varying slopes is outside the profile. Refs #1507 ## Verification Tested clean head `0479b8dece5fe54196605ae106c76199e8287fba` on `5042ab7514a4f5715795da44f5899b437c40d8d5`. ```powershell . .\tools\dev.ps1 $root = (Get-Location).Path cmake --preset dev -DINTAKE_PYTHON=<python.exe> cmake --build --preset dev --target offscreen_check $env:TEMP = "$root/out" $env:TMP = $env:TEMP ctest --preset dev --no-tests=error -R '^pixel_aot_(sample_(coarse_gradient|gradient|offset|lod)|compare_sample)_(warp|hardware)$' -V --output-junit "$root/out/coarse-0479b8de.xml" python -B tools/form_coverage.py out/coarse-0479b8de.xml --records out/build/dev/form_coverage --json out/coarse-0479b8de.coverage.json python -B tests/form_coverage_check.py python -B tests/docs_links_check.py python -B tests/bidi_controls_check.py ``` CTest reported 10 passes, 0 failures and 0 skips. Both coarse-gradient records contain all four forms. The tests check two-mip and four-mip textures and a spatial ramp against the expected readback. Zeroing the slopes first changed `(0,0)` from green to red. Channel 0 was expected `0` and read `1`. Zeroing the signed offset also changed the first pixel. The translator rejects a gradient loaded from a constant buffer as `Coarse gradients require statically known slopes`. Windows 11 build `26300.9974`, Intel Arc B390 driver `32.0.101.8509`, Microsoft WARP `10.0.26100.9818`. The debug layer was unavailable. ```sh python3 -B tests/pixel_sample_gradient_check.py binary-coarse llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 llc-15 python3 -B tests/pixel_sample_gradient_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 llc-15 ``` Both LLVM 15 checks passed. The four coarse forms assembled, disassembled and translated through the synthetic-container CLI. `git diff --check` and `git merge-tree --write-tree` passed against `be484d0f12aa6e7d6e755cbded6068dd7172a1f4`, including a simulation landing #1565 and #1568 first.
upstream-sync closed this pull request 2026-11-24 15:02:07 +00:00
tedin7 commented 2026-11-24 15:02:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T14:37:07Z.

Review: COMMENTED


Looks good overall. Reviewed the lowering in tools/pixel_aot.py, test coverage in tests/pixel_sample_gradient_check.py, and docs/build integration at 0479b8dece5fe54196605ae106c76199e8287fba.

Semantic & Edge-Case Review

  • ISA gating & operand layout: Restricting image_sample_cd{,_o}{,_g16} to cpu == "gfx1030" and dmask:0xf matches the explicit-gradient image_sample_d* path and RDNA2 active address operand layout.
  • Uniform finite-slope guard: Checking known_ssa_bits.get(vector[reg]) across coord_regs[:-2] rejects lane-varying/runtime slopes (s60/buffer loads), and checking the exponent masks (0x7c00 for both packed FP16 halves in g16, 0x7f800000 for FP32) rejects Inf/NaN while allowing finite normals, subnormals, and ±0.
  • Negative & binary coverage: check_coarse_lowering() and check_binary(..., coarse=True) verify equivalence with image_sample_d*, rejection on non-gfx1030, rejection of non-static and non-finite slopes, and llvm-mc/libLLVM round-trip.

Verification

  • Linux (LLVM 19):
    • python3 -B tests/pixel_sample_gradient_check.py — passed.
    • python3 -B tests/pixel_sample_gradient_check.py binary llvm-mc-19 llvm-objcopy-19 libLLVM-19.so llc-19 and binary-coarse — passed.
    • python3 -B tests/pixel_sample_offset_check.py, python3 -B tests/pixel_aot_check.py, python3 -B tests/docs_links_check.py, python3 -B tests/bidi_controls_check.py — passed.
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
    • Debug (--preset dev): offscreen_check built (29.03s), ctest --preset dev -R '^pixel_aot_sample_(coarse_)?gradient_' 4/4 passed (5.52s).
    • Release /O2 (--preset release): offscreen_check built (41.52s), ctest --preset release -R '^pixel_aot_sample_(coarse_)?gradient_' 4/4 passed (5.50s).
    • tests/pixel_sample_gradient_check.py — passed (3.1s).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6041228902 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1576#pullrequestreview-6041228902). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T14:37:07Z. **Review:** COMMENTED --- Looks good overall. Reviewed the lowering in `tools/pixel_aot.py`, test coverage in `tests/pixel_sample_gradient_check.py`, and docs/build integration at `0479b8dece5fe54196605ae106c76199e8287fba`. ### Semantic & Edge-Case Review - **ISA gating & operand layout**: Restricting `image_sample_cd{,_o}{,_g16}` to `cpu == "gfx1030"` and `dmask:0xf` matches the explicit-gradient `image_sample_d*` path and RDNA2 active address operand layout. - **Uniform finite-slope guard**: Checking `known_ssa_bits.get(vector[reg])` across `coord_regs[:-2]` rejects lane-varying/runtime slopes (`s60`/buffer loads), and checking the exponent masks (`0x7c00` for both packed FP16 halves in `g16`, `0x7f800000` for FP32) rejects `Inf`/`NaN` while allowing finite normals, subnormals, and `±0`. - **Negative & binary coverage**: `check_coarse_lowering()` and `check_binary(..., coarse=True)` verify equivalence with `image_sample_d*`, rejection on non-`gfx1030`, rejection of non-static and non-finite slopes, and `llvm-mc`/`libLLVM` round-trip. ### Verification - **Linux (LLVM 19)**: - `python3 -B tests/pixel_sample_gradient_check.py` — passed. - `python3 -B tests/pixel_sample_gradient_check.py binary llvm-mc-19 llvm-objcopy-19 libLLVM-19.so llc-19` and `binary-coarse` — passed. - `python3 -B tests/pixel_sample_offset_check.py`, `python3 -B tests/pixel_aot_check.py`, `python3 -B tests/docs_links_check.py`, `python3 -B tests/bidi_controls_check.py` — passed. - **Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)**: - Debug (`--preset dev`): `offscreen_check` built (`29.03s`), `ctest --preset dev -R '^pixel_aot_sample_(coarse_)?gradient_'` **4/4 passed** (`5.52s`). - Release `/O2` (`--preset release`): `offscreen_check` built (`41.52s`), `ctest --preset release -R '^pixel_aot_sample_(coarse_)?gradient_'` **4/4 passed** (`5.50s`). - `tests/pixel_sample_gradient_check.py` — passed (`3.1s`). 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!1569
No description provided.