Skip to content

vk_image_fuzz: enable shaderDrawParameters for the translated vs_ids - #4733

Open
tupacfan04 wants to merge 1 commit into
ItsNotRexed:mainfrom
tupacfan04:tupacfan04/image-fuzz-draw-params
Open

tupacfan04 wants to merge 1 commit into
ItsNotRexed:mainfrom
tupacfan04:tupacfan04/image-fuzz-draw-params

Conversation

@tupacfan04

Copy link
Copy Markdown
Contributor

Claim: #4683 (comment)

vk_image_fuzz draws with the translated vs_ids.spv, which declares the DrawParameters capability (BaseVertex / BaseInstance for the zero-based v0 / v3). Its device enabled only the Vulkan 1.0 and 1.2 features (runtime/test/vk_image_fuzz.cpp:270-282 on main), never VkPhysicalDeviceVulkan11Features::shaderDrawParameters. Under LEONIDA_VK_VALIDATION=1 the layer reports VUID-VkShaderModuleCreateInfo-pCode-08740, and the program counts that and exits 1 (:607). So tools/image_fuzz.py fails every case under validation. It's the same gap #3347 closed in vk_texture_test.

The fix queries the Vulkan 1.1 features with the others and enables shaderDrawParameters where the device has it, as vk_harness does (runtime/test/vk_harness.cpp:407-413). The program only picks devices with API 1.2 or later (:206), so chaining the 1.1 struct is valid.

Tests

NVIDIA GeForce RTX 5070, driver 621.24, Windows 11, Vulkan SDK 1.4.363.0. vk_image_fuzz built from this branch (on 98fa503f), MSVC.

  • LEONIDA_VK_VALIDATION=1 python -I tools/image_fuzz.py --programs 40:
    • with the fix: seed 9201 gives 40/40 match, seed 9202 gives 40/40 (the program fails on any validation error, so that means none)
    • negative control, main's vk_image_fuzz (the file is unchanged since 0db7fed5), seed 9201: the first case fails with vk_image_fuzz exit 1: 1 validation errors
    • with the fix and --pc-tail-ubo, seed 9204: 40/40
  • Default mode (no validation), with the fix, seed 9203: 40/40.
  • tests/test_image_fuzz.py, test_image_fuzz_hw.py, test_image_fuzz_work_isolation.py, test_build_runtime_fallback.py, test_mc_command.py: 115 passed, 5 skipped.

Found with GPU-assisted validation over the fuzzers' generated programs (all 100 vk_image_fuzz runs of seed 9101 reported the VUID).

Depends on: none.

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

🤖 Generated with Claude Code

vk_image_fuzz draws with the translated vs_ids, which declares the
DrawParameters capability, but its device enabled only the Vulkan 1.0
and 1.2 features. Under LEONIDA_VK_VALIDATION=1 the layer reported
VUID-VkShaderModuleCreateInfo-pCode-08740 and the program failed every
image_fuzz case. Query the Vulkan 1.1 features and enable
shaderDrawParameters where the device has it, as vk_harness does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Built vk_image_fuzz at 7a89cebfb on Windows 11 (Vulkan SDK 1.4.363): links, and with no arguments prints usage: vk_image_fuzz <vs.spv> <fs.spv> <out.raw> <spec.txt> (exit 2). git diff --check clean.

The fuzzer now enables shaderDrawParameters for the translated vs_ids, which uses gl_VertexIndex/gl_InstanceIndex; without it the pipeline could fail creation on a device that gates the feature. The actual draw needs a built shader pair, not present here, so this is build evidence only. No blocking issue.

@justr4mzi

Copy link
Copy Markdown
Contributor

Verified commit 7a89cebf live on Windows 11 x64 (AMD Radeon RX 6700 XT, LLVM 21.1.8, SPIRV-Tools, LEONIDA_VK_VALIDATION=1):

  • Built vk_image_fuzz.exe cleanly ([2/2]); invoking with no arguments prints usage (exit 2).
  • python -I tools/image_fuzz.py --self-test: image_fuzz self-test: ok (6 formats, 64x64 draw) (exit 0).
  • Live GPU draw (tools/image_fuzz.py --build build --programs 10 --seed 1 --oracle translator, exercising translated vs_ids with shaderDrawParameters enabled):
    • Standard: 10/10 programs that ran match (exit 0).
    • LEONIDA_VK_VALIDATION=1: 10/10 programs that ran match (exit 0, 0 validation errors), plus 1/1 (R8G8B8A8_UNORM 16x8 dmask:0xf: pass) under --show.
  • Repo checks: tests/test_ctest_registration.py (4/4 in 1.055s), scripts/check_no_game_data.py exit 0, and git diff --check exit 0.

Reviewed runtime/test/vk_image_fuzz.cpp: chaining VkPhysicalDeviceVulkan11Features with .shaderDrawParameters = have11.shaderDrawParameters matches vk_harness's setup cleanly. (Non-blocking observation: need(...) does not list shaderDrawParameters if a Vulkan 1.2 device were ever encountered without it, though standard desktop GPUs support it.)

AI-assisted (Gemini, Antigravity).

@Atomic258

Copy link
Copy Markdown
Contributor

GPU-tested at head 7a89cebf on Windows 11, NVIDIA GeForce RTX 5090 (driver 617.42), Vulkan SDK 1.4.363.0, MSVC 14.44 / Ninja / RelWithDebInfo. vk_image_fuzz built from this branch; llvm-mc 23.1.5 (MSYS2 UCRT64, AMDGPU) via LLVM_MC.

cmake --build runtime\build --target vk_image_fuzz
set LEONIDA_VK_VALIDATION=1
python -I tools\image_fuzz.py --programs 40 --seed 9201 --build runtime\build   → translator: 40/40 programs that ran match, exit 0
python -I tools\image_fuzz.py --programs 20 --seed 9202 --build runtime\build   → translator: 20/20 programs that ran match, exit 0

Under VK_LAYER_KHRONOS_validation every case passed — no VUID-VkShaderModuleCreateInfo-pCode-08740 for the translated vs_ids DrawParameters capability.

Red control: git checkout origin/main -- runtime/test/vk_image_fuzz.cpp, rebuilt, same command with --programs 4 --seed 9201 → first case FAIL (vk_image_fuzz exit 1: 1 validation errors) with SPIR-V Capability DrawParameters was declared, but ... shaderDrawParameters ... must be met (VUID-VkShaderModuleCreateInfo-pCode-08740), exit 1. Restored the PR file, rebuilt, re-verified green (20/20 above). Worktree clean.

Note: another GPU shader-test process was running concurrently; no flakes observed.

AI-assisted (Devin).

@chpeu

chpeu commented Nov 23, 2026

Copy link
Copy Markdown

Tested 7a89cebf (main 98fa503f is in its history, no rebase needed) on Linux, and this one I could push
through the code you changed.

The image fuzzer, on the GPU (RTX 3080, driver 615.71.09, Vulkan 1.4.351):
LLVM_MC=/usr/lib/llvm-20/bin/llvm-mc python3 -I tools/image_fuzz.py --programs 24 --seed 20261123 --build runtime/build/linux --work /tmp/prFUZZ/...

  • your branch: exit 0, translator: 24/24 programs that ran match, no skipped programs;
  • main 98fa503f, same seed and same command, minutes apart: exit 0, 24/24 match.

So enabling shaderDrawParameters for the translated vs_ids did not move a single result on this box: the vertex
stage the fuzzer generates goes through the same comparison as before.

One thing worth knowing about Linux coverage: nothing in scripts/run_gpu_tests.py or
runtime/test/shaders/check.py ever launches vk_image_fuzz — the only build script that mentions it is
scripts/build_runtime.ps1 — so on Linux the binary exists (runtime/build/linux/vk_image_fuzz, built fine with
GCC) but the only way to reach it is the Python driver above. Running vk_image_fuzz by hand just prints
usage: vk_image_fuzz <vs.spv> <fs.spv> <out.raw> <spec.txt>.

Rest of the suite, unchanged: with LEONIDA_W64_EMULATE=1 → 201/217 passed, 16 skipped, 0 failed; without
→ 170/217, 47 skipped — identical to main on this machine (the suite is at 217 programs now).
python -m compileall -q make_game.py tools tests: clean. The RTX 5080 was not run in this pass: 186 MiB free, the
card is holding another job here.

Machine note for reproducing: the first attempt died with 'llvm-mc' could not be started until LLVM_MC was set
(our box keeps it at /usr/lib/llvm-20/bin/llvm-mc). Machine: Linux Mint 22 (Ubuntu 24.04 base), SPIRV-Tools
2025.1~rc1, GCC 13.3, Python 3.12.3 with pytest 9.2.0 and numpy 2.5.5, built with cmake -S runtime -B runtime/build/linux -DLEONIDA_VULKAN_HEADERS_FETCH=ON. AI-assisted testing, output read through by hand.

@memorypressure

Copy link
Copy Markdown

Verified at head 7a89ceb merged with current main: code read only (C++ GPU tool). The shaderDrawParameters pass-through matches the DrawParameters use in translated vs_ids, and main's vk_image_fuzz had no Vulkan11Features struct at all. One thing for the pending linux-gpu-tools run to confirm: the designated-initializer enable11 zero-initializes every other Vulkan 1.1 feature the device previously received by API-version default — dependency rules cover the obvious cases, but a validation-on run is the real check. Checks pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only review).

@gertify

gertify commented Nov 23, 2026

Copy link
Copy Markdown

Tested 7a89ceb on Intel UHD 630 (Coffee Lake GT2), Mesa 25.2.8 ANV, Ubuntu 24.04: tools/image_fuzz.py --programs 40 --seed 9201 with LEONIDA_VK_DEVICE=Intel gives "translator: 40/40 programs that ran match". The validation-layer claim is not checked here: with LEONIDA_VK_VALIDATION=1 the run stops at the first case with "LEONIDA_VK_VALIDATION is set but VK_LAYER_KHRONOS_validation is not installed", because the layer is not installed on this system. A nonexistent device name fails every case with "no Vulkan 1.2 device matches", so the device filter applied. The seed 9202 and 9204 runs, the --pc-tail-ubo run and the tests/test_image_fuzz*.py suites were not run.

AI-assisted.

@tupacfan04

Copy link
Copy Markdown
Contributor Author

@memorypressure, on the Vulkan 1.1 features question: no device feature is on by API-version default. A feature is enabled only when the application sets it in pEnabledFeatures or in a feature struct chained on VkDeviceCreateInfo. On main, vk_image_fuzz chained no VkPhysicalDeviceVulkan11Features, so every 1.1 feature was already off. The zero-initialized enable11 keeps them off and turns on only shaderDrawParameters.

What the two shaders vk_image_fuzz loads declare (spirv-dis of this run's vs_ids.spv and ps_image_load.spv):

  • vs_ids: Shader DrawParameters SignedZeroInfNanPreserve DenormPreserve
  • ps_image_load: Shader RuntimeDescriptorArray GroupNonUniform GroupNonUniformBallot SignedZeroInfNanPreserve DenormPreserve

DrawParameters is the only one that needs a 1.1 feature. RuntimeDescriptorArray is enabled through the 1.2 struct as before. The rest depend on device properties (subgroup support, float controls), not on feature switches.

The validation-on check, again at 7a89cebf on an RTX 5070 (621.24, Vulkan SDK 1.4.363.0), on a new seed with the GPU-assisted validation layer loaded as well: LEONIDA_VK_VALIDATION=1 python -I tools/image_fuzz.py --programs 40 --seed 9501 gives 40/40 programs that ran match, with no validation error in any program. vk_image_fuzz exits 1 on any validation error, so 40/40 means the layer found none.

@gertify

gertify commented Nov 23, 2026

Copy link
Copy Markdown

Tested 7a89ceb on Intel UHD 770, driver 32.0.101.7088, Windows 11, MSVC: tools/image_fuzz.py --programs 40 prints "translator: 40/40 programs that ran match" both with LEONIDA_VK_VALIDATION=1 and the Khronos validation layer and with it off. VUID-VkShaderModuleCreateInfo-pCode-08740 does not appear in either harness log, and a direct vk_image_fuzz run with the layer loaded ("device: Intel(R) UHD Graphics 770 (validation on)") exits 0 with 0 occurrences of that VUID and no "Validation Error" lines. I did not run a control on the pre-fix base, so I have not shown that the layer reports this VUID on this driver. The harness captures the child's stderr, so the layer load inside the 40-program runs is shown only by the direct run.

AI-assisted.

@itsonlysimbo

Copy link
Copy Markdown
Contributor

Tested 7a89cebf on RTX 4070, NVIDIA 621.14, Windows 11 (10.0.26300), MSVC 19.44, Ninja, RelWithDebInfo, Vulkan SDK 1.4.363, llvm-mc 23.1.6: pass; reproduces the fix.

  • LEONIDA_VK_VALIDATION=1 python -I tools/image_fuzz.py --programs 40 --seed 9201: 40/40 programs match with this branch's vk_image_fuzz. With main 98fa503f's, the first program fails with vk_image_fuzz exit 1: 1 validation errors (the SPIR-V capability requirement), as your negative control found on the RTX 5070.
  • Default mode (no validation), seed 9203: 40/40.
  • ctest: 165 passed, 9 skipped, 0 failed; run_gpu_tests.py: 170/217 passed, 47 skipped, 0 failed, same as main 98fa503f.

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.

8 participants