Skip to content

image_fuzz: require fresh shader modules and readbacks for each case - #6965

Open
jewmaster1337 wants to merge 1 commit into
ItsNotRexed:mainfrom
jewmaster1337:codex/image-fuzz-fresh-case-artifacts
Open

jewmaster1337 wants to merge 1 commit into
ItsNotRexed:mainfrom
jewmaster1337:codex/image-fuzz-fresh-case-artifacts

Conversation

@jewmaster1337

@jewmaster1337 jewmaster1337 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in coordination #6910.

Within one invocation, the image fuzzer reuses fixed paths across cases. An old fragment module could mask the translator refusing the next shader. An old matching frame could also give a false pass if the next harness exited zero without producing pixels. Remove case outputs before their producers run and report missing or malformed readbacks as case failures. Device-unsupported returns retain their existing skip behavior.

  • Negative controls on the original code reproduced both false passes and the missing/truncated readback exceptions.
  • python -m pytest -q tests/test_image_fuzz.py tests/test_image_fuzz_hw.py: 91 passed, 6 skipped on Windows. The self-test and Python compilation passed.
  • Ubuntu 24.04 container, LLVM 18 and Mesa software Vulkan: built vk_image_fuzz and ran three R8G8B8A8_UNORM cases in the same work directory with seed 8. All three matched the reference across every pixel under the existing one-ULP allowance.
  • git diff --check passed. Native GPU and retail runs were outside this check.

Synthetic inputs only. AI-assisted (Codex).

Native Windows Vulkan check

Trial-merged the PR head with upstream 2382459 and built vk_image_fuzz with MSVC 19.44 and the pinned Vulkan-Headers. The harness selected an NVIDIA GeForce RTX 4070 with driver 621.01. LLVM 18.1.3 assembled the synthetic RDNA2 input in Ubuntu 24.04 and SPIRV-Tools 2026.3 validated the translated modules on Windows.

  • python -IB tools/image_fuzz.py --build build/gpu --programs 16 --seed 8 --work build/native-fuzz --show — 16/16 matched across six formats, including the newly merged noncontiguous mask coverage.
  • python -IB tools/image_fuzz.py --build build/gpu --programs 8 --seed 8 --work build/native-fuzz --pc-tail-ubo — 8/8 matched.
  • python -m pytest -q tests/test_image_fuzz.py tests/test_image_fuzz_hw.py — 92 passed and 6 skipped. python -IB tools/image_fuzz.py --self-test passed.

Synthetic fixtures only. AI-assisted (Codex).

@airp1ane

Copy link
Copy Markdown
Contributor

Tested ebc9086 on Windows 11, Python 3.15.2, NVIDIA RTX 4060 Ti (driver 621.24; CPU-only checks, no game files, no GPU/llvm-mc/MSVC used): pass.

Ran the test files this PR adds or changes, from a clean checkout of the PR head: test_image_fuzz.py - all exit 0.

AI-assisted (Claude Code).

@ne1i

ne1i commented Nov 23, 2026

Copy link
Copy Markdown

Tested ebc9086e on Linux, CPython 3.14, CPU only, synthetic inputs, merged onto main 867d922f: the tests pass, but they pass without the change too

  • python -I tests/test_image_fuzz.py: WITHOUT tests/test_image_fuzz.py rc=0. With only the non-test files reverted to main: .
  • compileall and scripts/check_no_game_data.py on the changed files: clean.

This file is pytest-style (no __main__ block), so python -I runs no tests and reports success; it needs python -m pytest. With pytest, an agent counted 69 passed, and 4 fail with only the tool reverted. Anyone checking it with python -I will see a vacuous pass.

Independent check (not the author). Run by an AI agent (DeepSeek V4.1 Flash) and re-run by the orchestrating session (Claude Code) before posting.

Raxstreams added a commit to Raxstreams/Leonida that referenced this pull request Nov 23, 2026
image_fuzz: require fresh shader modules and readbacks for each case

Independent review: ItsNotRexed#6965 (comment)

Fork integration. AI-assisted (Codex).
@AsgerCode

Copy link
Copy Markdown

Tested ebc9086 on Windows 11 (NTFS), Python 3.12.10 (CPU only, no GPU, no game files): pass

The earlier comments found that python -I tests/test_image_fuzz.py runs nothing. This run uses pytest, and also drives the real main() -> run_translator() -> run_case() loop over several cases in one work directory. Fakes replace llvm-mc (LLVM_MC set to a .bat), the translator (TRANSLATOR set to a script that can leave out ps_image_load.spv) and vk_image_fuzz (the launch is sent to a Python script that writes the correct 64x64 frame, nothing, 5 bytes, or exits 1 or 77).

What I ran:

  • python -I -m pytest -q tests/test_image_fuzz.py: 68 passed, 1 skipped. test_image_fuzz_hw.py 23 passed, 5 skipped; test_image_fuzz_work_isolation.py 6 passed; test_build_runtime_fallback.py 8 passed.
  • Negative control (merge-base tool): 4 failed, which are the new translation test and the missing, stale and truncated cases.
  • Merge with current main 867d922 (368 commits ahead; test(image-fuzz): exercise noncontiguous masks by default #6894 changed tools/image_fuzz.py): clean. On the merged tree the four files give 68/1, 24/5, 6 and 7 passed + 1 failed. The one failure (shims\xg_xs.cpp not in the cl.exe fallback) also fails on main without this PR.

End-to-end runs (--programs 3 --seed 8 --formats R8G8B8A8_UNORM, one work directory):

fake behaviour PR merge base
harness writes a correct frame every case 3/3 match, exit 0 not run
case 2: harness exits 0, writes no out.raw case 2 FAIL (could not read fresh pixels: [Errno 2] No such file or directory: ...), exit 1 case 2 compared case 1's frame: 6+ mismatched pixels
case 2: harness writes 5 bytes FAIL (could not read fresh pixels: <work>\out.raw: 5 bytes, expected 65536), exit 1 SystemExit with no case line or summary
case 2: translator leaves out ps_image_load.spv translator did not emit ps_image_load.spv, exit 1, harness not started harness ran case 2 with case 1's module (the fake logged dmask 0xf for a 0x1 case)
case 2: harness exits 77 SKIP (unsupported: fake format), then case 3 passes, exit 0 not run
case 1 leaves a read-only out.raw cannot remove the previous case output ...: [WinError 5] Access is denied, exit 1 not run

With 12 programs over all six formats on the merged tree, all 12 match. A stale readback or module in a later case is refused the same way.

Nits, none blocking:

  1. For a missing readback, the line shows Python's FileNotFoundError text, with the full path as a doubled-backslash repr. It would be clearer to say what happened, for example vk_image_fuzz exited 0 but wrote no out.raw. The summary line then counts the case as 1 mismatched, but no pixels were compared.

Overlap: no other open PR clears stale case outputs. #9227, #8433, #4426 and #4152 also change tools/image_fuzz.py, and each merges cleanly with this PR.

Not run: the real vk_image_fuzz, llvm-mc and the translator on a GPU (no Vulkan SDK or built runtime on this machine).

AI-assisted (Claude Code).

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