Skip to content

Size Vulkan pipeline checker descriptor layouts for the selected GPU (BUILD-1402) - #4811

Open
PingasMech wants to merge 3 commits into
ItsNotRexed:mainfrom
PingasMech:codex/build-1402-checker-layout
Open

PingasMech wants to merge 3 commits into
ItsNotRexed:mainfrom
PingasMech:codex/build-1402-checker-layout

Conversation

@PingasMech

Copy link
Copy Markdown

Claimed in the coordination issue as BUILD-1402. Claim · Original Intel measurements

What and why

The checker gave every device the same ordinary set-0 layout. On Intel UHD 770, that layout requested 4,352 storage-image descriptors per stage against a limit of 16. Khronos validation also reported 5,632 sampled images against a limit of 200. Valid compute and graphics pipelines then failed to build.

The checker now uses the runtime’s bindless::SetLayout and size_bindings with the enabled device features. It keeps the shared layout when reduced counts fit. On devices where even the smallest ordinary shared layout exceeds the limits, it compiles with one descriptor per binding declared by the shader. Indexes without binding metadata use the existing 0–19 binding set. The checker keeps descriptor set layouts alive until pipeline creation has finished.

Tested

Windows 11, MSVC 19.44, Intel UHD Graphics 770, driver 32.0.101.7088, Khronos validation 1.4.363. All inputs were repository-owned synthetic shaders.

Same 220-module index Pipelines built Failed Skipped
Main 98fa503f 95 107 18
This change 202 0 18

All descriptor-limit validation errors cleared. Validation still reports existing shader-capability and instruction diagnostics on the full index. In the compute-only run, the only such diagnostic was the lack of FP64 on the one skipped fixture.

AI-assisted (Codex).

  • No game data, keys or decryption. The change covers pipeline checking and adds no shader translation rule.

@Kev-Ball

Copy link
Copy Markdown

Retested the ordinary-layout case from the tracker report at cb8132be. The 1,537-descriptor validation error is resolved, and I checked the exact transition between layouts using cs_imgstore:

Sampled images allowed per stage Checker layout Compute pipeline Validation errors
128 per-shader built 0
1,536 per-shader built 0
1,537 shared built 0
4,096 shared built 0

At 128 and 4,096 the ps_texture_mip0 index also built both PS pipelines and its VS with zero validation errors. At 128 the earlier 047ad7cb implementation reported pipeline success but raised VUID-VkPipelineLayoutCreateInfo-descriptorType-06939 on the same input. The validation layer distinguishes the two implementations here.

RTX 3080 Ti, NVIDIA 620.73.04, CachyOS. Khronos Profiles disabled sampled-image update-after-bind and varied the ordinary sampled-image limit, keeping the per-stage sampler and storage-image limits at 32 and 128. Synthetic fixtures, pipeline creation only. AI-assisted.

@CryingLaughing

Copy link
Copy Markdown
Contributor

Windows RTX 4080 coverage for cb8132be against 98fa503f. I built vk_pipeline_check with MSVC 19.44 and ran both revisions against the same eight synthetic shaders with Khronos validation enabled and the NVIDIA driver’s native Vulkan limits.

Shader translation Base 98fa503f PR cb8132be
Default 8/8 built 8/8 built
LEONIDA_PC_TAIL_UBO=1 8/8 built 8/8 built

Each run built four compute, three pixel and one vertex pipeline. The UBO index contained 16-byte tail blocks in one compute and three pixel shaders. Both indexes passed spirv-val, and all four Vulkan runs had zero failures, skips or validation diagnostics. The PR kept the shared set-0 layout in both runs. This covers pipeline creation only.

AI-assisted (Codex).

@kotekompotek

Copy link
Copy Markdown

Tested cb8132be against main on Windows 10 Pro x64 (19045) across two GPUs (MinGW-w64 g++ 16.1.0, -DLEONIDA_BUILD_WINDOWS_RUNTIME=OFF -DLEONIDA_VULKAN_HEADERS_FETCH=ON, 42 compute .spv fixtures from tests/semantic/fixtures/disasm/cs_*.s with --wave64-emulate --assembler python):

No game data. AI-assisted (Gemini, Antigravity).

@evilclanker9000

Copy link
Copy Markdown
Contributor

Tested cb8132b on Windows 11 (MSVC BuildTools 2022, Ninja, RelWithDebInfo, -j 4; no Vulkan validation layer installed), one GPU at a time, device line confirmed: AMD Radeon RDNA2 iGPU (driver 26.10.1) and NVIDIA RTX 5080 (driver 616.92). Ran ctest -R "^(bindless_sizing)$" (the tests this PR adds/changes): pass on both GPUs, 1/1 each. No game files.

AI-assisted.

@Flyander Flyander 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.

Request changes: the checker omits multisample bindings that the shader declares, so pipeline creation runs with an incomplete descriptor-set layout and triggers Vulkan validation. This is reproducible with a synthetic SPIR-V module; details are on the inline comment.

Comment thread runtime/src/vulkan_bindless.h Outdated
std::uint32_t count = 0;
for (std::uint32_t b = 0; b < binding_count; ++b) {
if (!binding_enabled(b, features)) continue;
if (!binding_enabled(b, features) || !(binding_mask & (1u << b))) continue;

@Flyander Flyander Nov 23, 2026 •

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.

Source trace: PipelineCheckDescriptors leaves features.ms_samples at SAMPLE_COUNT_1; the parsed mask and fits() retain b20, but binding_enabled(20) is false, so this condition omits it. I reproduced the Vulkan validation result with a synthetic compute SPIR-V module that uses an SSBO at set 0/binding 2 and a multisampled image at set 0/binding 20 via OpImageFetch with the Sample operand: a manually created layout containing only b2 triggers VUID-VkComputePipelineCreateInfo-layout-07988; adding b20 as VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE removes the diagnostic. I could not build or run this PR's vk_pipeline_check executable on this host, so please exercise that exact path in a regression test.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@Flyander, thanks for the precise test case. Fixed in d77112cd. When a shader declares a multisample binding, the checker now builds a per-shader layout that includes that binding even when the runtime defaults to one sample.

I reproduced VUID-VkComputePipelineCreateInfo-layout-07988 on the parent commit with my Intel UHD 770 (Windows 11, driver 32.0.101.7088). The driver counted the pipeline as built, so the new vk_pipeline_check_ms_binding regression also checks the validation output. It fetches a sample from binding 20 and writes the result to binding 2.

On the fix, the regression built one pipeline with zero Khronos validation errors in each run, first with native driver features and then with ordinary descriptors forced. The CPU test covers bindings 20–25. The full 220-shader run built 202 pipelines with zero failures and 18 skips, with the same validation diagnostics as the parent.

Could you take another look at d77112cd and confirm it covers the case you reported? AI-assisted.

BUILD-1402. Compile shaders that declare multisample bindings with a per-shader set. Use one descriptor per declared binding and check storage-image counts against the limits of the active descriptor mode.

Add a validation-layer GPU regression for a compute shader that fetches a sample at binding 20 and writes to binding 2. Cover all six multisample bindings in the CPU sizing test.

AI-assisted. On Intel UHD 770 (32.0.101.7088), the parent reported VUID-VkComputePipelineCreateInfo-layout-07988. The regression now passes with native features and with ordinary descriptors forced. The 220-shader suite built 202 pipelines with zero failures and 18 skips.
@sebashord

Copy link
Copy Markdown

Tested cb8132be11708dbfce2c3fb02b37ac7dc3044734 on Windows 11 Pro build 26300.9974 with two GPUs: Radeon iGPU of a Ryzen 7 9800X3D (gfx1036, 0x1002:0x13c0, AMD proprietary driver 25.10.36 = Windows driver 32.0.21036.18, subgroup 32..64) and RTX 5070 Ti (driver 621.01, subgroup 32..32): pass, every pipeline of the repository's synthetic shader set builds on both GPUs. As far as I can see this is the first vk_pipeline_check.exe run of this head on an AMD GPU under Windows.

MSVC 14.44 build of this head (scripts\build_runtime.ps1). Shaders: python -I runtime\test\shaders\build.py <work> (242 shaders: 242 translated, 242 pass spirv-val). Then, one GPU at a time (LEONIDA_VK_DEVICE=radeon / 5070):

vk_pipeline_check.exe <work>\spirv
Radeon iGPU, 25.10.36 (subgroup 32..64) RTX 5070 Ti, 621.01 (subgroup 32..32)
cs 105 modules ok, 0 failed; pipelines: 105 ok, 0 failed, 0 skipped (wave32: 73 ok, wave64: 32 ok with required size 64) same counts (the 32 wave64 ones without a required subgroup size)
gs 3 modules ok; pipelines: 3 ok, 0 failed, 0 skipped same
ps 117 modules ok; pipelines: 117 ok, 0 failed, 0 skipped same
vs 17 modules ok; pipelines: 17 ok, 0 failed, 0 skipped same
exit code 0 0

I ran it twice on each GPU: plain, and with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (with VK_LOADER_DEBUG=layer the loader prints Insert instance layer "VK_LAYER_KHRONOS_validation" and Inserted device layer "VK_LAYER_KHRONOS_validation"). The counts are identical and neither stdout nor stderr of the validation runs contains a VUID or Validation Error line on either GPU.

The CTest part also passes on both GPUs (ctest -R "^(bindless_sizing|vk_pipeline_check_cli)$", 2/2), but those two tests do not open a Vulkan device, so they say nothing about the GPU.

This run does not cover the case from the review above (a multisample image at binding 20): I disassembled the 242 modules and none of them declares a multisample image type, so VUID-VkComputePipelineCreateInfo-layout-07988 cannot appear with this set.

Not run: the same index on main for comparison (neither of these GPUs has the small descriptor limits the PR is about, so I would expect no difference), LEONIDA_PC_TAIL_UBO=1, the Profiles layer, the full GPU suite on this head.

Tools: llvm-mc 23.1.6 (conda-forge), Vulkan SDK 1.4.363.0, Python 3.11.9, VK_LOADER_LAYERS_DISABLE=~implicit~.

AI-assisted. Synthetic test programs and counts only, no game files.

Created with Perplexity

@Flyander Flyander 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.

Request changes: the new multisample regression test is skipped by the repository default runtime CI invocation; details are on the inline comment.

@@ -0,0 +1,25 @@
# The driver may build the pipeline even when binding 20 is missing. Check the validation output too.
if(NOT "$ENV{LEONIDA_VK_VALIDATION}" STREQUAL "1")

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.

Repro using the checked-in workflow: .github/workflows/runtime.yml runs ctest --test-dir runtime/build --output-on-failure without setting LEONIDA_VK_VALIDATION (no workflow sets it). This script returns before compiling the fixture whenever that variable is absent, and the CTest SKIP_REGULAR_EXPRESSION turns the return into a skipped/passing test. Therefore the exact b20 regression case is not exercised in CI; the reviewer report above also notes that the 242-module run had no multisample shader. Please arrange for this test to run in CI with Khronos Validation available, or add a dedicated validation step.

@pwu2775-dev pwu2775-dev 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.

Tested cb8132b on Windows 11 (26300), MSVC 19.44 (VS 2022), scripts/build_runtime.ps1 (Ninja), RelWithDebInfo, NVIDIA GeForce RTX 4070 (driver 617.42): pass. ctest 173/173 (GameInput disabled, no SDL3), including bindless_sizing_test. I have no Intel UHD 770, so the 95 → 202 pipelines figures are not reproduced here.

Read-only observations on pipeline_check_descriptors.h, not blocking:

  • compact = !features.update_after_bind && !minimum_fits: when the three update-after-bind features are enabled and size_bindings still reports minimum_fits == false, the shared layout is kept even though it exceeds the limits.
  • The checker never sets features.ms_samples, so binding_enabled leaves bindings 20-25 out of SetLayout (only the tests set it). That is fine while the translator only emits 0-19, but an index that lists those bindings would get a layout that does not match the shader.

AI-assisted: the review was done by Codex (gpt-6.1-terra); both points were checked against the code.

@Flyander

Copy link
Copy Markdown
Contributor

On the current head, b20 is covered by the new path: layout_mask() returns the parsed shader mask when it contains any binding at or above first_ms_binding, and SetLayout then uses that mask instead of binding_enabled(). check_pipeline_ms_binding.cmake exercises binding 20.

The remaining issue is test execution: the standard ctest workflow does not set LEONIDA_VK_VALIDATION=1, so this CTest is marked skipped even when the suite reports all tests passed.

@CryingLaughing

Copy link
Copy Markdown
Contributor

I reproduced the binding-20 diagnostic on cb8132be and verified the fix at d77112cd on Windows 11 (build 26200), GeForce RTX 4080, NVIDIA 621.01, MSVC 19.44 and Khronos validation 1.4.357. Both revisions used the identical synthetic module generated by vk_pipeline_check_ms_binding.

Descriptor mode Parent cb8132be Fix d77112cd
Native RTX features VUID-VkComputePipelineCreateInfo-layout-07988 1 pipeline, zero diagnostics
Ordinary descriptors Same VUID 1 pipeline, zero diagnostics

The parent returned 0 and counted the pipeline as built in both modes, so the validation output caught the failure. I forced ordinary descriptors in local test builds by masking sampled-image update-after-bind after feature discovery, then restored both builds.

On the unmodified fix, vk_pipeline_check_ms_binding, vk_pipeline_check_cli, and bindless_sizing passed 3/3 with LEONIDA_VK_VALIDATION=1. The synthetic module also passed spirv-val for Vulkan 1.1. The separate CI execution review still applies.

AI-assisted (Codex).

BUILD-1402. Install Khronos validation and glslang in the Linux GPU job. Build the pipeline checker immediately after configuration and require its named multisample CTest to pass with validation active. Keep the remaining runtime tests in the existing suite.

AI-assisted. On Ubuntu 24.04 with Mesa llvmpipe and Khronos validation 1.3.275, the dedicated step passed. It failed for a skipped test, a missing test, an unavailable validation layer, and the pre-fix checker reporting VUID-VkComputePipelineCreateInfo-layout-07988.

@Flyander Flyander 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.

Both findings I raised are addressed on 16e6025: declared multisample bindings are retained in the per-shader layout, and the binding-20 regression now has a dedicated validation-enabled Linux CI step that explicitly requires Passed. The commit reports that the llvmpipe step passed locally. GitHub reports the hosted workflows as action_required, so I could not independently confirm those hosted checks; they should be authorized and run before merge.

@bobcatchris

Copy link
Copy Markdown
Contributor

On the CI skip Finder raised: the script's early return and the CTest SKIP_REGULAR_EXPRESSION mean no workflow change is needed for the variable itself, only for where it is set.

  • Set it in the registration rather than in the caller: set_tests_properties(vk_pipeline_check_ms_binding PROPERTIES ENVIRONMENT "LEONIDA_VK_VALIDATION=1"). CTest then sets LEONIDA_VK_VALIDATION=1 in the script's process, so ctest --test-dir runtime/build as .github/workflows/runtime.yml already invokes it (lines 197 and 312) is enough, with no workflow edit.
  • The script should skip on a missing layer instead of failing on one: check that the loader enumerates VK_LAYER_KHRONOS_validation (vulkaninfo --summary, or VK_LAYER_PATH for a local SDK) and print a skip reason. Otherwise the step fails on runners without the layer rather than reporting "not exercised".
  • The Linux GPU leg installs libvulkan-dev mesa-vulkan-drivers vulkan-tools spirv-tools; libvulkan-dev does not pull VK_LAYER_KHRONOS_validation, so a dedicated validation step would need vulkan-validationlayers added there. Whether the runner's llvmpipe leg then loads the layer cleanly is untested here — I have no GPU and did not run it.

Not claiming this; it is your change to land, and the fix belongs in the same PR so the regression is exercised from the run that introduces it. AI-assisted.

@gertify

gertify commented Nov 23, 2026

Copy link
Copy Markdown

Tested 16e6025 on Intel UHD Graphics 770 (driver 32.0.101.7088), Windows 11, MSVC 19.44, Vulkan SDK 1.4.357.0: pass for the checks below.

  • gta6rt, vk_pipeline_check, vk_bindless_test and bindless_sizing_test build.
  • ctest vk_pipeline_check_cli, vk_pipeline_check_ms_binding (with the validation layer active, not skipped) and bindless_sizing: 100% tests passed, 0 tests failed out of 3.
  • vk_pipeline_check on the ms_binding fixture index, device "Intel(R) UHD Graphics 770 (subgroup 8..32)": cs pipelines: 1 ok, 0 failed, 0 skipped; no VUID lines.

The 220-module index from the PR body was not available here, so the 202/95 pipeline counts are not reproduced.

AI-assisted.

@JRamos1993

Copy link
Copy Markdown
Contributor

Tested 16e6025 merged onto main 3faac55 on an RTX 5090 (driver 616.92), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363, RelWithDebInfo:

  • Full ctest: 179/179.
  • bindless_sizing: passes 20 of 20 runs, and passes under LEONIDA_VK_VALIDATION=1 with 0 validation messages.
  • Warnings: none new in the files this PR changes.

AI-assisted (Claude Code).

@memorypressure

Copy link
Copy Markdown

Verified against main 3faac55: clean merge, compileall and the docs guards (CLI flags, repo paths, env vars) pass. Reviewer-side static check: the compact per-shader set-0 layout matches the docs text (default mask bits 0..19, MS binding 20 kept when declared, one descriptor per binding only when the ordinary minimum does not fit), and the CI step greps for Passed so a SKIP cannot pass the binding-20 gate — good design. The ctest targets need a Vulkan/validation-layer build and were not run here, and the branch reports no CI checks at all — please trigger a run before merge. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only review).

@sovljanskii

Copy link
Copy Markdown
Contributor

Tested 16e60250 on Apple M4, MoltenVK 1.4.2 (macOS, AppleClang), the first Apple run here as far as I can see: pass, no change on this device.

  • Whole runtime build: clean. ctest: 50/51. The one failure is vk_overlapping_occlusion, which fails the same way on main 3faac557 here.
  • A real corpus slice from my own 1.0.2.1 copy, 100 cs entries plus 100 --mesh-compute mesh entries, run with --compute-only:
    • cs is identical to main's binary: 98 pipelines ok, and the same 2 module failures over this GPU's 32 KiB maxComputeSharedMemorySize (an older translation).
    • The ordinary set-0 layout fits MoltenVK's limits, so nothing changes here, as intended.

Heads-up for the merge order. This PR and my #2124 (--mesh-compute entries as compute pipelines) touch the same lines of the unsupported-reason lambda. They conflict in one hunk, and it's trivial: keep this PR's descriptors.fits(...) refusal, then #2124's two lines (!built_as_compute(meta) for dynamicRendering, !meta.mesh_compute for the mesh extension).

I built that merge on the M4:

  • tests/test_vk_pipeline_check_mesh_compute.py: 9 ok;
  • the same slice: cs 98 ok, and ms-compute 100/100 ok.

So your per-shader layouts work for the ms-compute entries too, since they're keyed by push size and binding mask with VK_SHADER_STAGE_ALL. Whichever lands second, I'll rebase #2124 if it's mine.

Counts only. AI-assisted.

@Racurs156

Copy link
Copy Markdown

A31 follow-up on exact 16e60250, Windows 11 build 26200, RTX 4060 Ti / 621.01. Built the checker with llvm-mingw. With the synthetic cs_set0_sample (bindings 0/1/2), the checker saves a 14,174-byte seed and reports a hit on reloading it into the same checker. The seed misses in three fresh processes using the runtime's 26-binding layout, including six MS fallback bindings.

Keeping the shader, logical device recipe, push range, 65,536 image slots, 3,936 samplers and update-after-bind flags fixed, the probe also hits with this PR's seed if the six MS bindings are omitted. In the fully controlled comparison, seed and read match with 20 bindings; adding only the runtime's three MS binding pairs to the read changes it to a miss; a seed made with 26 bindings hits with 26. No Vulkan validation diagnostics in the probe. These are application-cache feedback bits from the driver, synthetic only. A31 measurements

This confirms the branch fixes the ordinary layout mismatch on this device and isolates the remaining MS-pair cache difference. AI-assisted.

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.