Skip to content

[BUILD-546] Reject over-limit compute workgroup memory in vk_pipeline_check - #1958

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
Capi360:codex/pipeline-workgroup-limit
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
Capi360:codex/pipeline-workgroup-limit

Conversation

@Capi360

@Capi360 Capi360 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

BUILD-546, claimed in #1902. This is the pipeline-checker follow-up to #1882.

Changes

  • Read the optional lds_bytes field as an unsigned 32-bit integer. Reject malformed counts during index parsing.
  • Compare each selected compute entry with the Vulkan device's maxComputeSharedMemorySize before creating its shader module. Record an over-limit entry as a module failure and continue through the remaining entries and the final cache save. Indexes without the field and the explicit --max-bytes filter retain their existing behavior.

Verification

Windows 11 build 26200, MSVC 19.44, Windows SDK 10.0.28000.0, NVIDIA GeForce RTX 3060 Ti (616.56, Vulkan 1.4.351), RelWithDebInfo. All shader inputs were synthetic.

  • The unmodified checker accepted all three valid synthetic modules. The patched checker refused only the entry advertising 49,156 bytes against the device's 49,152-byte limit. It compiled the entry at the exact limit and the entry without lds_bytes, returned 1 for the mixed batch, and saved a nonempty cache. Verified with one and two workers. Selecting just the two valid entries returned 0. The size filter continued to skip all three when set below their file sizes.
  • vk_pipeline_check_cli passed, including negative, fractional, and overflowing counts. The extended test failed against the old binary.
  • test_docs_links.py, test_ctest_registration.py, Python compilation, CLI help, and git diff --check passed.

AI-assisted with Codex.

@AvantBras

Copy link
Copy Markdown
Contributor

Independent Linux/Vulkan check of BUILD-546 at ced200b263c64870ae552430aafff38678aa575f against its parent 6a6704df: RTX 3060 12 GB, NVIDIA 580.178.04, Pop!_OS 22.04 LTS, GCC 11.4.

I built vk_pipeline_check from both revisions and used three copies of one hand-written no-op compute module (spirv-val --target-env vulkan1.2 passed) with independent index entries: lds_bytes 49,152 (device limit), 49,156 (limit + 4), and missing (legacy index). The metadata deliberately exercises the boundary without ever handing the driver a genuinely oversized shader.

  • Parent, --jobs 1: all three compiled, exit 0.
  • PR head, --jobs 1 and --jobs 2: rejected only the 49,156-byte entry with the expected limit diagnostic. The exact-limit and legacy entries both compiled; exit 1 and a 5,440-byte cache was saved in both runs.
  • ctest --test-dir <build> --no-tests=error -R '^vk_pipeline_check_cli$' --output-on-failure: 1/1 passed, including malformed counts.

No game files. AI-assisted verification.

@Impre-visible

Copy link
Copy Markdown

Tested ced200b on NVIDIA GeForce GTX 1660 (Turing, TU116, subgroup 32..32), driver 620.73.04 (proprietary, Vulkan 1.4.357, maxComputeSharedMemorySize 49152), Arch Linux (kernel 6.18): pass.

Native build of runtime/ from this head (Ninja, RelWithDebInfo, clang 23.1.5), llvm-mc 23.1.5, SPIRV-Tools v2026.4.

  • vk_pipeline_check on the SPIR-V folder build.py writes for the repository's own test shaders (185 in the index, 12 compute entries carry lds_bytes, the largest 512): cs 86/86 modules and 86/86 pipelines, ps 90/90 and 90/90, vs 9/9 and 9/9, 0 failed. Nothing is wrongly rejected.
  • Same folder with one entry's lds_bytes raised to 1048576 in a copy of index.json: exit 1, MODULE FAIL cs_barrier_divergent (workgroup memory 1048576 bytes exceeds maxComputeSharedMemorySize 49152), cs 85 modules ok and 1 failed, and the run continues through the other stages (ps 90/90, vs 9/9).
  • ctest in the Linux build: 36/36 passed (2 skipped as on main: shader_library_corpus, vk_sync_validation)
  • tests/semantic: 1644 OK
  • run_gpu_tests.py: 178/178 translated and pass spirv-val; 133/173 passed, 40 skipped, 0 failed; with LEONIDA_W64_EMULATE=1: 164/173 passed, 9 skipped (8 fixtures run by the d3d12 tests, 1 needs a 64-wide fragment subgroup), 0 failed

AI-assisted run (Claude). Synthetic test shaders only, no game files involved.

@kapitche

Copy link
Copy Markdown
Contributor

Tested on Windows 11 with two GPUs on one machine (runtime built from this PR's head, MSVC 14.51): no regression from this PR. RTX 4080 SUPER: 111/113 pass. On current main three tests fail the same way on every PR I built, so they're not from this PR: d3d12_draw (bundle blend, bisected to #1660's merge, see #1902), d3d12_compute on both GPUs (line 515: device_proxy_ref_count(device.p) == 1), and d3d12_subgroup on the Intel UHD 770 (line 611: fragment_default). I'm bisecting the last two. Other Intel failures are the known d3d12_present and d3d12_m3_frame.

@crastinator

Copy link
Copy Markdown
Contributor

Tested ced200b merged into main 4eb6155d on an AMD Radeon RX 6700 XT, RADV Mesa 26.3.1, Linux. The limit works: with cs_store, lds_bytes 65536 passes, and 65537 gives MODULE FAIL ... exceeds maxComputeSharedMemorySize 65536. But vk_pipeline_check_cli fails after the merge: since #1847 the parser no longer says "malformed JSON" ("…/index.json: expected unsigned 32-bit lds_bytes at byte 37"), and the new loop still matches the old text.

@Capi360 I've opened Capi360#1 against your branch (crastinator:workgroup-limit-main-merge). It merges main and matches index.json: expected, like the check above it. ctest then passes 36/36.

AI-assisted (Claude Code).

@ItsNotRexed
ItsNotRexed merged commit e52eb24 into ItsNotRexed:main Nov 22, 2026
10 of 11 checks passed
ItsNotRexed added a commit that referenced this pull request Nov 22, 2026
…in, lds_bytes CLI check

- d3d12_vulkan_device.cpp, vk_test_device.h: #760 chained VkPhysicalDeviceCustomBorderColorFeaturesEXT onto
  enable13, which #1706 replaced with leonida::Vulkan13Features; it goes at *v13.next() like the other later
  feature structs. The runtime and the GPU test harness didn't compile.
- check_vk_pipeline_cli.cmake: #1958's lds_bytes cases matched "malformed JSON"; the index parser reports where it
  stopped ("... at byte 37"), which the check now matches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.

6 participants