Repository navigation
Bindless capacity on MoltenVK: the test follows the set's room, and the set is sized by its real limits - #2232
Conversation
…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.
|
Tested
AI-assisted (Claude Code). |
|
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.
AI-assisted (Claude). |
|
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
AI-assisted (Claude Code). |
|
Reported upstream on the existing issue KhronosGroup/MoltenVK#2573 (repro, and the |
|
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.
AI-assisted (GLM, operated by the account owner). |
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 reportsmaxSamplerAllocationCount500000 and update-after-bind per-set limits of 1000000 images and 500000 samplers.The cause is MoltenVK's
vkGetDescriptorSetLayoutSupport.MVKDevice::getDescriptorSetLayoutSupportonly checks that the descriptor total is belowmaxPerSetDescriptors(1212). So the runtime'ssize_bindingscan'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:
<for<=);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: MoltenVK1212 -> 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):
d3d12_descriptor_testasks 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.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.bindless_sizing_testgets a case with MoltenVK's real limits, andvk_bindless_testchecks the free counters.docs/d3d12_vulkan.mdsection 5 and adocs/testing.mdtroubleshooting 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_testunder Wine with the set grown both show that MoltenVK runs the full set. So on MoltenVK the D3D12 device no longer asksvkGetDescriptorSetLayoutSupport.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 isdriverID == VK_DRIVER_ID_MOLTENVKbecause 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_descriptorview 5001 through sampler 2100 … 0,0,0,0,differ == 0the set had room for 4074 more 2D views and 1016 more samplers … refused and read as the fallbackthe 5001th SRV through the 2100th sampler gave the texture, whole test rc=0d3d12_descriptorunder Wine with MoltenVK 1.4.3 passes end to end (rc=0). The output showsbindless set: 65536 2D images, 4096 samplersandbindless capacity: the 5001th SRV through the 2100th sampler gave the texture.the last view through the last sampler … got 224,0,135,255).run_wine_tests.py: 88 / 6 / 23 of 117 before and after, the same status for every test.bindless_sizing_testanddescriptor_table_testpass (I re-ran them);vk_bindless_testpasses on MoltenVK 1.4.3, KosmicKrisp and llvmpipe;xdxr_build_checkfailing, which fails on plainmaintoo and is in progress separately.No game files. AI-assisted.
Checklist
docs/design.md, with how it was confirmed. (No translator change.)🤖 Generated with Claude Code