Commit Graph

35 Commits

Author SHA1 Message Date
182746f038 Merge pull request #2189 from vinceychu/hw-image-load-pck
image_fuzz: image_load_pck / image_load_pck_sgn on the hardware oracle, measured on RDNA2 (HW-IMAGE-LOAD-PCK)
2026-12-01 15:53:45 +01:00
45df09b843 chore: remove 13 dead one-off scripts, fix /home/nolan test paths, drop unused imports (CHORE-TIER2A-PYTHON-CLEANUP) 2026-11-30 04:00:53 -05:00
6f6865c9a0 image_fuzz: retry fatal pre-device harness startup once 2026-11-26 07:35:13 +02:00
b7cea7ad9a image_fuzz: report harness errors separately from pixel mismatches
A nonzero vk_image_fuzz exit means the harness never produced an image,
but it shared run_case's False result with real pixel mismatches. The
fuzzer therefore counted a driver/loader crash as a translator mismatch
and exited 1 even though the documented harness-error exit is 2, which
made intermittent validation-loader startup crashes look like translator
regressions.

Keep the detailed harness failure line unchanged, return a distinct
sentinel, count harness errors separately, and preserve exit 2 as the
dominant status. Synthetic tests pin the classification and both exit
codes.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-26 07:13:29 +02:00
790b4f4364 image_fuzz: image_load_pck / image_load_pck_sgn on the hardware oracle, measured on RDNA2 (HW-IMAGE-LOAD-PCK)
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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RAL8MMXUuNpQAVa1iiyAMP
2026-11-25 22:55:38 -05:00
413ffd6eb2 test(image-fuzz): exercise noncontiguous masks by default (#6894)
Squash-merged after diff review of PR #6894 - test(image-fuzz): exercise noncontiguous masks by default
2026-11-23 09:44:21 -06:00
ae846b5b97 Merge pull request #4087 from tupacfan04
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:11:08 -05:00
3dc08ade7f image_fuzz: a dangling-symlink --work is a folder error too
Use lexists for the destination probe, so a dangling symlink or junction is
reported as "not a folder" instead of being treated as missing and failing in
makedirs. Strip the BOM and trailing blank line from the new test file, and add
a symlink case that skips where symlinks cannot be created.
2026-11-22 19:13:04 -06:00
4d3280e942 image_fuzz: reject a --work that is a file before the fuzz starts
A --work pointing at a file (or under one) reached os.makedirs after the cases were built and died with a raw FileExistsError traceback. Validate the destination (or its nearest existing parent) right after the argument checks, so it is one ERROR line and exit 2 before any work.
2026-11-22 17:22:12 -06:00
e1b17b3a79 Merge pull request #3770 from Yawnz
# Conflicts:
#	docs/shader_validation.md
2026-11-22 17:03:40 -05:00
960653b7e9 test: harden image fuzzer work path setup 2026-11-22 23:48:20 +02:00
9b7edc5add tools: isolate image fuzzer work output 2026-11-22 23:31:20 +02:00
d9e126b69f Merge pull request #3221 from Marco Luzzaro 2026-11-22 15:15:55 -05:00
ea09a5934b Merge pull request #2988 from Shrey Ratna 2026-11-22 15:13:51 -05:00
529e437f11 Merge pull request #2967 from Vonsek 2026-11-22 15:13:38 -05:00
ce82f16be5 Reject empty image fuzzer format selections 2026-11-22 20:44:19 +01:00
820e9bc877 image_fuzz: accept the driver's one-ulp UNORM8 conversion in the translator oracle
The translated image_load fetches a UNORM texel through a float view, so the 8-bit -> float conversion is
the driver's. RDNA2 returns the correctly rounded c / 255; llvmpipe multiplies by an f32 1/255, one ulp
above it for 126 of the 256 byte values (27: 0x3dd8d8da, not 0x3dd8d8d9). The comparison was bit exact
and a run stops at its first mismatch, so on llvmpipe every run ended at its first R8G8B8A8_UNORM case
and the other formats never ran.

The translator oracle now accepts one ulp on a UNORM8 texel component, never on another format or on the
sentinels of registers dmask leaves unwritten, and the summary counts how many components needed it.
--oracle hw stays bit exact.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 19:01:57 +00:00
f457ba10c2 fix(test): require translated image fuzzer modules
The batch translator can exit successfully without one of the fuzzer's required modules. Report that rejection before device capability checks can mask it as a skip.
2026-11-22 19:58:29 +01:00
861df84bfd image_fuzz: support --pc-tail-ubo / LEONIDA_PC_TAIL_UBO=1 on 128-byte devices
Honour LEONIDA_PC_TAIL_UBO=1 in runtime/test/vk_image_fuzz.cpp by sizing the
push-constant range and vkCmdPushConstants to 128 bytes (s0..s31; the fuzz
shaders read neither heap base nor code base, so they declare no set-1 block).

Add --pc-tail-ubo (and LEONIDA_PC_TAIL_UBO=1 env detection) to
tools/image_fuzz.py so it forwards --pc-tail-ubo to rdna2spirv.py and sets
LEONIDA_PC_TAIL_UBO=1 for vk_image_fuzz, enabling 128-byte push-constant GPUs
to run the image fuzzer instead of skipping every case.

Co-Authored-By: Gemini 4 Neon <noreply@google.com>
2026-11-22 19:32:05 +02:00
ec9b6cf22b tools: text reports are written with LF line ends on every platform (BUILD-468)
open(path, "w") without newline= turns each \n into \r\n on Windows, so the same JSON report, manifest or assembly
listing was CRLF there and LF elsewhere. 91 text-mode writes (open, os.fdopen, Path.write_text) under tools/, scripts/,
make_game.py and runtime/test/shaders/ now pass newline="\n". tests/test_text_write_line_endings.py reads the source
with ast and fails for a writer that forgets it; CONTRIBUTING.md names the convention.

AI-assisted (Claude), on behalf of dev-ewann.
2026-11-22 14:20:30 +00:00
4c544f5a79 Merge remote-tracking branch 'origin/main' into hw-oracle-image
# Conflicts:
#	tools/image_fuzz.py
2026-11-22 13:37:42 +01:00
719565bbc7 image_fuzz: --oracle hw, the image_load fetches as native kernels with a per-family T#
Runs the same texel fetches as raw compute kernels on the AMD GPU through tools/hw_oracle/: a linear texture the
kernel carries in its own code (256-byte aligned, found with s_getpc_b64), a T# built in s[8:15] for the GPU's family
(hw_oracle/tsharp.py: GFX11 on gfx11xx, GFX10 on gfx103x/gfx10xx), image_load with every dmask for one texel per lane,
all four result registers stored and compared word for word with the CPU model. --oracle translator,hw runs both on
the same textures; --negative-control checks seven wrong models and a wrong T# FORMAT are caught. Exit 77 without the
tools. gfx1150 is RDNA3.5, not RDNA2: the docs say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:16:24 +01:00
1b3d432a71 Merge pull request #1527 from Gino 2026-11-22 07:08:03 -05:00
c9f4cd1a37 image_fuzz: name vk_image_fuzz's exit code or signal and print its stderr
A crash in the harness (the ANV SIGSEGV in vkCreateGraphicsPipelines of #1429)
printed only "FAIL (harness error)". The failure line now says how the harness
ended (exit N, killed by SIGSEGV, or a Windows NTSTATUS such as 0xc0000005
access violation) and its last stderr line, followed by the last 20 lines of
stderr (stdout when stderr is empty).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 12:56:13 +01:00
b656c25b99 Merge pull request #1445 from UlteriorMotive00 2026-11-22 06:38:05 -05:00
52616e8f6d image_fuzz: default --build is runtime/build, and a VS config subfolder is found
The default was runtime/build/linux, which only a Linux build that follows docs/testing.md has. Following
docs/shader_validation.md (cmake --build runtime/build --target vk_image_fuzz, then run with no --build), every
run stopped with "vk_image_fuzz not found". Default to runtime/build like lds_fuzz and valu_fuzz, and look in its
RelWithDebInfo/Release subfolder with compute_fixture.find_test_program as lds_fuzz does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 06:29:58 -05:00
f698bf2206 tools: a path outside the console's code page no longer crashes a tool's output
On Windows a redirected stdout uses the console's ANSI code page, and python -I ignores PYTHONUTF8 and
PYTHONIOENCODING, so a caller path with a character outside that code page ended a run with
UnicodeEncodeError as soon as a tool printed it. #1406 fixed make_game.py; every CLI tool in tools/ now starts
its __main__ block the same way (stdout errors="replace").

tests/test_tool_stdout_encoding.py checks every tool's __main__ block and reruns two measured crashes
(analyze_4240_full.py, meshlet_page.py) with a private-use-named input. Found by @abilliontokens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 11:27:00 +00:00
40bd14777a Merge pull request #1249 from Felix Croasdale 2026-11-22 04:07:53 -05:00
e63bf6bdef mc_command.run: a missing llvm-mc is one line, not a FileNotFoundError traceback
Without llvm-mc, run_gpu_tests.py, valu_fuzz.py, lds_fuzz.py,
image_fuzz.py, crosslane_fuzz.py and runtime/test/shaders/build.py
ended in 'FileNotFoundError: [WinError 2]' from subprocess.run: the first
step of TEST-71 on a Windows machine without one. Only shader_disasm.py
said what was missing. mc_command.run() starts an llvm-mc command and
turns a command that can't be started into shader_disasm.py's message
(set LLVM_MC or --llvm-mc, build_llvm_mc.ps1, the WSL form); the six
llvm-mc call sites use it. tests/test_mc_command.py covers run() and
each tool with a nonexistent LLVM_MC.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 03:02:20 -06:00
fd17f11a5c Translator: typed image_load fetches UINT/SINT formats from the sampled arrays (SHADER-151)
UINT/SINT image_load read the uint/sint storage arrays with OpImageRead, so
every typed load declared StorageImageReadWithoutFormat (missing on Intel
Xe-LP, #619), and read-only integer textures, which the runtime binds only in
the sampled arrays, read the fallback or past the 256-entry storage arrays.
They now fetch through uint/sint aliases of the dimension's sampled array;
a lookup miss takes the float path.

vk_store_test load fills the images before the dispatch, runs without
shaderStorageImageReadWithoutFormat and fails a module that declares it.
vk_image_fuzz no longer requires the without-format features, and binds
its UINT/SINT cases (#1087) as sampled images, as the runtime binds a
read-only texture, instead of storage-only images.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 08:37:47 +00:00
71eea4a73e GPU tests: vk_bindless_test and vk_image_fuzz skip below 144 push constant bytes (TEST-149)
Both harnesses create a pipeline layout with the 144-byte translated
user-data block and never checked maxPushConstantsSize, so on a
128-byte device (Intel Arc, some AMD drivers) they failed validation
instead of skipping, although every pixel was exact. Each now prints
"unsupported: need 144 push constant bytes, device has N" and exits
77 before creating anything, as vk_texture_test does since 0c84bff;
the range uses the same constant.

run_gpu_tests.py already reported ps_tex's 77 as SKIP; image_fuzz.py
skipped it with a fixed message and now quotes the harness's
unsupported line. CPU tests cover both runners' 77 path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 01:52:32 -06:00
dd380ef2fb Tests: fuzz integer image loads 2026-11-22 03:46:54 -03:00
0412134056 Test image loads with partial component masks 2026-11-22 02:39:51 -03:00
67c22b3da0 image_fuzz: compare the f32 bits, not Python floats (signed zero)
Vonsek reproduced a blind spot: +0.0 == -0.0 in Python, so a wrong binding that returns +0 where the texture holds -0 passed silently (4096/4096 raw words differ, compare() reported none; 192/4096 on a generated float case).

same_component() now compares the packed f32 words and keeps the any-NaN policy (payloads are not modelled). Two CPU regressions: one flips a single output channel from -0 to +0 and expects exactly that pixel; the other feeds a different NaN payload and expects no mismatch. 40/40 programs still match on the RTX 2060 SUPER with validation, so the GPU preserves signed zeros for these formats.
2026-11-22 02:01:58 -03:00
e6c767bdd3 Tools: image_load differential fuzzer with a GPU harness
AI-assisted. docs/shader_validation.md said "Not covered yet: images", and
FUZZ-1..13 touch VALU, memory, LDS, crosslane and control flow but not a single
image instruction. This is the first slice of that gap:

- runtime/test/vk_image_fuzz.cpp: headless harness that binds one 2D sampled
  image from a key=value spec (format, size, texels, T# key) through the
  bindless set and the descriptor table, draws a 64x64 full-screen triangle with
  a caller-supplied VS/PS, and dumps RGBA32F. It enables the without-format
  storage-image reads/writes and fragment atomics the translated image path
  declares, and fails on validation errors with LEONIDA_VK_VALIDATION=1.
- tools/image_fuzz.py: assembles a pixel shader that reads one texel with
  image_load (dmask 0xf, T# in s[8:15]), translates it with rdna2spirv.py, runs
  the harness, and compares every pixel with an independent CPU oracle for the
  T# format. A fetch is a memory read, so the oracle is exact.
- tests/test_image_fuzz.py: the oracle, the texel mapping, the T# word and the
  generated shader, without a GPU.

Covered: R8G8B8A8_UNORM, R16G16B16A16_SFLOAT, R32G32B32A32_SFLOAT and
R32_SFLOAT, at 8/16/32/64 square sizes that divide the draw; a fifth of the
values are NaN, +-inf, +-0 or denormals.
Not covered yet: dmask variants, UINT/SINT formats (they read through the
storage views), mips, 1D/2D-array/3D/cube, image_sample/gather with filters and
borders, and texel offsets with VK_KHR_maintenance8.

Verified on an NVIDIA RTX 2060 SUPER (Linux, 620.73.04, Vulkan 1.4.357):
40/40 programs match under LEONIDA_VK_VALIDATION=1; ctest 11/11; the GPU suite
is unchanged with a clean build. Synthetic fixtures only, no game data.
2026-11-22 01:56:25 -03:00