Skip to content

mesh_compute_vs: read output address from %pc_tail when pc_tail_address_dwords is set - #2528

Open
whoalin1 wants to merge 1 commit into
ItsNotRexed:mainfrom
whoalin1:mesh-compute-vs-pc-tail
Open

whoalin1 wants to merge 1 commit into
ItsNotRexed:mainfrom
whoalin1:mesh-compute-vs-pc-tail

Conversation

@whoalin1

Copy link
Copy Markdown
Contributor

Claimed in #2300 (comment).
Depends on: #2046 (which adds --pc-tail-ubo and writes pc_tail_address_dwords: [4, 5] into mesh_compute metadata).

Summary

  • tools/mesh_compute_vs.py:
    • When a mesh_compute layout contains pc_tail_address_dwords (two non-negative ints, e.g. [4, 5] from rdna2spirv.py --mesh-compute --pc-tail-ubo), emit the vertex shader's 64-bit output-buffer address loads from the set-1 binding-0 Uniform block %pc_tail (%PcTail, 24 bytes / 6 dwords) instead of a 152-byte %pc PushConstant block, and include %pc_tail in OpEntryPoint's interface.
    • Because this vertex shader does not read user SGPRs s0..s31, omitting the PushConstant block leaves it at 0 push-constant bytes, so it links cleanly on 128-byte push-constant devices alongside a 128-byte --pc-tail-ubo pixel shader.
    • Reject malformed pc_tail_address_dwords values (wrong length, negative, bool, non-int) with ValueError.
    • Without pc_tail_address_dwords, vs_spvasm() output is byte-identical to main.
  • Tests:
    • tests/test_mesh_compute_vs.py: add interface check for %pc_tail / set-1 binding-0 / no PushConstant, malformed-value validation tests, and spirv-as + spirv-val --target-env vulkan1.2 assembly tests (plain, clip, clip+cull+params, f16_halves).
    • tests/test_mesh_compute.py: add test_vertex_shader_text_pc_tail and parametrize test_vertex_shader_validates across both push-constant and --pc-tail-ubo layouts.

Testing

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

  1. Unit & SPIR-V validation tests (pytest):
    • tests/test_mesh_compute_vs.py, tests/test_mesh_compute.py, tests/test_text_write_line_endings.py: 43 passed, 10 subtests passed (0 failed).
    • Verified vs_spvasm() output without pc_tail_address_dwords is byte-identical to origin/main across plain, clip, clip+cull+params, and f16_halves layouts.
    • py -3.14 -m compileall -q tools/mesh_compute_vs.py tests/test_mesh_compute_vs.py tests/test_mesh_compute.py: clean.
  2. Real-GPU pipeline check (vk_pipeline_check from vk_pipeline_check: support --pc-tail-ubo set-1 layouts and 128-byte push-constant devices #2480 with VK_LAYER_KHRONOS_validation, paired with spirv_stubs.py PS stubs using #2046's mesh_compute_layout(..., PC_TAIL_UBO=True)):
    • AMD Radeon(TM) Graphics (Ryzen 5 7600 RDNA2 iGPU, AMD Windows driver 24.10.24, Vulkan 1.3.280, 128-byte push constants): 2/2 VS pipelines ok, 0 failed, 0 skipped, 0 validation errors (ms_tri.mesh_vs, ms_clip.mesh_vs).
    • NVIDIA GeForce RTX 4070 SUPER (driver 610.88, 256-byte push constants): 2/2 VS pipelines ok, 0 failed, 0 skipped, 0 validation errors.

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)

@duudiis

duudiis commented Nov 22, 2026

Copy link
Copy Markdown

Independent RTX 5070 / Windows run at 784580d (driver 621.24, 32-wide subgroups). I dispatched and drew the synthetic ms_tri fixture using wave64 emulation and the generated companion VS.

  • Baseline used a 152-byte push-constant range. The tail build used a 128-byte range and a 24-byte uniform block at set 1, binding 0, with the address words at offsets 16 and 20.
  • Both generated companion shaders passed spirv-val --target-env vulkan1.2. Both GPU draws produced byte-identical 64×64 RGBA32F readbacks. All 4,096 pixels matched the analytic ramp exactly.
  • For the tail run, I added the descriptor binding to a temporary copy of the test harness. The RTX 5070 exposes 256 push-constant bytes, so this covers the shader pair and the 128-byte layout on NVIDIA. The hardware-limit result on a 128-byte device is covered by the author’s pipeline test above.

@Dom-in

Dom-in commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested head 784580d merged onto main 4947579 (clean merge), Windows 11, Python 3.13, CPU only. python -m pytest tests/test_mesh_compute.py tests/test_mesh_compute_vs.py: 41 passed, 10 subtests passed in 2.77s. Negative control: the same test file against main's non-test sources gives 10 failed, 39 passed, 2 subtests passed in 2.19s, so the test exercises the change.

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

…ss_dwords is set

When index.json's mesh_compute layout carries pc_tail_address_dwords (as
produced by rdna2spirv.py --mesh-compute --pc-tail-ubo), emit the vertex
shader's output-buffer address loads from the set-1 binding-0 Uniform block
%pc_tail (%PcTail) instead of a 152-byte PushConstant block, omitting
PushConstant completely so the vertex shader fits 128-byte push-constant
devices. Without pc_tail_address_dwords, the emitted SPIR-V assembly is
byte-identical to before.

Co-Authored-By: Gemini 4 Neon <noreply@google.com>
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.

3 participants