Skip to content

Tests: cover image_load component masks in image fuzzer - #1005

Merged
ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
caua-an:feat/image-load-dmask
Nov 22, 2026
Merged

ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
caua-an:feat/image-load-dmask

Conversation

@caua-an

@caua-an caua-an commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

TEST-132: extend the synthetic image_load fuzzer from #863 (now merged) to cover all 15 nonzero dmask values. Selected RGBA channels are packed into consecutive destination VGPRs; initialized sentinel values check that the remaining VGPRs are not overwritten. With the four default formats, 60 cases exercise every format/mask pair.

The packing model follows the image VGPR usage description in the AMD RDNA 1.0 ISA guide, as documented in docs/shader_validation.md. GPU runs execute translated SPIR-V on the host, not native RDNA2 instructions.

Coordination claim: #634 (comment)

Tests

On head f6e0ffb after merging main 43d4703:

  • python3 -m pytest tests/test_image_fuzz.py tests/test_desc_cache.py -q — 40 passed.
  • python3 -m unittest discover -s tests/semantic — 1062 passed.
  • python3 -m compileall -q make_game.py tools tests — passed.
  • RX 7600, RADV Mesa 26.2.4, Zorin OS 18.1, LLVM 21.1.8, SPIRV-Tools 2025.1: image_fuzz.py --programs 60 --seed 11 and --seed 7600 — 60/60 matched in each run with LEONIDA_VK_VALIDATION=1 and implicit Vulkan layers disabled.

Before the merge, on #863 head 67c22b3: 13 image fuzzer unit tests passed and image_fuzz.py --programs 40 --seed 11 matched 40/40. GPU negative controls on the initial implementation, applied in memory only: substituting a different selected channel or changing an unwritten sentinel was detected by the oracle. CPU tests also check both cases.

No game files or game-derived data were used. No corpus-wide result is claimed.

AI-assisted (OpenCode).

@UlteriorMotive00

Copy link
Copy Markdown
Contributor

Tested 0412134 on Windows with an AMD RDNA2 iGPU and an RTX 5070: pass (first Windows, AMD proprietary driver and NVIDIA runs; the PR was tested on an RX 7600 with RADV).

Windows 11 Home 10.0.26300, MSVC 14.44.35207, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8, Python 3.14.7, LEONIDA_VK_VALIDATION=1, VK_LOADER_LAYERS_DISABLE=~implicit~. One PC, two GPUs, picked with VK_LOADER_DRIVERS_SELECT: AMD Radeon iGPU of a Ryzen 7 9800X3D (RDNA2, AMD 2026.04.17) and NVIDIA GeForce RTX 5070 (Blackwell, 617.42).

  • image_fuzz.py --programs 60 --seed 11 and --seed 7600: 60/60 programs that ran match on both GPUs, all four runs.
  • tests/test_image_fuzz.py (pytest 9.2.0): 35 passed.

One Windows snag, probably from #863 rather than this PR: --build defaults to runtime/build/linux (tools/image_fuzz.py:281), so on Windows the default run stops with runtime\build\linux\vk_image_fuzz.exe not found. The runs above pass --build runtime\build. lds_fuzz.py and valu_fuzz.py default to runtime/build, which is where scripts\build_runtime.ps1 puts it.

AI-assisted (Claude Code). No game files.

@SuarezPM

Copy link
Copy Markdown
Contributor

Tested your head on the machine #863 was developed on: NVIDIA RTX 2060 SUPER, Linux 620.73.04, Vulkan 1.4.357, 32-wide subgroup, harness built from current main (43d4703; your commit does not touch it), with LEONIDA_VK_VALIDATION=1:

  • pytest tests/test_image_fuzz.py: 35 passed; --self-test: ok.
  • --programs 60 --seed 11, --seed 1, --seed 2, --seed 7600: 60/60 matched in each run; no validation errors.
  • Negative control: reversing the selected-component order in the oracle (masked_components) makes dmask 0x5 report mismatches on both an UNORM and a float format, e.g. want [B, R, 3.0, 4.0] got [R, B, 3.0, 4.0]. So the GPU run really checks the packing order, not only the CPU comparator.

The model matches the translator: image_load_typed writes the selected components in ascending R,G,B,A order into consecutive VGPRs (tools/rdna2spirv.py, the write() loop over range(4)), which is exactly masked_components, and the sentinel initialisation is what catches a clobbered unwritten register. Passing on NVIDIA as well as your RADV run means there is no driver-specific packing behaviour in this range.

One procedural thing: the branch is still based on 067d3e8, before #863 merged, so the PR diff currently shows 1092 additions across 5 files — it re-includes the already-merged fuzzer. A git rebase upstream/main drops those four commits by itself (I did it locally: it leaves your single commit, 3 files, +75/−18, no content change). Worth the force-push so reviewers see the real delta.

Nit, not blocking: the four v_mov_b32 sentinel initialisations are emitted even for dmask:0xf, where all are overwritten; skipping them when count == 4 saves four instructions per shader, at the cost of adjusting the test that asserts they are always present.

@caua-an
caua-an marked this pull request as ready for review November 22, 2026 05:55
@caua-an

caua-an commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Thank you both for the independent AMD and NVIDIA runs and for the negative control.

I updated the branch with current main after #863 merged. The PR now shows only the three files in this follow-up, and I reran the tests on the updated head f6e0ffb.

Thanks also for spotting the Windows default build-path issue. Since it comes from the existing fuzzer, I suggest tracking it separately from this dmask change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants