image_fuzz: image_load_pck / image_load_pck_sgn on the hardware oracle, measured on RDNA2 (HW-IMAGE-LOAD-PCK) #2189

Open
github-bot wants to merge 1 commit from github-bot/gh-2189 into main AGit
Owner

@⁠vinceychu on GitHub · 2026-11-26 03:56 UTC · original
vinceychu:hw-image-load-pck → main · +311 −45 · 5 files · 1 commits · open

Claimed in the coordination issue as: HW-IMAGE-LOAD-PCK (#1608)

What and why

image_load_pck / image_load_pck_sgn ("image load with no format conversion") had no measured rule, and the
translator does not translate them. I measured them natively on an RDNA2 GPU and put the result into the hardware
oracle, so the rule is pinned before anyone implements the op.

Measured rule (gfx1036): the texel's S bytes (S = bytes per texel from the T# FORMAT) form ceil(S/4)
little-endian dwords; a texel under 4 bytes is one dword, zero-extended for pck and sign-extended from bit 8·S−1
for pck_sgn (the whole texel's sign, not per component). dmask bit i selects dword i (0 past the last), packed
into consecutive VGPRs. The FORMAT's numeric type (UINT/SINT/UNORM/FLOAT) does not matter.

Format, texel 0 bytes image_load (dmask 0xf) image_load_pck image_load_pck_sgn
R8G8B8A8_UINT 81 7f ff 02 81 7f ff 02 per component 02ff7f81 0 0 0 same
R8G8B8A8_UNORM same bytes floats 02ff7f81 0 0 0 same
R16G16B16A16_SFLOAT 01 80 ff fb 34 12 00 80 floats fbff8001 80001234 0 0 same
R32G32B32A32_SFLOAT f0..ff the 4 words the 4 words same
R32_SFLOAT 81 7f ff 02 02ff7f81 0 0 3f800000 02ff7f81 0 0 0 same
R8_UINT / R8_SINT 81 81 / ffffff81 00000081 ffffff81
R16_UINT / R16_SINT 01 80 8001 / ffff8001 00008001 ffff8001
R8G8_UINT / R8G8_SINT 81 f2 per component 0000f281 fffff281
R16G16_SINT 01 80 fe 7f per component 7ffe8001 7ffe8001

dmask: R8G8B8A8 dmask 2 → 0, dmask 5 → 02ff7f81 0; R16G16B16A16 dmask 2 → 80001234, dmask e → 80001234 0 0.

Changes:

  • tools/image_fuzz.py: --op image_load|image_load_pck|image_load_pck_sgn for the hardware oracle (the opcode in the
    kernel, without unorm), the pck_oracle CPU model, the sub-4-byte formats R8/R16/R8G8 UINT/SINT and R16G16_SINT for
    the pck ops, a pck_sgn_zero_extend perturbation, and a wrong-FORMAT control that changes the texel size for the
    pck ops (a same-size FORMAT of another type gives the same words, as measured, so it could not be caught).
    --oracle translator skips the pck ops (the translator does not handle them yet).
  • tools/hw_oracle/tsharp.py: the FORMAT codes of those formats.
  • tests/test_image_fuzz_hw.py: pck_oracle against the measured words.
  • docs/shader_validation.md: the rule, the measurements and the commands; docs/design.md: the op is measured, not
    translated.

Tested

Natively on the RDNA2 iGPU (gfx1036) of a Ryzen 9 9950X, Linux amdgpu DRM through tools/hw_oracle/drm.py, clang 21:

  • image_fuzz.py --oracle hw --op image_load_pck --programs 60 --seed 1: 60/60 match (wave32 34, wave64 26).
  • --op image_load_pck_sgn --programs 200 --seed 9: 200/200 match.
  • --op image_load_pck[_sgn] --negative-control --programs 60 --seed 2: unperturbed 0 mismatches; every perturbation
    and every wrong FORMAT caught; exit 0. pck_sgn_zero_extend caught by 20 of 60 (the sub-4-byte cases).
  • --op image_load (default path): 60/60 match and its negative control unchanged (exit 0): no regression.
  • pytest tests/test_image_fuzz_hw.py tests/test_image_fuzz.py: 99 passed, 1 skipped; image_fuzz.py --self-test,
    tests/test_ci_registration.py, compileall: clean.

GPUs tested: AMD Radeon iGPU of the Ryzen 9 9950X (gfx1036, RDNA2), natively via tools/hw_oracle on Linux amdgpu

AI-assisted: yes (measured by hand with Claude Code; the fuzzer change drafted by Devin, reviewed, fixed and run on the GPU)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md (n/a: measured, not translated yet)

🤖 Generated with Claude Code

https://claude.ai/code/session_01RAL8MMXUuNpQAVa1iiyAMP

**@⁠vinceychu** on GitHub · 2026-11-26 03:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2189) `vinceychu:hw-image-load-pck` → `main` · +311 −45 · 5 files · 1 commits · open Claimed in the coordination issue as: HW-IMAGE-LOAD-PCK (#1608) ### What and why `image_load_pck` / `image_load_pck_sgn` ("image load with no format conversion") had no measured rule, and the translator does not translate them. I measured them natively on an RDNA2 GPU and put the result into the hardware oracle, so the rule is pinned before anyone implements the op. **Measured rule (gfx1036):** the texel's S bytes (S = bytes per texel from the T# FORMAT) form ceil(S/4) little-endian dwords; a texel under 4 bytes is one dword, zero-extended for `pck` and sign-extended from bit 8·S−1 for `pck_sgn` (the whole texel's sign, not per component). `dmask` bit i selects dword i (0 past the last), packed into consecutive VGPRs. The FORMAT's numeric type (UINT/SINT/UNORM/FLOAT) does not matter. | Format, texel 0 bytes | `image_load` (dmask 0xf) | `image_load_pck` | `image_load_pck_sgn` | |---|---|---|---| | `R8G8B8A8_UINT` `81 7f ff 02` | `81 7f ff 02` per component | `02ff7f81 0 0 0` | same | | `R8G8B8A8_UNORM` same bytes | floats | `02ff7f81 0 0 0` | same | | `R16G16B16A16_SFLOAT` `01 80 ff fb 34 12 00 80` | floats | `fbff8001 80001234 0 0` | same | | `R32G32B32A32_SFLOAT` `f0..ff` | the 4 words | the 4 words | same | | `R32_SFLOAT` `81 7f ff 02` | `02ff7f81 0 0 3f800000` | `02ff7f81 0 0 0` | same | | `R8_UINT` / `R8_SINT` `81` | `81` / `ffffff81` | `00000081` | `ffffff81` | | `R16_UINT` / `R16_SINT` `01 80` | `8001` / `ffff8001` | `00008001` | `ffff8001` | | `R8G8_UINT` / `R8G8_SINT` `81 f2` | per component | `0000f281` | `fffff281` | | `R16G16_SINT` `01 80 fe 7f` | per component | `7ffe8001` | `7ffe8001` | dmask: `R8G8B8A8` dmask 2 → `0`, dmask 5 → `02ff7f81 0`; `R16G16B16A16` dmask 2 → `80001234`, dmask e → `80001234 0 0`. Changes: - `tools/image_fuzz.py`: `--op image_load|image_load_pck|image_load_pck_sgn` for the hardware oracle (the opcode in the kernel, without `unorm`), the `pck_oracle` CPU model, the sub-4-byte formats R8/R16/R8G8 UINT/SINT and R16G16_SINT for the pck ops, a `pck_sgn_zero_extend` perturbation, and a wrong-FORMAT control that changes the texel size for the pck ops (a same-size FORMAT of another type gives the same words, as measured, so it could not be caught). `--oracle translator` skips the pck ops (the translator does not handle them yet). - `tools/hw_oracle/tsharp.py`: the FORMAT codes of those formats. - `tests/test_image_fuzz_hw.py`: `pck_oracle` against the measured words. - `docs/shader_validation.md`: the rule, the measurements and the commands; `docs/design.md`: the op is measured, not translated. ### Tested Natively on the RDNA2 iGPU (gfx1036) of a Ryzen 9 9950X, Linux amdgpu DRM through `tools/hw_oracle/drm.py`, clang 21: - `image_fuzz.py --oracle hw --op image_load_pck --programs 60 --seed 1`: 60/60 match (wave32 34, wave64 26). - `--op image_load_pck_sgn --programs 200 --seed 9`: 200/200 match. - `--op image_load_pck[_sgn] --negative-control --programs 60 --seed 2`: unperturbed 0 mismatches; every perturbation and every wrong FORMAT caught; exit 0. `pck_sgn_zero_extend` caught by 20 of 60 (the sub-4-byte cases). - `--op image_load` (default path): 60/60 match and its negative control unchanged (exit 0): no regression. - `pytest tests/test_image_fuzz_hw.py tests/test_image_fuzz.py`: 99 passed, 1 skipped; `image_fuzz.py --self-test`, `tests/test_ci_registration.py`, `compileall`: clean. GPUs tested: AMD Radeon iGPU of the Ryzen 9 9950X (gfx1036, RDNA2), natively via tools/hw_oracle on Linux amdgpu AI-assisted: yes (measured by hand with Claude Code; the fuzzer change drafted by Devin, reviewed, fixed and run on the GPU) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md` (n/a: measured, not translated yet) 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01RAL8MMXUuNpQAVa1iiyAMP
design.md had no measured rule for the no-format-conversion image loads.
Measured natively on an RDNA2 iGPU (gfx1036) through tools/hw_oracle: the
texel's bytes form little-endian dwords selected by dmask (0 past the last),
a texel under 4 bytes is zero-extended (pck) or sign-extended from its top
bit (pck_sgn), and the FORMAT's numeric type does not matter.

image_fuzz.py gets --op image_load_pck|image_load_pck_sgn for the hw oracle,
the pck_oracle CPU model, sub-4-byte texel formats, a pck_sgn_zero_extend
perturbation and a wrong-FORMAT control that changes the texel size;
tests/test_image_fuzz_hw.py pins the measured words. The translator does not
translate these ops yet; this is the measured model it needs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RAL8MMXUuNpQAVa1iiyAMP
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:21:47 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2189/head:github-bot/gh-2189'
git switch 'github-bot/gh-2189'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2189'
git switch 'github-bot/gh-2189'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2189'
git switch 'github-bot/gh-2189'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2189'
git switch 'main'
git merge --squash 'github-bot/gh-2189'
git switch 'main'
git merge --ff-only 'github-bot/gh-2189'
git switch 'main'
git merge 'github-bot/gh-2189'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.