upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/test/bindless_sizing_test.cpp
diff options
context:
space:
mode:
authorJan Trencansky <jan.trencansky@protonmail.com>2026-11-26 14:40:41 -0500
committerJan Trencansky <jan.trencansky@protonmail.com>2026-11-26 14:48:57 -0500
commit7d5d820779cc7a348657ebf191531f9987d61d76 (patch)
treeef5485501f706184547fbe3022136b491313f1d5 /runtime/test/bindless_sizing_test.cpp
parent2d43417d49fdd8f2d8241f75ea8fd0cdd8811137 (diff)
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 <noreply@anthropic.com>
Diffstat (limited to 'runtime/test/bindless_sizing_test.cpp')
-rw-r--r--runtime/test/bindless_sizing_test.cpp54
1 files changed, 46 insertions, 8 deletions
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() {
133 const Device d = uniform(1048576, 1048576); 133 const Device d = uniform(1048576, 1048576);
134 BindlessFeatures f = with_ms(update_after_bind); 134 BindlessFeatures f = with_ms(update_after_bind);
135 EXPECT(bindless::size_bindings(f, d.limits, d.v11, d.v12)); 135 EXPECT(bindless::size_bindings(f, d.limits, d.v11, d.v12));
136 EXPECT(count(f, D::dim_2d) == bindless::max_2d_images); 136 EXPECT(count(f, D::dim_2d) == bindless::max_images);
137 EXPECT(f.counts[bindless::sampler_binding] == 4000 - bindless::reserved_samplers); 137 EXPECT(f.counts[bindless::sampler_binding] == 4000 - bindless::reserved_samplers);
138 EXPECT(f.counts[bindless::sampler_binding] > 2048); // a full sampler heap and the fallback 138 EXPECT(f.counts[bindless::sampler_binding] > 2048); // a full sampler heap and the fallback
139 EXPECT(storage(f, D::dim_2d) == bindless::max_storage_indices); 139 EXPECT(storage(f, D::dim_2d) == bindless::max_storage_indices);
140 // The other dimensions grow too (a title's cube maps, texture arrays and 1D lookups outnumber the defaults); 140 // The other dimensions grow as far as 2D (a title's textures are of whichever dimension it chose); their
141 // their storage arrays hold as many indices as the 2D one. The storage-only 1D array keeps its 256. 141 // storage arrays hold as many indices as the 2D one. The storage-only 1D array keeps its 256.
142 EXPECT(count(f, D::dim_2d_array) == bindless::max_2d_array_images && 142 EXPECT(count(f, D::dim_2d_array) == bindless::max_images && count(f, D::dim_3d) == bindless::max_images &&
143 count(f, D::dim_3d) == bindless::max_3d_images && count(f, D::dim_1d) == bindless::max_1d_images); 143 count(f, D::dim_1d) == bindless::max_images);
144 EXPECT(storage(f, D::dim_2d_array) == bindless::max_storage_indices && 144 EXPECT(storage(f, D::dim_2d_array) == bindless::max_storage_indices &&
145 storage(f, D::dim_3d) == bindless::max_storage_indices && 145 storage(f, D::dim_3d) == bindless::max_storage_indices &&
146 storage(f, D::dim_1d) == bindless::max_storage_indices); 146 storage(f, D::dim_1d) == bindless::max_storage_indices);
147 EXPECT(storage(f, D::dim_1d_array) == 256 && totals(f).all == 153697); 147 EXPECT(storage(f, D::dim_1d_array) == 256 && totals(f).all == 325729);
148 EXPECT(f.ms_samples[0] == VK_SAMPLE_COUNT_4_BIT && f.ms_samples[2] == VK_SAMPLE_COUNT_4_BIT); 148 EXPECT(f.ms_samples[0] == VK_SAMPLE_COUNT_4_BIT && f.ms_samples[2] == VK_SAMPLE_COUNT_4_BIT);
149 EXPECT(storage_consistent(f)); 149 EXPECT(storage_consistent(f));
150 if (update_after_bind) 150 if (update_after_bind)
@@ -152,6 +152,44 @@ int main() {
152 count(f, D::dim_2d), f.counts[bindless::sampler_binding], storage(f, D::dim_2d), totals(f).all); 152 count(f, D::dim_2d), f.counts[bindless::sampler_binding], storage(f, D::dim_2d), totals(f).all);
153 } 153 }
154 154
155 // RADV (Mesa 26.3, a Raphael iGPU and an RX 7900 XTX alike) and llvmpipe: their update-after-bind limits hold
156 // every sampled dimension at the full size. A world run kept 4090 live 1D textures, filling the 4096 1D indices
157 // the set used to stop at whatever the device held; now 1D, 3D and 2D-array images get as many as 2D.
158 {
159 Device radv = uniform(8388606, 8388606);
160 radv.limits.maxPerStageResources = radv.v12.maxPerStageUpdateAfterBindResources = 8388606;
161 radv.v12.maxUpdateAfterBindDescriptorsInAllPools = 67108863;
162 radv.v11.maxPerSetDescriptors = 22369621;
163 radv.limits.maxSamplerAllocationCount = 4294967295u;
164 Device lvp = uniform(1015808, 1015808);
165 lvp.limits.maxPerStageResources = lvp.v12.maxPerStageUpdateAfterBindResources = 1015808;
166 lvp.v11.maxPerSetDescriptors = 1015808;
167 lvp.limits.maxSamplerAllocationCount = 32768;
168 for (const Device* d : {&radv, &lvp}) {
169 BindlessFeatures f = with_ms(true);
170 EXPECT(bindless::size_bindings(f, d->limits, d->v11, d->v12));
171 for (const D dimension : {D::dim_2d, D::dim_2d_array, D::dim_3d, D::dim_1d}) {
172 EXPECT(count(f, dimension) == bindless::max_images);
173 EXPECT(count(f, dimension) > 4096 + 1); // more than 4096 live images and the fallback
174 }
175 EXPECT(storage_consistent(f));
176 }
177 }
178
179 // A device whose limits stop growth short of max_images: the 2D-array, 3D and 1D arrays share what is left alike,
180 // whichever is grown first.
181 {
182 Device d = uniform(1048576, 1048576);
183 d.v12.maxPerStageDescriptorUpdateAfterBindSampledImages = 65536 + 3 * 20000 + 6 * 256 + bindless::growth_headroom;
184 BindlessFeatures f = with_ms(true);
185 EXPECT(bindless::size_bindings(f, d.limits, d.v11, d.v12));
186 EXPECT(count(f, D::dim_2d) == bindless::max_images);
187 EXPECT(count(f, D::dim_2d_array) == count(f, D::dim_3d) && count(f, D::dim_3d) == count(f, D::dim_1d));
188 EXPECT(count(f, D::dim_1d) > 4096 && count(f, D::dim_1d) <= 20000);
189 EXPECT(totals(f).sampled + bindless::growth_headroom <= d.v12.maxPerStageDescriptorUpdateAfterBindSampledImages);
190 EXPECT(storage_consistent(f));
191 }
192
155 // At today's sizes exactly (5632 sampled images, 1024 samplers, 4352 storage images): no MS pairs. 193 // At today's sizes exactly (5632 sampled images, 1024 samplers, 4352 storage images): no MS pairs.
156 { 194 {
157 Device d = uniform(1048576, 1048576); 195 Device d = uniform(1048576, 1048576);
@@ -191,7 +229,7 @@ int main() {
191 BindlessFeatures uab = with_ms(true), plain = with_ms(false); 229 BindlessFeatures uab = with_ms(true), plain = with_ms(false);
192 EXPECT(bindless::size_bindings(uab, d.limits, d.v11, d.v12)); 230 EXPECT(bindless::size_bindings(uab, d.limits, d.v11, d.v12));
193 EXPECT(bindless::size_bindings(plain, d.limits, d.v11, d.v12)); 231 EXPECT(bindless::size_bindings(plain, d.limits, d.v11, d.v12));
194 EXPECT(count(uab, D::dim_2d) == bindless::max_2d_images); 232 EXPECT(count(uab, D::dim_2d) == bindless::max_images);
195 const Totals t = totals(plain); 233 const Totals t = totals(plain);
196 EXPECT(count(plain, D::dim_2d) > 4096 && count(plain, D::dim_2d) < 16384); 234 EXPECT(count(plain, D::dim_2d) > 4096 && count(plain, D::dim_2d) < 16384);
197 EXPECT(t.sampled + bindless::growth_headroom <= 16384 && t.storage + bindless::growth_headroom <= 16384); 235 EXPECT(t.sampled + bindless::growth_headroom <= 16384 && t.storage + bindless::growth_headroom <= 16384);
@@ -232,7 +270,7 @@ int main() {
232 BindlessFeatures f = with_ms(true); 270 BindlessFeatures f = with_ms(true);
233 EXPECT(bindless::size_bindings(f, d.limits, d.v11, d.v12, all_supported)); 271 EXPECT(bindless::size_bindings(f, d.limits, d.v11, d.v12, all_supported));
234 EXPECT(asked > 0 && asked_within == 0 && missing_storage == 0); 272 EXPECT(asked > 0 && asked_within == 0 && missing_storage == 0);
235 EXPECT(count(f, D::dim_2d) == bindless::max_2d_images && 273 EXPECT(count(f, D::dim_2d) == bindless::max_images &&
236 f.counts[bindless::sampler_binding] == 4000 - bindless::reserved_samplers); 274 f.counts[bindless::sampler_binding] == 4000 - bindless::reserved_samplers);
237 EXPECT(storage(f, D::dim_2d) == bindless::max_storage_indices && storage_consistent(f)); 275 EXPECT(storage(f, D::dim_2d) == bindless::max_storage_indices && storage_consistent(f));
238 276