Skip to content

vk_pipeline_check: support --pc-tail-ubo set-1 layouts and 128-byte push-constant devices - #2480

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
whoalin1:vk-pipeline-check-pc-tail
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
whoalin1:vk-pipeline-check-pc-tail

Conversation

@whoalin1

Copy link
Copy Markdown
Contributor

Claimed in #2300: #2300 (comment).

Follow-up to #2046 (--pc-tail-ubo; no merge dependency — vk_pipeline_check works on main as-is and handles pc_tail / push_constant_bytes entries from #2046 once present).

What and why

vk_pipeline_check (the pipelines stage of make_game.py) previously created a single VkPipelineLayout with a hardcoded 144-byte push-constant range and only set 0, without checking vkCreatePipelineLayout's return value. On a 128-byte push-constant device (AMD Windows driver on RDNA2 iGPUs, some Intel Arc drivers) or on shaders translated with --pc-tail-ubo (#2046):

  • Declaring a 144-byte range violates VUID-VkPushConstantRange-size-00298 when maxPushConstantsSize == 128.
  • Every shader declaring set 1 (%pc_tail) fails pipeline creation with VUID-VkComputePipelineCreateInfo-layout-07988 / VK_ERROR_UNKNOWN (-13) because set 1 is absent from the pipeline layout (reproduced on AMD Radeon Ryzen 5 7600 iGPU: PIPELINE FAIL cs_tail (cs w0, -13)).

Changes (runtime/test/vk_pipeline_check.cpp, runtime/test/check_vk_pipeline_cli.cmake):

  • Parse push_constant_bytes and pc_tail.bytes from index.json using strict std::from_chars unsigned 32-bit parsing (matching lds_bytes, rejecting negative/float/overflow values; checked in check_vk_pipeline_cli.cmake).
  • Add required_push_bytes() (with static_assert checks): uses push_constant_bytes when recorded (128 with --pc-tail-ubo, 144 by default, 152 with --mesh-compute), or 128 when pc_tail is present, else 144, rounded up to a 4-byte multiple without overflow.
  • Skip shaders in check_missing_feature() whose required_push_bytes exceeds props.limits.maxPushConstantsSize (reporting e.g. needs 144 push-constant bytes, device has 128 (translate with --pc-tail-ubo)).
  • Create set 1 (VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC at binding 0, VK_SHADER_STAGE_ALL) alongside set 0, and pre-create one VkPipelineLayout per distinct (push_bytes, has_pc_tail) needed by the selected shaders that fits maxPushConstantsSize (checking vkCreatePipelineLayout for errors). Never creates a push-constant range above maxPushConstantsSize.
  • Use the matching layout for both compute (cpi.layout) and graphics (gpci.layout) pipelines.

Tested

AI-assisted (Gemini 4 Neon / Antigravity). Windows 11 (build 26200), MSVC 14.44, Windows SDK 10.0.26100, Vulkan SDK 1.4.363 (VK_LAYER_KHRONOS_validation, SPIRV-Tools v2026.4), Python 3.14.4, llvm-mc 21.1.8 (WSL). No game files.

  • Before the fix (AMD Radeon Ryzen 5 7600 iGPU, AMD driver 24.10.24, maxPushConstantsSize 128, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation): failed with VUID-VkPushConstantRange-size-00298, VUID-VkComputePipelineCreateInfo-layout-07988, and PIPELINE FAIL cs_tail (cs w0, -13) (exit 1).
  • CLI & parser checks:
    • ctest -R vk_pipeline_check_cli: 1/1 passed (including malformed push_constant_bytes and pc_tail.bytes cases).
    • py -3.14 -I tests/test_shader_meta.py: 15/15 OK.
  • Synthetic mixed index (144-byte CS + 128-byte pc_tail CS + 128-byte tail-less VS + 128-byte pc_tail PS, with VK_LAYER_KHRONOS_validation):
    • AMD Radeon Graphics (Ryzen 5 7600 iGPU, driver 24.10.24, Vulkan 1.3.280, 128 bytes): 3/4 pipelines compiled OK (cs_tail, vs_tail, ps_tail), 1/4 skipped (cs_full: needs 144 push-constant bytes, device has 128 (translate with --pc-tail-ubo)), 0 failed, 0 validation errors, exit 0.
    • NVIDIA RTX 4070 SUPER (Ada, driver 610.88, 256 bytes): 4/4 pipelines compiled OK, 0 failed, 0 skipped, 0 validation errors, exit 0.
  • All 204 translated repo test shaders (runtime/test/shaders/build.py + tools/spirv_stubs.py, with VK_LAYER_KHRONOS_validation):

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (No translator change here.)

🤖 Generated with Antigravity (Gemini 4 Neon)

…ush-constant devices

vk_pipeline_check previously created one VkPipelineLayout with a hardcoded 144-byte push-constant range and set 0 only (without checking vkCreatePipelineLayout's result). On a 128-byte push-constant device (AMD Windows RDNA2 iGPUs, some Intel Arc drivers) that violates VUID-VkPushConstantRange-size-00298, and every --pc-tail-ubo shader declaring set 1 fails pipeline creation with VK_ERROR_UNKNOWN / VUID-VkComputePipelineCreateInfo-layout-07988.

Parse push_constant_bytes and pc_tail.bytes from index.json (with strict from_chars validation, tested in check_vk_pipeline_cli.cmake), skip shaders whose required push-constant size exceeds props.limits.maxPushConstantsSize, add set 1 (UNIFORM_BUFFER_DYNAMIC at binding 0), and create one pipeline layout per distinct (push_bytes, has_pc_tail) needed by the selected shaders within the device limit.

Claimed in ItsNotRexed#2300.

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

duudiis commented Nov 22, 2026

Copy link
Copy Markdown

Independent Windows check of 3917298 with MSVC 19.44, SDK 10.0.26100.0, RTX 5070 driver 621.24, physical push-constant limit 256 bytes. The stock vk_pipeline_check_cli CTest passed.

I ran the checker with three workers on a synthetic index with 128-byte tail and tail-less graphics entries, a 128-byte compute entry that inferred its width from pc_tail.bytes=16, a legacy 144-byte compute entry, and hand-written compute modules accessing the last dword of 152-, 256-, and 260-byte ranges. All seven modules and the two generated partner stubs passed Vulkan 1.3 SPIR-V validation.

  • Mixed check: six pipelines passed, no failures, one expected skip.
  • Compute-only: four passed and only the 260-byte entry was skipped. The module using bytes 252–255 compiled. The skip explicitly reported “needs 260 push-constant bytes, device has 256.”
  • Graphics-only: both the tail-using fragment and tail-less vertex pipeline checks passed with their generated partners.

This checks driver pipeline creation. Synthetic inputs only. AI-assisted review.

@whattheflop

Copy link
Copy Markdown
Contributor

Independent AI-assisted review of 3917298d1ba19404ad2bde91c2b8d6b789093941 against 49475796c226c8511b9470bf97a4daf57b8af323.

Integration with #2366. git merge-tree --write-tree against its open head 5717868230494a689a0dedd25e5a71762334b427 reports a content conflict in runtime/test/vk_pipeline_check.cpp at layout setup and the stub-backed graphics call. The real-chain path also needs an explicit layout passed into the shared create_graphics helper. #2366 currently captures the single 144-byte, set-0-only layout there. Its manifest flattens the selected chains into individual shaders for setup, so prebuilding only #2480's per-shader keys can miss the key the chain needs. For example, a 128-byte tail-less VS and a 96-byte tail-using PS require (128, true) together, even when neither shader supplies that key. When reconciling, prebuild the key for each selected chain from the maximum rounded push size and whether any stage uses set 1. Keep the device-limit skip with the offending stage named, and pass the selected layout into the shared helper from both graphics paths. Compute and stub-backed graphics can keep their per-shader selection. This is a source finding from the two pinned heads. Manifest work selection · Shared helper layout · Manifest call

Native AMD check of #2480. AMD Radeon iGPU, AMD proprietary driver 25.10.30.02, physical maxPushConstantsSize=256 bytes. This adds coverage on that driver for mixed layout keys and cache reload. The PR description documents the 128-byte physical-device case separately. Built x64 with MSVC 19.38 and Windows SDK 10.0.26100, and ran with uv CPython 3.12.13, a single AMD ICD, an empty implicit-layer path, and Vulkan SDK 1.4.363 Khronos core and synchronization validation.

  • One synthetic index compiled a 96-byte explicit tail CS, a 128-byte inferred tail CS, a 144-byte legacy CS, a 112-byte tail-less VS, and a 160-byte explicit tail PS. The indexed stages accessed the last push dword, and all three tail stages read set 1, binding 0. All five modules and both partner stubs passed Vulkan 1.3 spirv-val.
  • Both runs finished with 5/5 pipelines created, zero failures, skips, validation errors or validation warnings, and exit 0. Application-cache feedback went from 0/5 to 5/5 hits on reload. Synthetic pipeline creation only.

@Marukooh

Copy link
Copy Markdown
Contributor

Tested 3917298 on NVIDIA GeForce RTX 5070 Ti (Blackwell), NVIDIA 620.73.04, CachyOS Linux, GCC 16.2.1. The device reports 256 push-constant bytes and subgroup size 32..32.

  • ctest -R '^vk_pipeline_check_cli$' passed, including the new malformed byte-count cases.
  • A mixed synthetic index with a 144-byte compute shader and a 128-byte compute shader using set 1 binding 0 passed spirv-val --target-env vulkan1.2 for both modules. vk_pipeline_check --compute-only --jobs 1 reported 2 pipelines OK, 0 failed, and 0 skipped.

This checks the mixed-layout path on Blackwell. The device has a 256-byte limit, so this run does not exercise the 128-byte device skip. AI-assisted.

@Ingenioeren

Copy link
Copy Markdown

Independent pipeline checker run on 3917298d, Windows 11, clang-cl/lld 23.1.5 and Vulkan validation 1.4.341.1. SwiftShader reports 128 push-constant bytes. The CLI CTest passed. The mixed fixture was one legacy 144-byte CS, a set-1-only CS and PS, and a tail-less 128-byte VS. All four SPIR-V modules and both graphics stubs passed spirv-val.

On 49475796 I reproduced the push-constant and missing-set-1 validation errors. This PR compiled three pipelines and correctly skipped the 144-byte CS. It still produced validation errors from the full set-0 layout exceeding SwiftShader’s descriptor limits, even with bindings: [] for every shader. The checker also requested unused update-after-bind flags that conflict with robustBufferAccess on that adapter (VUID-VkDeviceCreateInfo-robustBufferAccess-10247).

The attached patch uses explicit empty bindings metadata to omit the full set-0 layout, supplies an empty set 0 for set-1-only shaders, and clears the four unused update-after-bind features implicated by the VUID. With it, SwiftShader compiled all three eligible pipelines and skipped the legacy CS, with zero validation errors in the combined, compute-only, and graphics-only runs. On RX 6750 XT, three compute pipelines with empty, populated, or absent bindings metadata passed before and after the patch with zero validation errors. The CLI CTest still passed. Synthetic inputs only. AI-assisted.

vk-pipeline-empty-set.patch.txt

@Ingenioeren

Copy link
Copy Markdown

Follow-up on the SwiftShader run above. With the empty-set patch applied, the translated cs_buf_tail and cs_workgroup_yz modules were correctly counted as skips for missing shaderInt64, but Vulkan validation still emitted VUID-VkShaderModuleCreateInfo-pCode-08740 for both modules before that check. The attached incremental patch moves the existing per-shader check ahead of vkCreateShaderModule. Apply it after the empty-set patch.

On SwiftShader both modules now skip cleanly, with zero validation errors. The RX 6750 XT still compiles both modules with zero validation errors. I also reran the mixed, compute-only, and graphics-only SwiftShader cases, the three Radeon set-0 metadata cases, and the CLI CTest. All passed with the expected skips and zero Vulkan validation errors. AI-assisted testing on synthetic fixtures.
vk-pipeline-early-feature-check.patch.txt

@NRXM

NRXM commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 3917298 (fast-forward onto main 4947579) on Windows 11, MSVC 19.44, Ninja Release, Vulkan SDK 1.4.363, Python 3.12.10, with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, on two GPUs in one machine: pass.

  • RTX 4090, NVIDIA 621.24, and AMD Radeon(TM) Graphics (Ryzen 7000 iGPU, gfx1036), AMD driver 26.11.2 / Vulkan 2.0.353. Note: on this newer AMD driver the iGPU reports maxPushConstantsSize 256, not 128, so the limit-based skip path was not exercised here.
  • ctest -C Release: 116/116 on both GPUs, 0 validation messages (vk_pipeline_check_cli 1/1 including the malformed push_constant_bytes / pc_tail.bytes cases).
  • Mixed index: the 36 hand-written cs_* fixtures in tests/semantic/fixtures/disasm, translated with Translator: --pc-tail-ubo moves the push-constant tail to a uniform block (128-byte push-constant devices, 1/3) #2046's rdna2spirv.py (8d89bfa) without and with --pc-tail-ubo (36/36 each, spirv-val clean), combined into one index of 18 plain shaders (144 bytes) and 18 pc_tail shaders (128 bytes, set 1 binding 0, 16 bytes):
    • this PR: cs pipelines: 36 ok, 0 failed, 0 skipped on both GPUs, 0 validation messages.
    • main 4947579 for comparison: on the AMD iGPU cs pipelines: 18 ok, 18 failed (-13, VK_ERROR_UNKNOWN), and 20× VUID-VkComputePipelineCreateInfo-layout-07988 on both GPUs (NVIDIA still builds them).

So the set-1 layout fixes the pc_tail pipelines on both vendors.

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


Generated by Claude Code

@crastinator

Copy link
Copy Markdown
Contributor

Tested 3917298 merged into main ec8ec4c9 (clean merge) 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.

  • Whole run_gpu_tests.py: 175/189 native, 175/189 with LEONIDA_W64_EMULATE=1 (the skips are the D3D12-only fixtures and ps_w64x_readlane, as on main). ctest 37/37. vk_pipeline_check_cli passes.

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

@lunisahdidouch

Copy link
Copy Markdown

Tested 3917298 on Windows 11 with an RX 9070 (AMD 26.11.1, Vulkan 1.4.359), built with VS 2022 Build Tools: pass

Builds clean. ctest -R pipeline gives 4/4 passed, including vk_pipeline_check_cli with the new set-1 / 128-byte push-constant cases (also pipeline_cache_file, d3d12_pipeline_library, pipeline_cache_snapshot).

AI-assisted

@ItsNotRexed
ItsNotRexed merged commit 4fa6c61 into ItsNotRexed:main Nov 22, 2026
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.

9 participants