shader: run ordinary gfx1030 biased gather probes through Vulkan #2741

Open
stan495 wants to merge 1 commit from upstream-pr/2749 into main
stan495 commented 2026-11-26 05:44:25 +00:00 (Migrated from github.com)

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


Behavior

Add a source-built Vulkan entry point for the ordinary biased gather cases from #1643, which is already on main. The harness uploads the distinct 8×8, 4×4 and 2×2 RGBA32F mips, executes the SPIR-V fragments and checks exact RGBA32F readbacks against the CPU tap reference. Its ordinary and signed-offset cases target image_gather4_b and image_gather4_b_o. The single-mip controls run without the AMD extension; the full-view Bias and Lod fragments require VK_AMD_texture_gather_bias_lod and the format's AMD capability bit. Comparison, clamp and fractional-threshold behavior are outside this Vulkan probe. No AOT lowering or coverage registration is added.

This is separate from the general Vulkan pixel harness in #2297, which has no RGBA32F gather-bias extension path. It reuses the source-built texture and CPU model from #1643.

Verification

Tested clean 5e443b5322856581e71eccbf04f2d5fb2d383747, based on 651577a07f1d7122b21bf6f0010ee0903272b14c. Ubuntu 22.04.5 in Docker, GCC 11.4.0, LLVM 15.0.7, SPIRV-Tools v2022.2-dev, Mesa lavapipe 23.2.1 (llvmpipe, LLVM 15.0.7, Vulkan device API 1.3.255), Khronos validation enabled (package 1.3.204.1-2). This is a software Vulkan run, not native AMD execution.

mkdir -p out
python3 -B tests/pixel_gather_bias_probe.py --binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1
c++ -std=c++17 -O2 -Wall -Wextra -Wpedantic -Werror tests/pixel_gather_bias_vulkan.cpp -lvulkan -o out/pixel_gather_bias_vulkan
export VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/lvp_icd.x86_64.json
export VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation
python3 -B tests/pixel_gather_bias_vulkan.py spirv-as spirv-val --runner out/pixel_gather_bias_vulkan
python3 -B tests/pixel_gather_bias_vulkan.py spirv-as spirv-val --runner out/pixel_gather_bias_vulkan --native --case image_gather4_b-magnify
out/pixel_gather_bias_vulkan out/gfx1030-gather-bias-vulkan image_gather4_b-positive single-mip 3 out/bad-mip.rgba32f
out/pixel_gather_bias_vulkan out/gfx1030-gather-bias-vulkan image_gather4_b-positive bias 1 out/bad-base.rgba32f

LLVM round-tripped 24 native shaders and checked the four existing biased-gather encodings. SPIRV-Tools assembled and validated 19 modules. All 18 single-view draws matched the CPU reference bit for bit, and all 12 wrong-view comparisons differed; no Vulkan validation errors were emitted. The first Vulkan wrong-view check (positive bias; view at mip 0 instead of 2) differed at (0,0), tap 0: expected 8705, actual 529. The magnification discriminator at the same tap gives mip 1 4609 and mip 2 8705. Both invalid invocations returned 1: Base mip must be in [0, 2] and Full-view modes require base mip 0.

The native command returned capability skip 77: VK_AMD_texture_gather_bias_lod unavailable. No native biased draw was counted as a pass. On gfx1030/RADV, unset the lavapipe ICD override and rerun the native command with RADV_DEBUG=ps,nocache; retain the raw readbacks and confirm image_gather4_l and image_gather4_b in the driver ISA. A mismatch after the explicit control passes is useful evidence against the candidate, not a skip.

python3 -B tests/pixel_gather_check.py --binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1
python3 -B tests/pixel_compare_gather_check.py --binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1
python3 -B tests/docs_links_check.py
python3 -B tests/bidi_controls_check.py
git diff --check HEAD^ HEAD

The adjacent 24 ordinary and six comparison LLVM/archive CLI cases passed, as did the docs, bidi and diff checks. These standalone probes are not CTest cases and add no passing FORM_COVERAGE_RECORD entries. Local merge simulation against 1ec01d7037d30fbdc383d48dceb43ad8c48e0f0b passed independently and with the clamp probe in either order. The merged tree was not used for the execution results above.

Windows AMD RDNA 2 Vulkan verification on 5e443b5322856581e71eccbf04f2d5fb2d383747

Tested clean head 5e443b5322856581e71eccbf04f2d5fb2d383747 on Windows 11 build 10.0.26200.9974 with MSVC 19.44.35228.0 (/std:c++17 /O2 /EHsc /W4 /WX), SPIRV-Tools v2025.5 (262bdab48146c937467f826699a40da0fdfc0f1a), source-built Khronos Vulkan-Headers / Vulkan-Loader linked against system vulkan-1.dll (1.4.357), and Python 3.12.10 (out/pe-env). Khronos Vulkan validation layers were not installed on this Windows host.

. .\tools\dev.ps1
cl.exe /nologo /std:c++17 /O2 /EHsc /W4 /WX /I..\..\out\tools\vulkan\install\include tests\pixel_gather_bias_vulkan.cpp /Fo:out\pixel_gather_bias_vulkan.obj /Fe:out\pixel_gather_bias_vulkan.exe /link /LIBPATH:..\..\out\tools\vulkan\install\lib vulkan-1.lib
python -B tests/pixel_gather_bias_vulkan.py spirv-as.exe spirv-val.exe --runner out\pixel_gather_bias_vulkan.exe --device 0
python -B tests/pixel_gather_bias_vulkan.py spirv-as.exe spirv-val.exe --runner out\pixel_gather_bias_vulkan.exe --native --device 0 --case image_gather4_b-magnify
python -B tests/pixel_gather_bias_vulkan.py spirv-as.exe spirv-val.exe --runner out\pixel_gather_bias_vulkan.exe --native --device 1
out\pixel_gather_bias_vulkan.exe out/gfx1030-gather-bias-vulkan image_gather4_b-positive single-mip 3 out/bad-mip.rgba32f
out\pixel_gather_bias_vulkan.exe out/gfx1030-gather-bias-vulkan image_gather4_b-positive bias 1 out/bad-base.rgba32f
python -B tests/docs_links_check.py
python -B tests/bidi_controls_check.py
  • Device 0 — AMD Radeon RX 7900 XTX (1002:744c, driver_version=0x8001a0, device_api=1.4.359, Adrenalin 26.11.2 (LLPC)):
    • single-mip controls: 18 Vulkan readbacks and 12 wrong-view comparisons matched bit-for-bit (exit=0).
    • --native --case image_gather4_b-magnify: single-mip controls passed; explicit returned capability skip 77 (SKIP: VK_AMD_texture_gather_bias_lod unavailable).
  • Device 1 — AMD Radeon(TM) Graphics (1002:164e, driver_version=0x800161, device_api=1.4.315, Adrenalin 26.11.2 (AMD proprietary shader compiler)):
    • --native across all six cases (image_gather4_b and image_gather4_b_o across positive, negative, magnify): 30 Vulkan readbacks (18 single-mip, 6 explicit, 6 bias) and 12 wrong-view comparisons matched the CPU reference bit-for-bit (exit=0).
    • Magnification discriminator (base=0 full-view):
      • image_gather4_b-magnify: explicit (matching_mips=[1], readback_sha256=ce332d205847b68d92ece27f7c8665684ff4e3be69978c0bc14274879acd0706) and bias (matching_mips=[1], readback_sha256=ce332d205847b68d92ece27f7c8665684ff4e3be69978c0bc14274879acd0706) both matched mip 1 bit-for-bit.
      • image_gather4_b_o-magnify: explicit (matching_mips=[1], readback_sha256=ecd22050bf7a55fb210745b048ff2ed877787b75a0a8a852db8caa96894b58c9) and bias (matching_mips=[1], readback_sha256=ecd22050bf7a55fb210745b048ff2ed877787b75a0a8a852db8caa96894b58c9) both matched mip 1 bit-for-bit.
  • Negative CLI & repo checks: Both invalid invocations returned 1 (Base mip must be in [0, 2] and Full-view modes require base mip 0); docs_links_check.py (19 files, 525 links) and bidi_controls_check.py (1991 files) passed.
  • Scope note: Executed on the Windows proprietary AMD Vulkan driver rather than Linux Mesa RADV, so RADV_DEBUG=ps,nocache driver ISA confirmation (image_gather4_l / image_gather4_b) remains Linux-only.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6620379558 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2749). Originally posted by [stan495](https://github.com/stan495) on 2026-11-26T05:44:25Z. --- ## Behavior Add a source-built Vulkan entry point for the ordinary biased gather cases from #1643, which is already on `main`. The harness uploads the distinct 8×8, 4×4 and 2×2 RGBA32F mips, executes the SPIR-V fragments and checks exact RGBA32F readbacks against the CPU tap reference. Its ordinary and signed-offset cases target `image_gather4_b` and `image_gather4_b_o`. The single-mip controls run without the AMD extension; the full-view `Bias` and `Lod` fragments require `VK_AMD_texture_gather_bias_lod` and the format's AMD capability bit. Comparison, clamp and fractional-threshold behavior are outside this Vulkan probe. No AOT lowering or coverage registration is added. This is separate from the general Vulkan pixel harness in #2297, which has no RGBA32F gather-bias extension path. It reuses the source-built texture and CPU model from #1643. ## Verification Tested clean `5e443b5322856581e71eccbf04f2d5fb2d383747`, based on `651577a07f1d7122b21bf6f0010ee0903272b14c`. Ubuntu 22.04.5 in Docker, GCC 11.4.0, LLVM 15.0.7, SPIRV-Tools v2022.2-dev, Mesa lavapipe 23.2.1 (`llvmpipe`, LLVM 15.0.7, Vulkan device API 1.3.255), Khronos validation enabled (package 1.3.204.1-2). This is a software Vulkan run, not native AMD execution. ```sh mkdir -p out python3 -B tests/pixel_gather_bias_probe.py --binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 c++ -std=c++17 -O2 -Wall -Wextra -Wpedantic -Werror tests/pixel_gather_bias_vulkan.cpp -lvulkan -o out/pixel_gather_bias_vulkan export VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/lvp_icd.x86_64.json export VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation python3 -B tests/pixel_gather_bias_vulkan.py spirv-as spirv-val --runner out/pixel_gather_bias_vulkan python3 -B tests/pixel_gather_bias_vulkan.py spirv-as spirv-val --runner out/pixel_gather_bias_vulkan --native --case image_gather4_b-magnify out/pixel_gather_bias_vulkan out/gfx1030-gather-bias-vulkan image_gather4_b-positive single-mip 3 out/bad-mip.rgba32f out/pixel_gather_bias_vulkan out/gfx1030-gather-bias-vulkan image_gather4_b-positive bias 1 out/bad-base.rgba32f ``` LLVM round-tripped 24 native shaders and checked the four existing biased-gather encodings. SPIRV-Tools assembled and validated 19 modules. All 18 single-view draws matched the CPU reference bit for bit, and all 12 wrong-view comparisons differed; no Vulkan validation errors were emitted. The first Vulkan wrong-view check (positive bias; view at mip 0 instead of 2) differed at `(0,0)`, tap 0: expected `8705`, actual `529`. The magnification discriminator at the same tap gives mip 1 `4609` and mip 2 `8705`. Both invalid invocations returned 1: `Base mip must be in [0, 2]` and `Full-view modes require base mip 0`. The native command returned capability skip **77**: `VK_AMD_texture_gather_bias_lod unavailable`. No native biased draw was counted as a pass. On gfx1030/RADV, unset the lavapipe ICD override and rerun the native command with `RADV_DEBUG=ps,nocache`; retain the raw readbacks and confirm `image_gather4_l` and `image_gather4_b` in the driver ISA. A mismatch after the explicit control passes is useful evidence against the candidate, not a skip. ```sh python3 -B tests/pixel_gather_check.py --binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 python3 -B tests/pixel_compare_gather_check.py --binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 python3 -B tests/docs_links_check.py python3 -B tests/bidi_controls_check.py git diff --check HEAD^ HEAD ``` The adjacent 24 ordinary and six comparison LLVM/archive CLI cases passed, as did the docs, bidi and diff checks. These standalone probes are not CTest cases and add no passing `FORM_COVERAGE_RECORD` entries. Local merge simulation against `1ec01d7037d30fbdc383d48dceb43ad8c48e0f0b` passed independently and with the clamp probe in either order. The merged tree was not used for the execution results above. ## Windows AMD RDNA 2 Vulkan verification on `5e443b5322856581e71eccbf04f2d5fb2d383747` Tested clean head `5e443b5322856581e71eccbf04f2d5fb2d383747` on Windows 11 build `10.0.26200.9974` with MSVC `19.44.35228.0` (`/std:c++17 /O2 /EHsc /W4 /WX`), SPIRV-Tools `v2025.5` (`262bdab48146c937467f826699a40da0fdfc0f1a`), source-built Khronos `Vulkan-Headers` / `Vulkan-Loader` linked against system `vulkan-1.dll` (`1.4.357`), and Python `3.12.10` (`out/pe-env`). Khronos Vulkan validation layers were not installed on this Windows host. ```powershell . .\tools\dev.ps1 cl.exe /nologo /std:c++17 /O2 /EHsc /W4 /WX /I..\..\out\tools\vulkan\install\include tests\pixel_gather_bias_vulkan.cpp /Fo:out\pixel_gather_bias_vulkan.obj /Fe:out\pixel_gather_bias_vulkan.exe /link /LIBPATH:..\..\out\tools\vulkan\install\lib vulkan-1.lib python -B tests/pixel_gather_bias_vulkan.py spirv-as.exe spirv-val.exe --runner out\pixel_gather_bias_vulkan.exe --device 0 python -B tests/pixel_gather_bias_vulkan.py spirv-as.exe spirv-val.exe --runner out\pixel_gather_bias_vulkan.exe --native --device 0 --case image_gather4_b-magnify python -B tests/pixel_gather_bias_vulkan.py spirv-as.exe spirv-val.exe --runner out\pixel_gather_bias_vulkan.exe --native --device 1 out\pixel_gather_bias_vulkan.exe out/gfx1030-gather-bias-vulkan image_gather4_b-positive single-mip 3 out/bad-mip.rgba32f out\pixel_gather_bias_vulkan.exe out/gfx1030-gather-bias-vulkan image_gather4_b-positive bias 1 out/bad-base.rgba32f python -B tests/docs_links_check.py python -B tests/bidi_controls_check.py ``` - **Device 0 — `AMD Radeon RX 7900 XTX` (`1002:744c`, `driver_version=0x8001a0`, `device_api=1.4.359`, Adrenalin `26.11.2 (LLPC)`)**: - `single-mip` controls: **18 Vulkan readbacks and 12 wrong-view comparisons** matched bit-for-bit (`exit=0`). - `--native --case image_gather4_b-magnify`: `single-mip` controls passed; `explicit` returned capability skip **77** (`SKIP: VK_AMD_texture_gather_bias_lod unavailable`). - **Device 1 — `AMD Radeon(TM) Graphics` (`1002:164e`, `driver_version=0x800161`, `device_api=1.4.315`, Adrenalin `26.11.2 (AMD proprietary shader compiler)`)**: - `--native` across all six cases (`image_gather4_b` and `image_gather4_b_o` across `positive`, `negative`, `magnify`): **30 Vulkan readbacks** (18 `single-mip`, 6 `explicit`, 6 `bias`) and **12 wrong-view comparisons** matched the CPU reference bit-for-bit (`exit=0`). - Magnification discriminator (`base=0` full-view): - `image_gather4_b-magnify`: `explicit` (`matching_mips=[1]`, `readback_sha256=ce332d205847b68d92ece27f7c8665684ff4e3be69978c0bc14274879acd0706`) and `bias` (`matching_mips=[1]`, `readback_sha256=ce332d205847b68d92ece27f7c8665684ff4e3be69978c0bc14274879acd0706`) both matched mip 1 bit-for-bit. - `image_gather4_b_o-magnify`: `explicit` (`matching_mips=[1]`, `readback_sha256=ecd22050bf7a55fb210745b048ff2ed877787b75a0a8a852db8caa96894b58c9`) and `bias` (`matching_mips=[1]`, `readback_sha256=ecd22050bf7a55fb210745b048ff2ed877787b75a0a8a852db8caa96894b58c9`) both matched mip 1 bit-for-bit. - **Negative CLI & repo checks**: Both invalid invocations returned `1` (`Base mip must be in [0, 2]` and `Full-view modes require base mip 0`); `docs_links_check.py` (19 files, 525 links) and `bidi_controls_check.py` (1991 files) passed. - **Scope note**: Executed on the Windows proprietary AMD Vulkan driver rather than Linux Mesa RADV, so `RADV_DEBUG=ps,nocache` driver ISA confirmation (`image_gather4_l` / `image_gather4_b`) remains Linux-only.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2749:upstream-pr/2749'
git switch 'upstream-pr/2749'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2749'
git switch 'upstream-pr/2749'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2749'
git switch 'upstream-pr/2749'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2749'
git switch 'main'
git merge --squash 'upstream-pr/2749'
git switch 'main'
git merge --ff-only 'upstream-pr/2749'
git switch 'main'
git merge 'upstream-pr/2749'
git push origin 'main'
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!2741
No description provided.