From 7d5d820779cc7a348657ebf191531f9987d61d76 Mon Sep 17 00:00:00 2001 From: Jan Trencansky Date: Thu, 26 Nov 2026 14:40:41 -0500 Subject: bindless: size every sampled dimension alike and name a full array as its own refusal (RT-BINDLESS-DIMENSION-LIMITS) World runs fill one bindless image array a few minutes in: `a bindless image array is full; dimension 3: 4096 indices, 4092 T#s of 4090 textures`. Dimension 3 is 1D (ImageDimension: 2D, 2D array, 3D, 1D). From then on every new 1D T# reads the fallback's zeros, and the console heaps count it as "no view for the T#'s format or range", which went from 2-28 a window to over 4000. Nothing leaks: the 4096 indices are the fallback, 4092 entries of image_entries and 3 replaced views, every one held by a texture the runtime still has registered, and a texture's indices go back when it goes (forget_image, the deferred bindless_slot release, remove_image). The cause is the size: size_bindings grew 2D images to 65536 but 3D and 1D only to 4096 and 2D arrays to 16384, constants that guessed how many textures of each dimension a title keeps, whatever the device holds (RADV allows 8388606 sampled images, llvmpipe 1015808). - vulkan_bindless.h: one maximum (max_images, 65536) for the sampled array of every single-sample dimension, in place of max_2d_images, max_2d_array_images, max_3d_images and max_1d_images. The 2D-array, 3D and 1D arrays grow together after 2D and the storage arrays, so on a device whose limits stop growth earlier none of them is favoured. The bound is memory (each generation's pool holds every element): 325729 descriptors on an RTX 5070, 10-20 MiB at 32-64 bytes a descriptor. The shaders declare runtime arrays, so no shader changes; the set layout changes, so compute pipelines get new journal names (hash_bindless_layout) and the pipeline cache is rebuilt. - BindlessSet::image_refusal says why add_image returned 0: no array for the dimension, the array is full, or only its shorter storage range is. - d3d12_vulkan_device.cpp: bind_image_locked and bind_image_views_locked report that reason; bind_title_image counts it ("the bindless array of the T#'s dimension is full", or "the bindless storage arrays of the T#'s dimension are full") instead of "no view for the T#'s format or range". The once-per-dimension line names the dimension, the storage range and how many of the textures holding indices are still registered at their address. - docs/d3d12_vulkan.md: the sizes, and the new reason. Tests: bindless_sizing_test checks RADV's and llvmpipe's limits (every sampled dimension at 65536; on main 1D and 3D stop at 4096) and that the three dimensions share a short budget alike. vk_bindless_dimensions_test (new, GLSL shader) sizes a set from the device, gives 5000 live 1D, 2D-array and 3D images an index each and reads every one through its index, then fills the rest of the array: the next is refused as full, and removed indices come back at once or, after an erased key, at the next flush. On main it fails at "1D: 4096 indices in the set". vk_bindless_test's index-space case filled 1D expecting the first index to be 1, which held only while the 1D array was as short as its storage arrays; it now checks every index once and that indices above the storage arrays go first. Co-Authored-By: Claude Opus 5.5 --- runtime/test/bindless_sizing_test.cpp | 54 +++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 8 deletions(-) (limited to 'runtime/test/bindless_sizing_test.cpp') diff --git a/runtime/test/bindless_sizing_test.cpp b/runtime/test/bindless_sizing_test.cpp index b7d501aab..b83294852 100644 --- a/runtime/test/bindless_sizing_test.cpp +++ b/runtime/test/bindless_sizing_test.cpp @@ -133,18 +133,18 @@ int main() { const Device d = uniform(1048576, 1048576); BindlessFeatures f = with_ms(update_after_bind); EXPECT(bindless::size_bindings(f, d.limits, d.v11, d.v12)); - EXPECT(count(f, D::dim_2d) == bindless::max_2d_images); + EXPECT(count(f, D::dim_2d) == bindless::max_images); EXPECT(f.counts[bindless::sampler_binding] == 4000 - bindless::reserved_samplers); EXPECT(f.counts[bindless::sampler_binding] > 2048); // a full sampler heap and the fallback EXPECT(storage(f, D::dim_2d) == bindless::max_storage_indices); - // The other dimensions grow too (a title's cube maps, texture arrays and 1D lookups outnumber the defaults); - // their storage arrays hold as many indices as the 2D one. The storage-only 1D array keeps its 256. - EXPECT(count(f, D::dim_2d_array) == bindless::max_2d_array_images && - count(f, D::dim_3d) == bindless::max_3d_images && count(f, D::dim_1d) == bindless::max_1d_images); + // The other dimensions grow as far as 2D (a title's textures are of whichever dimension it chose); their + // storage arrays hold as many indices as the 2D one. The storage-only 1D array keeps its 256. + EXPECT(count(f, D::dim_2d_array) == bindless::max_images && count(f, D::dim_3d) == bindless::max_images && + count(f, D::dim_1d) == bindless::max_images); EXPECT(storage(f, D::dim_2d_array) == bindless::max_storage_indices && storage(f, D::dim_3d) == bindless::max_storage_indices && storage(f, D::dim_1d) == bindless::max_storage_indices); - EXPECT(storage(f, D::dim_1d_array) == 256 && totals(f).all == 153697); + EXPECT(storage(f, D::dim_1d_array) == 256 && totals(f).all == 325729); EXPECT(f.ms_samples[0] == VK_SAMPLE_COUNT_4_BIT && f.ms_samples[2] == VK_SAMPLE_COUNT_4_BIT); EXPECT(storage_consistent(f)); if (update_after_bind) @@ -152,6 +152,44 @@ int main() { count(f, D::dim_2d), f.counts[bindless::sampler_binding], storage(f, D::dim_2d), totals(f).all); } + // RADV (Mesa 26.3, a Raphael iGPU and an RX 7900 XTX alike) and llvmpipe: their update-after-bind limits hold + // every sampled dimension at the full size. A world run kept 4090 live 1D textures, filling the 4096 1D indices + // the set used to stop at whatever the device held; now 1D, 3D and 2D-array images get as many as 2D. + { + Device radv = uniform(8388606, 8388606); + radv.limits.maxPerStageResources = radv.v12.maxPerStageUpdateAfterBindResources = 8388606; + radv.v12.maxUpdateAfterBindDescriptorsInAllPools = 67108863; + radv.v11.maxPerSetDescriptors = 22369621; + radv.limits.maxSamplerAllocationCount = 4294967295u; + Device lvp = uniform(1015808, 1015808); + lvp.limits.maxPerStageResources = lvp.v12.maxPerStageUpdateAfterBindResources = 1015808; + lvp.v11.maxPerSetDescriptors = 1015808; + lvp.limits.maxSamplerAllocationCount = 32768; + for (const Device* d : {&radv, &lvp}) { + BindlessFeatures f = with_ms(true); + EXPECT(bindless::size_bindings(f, d->limits, d->v11, d->v12)); + for (const D dimension : {D::dim_2d, D::dim_2d_array, D::dim_3d, D::dim_1d}) { + EXPECT(count(f, dimension) == bindless::max_images); + EXPECT(count(f, dimension) > 4096 + 1); // more than 4096 live images and the fallback + } + EXPECT(storage_consistent(f)); + } + } + + // A device whose limits stop growth short of max_images: the 2D-array, 3D and 1D arrays share what is left alike, + // whichever is grown first. + { + Device d = uniform(1048576, 1048576); + d.v12.maxPerStageDescriptorUpdateAfterBindSampledImages = 65536 + 3 * 20000 + 6 * 256 + bindless::growth_headroom; + BindlessFeatures f = with_ms(true); + EXPECT(bindless::size_bindings(f, d.limits, d.v11, d.v12)); + EXPECT(count(f, D::dim_2d) == bindless::max_images); + EXPECT(count(f, D::dim_2d_array) == count(f, D::dim_3d) && count(f, D::dim_3d) == count(f, D::dim_1d)); + EXPECT(count(f, D::dim_1d) > 4096 && count(f, D::dim_1d) <= 20000); + EXPECT(totals(f).sampled + bindless::growth_headroom <= d.v12.maxPerStageDescriptorUpdateAfterBindSampledImages); + EXPECT(storage_consistent(f)); + } + // At today's sizes exactly (5632 sampled images, 1024 samplers, 4352 storage images): no MS pairs. { Device d = uniform(1048576, 1048576); @@ -191,7 +229,7 @@ int main() { BindlessFeatures uab = with_ms(true), plain = with_ms(false); EXPECT(bindless::size_bindings(uab, d.limits, d.v11, d.v12)); EXPECT(bindless::size_bindings(plain, d.limits, d.v11, d.v12)); - EXPECT(count(uab, D::dim_2d) == bindless::max_2d_images); + EXPECT(count(uab, D::dim_2d) == bindless::max_images); const Totals t = totals(plain); EXPECT(count(plain, D::dim_2d) > 4096 && count(plain, D::dim_2d) < 16384); EXPECT(t.sampled + bindless::growth_headroom <= 16384 && t.storage + bindless::growth_headroom <= 16384); @@ -232,7 +270,7 @@ int main() { BindlessFeatures f = with_ms(true); EXPECT(bindless::size_bindings(f, d.limits, d.v11, d.v12, all_supported)); EXPECT(asked > 0 && asked_within == 0 && missing_storage == 0); - EXPECT(count(f, D::dim_2d) == bindless::max_2d_images && + EXPECT(count(f, D::dim_2d) == bindless::max_images && f.counts[bindless::sampler_binding] == 4000 - bindless::reserved_samplers); EXPECT(storage(f, D::dim_2d) == bindless::max_storage_indices && storage_consistent(f)); -- cgit v1.2.3