Skip to content

valu_fuzz, lds_fuzz: support --pc-tail-ubo / LEONIDA_PC_TAIL_UBO=1 - #2608

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
whoalin1:fuzzers-pc-tail-ubo
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
whoalin1:fuzzers-pc-tail-ubo

Conversation

@whoalin1

Copy link
Copy Markdown
Contributor

Claimed in #2516 (comment).
Depends on: #2046 (adds --pc-tail-ubo to tools/rdna2spirv.py) and #2048 (adds LEONIDA_PC_TAIL_UBO=1 set-1 binding to vk_compute_test).

Summary

  • tools/valu_fuzz.py and tools/lds_fuzz.py:
    • Add --pc-tail-ubo (also enabled when LEONIDA_PC_TAIL_UBO is truthy: 1/true/yes/on, case-insensitive, trimmed).
    • Forward --pc-tail-ubo to tools/rdna2spirv.py in translate().
    • Pass LEONIDA_PC_TAIL_UBO=1 in the vk_compute_test subprocess environment in run_gpu().
    • Default path (without --pc-tail-ubo or LEONIDA_PC_TAIL_UBO=1) is unchanged.
  • Tests:
    • tests/test_valu_fuzz.py and tests/test_lds_fuzz_cli.py: verify translate() forwards --pc-tail-ubo, run_gpu() sets LEONIDA_PC_TAIL_UBO=1, and main() honours both --pc-tail-ubo and LEONIDA_PC_TAIL_UBO.

Testing

All tests ran on Windows 11 with Python 3.14, Vulkan SDK 1.4.363 (VK_LAYER_KHRONOS_validation), llvm-mc 21, synthetic inputs only (no game data):

  1. Unit tests (pytest):
    • tests/test_valu_fuzz.py, tests/test_lds_fuzz.py, tests/test_lds_fuzz_cli.py, tests/test_lds_fuzz_hw.py, tests/test_fuzz_find_harness.py, tests/test_text_write_line_endings.py: 149 passed, 8 skipped (hw oracle), 25 subtests passed, 0 failed.
    • py -3.14 -m compileall -q tools/valu_fuzz.py tools/lds_fuzz.py tests/test_valu_fuzz.py tests/test_lds_fuzz_cli.py: clean.
  2. Real-GPU runs (using #2046's rdna2spirv.py and #2048's vk_compute_test):
    • AMD Radeon(TM) Graphics (Ryzen 5 7600 RDNA2 iGPU, AMD Windows driver 24.10.24, Vulkan 1.3.280, 128-byte push constants):
      • Default 144B under VK_LAYER_KHRONOS_validation: triggers VUID-VkPushConstantRange-size-00298 and VUID-vkCmdPushConstants-size-00371 (144 > 128).
      • --pc-tail-ubo (128B) under VK_LAYER_KHRONOS_validation: 0 validation errors, exact matching output.
      • valu_fuzz.py --family mem --programs 10 --wave both --pc-tail-ubo: 20/20 programs that ran match (native), 0 mismatched, 0 skipped, 0 errors.
      • lds_fuzz.py --programs 10 --wave both --pc-tail-ubo: 20/20 programs that ran match (native), 0 mismatched, 0 skipped, 0 errors.
    • NVIDIA GeForce RTX 4070 SUPER (driver 610.88, 256-byte push constants):
      • valu_fuzz.py --family mem --programs 4 --wave 32 --pc-tail-ubo: 4/4 programs that ran match (native).
      • lds_fuzz.py --programs 4 --wave 32 --pc-tail-ubo: 4/4 programs that ran match (native).

Checklist

  • Synthetic inputs only (no game data)
  • AI-assisted (Antigravity / Gemini 4 Neon)
  • Pure LF line endings verified (git diff --check clean)

🤖 Generated with Antigravity (Gemini 4 Neon)

Add --pc-tail-ubo (also honoured via LEONIDA_PC_TAIL_UBO=1) to both
tools/valu_fuzz.py and tools/lds_fuzz.py so they pass --pc-tail-ubo to
rdna2spirv.py and LEONIDA_PC_TAIL_UBO=1 to vk_compute_test. Without this,
128-byte push-constant GPUs hit VUID-VkPushConstantRange-size-00298 /
VUID-vkCmdPushConstants-size-00371 (144 > 128) or skip/fail when fuzzing.

Co-Authored-By: Gemini 4 Neon <noreply@google.com>
@Dom-in

Dom-in commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested aca640b merged onto main 4947579 (clean merge) on Windows 11, Python 3.13: pytest tests/test_lds_fuzz_cli.py tests/test_valu_fuzz.py: 77 passed, 5 skipped, 21 subtests passed. Negative control: the same tests against main's copies of the changed sources give 6 failed, so the tests really cover the change.

AI-assisted (Claude Code); runs on my machine.

@ricarmandoagent

Copy link
Copy Markdown

Checked aca640bb4109ccf66591aad39f2ee5ea7c07ce5f (Linux, Python 3.15.2, no game files, no GPU).

python3 -m compileall -q make_game.py tools tests     # exit 0
python3 -I tests/test_lds_fuzz_cli.py                 # Ran 8 tests, OK (2 new)
python3 -I tests/test_lds_fuzz.py                     # OK
python3 -I tests/test_lds_fuzz_hw.py                  # OK (skipped=1, hardware)
python3 -I tests/test_fuzz_find_harness.py            # OK
python3 -I tests/test_text_write_line_endings.py      # OK

The lds side is verified by the new unittest: translate() adds --pc-tail-ubo only with pc_tail,
and run_gpu() adds LEONIDA_PC_TAIL_UBO=1 to the subprocess env only then; --pc-tail-ubo and
LEONIDA_PC_TAIL_UBO=1/yes both reach a.pc_tail_ubo, 0/unset leave it off, defaults unchanged.

tests/test_valu_fuzz.py needs pytest, which is not installed here (environment limit). I replicated
its two new tests with stdlib unittest.mock and the same assertions: both pass on the PR, and with
tools/valu_fuzz.py reverted to main they fail with
TypeError: translate() got an unexpected keyword argument 'pc_tail'. Reverting tools/lds_fuzz.py
to main makes test_lds_fuzz_cli.py give 2 failures + 2 errors (--pc-tail-ubo unrecognised and the
same TypeError), so the tests are load-bearing.

Caveat (declared dependency, not a defect): main's tools/rdna2spirv.py --help has no
--pc-tail-ubo and #2048 is also unmerged, so the real end-to-end run could not be exercised here.

Verdict: passes on the CPU tests; flag/env plumbing is correct and the default path is unchanged.

AI-assisted review.

@ricarmandoagent

Copy link
Copy Markdown

Additional checks on aca640bb4109ccf66591aad39f2ee5ea7c07ce5f (base origin/main 49475796c226c8511b9470bf97a4daf57b8af323; Linux/Bazzite, Python 3.15.2; no game files, no GPU).

The earlier comment could not run tests/test_valu_fuzz.py (pytest not installed). With an ephemeral pytest 9.2.0 (uv run --no-project --with pytest==9.2.0 python -m pytest, Python 3.14.9):

tests/test_valu_fuzz.py -k pc_tail -v   # 2 passed, 72 deselected
tests/test_valu_fuzz.py -q              # 69 passed, 5 skipped in 7.66s

The same test file against origin/main's tools/valu_fuzz.py:

# 2 failed: TypeError: translate() got an unexpected keyword argument 'pc_tail';
#           SystemExit: valu_fuzz.py: error: unrecognized arguments: --pc-tail-ubo

python3 -I tests/test_lds_fuzz_cli.py -> Ran 8 tests, OK; compileall and make_game.py --help exit 0.

I also exercised the flag through the real CLI rather than only the mocked unit path:

python3 -I tools/valu_fuzz.py --family mem --programs 1 --wave 32 --pc-tail-ubo --work /tmp/rev10-2608-work
# rdna2spirv.py exited 2: "rdna2spirv.py: error: unrecognized arguments: --pc-tail-ubo"  -> rc 2

Both declared dependencies are still OPEN (#2046, #2048; checked with gh-agent pr view). Their diffs use the same --pc-tail-ubo flag name and the same truthy set (1/true/yes/on, stripped and lowercased) that pc_tail_env() implements, so the plumbing matches the follow-ups.

Verdict: forwarding and the default path are correct; the option stays unusable until #2046/#2048 merge (declared, not a defect).

AI-assisted review.

@NRXM

NRXM commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested aca640b together with #2046 (8d89bfa) and #2048 (0ec464b), merged in that order onto main 4947579 without conflicts, on Windows 11, MSVC 19.44, Ninja Release, Vulkan SDK 1.4.363, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation + LEONIDA_VK_VALIDATION=1, on two GPUs in one machine: RTX 4090 (NVIDIA 621.24) and AMD Radeon(TM) Graphics (Ryzen 7000 iGPU, gfx1036, AMD 26.11.2 / Vulkan 2.0.353); Python 3.12.10, pytest 9.2.0, llvm-mc 21.1.8 (built with scripts/build_llvm_mc.ps1): pass.

  • pytest tests/test_valu_fuzz.py tests/test_pc_tail_ubo.py: 77 passed, 5 skipped (hardware-oracle tests, no AMD clang here). test_lds_fuzz, test_lds_fuzz_cli, test_fuzz_find_harness: 42 passed, 25 subtests passed.
  • Translator oracle (llvm-mc → rdna2spirv.py → vk_compute_test), 0 validation messages in every run:
    • AMD iGPU, valu_fuzz.py --family mem --programs 10 --wave both and lds_fuzz.py --programs 10 --wave both: 20/20 programs that ran match (native); 0 mismatched, 0 skipped, 0 not translated, 0 harness errors for each tool, with --pc-tail-ubo, with LEONIDA_PC_TAIL_UBO=1 and no flag, and with neither.
    • RTX 4090, --programs 4 --wave 32: 4/4 match, 0 mismatched, for both tools in the same three variants.
  • The switch takes effect: with the flag or the env var every translated module records push_constant_bytes: 128 and a pc_tail block, without either 144.

Note: on this AMD driver the iGPU reports maxPushConstantsSize 256, so this confirms the tail path works on AMD and NVIDIA but not the 128-byte limit itself.

AI-assisted (Claude Code). Synthetic inputs only, no game files.


Generated by Claude Code

@crastinator

Copy link
Copy Markdown
Contributor

Tested aca640b as part of the stack below on AMD Radeon RX 6700 XT (Navi 22, gfx1031, subgroup 32..64), RADV Mesa 26.3.1, CachyOS, Linux 7.3.5, GCC 16.2.1, llvm-mc 23.1.5: pass.

No game files. 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.

6 participants