shader: lower gfx1030 non-comparison 2D gathers #1506

Merged
stan495 merged 1 commit from upstream-pr/1513 into main 2026-11-24 13:49:41 +00:00
stan495 commented 2026-11-24 13:24:49 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-24T13:24:49Z.


Summary

Lower six gfx1030 contiguous-address 2D non-comparison image_gather4* forms for a matching float4 SRV. Use a one-hot DMASK, normalized XY clamp, and one visible mip for implicit LOD. Explicit lz and known integral l can address a multi-mip view. The _o forms take a static signed six-bit XY displacement. The lowering reads four taps with Load and requires coordinates whose footprints agree at native and desktop precision. Comparison gathers and other unverified modifiers are outside this PR.

The test renderer adds a dedicated gather operation without changing the sampling, comparison, MSAA or #1445 raw-LOD paths.

Verification

Tested clean head 7536843c8e154a91a2c73ac8fd352ff28c1e9a09.

. .\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 -j 1 -R '^pixel_aot_(gather|compare_sample|compare|sample_offset|sample_lod|dmask|get_lod|three_way|cmpx_regions)_(warp|hardware)$' -V --output-junit "$root/out/gather-7536843c.xml"
python -B tools/form_coverage.py out/gather-7536843c.xml --records out/build/dev/form_coverage --json out/gather-7536843c.coverage.json
python -B tests/form_coverage_check.py
python -B tests/docs_links_check.py
python -B tests/bidi_controls_check.py

CTest: 18 passed, 0 failed, 0 skipped. Both gather records contain all six forms. Each backend compares desktop DXIL for all 24 opcode and mask pairs with an independent CPU reference over 64 pixels and 256 exact channel values per case. Direct desktop HLSL Gather{Red,Green,Blue,Alpha} also matches the CPU reference at view mip zero. The wrong-channel control first differs at (0,0), channel 0: 4609 expected, 4353 actual. Swapped taps first differ at (0,1), 4625 versus 4609; forcing mip zero at (0,0) changes 4609 to 529, and zero-extending a negative offset changes 817 to 824. Unsupported masks, operands, sampler modes and waits are rejected by the fixture.

Windows 11 build 26300.9974; Intel Arc B390 32.0.101.8509; Microsoft WARP 10.0.26100.9818. Debug layer unavailable on both.

python3 -B tests/pixel_gather_check.py --binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1
python3 -B tests/pixel_aot_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1

Both LLVM checks passed. The gather check assembles and disassembles all 24 pairs and checks identical HLSL via the synthetic-container CLI. git diff --check passed. git merge-tree --write-tree refs/remotes/origin/main HEAD passed against 7b0d795484155cced986e687be56e974479bf259, including a separate simulation after #1504 and #1507. Those simulations did not execute fixtures.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6582795443 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1513). Originally posted by [stan495](https://github.com/stan495) on 2026-11-24T13:24:49Z. --- ## Summary Lower six gfx1030 contiguous-address 2D non-comparison `image_gather4*` forms for a matching float4 SRV. Use a one-hot DMASK, normalized XY clamp, and one visible mip for implicit LOD. Explicit `lz` and known integral `l` can address a multi-mip view. The `_o` forms take a static signed six-bit XY displacement. The lowering reads four taps with `Load` and requires coordinates whose footprints agree at native and desktop precision. Comparison gathers and other unverified modifiers are outside this PR. The test renderer adds a dedicated gather operation without changing the sampling, comparison, MSAA or #1445 raw-LOD paths. ## Verification Tested clean head `7536843c8e154a91a2c73ac8fd352ff28c1e9a09`. ```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 -j 1 -R '^pixel_aot_(gather|compare_sample|compare|sample_offset|sample_lod|dmask|get_lod|three_way|cmpx_regions)_(warp|hardware)$' -V --output-junit "$root/out/gather-7536843c.xml" python -B tools/form_coverage.py out/gather-7536843c.xml --records out/build/dev/form_coverage --json out/gather-7536843c.coverage.json python -B tests/form_coverage_check.py python -B tests/docs_links_check.py python -B tests/bidi_controls_check.py ``` CTest: 18 passed, 0 failed, 0 skipped. Both gather records contain all six forms. Each backend compares desktop DXIL for all 24 opcode and mask pairs with an independent CPU reference over 64 pixels and 256 exact channel values per case. Direct desktop HLSL `Gather{Red,Green,Blue,Alpha}` also matches the CPU reference at view mip zero. The wrong-channel control first differs at `(0,0)`, channel 0: `4609` expected, `4353` actual. Swapped taps first differ at `(0,1)`, `4625` versus `4609`; forcing mip zero at `(0,0)` changes `4609` to `529`, and zero-extending a negative offset changes `817` to `824`. Unsupported masks, operands, sampler modes and waits are rejected by the fixture. Windows 11 build `26300.9974`; Intel Arc B390 `32.0.101.8509`; Microsoft WARP `10.0.26100.9818`. Debug layer unavailable on both. ```sh python3 -B tests/pixel_gather_check.py --binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 python3 -B tests/pixel_aot_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 ``` Both LLVM checks passed. The gather check assembles and disassembles all 24 pairs and checks identical HLSL via the synthetic-container CLI. `git diff --check` passed. `git merge-tree --write-tree refs/remotes/origin/main HEAD` passed against `7b0d795484155cced986e687be56e974479bf259`, including a separate simulation after #1504 and #1507. Those simulations did not execute fixtures.
upstream-sync closed this pull request 2026-11-24 14:03:04 +00:00
tedin7 commented 2026-11-24 14:03:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T13:31:31Z.

Review: COMMENTED


Reviewed 7536843c8e154a91a2c73ac8fd352ff28c1e9a09:

  • Change: tools/pixel_aot.py lowers six gfx1030 non-comparison 2D image_gather4* forms (image_gather4, _o, _lz, _lz_o, _l, _l_o) via gather_2d using four Load taps in (0,1), (1,1), (1,0), (0,0) order. Sampler validation (check_gather_sampler), signed 6-bit packed XY offset decoding (gather_offset), one-hot DMASK check, single-mip requirement for implicit LOD, known integral LOD bounds check for _l, register-range/outstanding-load checks, and sample_kind != "gather" guard at the end of lower() are all consistent. tests/pixel_gather_check.py, tests/pixel_aot_render.cpp, tests/offscreen_check.cpp, CMakeLists.txt, .github/workflows/windows.yml, README.md, and docs/experiments.md wire up the fixture, controls, and negative mutations.
  • Linux checks:
    • git diff --check origin/main..HEAD, python3 tests/docs_links_check.py (340 links across 16 files), and python3 tests/bidi_controls_check.py (1234 files) all passed.
    • python3 -B tests/pixel_gather_check.py --binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM.so.1 passed (all 24 LLVM-assembled CLI cases + controls).
  • Win2025 verification (Windows Server 2025 Build 26100, MSVC 14.44.35207 + D3D12 WARP):
    • tests/form_coverage_check.py: passed (42.51s).
    • Debug (--preset dev): offscreen_check built (35.05s); ctest --preset dev -R '^pixel_aot_(gather|compare_sample|compare|sample_offset|sample_lod|dmask|get_lod|three_way|cmpx_regions)_(warp|hardware)$' --parallel 4 --no-tests=error --output-on-failure — 18/18 passed (41.28s, including pixel_aot_gather_warp and pixel_aot_gather_hardware).
    • Release /O2 (--preset release): offscreen_check built (51.76s); same CTest filter — 18/18 passed (40.81s).

Looks good to me.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6040077957 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1513#pullrequestreview-6040077957). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T13:31:31Z. **Review:** COMMENTED --- Reviewed `7536843c8e154a91a2c73ac8fd352ff28c1e9a09`: - **Change**: `tools/pixel_aot.py` lowers six gfx1030 non-comparison 2D `image_gather4*` forms (`image_gather4`, `_o`, `_lz`, `_lz_o`, `_l`, `_l_o`) via `gather_2d` using four `Load` taps in `(0,1), (1,1), (1,0), (0,0)` order. Sampler validation (`check_gather_sampler`), signed 6-bit packed XY offset decoding (`gather_offset`), one-hot DMASK check, single-mip requirement for implicit LOD, known integral LOD bounds check for `_l`, register-range/outstanding-load checks, and `sample_kind != "gather"` guard at the end of `lower()` are all consistent. `tests/pixel_gather_check.py`, `tests/pixel_aot_render.cpp`, `tests/offscreen_check.cpp`, `CMakeLists.txt`, `.github/workflows/windows.yml`, `README.md`, and `docs/experiments.md` wire up the fixture, controls, and negative mutations. - **Linux checks**: - `git diff --check origin/main..HEAD`, `python3 tests/docs_links_check.py` (340 links across 16 files), and `python3 tests/bidi_controls_check.py` (1234 files) all passed. - `python3 -B tests/pixel_gather_check.py --binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM.so.1` passed (all 24 LLVM-assembled CLI cases + controls). - **Win2025 verification** (Windows Server 2025 Build 26100, MSVC 14.44.35207 + D3D12 WARP): - `tests/form_coverage_check.py`: passed (`42.51s`). - **Debug (`--preset dev`)**: `offscreen_check` built (`35.05s`); `ctest --preset dev -R '^pixel_aot_(gather|compare_sample|compare|sample_offset|sample_lod|dmask|get_lod|three_way|cmpx_regions)_(warp|hardware)$' --parallel 4 --no-tests=error --output-on-failure` — **18/18 passed** (`41.28s`, including `pixel_aot_gather_warp` and `pixel_aot_gather_hardware`). - **Release `/O2` (`--preset release`)**: `offscreen_check` built (`51.76s`); same CTest filter — **18/18 passed** (`40.81s`). Looks good to me.
ChazY11 commented 2026-11-24 15:02:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T14:59:18Z.


Both the tap order and the offset sign extension are covered

Independent reviewer, not the author. Reviewed 7536843c; nothing pushed to the branch. Mutations were made locally in
tools/pixel_aot.py, reverted between each; working tree is clean.

Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100, DXC 1.8.2502.11, LLVM gfx1013 tooling
available, RTX 5080 Laptop (32.0.15.8142) for _hardware.

cmake --preset dev
cmake --build --preset dev
ctest --preset dev --no-tests=error -R 'pixel_aot_gather' -V
pixel_aot_gather_hardware ... Passed 23.23 s
pixel_aot_gather_warp ....... Passed  6.67 s

Mutation 1 — the first and last taps exchanged

The emitted helper loads (0,1), (1,1), (1,0), (0,0) into the four components. Swapping the first and the last:

pixel_aot_gather_hardware ***Failed
pixel_aot_gather_warp ..... ***Failed

Good: the component order is asserted, not just "four taps happen".

Mutation 2 — the six-bit offset loses its sign extension

-    return (x ^ 32) - 32, (y ^ 32) - 32
+    return x, y
pixel_aot_gather_hardware ***Failed
pixel_aot_gather_warp ..... ***Failed

So the fixture actually uses a negative offset somewhere; a bias-by-32 error is caught rather than being invisible because
all offsets happen to be positive.

What I did not test

The check_gather_sampler refusals (non-clamp addressing, non-bilinear XY, LOD modifiers). Those are ValueError paths in
the translator; I can drive them by editing the case words if you want them confirmed, but they are cheap to reason about
and I did not want to guess at which sampler word layout you consider canonical.

Verdict

Reviewed 7536843c. Builds clean, both gather cases pass on WARP and on a physical adapter, and two independent
mutations in the emitted taps and in the offset decode are caught. No objection from me.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7135274383 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1513#issuecomment-7135274383). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T14:59:18Z. --- ## Both the tap order and the offset sign extension are covered Independent reviewer, not the author. Reviewed `7536843c`; nothing pushed to the branch. Mutations were made locally in `tools/pixel_aot.py`, reverted between each; working tree is clean. Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100, DXC 1.8.2502.11, LLVM gfx1013 tooling available, RTX 5080 Laptop (32.0.15.8142) for `_hardware`. ```powershell cmake --preset dev cmake --build --preset dev ctest --preset dev --no-tests=error -R 'pixel_aot_gather' -V ``` ```text pixel_aot_gather_hardware ... Passed 23.23 s pixel_aot_gather_warp ....... Passed 6.67 s ``` ### Mutation 1 — the first and last taps exchanged The emitted helper loads `(0,1)`, `(1,1)`, `(1,0)`, `(0,0)` into the four components. Swapping the first and the last: ```text pixel_aot_gather_hardware ***Failed pixel_aot_gather_warp ..... ***Failed ``` Good: the component order is asserted, not just "four taps happen". ### Mutation 2 — the six-bit offset loses its sign extension ```diff - return (x ^ 32) - 32, (y ^ 32) - 32 + return x, y ``` ```text pixel_aot_gather_hardware ***Failed pixel_aot_gather_warp ..... ***Failed ``` So the fixture actually uses a negative offset somewhere; a bias-by-32 error is caught rather than being invisible because all offsets happen to be positive. ### What I did not test The `check_gather_sampler` refusals (non-clamp addressing, non-bilinear XY, LOD modifiers). Those are ValueError paths in the translator; I can drive them by editing the case words if you want them confirmed, but they are cheap to reason about and I did not want to guess at which sampler word layout you consider canonical. ### Verdict Reviewed `7536843c`. Builds clean, both gather cases pass on WARP and on a physical adapter, and two independent mutations in the emitted taps and in the offset decode are caught. No objection from me.
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!1506
No description provided.