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

Open
opened 2026-11-26 21:20:21 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2189
Author: @vinceychu
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: hw-image-load-pck


📝 Commits (1)

  • 790b4f4 image_fuzz: image_load_pck / image_load_pck_sgn on the hardware oracle, measured on RDNA2 (HW-IMAGE-LOAD-PCK)

📊 Changes

5 files changed (+311 additions, -45 deletions)

View changed files

📝 docs/design.md (+1 -0)
📝 docs/shader_validation.md (+36 -0)
📝 tests/test_image_fuzz_hw.py (+125 -17)
📝 tools/hw_oracle/tsharp.py (+6 -2)
📝 tools/image_fuzz.py (+143 -26)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2189 **Author:** [@vinceychu](https://github.com/vinceychu) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `hw-image-load-pck` --- ### 📝 Commits (1) - [`790b4f4`](https://github.com/ubiquitarianism/leonida/commit/790b4f4364a22388e6af311c892349eb4b9abd9e) image_fuzz: image_load_pck / image_load_pck_sgn on the hardware oracle, measured on RDNA2 (HW-IMAGE-LOAD-PCK) ### 📊 Changes **5 files changed** (+311 additions, -45 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -0) 📝 `docs/shader_validation.md` (+36 -0) 📝 `tests/test_image_fuzz_hw.py` (+125 -17) 📝 `tools/hw_oracle/tsharp.py` (+6 -2) 📝 `tools/image_fuzz.py` (+143 -26) </details> ### 📄 Description 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#2193
No description provided.