Skip to content

vk_harness: run mesh-compute with the 128-byte push-constant fallback - #7255

Draft
fever308 wants to merge 2 commits into
ItsNotRexed:mainfrom
fever308:codex/mesh-compute-pc-tail
Draft

fever308 wants to merge 2 commits into
ItsNotRexed:mainfrom
fever308:codex/mesh-compute-pc-tail

Conversation

@fever308

@fever308 fever308 commented Nov 23, 2026 •

Copy link
Copy Markdown

Claimed in the coordination issue: #7049 (comment)
Depends on: #2528

What and why

The Vulkan harness unconditionally skipped VKH_MESH_COMPUTE with LEONIDA_PC_TAIL_UBO=1. This checks that both shader stages match the selected layout, writes the mesh output address into the six-dword tail, and binds the shared tail slot separately for compute dispatch and graphics draw. The legacy push-constant path is preserved. When VKH_TEX_RGBA supplies a graphics texture descriptor layout, the pipeline keeps it at set 0 and binds the tail UBO at set 1. It uses an empty set-0 layout only when no texture layout is present. A shader layout mismatch reports the actual and expected modes and exits 2 instead of skipping.
#2528 supplies the generated vertex shader that reads the address from the tail. This draft changes only the harness and its testing documentation.

Tested

  • Windows build 26300, MSVC 19.44, Release Ninja. Rebased on cc67780; reran the synthetic ms_tri fixture with LLVM 23.1.6, SPIRV-Tools 2026.4, and the mesh_compute_vs: read output address from %pc_tail when pc_tail_address_dwords is set #2528 vertex helper at 312794a1.
  • AMD Radeon iGPU, driver 25.10.42: 4,096/4,096 expected pixels in each mode. The compute and generated vertex modules passed spirv-val.
  • RTX 5090, driver 617.42: both deliberate layout mismatches exited 2 with a configuration diagnostic and no readback. The matched fixture produced a blank frame in both modes; the clean-base legacy control also produced a blank frame. No NVIDIA rendering pass is claimed.
  • Full translator suite: 443 files, 5,889 tests, two failing files (test_image_atomics_guard and test_image_store_d16). Both failures reproduced on clean cc67780; no translator code is changed.
  • Docs environment-variable checks: 4 passed. The docs-links suite has one pre-existing missing anchor in docs/dev-tools.md, also reproduced on clean cc67780. git diff --check and the changed-file game-data check passed.

AI-assisted: yes (Codex).

Checklist

  • No game data, keys, or decryption; synthetic fixture only.
  • Translator contract: not applicable (test harness and docs only).

@tikD1337

Copy link
Copy Markdown
Contributor

Review: #7255 — vk_harness: run mesh-compute with the 128-byte push-constant fallback

Environment: Windows 11, CPython 3.13. Reviewed at PR head 338b2f5c5.

What changed

runtime/test/vk_harness.cpp

  1. The hard skip is gone. Before this PR, LEONIDA_PC_TAIL_UBO=1 together with VKH_MESH_COMPUTE returned 77 straight away. Now the harness reads both mesh-compute stages: the generated VS (VKH_MESH_COMPUTE) and the compute module (argv[1]). It checks each one with spirv_declares_set(..., pc_tail_set) and returns 77 only if a module's tail mode differs from LEONIDA_PC_TAIL_UBO. A file it can't read now returns 2.
  2. The tail is written before the dispatch, with six dwords for mesh-compute. tail.write(0, pc, 6) copies pc[32..37]: the heap base, the code base, then the output address. That puts the output address at tail dwords 4..5, which matches the updated comment ("push-constant dwords 36..37 or tail 4..5"). pc[36..37] is filled at vk_harness.cpp:1036, before the write at ~1097, so the ordering is correct. PcTail::slot_bytes is already 6 dwords (vk_pc_tail.h, "the 24-byte --mesh-compute tail"), and the descriptor range covers it.
  3. The tail set is bound at both bind points. The new bind_tail lambda binds it for COMPUTE before vkCmdDispatch and for GRAPHICS before the draw. Both binds use one slot and one dynamic offset. Compute can read the binding: tail.create(..., pcs, 1) takes pcs, and pcs gets VK_SHADER_STAGE_COMPUTE_BIT when mesh_compute is set (vk_harness.cpp:714). cpipe uses the same pl (cpi.layout = pl), so the compute bind is layout-compatible.
  4. Separate fix for set 0. tail_layouts[0] is now dsl ? dsl : tail.empty_layout. Before this, VKH_TEX_RGBA + --pc-tail-ubo replaced the texture set layout with the empty layout at set 0. The later vkCmdBindDescriptorSets(..., 0, 1, &ds, ...) then bound a set the pipeline layout didn't declare, which is invalid usage. The new code matches the contract in vk_pc_tail.h ("a program with no set 0 of its own puts empty_layout at index 0"). It's a good fix, but neither the title nor the description mentions it. Please add a sentence about it to the PR body.

docs/testing.md: both copies of the duplicated paragraph get the same edit. The file already had that paragraph twice before this PR; this PR doesn't add the duplication.

Issues

  1. This PR depends on mesh_compute_vs: read output address from %pc_tail when pc_tail_address_dwords is set #2528, which is still open, and the PR doesn't declare it. On main, tools/mesh_compute_vs.py has no tail mode. Its docstring still says the address is "in push-constant dwords 36..37", and run_gpu_tests.py:851 calls mesh_compute_vs.build_for_index(spirv_dir) without passing any pc-tail flag. So with LEONIDA_PC_TAIL_UBO=1, the generated VS never declares set 1, the new check sees shader_tail != pc_tail, and every mesh-compute test still returns 77.

  2. A tail-mode mismatch now returns 77, so a configuration mistake shows up as SKIP. In the old code, 77 meant "device limit" (D3D-14). The new check also returns 77 when the user's own setup is wrong. For example, the shaders were built with --pc-tail-ubo but check.py runs without the variable — the exact mistake docs/testing.md warns about ("set it for both build.py and check.py"). The check also fires in the non-tail direction: a stale --pc-tail-ubo module with the variable unset now skips instead of failing. In both directions the suite reports SKIP and goes green. I suggest returning 2 (usage error) or 1 for a mismatch. Keep 77 for the one case that really is missing support: pc_tail is set and only the VS lacks set 1 because mesh_compute_vs: read output address from %pc_tail when pc_tail_address_dwords is set #2528 isn't in yet, and that could get its own message. As written, the message mesh-compute shader mode does not match LEONIDA_PC_TAIL_UBO doesn't tell the user which direction is wrong. Printing pc_tail and shader_tail would fix that.

  3. Nit: both mesh-compute modules are read from disk twice. The check at line ~376 reads both files, then module() at line ~644 reads them again and redoes the spirv_declares_set scan. It's harmless for a test program. Keeping the vectors from the check, or doing the check inside module(), would remove the duplication.

  4. Nit: the compute pass binds set 1 but not set 0. With VKH_TEX_RGBA + mesh-compute + tail, the compute pass leaves set 0 unbound. That's fine while no --mesh-compute module reads set 0, which is how the code already behaved before this PR. This change doesn't make it worse.

Test results (no game files)

Check Result
git diff --check PASS
python -m compileall -q make_game.py tools tests PASS
python -I scripts/check_no_game_data.py on changed files PASS
python -I make_game.py --help PASS
Targeted tests None run. No test file covers vk_harness.cpp or docs/testing.md.

I didn't build the runtime and didn't run vk_harness/ctest on a GPU here. The new path can only do anything once #2528 is merged, so no GPU run of LEONIDA_PC_TAIL_UBO=1 LEONIDA_MESH_COMPUTE=1 has checked it yet. Before merge, please post a run of that combination on a device with maxPushConstantsSize = 128 (or with #2528 applied on any GPU), with the GPU and driver, and the translated / pass counts before and after.

Adherence

  • No game data: the diff contains only C++ harness code and prose. It adds no shaders, SPIR-V, disassembly or logs.
  • No keys, decryption or protection workarounds: none.
  • Nothing online: none.
  • Fix, don't disable: this PR removes an unconditional skip and replaces it with a capability check. That follows the rule, but see issue 2: the new check shouldn't turn a configuration mistake into a skip. It adds no translator rule, so docs/design.md and tests/semantic/ don't need updates.

Verdict: The harness side is correct. The tail slot layout, the compute stage flags, the shared pipeline layout and the bind order all check out, and the set-0 fix is a real improvement. Before merge, it needs Depends on: #2528, a reconsidered exit code for mode mismatches, and a GPU run of the combined mode.

AI-assisted.

@fever308

Copy link
Copy Markdown
Author

@tikD1337 Thanks for checking the layout and bind order. Follow-up 8865788 now exits 2 for a shader layout mismatch, prints the actual and expected modes, and reuses the shader words instead of reading the files twice. The PR description now calls out that VKH_TEX_RGBA keeps its texture layout at set 0 while the tail UBO uses set 1.

Rechecked synthetic ms_tri on Windows with the #2528 generated vertex shader helper: AMD Radeon iGPU (25.10.42) rendered 4,096/4,096 exact pixels in both legacy and tail-UBO modes. The compute shader translated and passed spirv-val in each mode (1/1). Both deliberate mismatch directions on RTX 5090 (617.42) exited 2 without readback; no matched NVIDIA render pass is claimed. Depends on: #2528 remains in the description. AI-assisted (Codex).

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.

2 participants