Skip to content

Bindless capacity on MoltenVK: the test follows the set's room, and the set is sized by its real limits - #2232

Merged
ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
Jolymmiles:mac/bindless-capacity-follows-room
Nov 22, 2026
Merged

ItsNotRexed merged 2 commits into
ItsNotRexed:mainfrom
Jolymmiles:mac/bindless-capacity-follows-room

Conversation

@Jolymmiles

@Jolymmiles Jolymmiles commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: item 2 of #1902 (comment) (bindless sampler capacity on MoltenVK)

What and why

On a Mac under Wine, d3d12_descriptor's capacity check read zeros: view 5001 through sampler 2100 … got 0,0,0,0. This is not Metal's sampler limit. MoltenVK 1.4.3 on an M3 Max reports maxSamplerAllocationCount 500000 and update-after-bind per-set limits of 1000000 images and 500000 samplers.

The cause is MoltenVK's vkGetDescriptorSetLayoutSupport. MVKDevice::getDescriptorSetLayoutSupport only checks that the descriptor total is below maxPerSetDescriptors (1212). So the runtime's size_bindings can't grow the bindless set past its defaults, and the set stays at 4096 2D images and 1024 samplers (a bindless image array is full, the bindless sampler array is full; samplers 1023). The 5001st view then misses the table and reads index 0, the null image.

The runtime itself behaves as specified: it doesn't oversize, doesn't drop writes silently, and returns index 0 on a miss. Two things are MoltenVK's:

  • it says "unsupported" even at exactly 1212 descriptors, which the spec guarantees to be supported (< for <=);
  • an update-after-bind, argument-buffer layout is compared with the non-argument-buffer limit.

Native repro, plain Vulkan on arm64: a 65536-image plus 4096-sampler update-after-bind set, each sampler with a different maxLod. MoltenVK 1.4.2/1.4.3 report it unsupported and then create and sample it correctly; all three probes are right. KosmicKrisp and llvmpipe report it supported and give the same samples. I re-ran it: MoltenVK 1212 -> 0, 1211 -> 1, 69633 -> 0 … all three samples correct; … said NOT supported.

Two commits:

1. The test checks the right thing on every device (the first commit leaves sizing to the driver's answer):

  • Test: d3d12_descriptor_test asks the set how much room it has (rt::d3d12::bindless_room). With enough room the old check runs unchanged: the 5001st SRV through the 2100th sampler gives the texture. With less, it fills each short array to its last index and checks three things. The last view through the last sampler gives the texture. One more view is refused and reads zeros. One more sampler is refused and reads through the clamping fallback. The capacity it found is printed.
  • Runtime: BindlessSet::free_images / free_samplers. When the set holds fewer samplers than a full shader-visible D3D12 sampler heap (2048), the device logs it once at start-up (1023 of 2048 besides the fallback), so the limit is visible.
  • Tests: bindless_sizing_test gets a case with MoltenVK's real limits, and vk_bindless_test checks the free counters.
  • Docs: docs/d3d12_vulkan.md section 5 and a docs/testing.md troubleshooting row.

2. On MoltenVK the set is sized by its real limits. An experiment can settle this choice, and it did: the native repro and d3d12_descriptor_test under Wine with the set grown both show that MoltenVK runs the full set. So on MoltenVK the D3D12 device no longer asks vkGetDescriptorSetLayoutSupport. size_bindings' per-type update-after-bind limits decide alone; MoltenVK takes them from Metal's argument-buffer limits, 500000 samplers on an M3 Max. The gate is driverID == VK_DRIVER_ID_MOLTENVK because no property reports this. The set grows to 65536 2D images and 4096 samplers ([rt] d3d12: bindless set: 65536 2D images, 4096 samplers, …), like on other GPUs. A D3D12 heap of up to 2048 samplers, and the game's large SRV heaps, then fit on a Mac.

A ready-to-file MoltenVK report with the repro is prepared and will be linked here once filed.

Tested

Apple M3 Max, macOS 27.3. The Windows build is cross-compiled with clang-cl 23.1.6, lld-link 22.1.8 and the xwin 10.0.26100 SDK, and runs under Wine 11.0 (CrossOver 26.3's loader) with MoltenVK 1.4.3. The earlier "literal sampler bias 31" case was bypassed locally to reach this check; #1845 handles that case.

d3d12_descriptor result
before FAIL: view 5001 through sampler 2100 … 0,0,0,0, differ == 0
after, default set the capacity check passes: the set had room for 4074 more 2D views and 1016 more samplers … refused and read as the fallback
after, set forced to grow (experiment only) the 5001th SRV through the 2100th sampler gave the texture, whole test rc=0
  • Both commits together, plus Apply the S#'s LOD bias in the shader where samplers take none (SHADER-268) #1845's test change (merged locally for the run only): d3d12_descriptor under Wine with MoltenVK 1.4.3 passes end to end (rc=0). The output shows bindless set: 65536 2D images, 4096 samplers and bindless capacity: the 5001th SRV through the 2100th sampler gave the texture.
  • Regression check: with the write of the last sampler slot disabled, the test fails at the new check (the last view through the last sampler … got 224,0,135,255).
  • Full run_wine_tests.py: 88 / 6 / 23 of 117 before and after, the same status for every test.
  • Native:
    • bindless_sizing_test and descriptor_table_test pass (I re-ran them);
    • vk_bindless_test passes on MoltenVK 1.4.3, KosmicKrisp and llvmpipe;
    • ctest is 35/36, with only xdxr_build_check failing, which fails on plain main too and is in progress separately.
  • Not run: Linux Wine/llvmpipe, where the set grows to full size and the old check runs, and older Apple GPUs.

No game files. AI-assisted.

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.)

🤖 Generated with Claude Code

…room

On MoltenVK (1.4.2, 1.4.3) the check sampled zeros: vkGetDescriptorSetLayoutSupport there accepts only layouts
of fewer than maxPerSetDescriptors (1212) descriptors, so size_bindings keeps the default 4096 2D images and
1024 samplers, and the test's 5001st view and 2100th sampler were refused as the arrays filled. MoltenVK does
create and sample a 65536-image, 4096-sampler set correctly (a native reproduction, and the whole test passes
under Wine with growth forced), so that is MoltenVK's to fix; the runtime keeps following the driver's answer.

The test now asks the set how much room it has (rt::d3d12::bindless_room, from BindlessSet::free_images and
free_samplers). Where the set holds the full counts nothing changes. Where it holds fewer, the test fills each
short array to its last index, checks the last view through the last sampler gives the texture, and that one
more view and sampler are refused and read as the fallbacks. The device logs at startup when its set holds
fewer samplers than a full shader-visible sampler heap. bindless_sizing_test gets MoltenVK's limits;
vk_bindless_test checks the free counts.
…its layout-support answer

MoltenVK's vkGetDescriptorSetLayoutSupport compares every layout with maxPerSetDescriptors (1212, the limit without
argument buffers) and rejects even 1212 itself, although it creates and samples a 65536-image, 4096-sampler
update-after-bind set correctly (native repro; d3d12_descriptor_test under Wine with the set grown). On MoltenVK the
D3D12 device no longer asks it: size_bindings' per-type update-after-bind limits, which MoltenVK takes from Metal's
argument-buffer limits, decide, and the set grows to 65536 2D images and 4096 samplers on an M3 Max.
@Jolymmiles Jolymmiles changed the title d3d12_descriptor_test: the bindless capacity check follows the set's room (MoltenVK under-reports layout support) Bindless capacity on MoltenVK: the test follows the set's room, and the set is sized by its real limits Nov 22, 2026
@itsonlysimbo

Copy link
Copy Markdown
Contributor

Tested 7e727591 on RTX 4070, NVIDIA 621.14, Windows 11 (10.0.26300), MSVC 19.44, Vulkan SDK 1.4.363: pass.

AI-assisted (Claude Code).

@FaKL-Code

Copy link
Copy Markdown
Contributor

Tested 7e72759 (merged onto main 4947579) on NVIDIA GeForce RTX 4060 Ti, driver 610.88 (32.0.16.1088), Windows 11 26200, MSVC 14.51 (VS 2026), Vulkan SDK 1.4.363.0: pass.

  • Full ctest -C RelWithDebInfo -j 4: 116/116 (7 skips that need game files or validation).
  • bindless_sizing, d3d12_descriptor and vk_sync_validation rerun with LEONIDA_VK_VALIDATION=1: pass, no validation messages.
  • Not run: vk_bindless_test (ps_tex / ps_imgatomic through scripts/run_gpu_tests.py), since this machine has no llvm-mc to assemble the fixtures.

AI-assisted (Claude).

@ezwinxdlmao

Copy link
Copy Markdown
Contributor

Tested 7e72759 on an NVIDIA GeForce RTX 3050 Laptop GPU, driver 32.0.16.2101, Windows 11, native MSVC (VS 2022 Build Tools, Ninja, RelWithDebInfo), with llvm-mc 21.1.8 for the translated-shader tests: pass.

  • ctest -R "bindless_sizing|d3d12_descriptor": 2/2 pass. This is a no-regression check on a desktop driver: the MoltenVK update-after-bind sizing path itself needs an Apple GPU.
  • Full ctest -j3: 115/116. The one failure is d3d12_draw (bundle blend pixel 127,0,127,255; TEST-266, fixed by Tests: wait for the bundle blend draws in d3d12_draw (fence 31, not 21) #1995), which fails identically on unmodified main 4eb6155d (this PR's base) on the same GPU. No build warnings in the files this PR touches.

AI-assisted (Claude Code).

@Jolymmiles

Copy link
Copy Markdown
Contributor Author

Reported upstream on the existing issue KhronosGroup/MoltenVK#2573 (repro, and the < vs <= spec violation): KhronosGroup/MoltenVK#2573 (comment)

@ItsNotRexed
ItsNotRexed merged commit 3fd09d4 into ItsNotRexed:main Nov 22, 2026
4 checks passed
@mesterember104-cpu

Copy link
Copy Markdown

Tested 7e72759 on Tiger Lake (Xe-LP) iGPU 0x9a78 (subgroup 8..32, no mesh), driver 32.0.101.7088, Windows 11, MSVC 14.44: pass — the PR's own surface behaves as intended on Intel; both failing tests are pre-existing Intel-main failures outside the PR's area.

  • The reworked capacity check runs its "room" path on this driver and passes: "bindless capacity: the 5001th SRV through the 2100th sampler gave the texture" (no more black-texel capacity abort on this machine). The set stays driver-sized and full: startup log "bindless set: 65536 2D images, 3936 samplers, 1024 2D-array, 256 3D, 256 1D, 4096 storage indices in 2D" — the VK_DRIVER_ID_MOLTENVK gate correctly leaves Windows/Intel behavior unchanged, and the new "1023 of 2048 besides the fallback" startup line correctly does not appear (the set holds more than 2048 samplers here).
  • bindless_sizing (including the new synthetic-limits case: "RTX 5070-like: 65536 2D images, 3936 samplers, 4096 storage indices in 2D, 93793 descriptors") and descriptor_table both pass.
  • vk_bindless_test (the new free-counter checks) could not run: it needs compiled SPIR-V shaders (vs_ids.spv / ps_tex.spv) and this machine has no llvm-mc/spirv-as — the same limitation that keeps GPU-only PRs unchecked here.
  • Full ctest: 99/101 pass, 7 skipped (shader_library_corpus, bink_decode, bink_audio, vk_sync_validation, d3d12_queue_wait, d3d12_rgb9e5_rtv skip; gameinput disabled — no SDL3). Failing: d3d12_descriptor at the pre-existing Intel minLOD mismatch (line 2384: lod_mismatches == 0; "minimum LOD view 1 texel 0: got 0 0 128 255, expected 16 160 64 255" — D3D-219/220 class; fails the same way on plain main here) and d3d12_draw ("bundle blend pixel (0, 0): got 128,0,128,255, expected red 64" — the known Runtime: carry bundle blend factors back to parent draws #1660 bundle-blend failure).

AI-assisted (GLM, operated by the account owner).

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