shader: probe gfx1030 2D gather instruction bias #1643

Manually merged
github merged 1 commit from gh-pr/1643/head into gh-pr/1643/base 2026-11-26 23:22:56 +00:00
Owner

@⁠stan495 on GitHub · 2026-11-24 15:40 UTC · original
stan495:codex/gfx1030-mimg-gather-bias → main · +455 −0 · 2 files · 1 commits · merged 2026-11-25 06:12 UTC

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.

**@⁠stan495** on GitHub · 2026-11-24 15:40 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1643) `stan495:codex/gfx1030-mimg-gather-bias` → `main` · +455 −0 · 2 files · 1 commits · merged 2026-11-25 06:12 UTC ## 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:22:55 +00:00
github manually merged commit 92204dfebb into gh-pr/1643/base 2026-11-26 23:22:56 +00:00
Author
Owner

@⁠stan495 on GitHub · 2026-11-25 05:55 UTC · original

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).

**@⁠stan495** on GitHub · 2026-11-25 05:55 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1643#issuecomment-7154263939) 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).
Author
Owner

@⁠tedin7 on GitHub · 2026-11-25 05:59 UTC · original · reviewed

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.

**@⁠tedin7** on GitHub · 2026-11-25 05:59 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1643#pullrequestreview-6052576504) · **reviewed** 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.