shader: probe gfx1030 2D gather instruction bias #1636

Merged
stan495 merged 1 commit from upstream-pr/1643 into main 2026-11-25 06:12:44 +00:00
stan495 commented 2026-11-24 15:40:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-24T15:40:37Z.


Behavior

Add a source-built discriminator for image_gather4_b, image_gather4_b_o, image_gather4_c_b, and image_gather4_c_b_o. It builds a biased shader and an explicit-LOD control for each form with positive bias, negative bias and magnification. It emits three distinguishable texture mips, a manifest, and a checker that identifies the mip and first differing tap in raw native readback.

The standalone desktop model computes LOD from quad derivatives before adding instruction bias and selecting a mip. It draws through the existing offscreen fixture. This draft adds a probe. Native gfx1030 execution of the biased shader and its control is pending, and no MIMG coverage record is added. The first native discriminator is image_gather4_b-magnify: the candidate predicts mip 1 and clamping the negative base LOD first predicts mip 2. The documentation specifies the native pipeline bindings and readback format.

Verification

Tested commit 92204dfebbbc7ad05f54bccb38bfc37f136e7739.

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

CPU footprint and controls passed for 12 cases. LLVM 15 round-tripped 24 source-built gfx1030 shaders and checked the opcode encodings for all four biased forms.

. .\tools\dev.ps1
cmake --preset dev -DINTAKE_PYTHON=<python-with-dev-requirements>
cmake --build --preset dev --target offscreen_check
$renderer = (Resolve-Path out/build/dev/offscreen_check.exe).Path
$dxc = (Get-Command dxc).Source
python -B tests/pixel_gather_bias_probe.py --dxc $dxc --draw $renderer warp
python -B tests/pixel_gather_bias_probe.py --dxc $dxc --draw $renderer hardware
ctest --preset dev --no-tests=error -j 1 -R '^pixel_aot_(gather|compare_gather)_(warp|hardware)$' -V --output-junit "$(Resolve-Path out)/gather-bias-92204dfe.xml"
python -B tools/form_coverage.py out/gather-bias-92204dfe.xml --records out/build/dev/form_coverage

Both adapters matched 12 desktop cases and their 12 wrong-mip controls across all 64 RGBA pixels. All 12 mutants per adapter then failed against the original reference at the predicted first pixel. For ordinary magnification the first mismatch was pixel (0,0), tap 0, expected 4609 (0x45900800) and actual 8705 (0x46080400). Windows 11 build 26300.9974, Intel Arc B390 driver 32.0.101.8509, Microsoft WARP driver 10.0.26100.9818, D3D12 debug layer unavailable. The gather regressions passed 4/0/0 and recorded the existing 12 gfx1030 gather forms. The docs links, bidi controls and coverage-tool checks passed.
Merge simulation passed against upstream cb94b8caff25ed8d946e040167265263bc1cb8b5 and the checked comparison, image-store, atomics and clamp branches.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6585575640 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1643). Originally posted by [stan495](https://github.com/stan495) on 2026-11-24T15:40:37Z. --- ## Behavior Add a source-built discriminator for `image_gather4_b`, `image_gather4_b_o`, `image_gather4_c_b`, and `image_gather4_c_b_o`. It builds a biased shader and an explicit-LOD control for each form with positive bias, negative bias and magnification. It emits three distinguishable texture mips, a manifest, and a checker that identifies the mip and first differing tap in raw native readback. The standalone desktop model computes LOD from quad derivatives before adding instruction bias and selecting a mip. It draws through the existing offscreen fixture. This draft adds a probe. Native gfx1030 execution of the biased shader and its control is pending, and no MIMG coverage record is added. The first native discriminator is `image_gather4_b-magnify`: the candidate predicts mip 1 and clamping the negative base LOD first predicts mip 2. The documentation specifies the native pipeline bindings and readback format. ## Verification Tested commit `92204dfebbbc7ad05f54bccb38bfc37f136e7739`. ```sh python3 -B tests/pixel_gather_bias_probe.py --binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 ``` CPU footprint and controls passed for 12 cases. LLVM 15 round-tripped 24 source-built gfx1030 shaders and checked the opcode encodings for all four biased forms. ```powershell . .\tools\dev.ps1 cmake --preset dev -DINTAKE_PYTHON=<python-with-dev-requirements> cmake --build --preset dev --target offscreen_check $renderer = (Resolve-Path out/build/dev/offscreen_check.exe).Path $dxc = (Get-Command dxc).Source python -B tests/pixel_gather_bias_probe.py --dxc $dxc --draw $renderer warp python -B tests/pixel_gather_bias_probe.py --dxc $dxc --draw $renderer hardware ctest --preset dev --no-tests=error -j 1 -R '^pixel_aot_(gather|compare_gather)_(warp|hardware)$' -V --output-junit "$(Resolve-Path out)/gather-bias-92204dfe.xml" python -B tools/form_coverage.py out/gather-bias-92204dfe.xml --records out/build/dev/form_coverage ``` Both adapters matched 12 desktop cases and their 12 wrong-mip controls across all 64 RGBA pixels. All 12 mutants per adapter then failed against the original reference at the predicted first pixel. For ordinary magnification the first mismatch was pixel `(0,0)`, tap 0, expected `4609` (`0x45900800`) and actual `8705` (`0x46080400`). Windows 11 build `26300.9974`, Intel Arc B390 driver `32.0.101.8509`, Microsoft WARP driver `10.0.26100.9818`, D3D12 debug layer unavailable. The gather regressions passed 4/0/0 and recorded the existing 12 gfx1030 gather forms. The docs links, bidi controls and coverage-tool checks passed. Merge simulation passed against upstream `cb94b8caff25ed8d946e040167265263bc1cb8b5` and the checked comparison, image-store, atomics and clamp branches.
tedin7 commented 2026-11-25 06:01:02 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T05:59:30Z.

Review: COMMENTED


Review of head 92204dfebbbc7ad05f54bccb38bfc37f136e7739 (docs/experiments.md, tests/pixel_gather_bias_probe.py).

Findings: 0 P1, 0 P2.

Clean-room / ISA check:

  • Gather4 _b, _b_o, _c_b, _c_b_o opcodes and address order (offset, bias, reference, U, V) match the RDNA2 ISA text cited in the doc; only public ISA and LLVM round-trip bytes are used.
  • The candidate LOD rule (log2 of the larger quad derivative length, plus the instruction bias, then clamp and round to a point mip) is applied in the right order. The magnify case correctly pins "bias before clamp".
  • The PR touches only a probe script and an experiments note. No product code changes. No competing open or merged PR covers gather4 bias; #1568 and #2045 are sample_l/b and sample_c lowerings, a different family.

Commands run locally on the exact head:

  • git diff --check origin/main...HEAD: clean
  • python3 tests/docs_links_check.py: pass (16 files, 348 links)
  • python3 tests/bidi_controls_check.py: pass (1266 files)
  • python3 -B tests/pixel_gather_bias_probe.py: pass, 12 biased gather cases and all negative controls
  • Mutation 1: lod + case.bias changed to lod - case.bias in cpu_check: AssertionError, killed
  • Mutation 2: max(math.hypot...) changed to min(...) in cpu_check: AssertionError, killed
  • Mutations were reverted afterwards with git checkout -- ..

CI: Build and test on Windows is SUCCESS. The Python-only fast path applies, because the PR touches only a .py file and a .md file.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6052576504 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1643#pullrequestreview-6052576504). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T05:59:30Z. **Review:** COMMENTED --- Review of head `92204dfebbbc7ad05f54bccb38bfc37f136e7739` (docs/experiments.md, tests/pixel_gather_bias_probe.py). Findings: 0 P1, 0 P2. Clean-room / ISA check: - Gather4 `_b`, `_b_o`, `_c_b`, `_c_b_o` opcodes and address order (offset, bias, reference, U, V) match the RDNA2 ISA text cited in the doc; only public ISA and LLVM round-trip bytes are used. - The candidate LOD rule (log2 of the larger quad derivative length, plus the instruction bias, then clamp and round to a point mip) is applied in the right order. The magnify case correctly pins "bias before clamp". - The PR touches only a probe script and an experiments note. No product code changes. No competing open or merged PR covers gather4 bias; #1568 and #2045 are sample_l/b and sample_c lowerings, a different family. Commands run locally on the exact head: - `git diff --check origin/main...HEAD`: clean - `python3 tests/docs_links_check.py`: pass (16 files, 348 links) - `python3 tests/bidi_controls_check.py`: pass (1266 files) - `python3 -B tests/pixel_gather_bias_probe.py`: pass, 12 biased gather cases and all negative controls - Mutation 1: `lod + case.bias` changed to `lod - case.bias` in `cpu_check`: AssertionError, killed - Mutation 2: `max(math.hypot...)` changed to `min(...)` in `cpu_check`: AssertionError, killed - Mutations were reverted afterwards with `git checkout -- .`. CI: `Build and test on Windows` is SUCCESS. The Python-only fast path applies, because the PR touches only a .py file and a .md file. AI-assisted; commands listed were executed locally.
stan495 commented 2026-11-25 06:01:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-25T05:55:10Z.


Verified head 92204dfe on Windows x64 (dev preset, MSVC 19.44.35228.0, SDK/DXC 10.0.26100.0, Python 3.12):

  • python -B tests/pixel_gather_bias_probe.py -> passed (CPU footprint and negative controls passed for 12 biased gather cases)
  • python -B tests/pixel_gather_bias_probe.py --dxc <dxc.exe> --draw <offscreen_check.exe> warp -> passed (DXC compiled 12 standalone desktop shaders, warp matched 12 desktop draws and their wrong-mip controls; Microsoft Basic Render Driver, driver 10.0.26100.9818, debug_layer=enabled, debug_errors=0 debug_warnings=0)
  • python -B tests/pixel_gather_bias_probe.py --dxc <dxc.exe> --draw <offscreen_check.exe> hardware -> passed (DXC compiled 12 standalone desktop shaders, hardware matched 12 desktop draws and their wrong-mip controls; AMD Radeon RX 7900 XTX, vendor=1002 device=744c, driver 32.0.32029.2010, debug_layer=enabled, debug_errors=0 debug_warnings=0)

Native gfx1030 HIP execution remains pending on Linux; marking Ready for Review as a verified probe + desktop reference baseline (same scope as #1623).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7154263939 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1643#issuecomment-7154263939). Originally posted by [stan495](https://github.com/stan495) on 2026-11-25T05:55:10Z. --- Verified head `92204dfe` on Windows x64 (`dev` preset, MSVC `19.44.35228.0`, SDK/DXC `10.0.26100.0`, Python 3.12): - `python -B tests/pixel_gather_bias_probe.py` -> passed (`CPU footprint and negative controls passed for 12 biased gather cases`) - `python -B tests/pixel_gather_bias_probe.py --dxc <dxc.exe> --draw <offscreen_check.exe> warp` -> passed (`DXC compiled 12 standalone desktop shaders`, `warp matched 12 desktop draws and their wrong-mip controls`; `Microsoft Basic Render Driver`, driver `10.0.26100.9818`, `debug_layer=enabled`, `debug_errors=0 debug_warnings=0`) - `python -B tests/pixel_gather_bias_probe.py --dxc <dxc.exe> --draw <offscreen_check.exe> hardware` -> passed (`DXC compiled 12 standalone desktop shaders`, `hardware matched 12 desktop draws and their wrong-mip controls`; `AMD Radeon RX 7900 XTX`, `vendor=1002 device=744c`, driver `32.0.32029.2010`, `debug_layer=enabled`, `debug_errors=0 debug_warnings=0`) Native gfx1030 HIP execution remains pending on Linux; marking Ready for Review as a verified probe + desktop reference baseline (same scope as #1623).
upstream-sync closed this pull request 2026-11-25 07:00:41 +00:00
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!1636
No description provided.