upleb.uk

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

summaryrefslogtreecommitdiff
path: root/runtime/src
diff options
context:
space:
mode:
authorItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 03:14:28 -0500
committerItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 03:14:28 -0500
commit209f5e1f2a42fcfbf9916c2d0333fa906bb931ef (patch)
tree953cab766d5e0a6aac2d53aa32c434689875ad30 /runtime/src
parentde4d3321a34a6c4bed5ba5afe5fb5328095ceab1 (diff)
parentea512f284ce3b58c144850d70371091e1522ce72 (diff)
Merge pull request #1199 from quackottu
Diffstat (limited to 'runtime/src')
-rw-r--r--runtime/src/vulkan_bindless.h184
1 files changed, 150 insertions, 34 deletions
diff --git a/runtime/src/vulkan_bindless.h b/runtime/src/vulkan_bindless.h
index f68b6f292..3bf07fa5d 100644
--- a/runtime/src/vulkan_bindless.h
+++ b/runtime/src/vulkan_bindless.h
@@ -11,14 +11,17 @@
11// dimension: 0 = 2D, 1 = 2D array, 2 = 3D, 3 = 1D (the translator's STORE_DIMS); class: 0 = float, 1 = uint, 2 = sint. 11// dimension: 0 = 2D, 1 = 2D array, 2 = 3D, 3 = 1D (the translator's STORE_DIMS); class: 0 = float, 1 = uint, 2 = sint.
12// bindings 20/21: sampled multisample 2D images / 2D arrays, 256 each (runtime SRVs). 12// bindings 20/21: sampled multisample 2D images / 2D arrays, 256 each (runtime SRVs).
13// bindings 22/23 and 24/25 are their UINT and SINT equivalents on devices supporting those classes. 13// bindings 22/23 and 24/25 are their UINT and SINT equivalents on devices supporting those classes.
14// These are the default counts (BindlessFeatures::counts). size_bindings() sizes the 2D, sampler and storage arrays
15// from the device's limits instead; the shaders declare runtime arrays, so any count works for them.
14// 16//
15// A shader turns a T# or S# into an index through the hash table (descriptor_table.h) and uses that index in 17// A shader turns a T# or S# into an index through the hash table (descriptor_table.h) and uses that index in
16// whichever binding the instruction calls for: the sampled array of the image's dimension, or one of its storage 18// whichever binding the instruction calls for: the sampled array of the image's dimension, or one of its storage
17// arrays. So an image has one index, the same in every binding of its dimension, and each dimension has its own 19// arrays. So an image has one index, the same in every binding of its dimension, and each dimension has its own
18// index space. The storage arrays hold 256, so an image with storage views gets an index below 256; one without 20// index space. The storage arrays are shorter (storage_capacity()), so an image with storage views gets an index
19// takes a higher index while there is one. Index 0 of every array is a fallback, because a miss gives 0: a 1x1 21// they hold; one without takes a higher index while there is one. Index 0 of every array is a fallback, because a
20// image of zeros, a nearest clamping sampler, and 1x1 storage images. The caller owns the views and samplers it 22// miss gives 0: a 1x1 image of zeros, a nearest clamping sampler, and 1x1 storage images. The caller owns the views
21// adds and keeps them alive while they are in the set; this class owns only the fallbacks and the table's buffer. 23// and samplers it adds and keeps them alive while they are in the set; this class owns only the fallbacks and the
24// table's buffer.
22// 25//
23// Device features: runtimeDescriptorArray for the shaders. With BindlessFeatures::update_after_bind 26// Device features: runtimeDescriptorArray for the shaders. With BindlessFeatures::update_after_bind
24// (descriptorBindingSampledImageUpdateAfterBind, ...StorageImage..., ...StorageBuffer...) flush() may run while 27// (descriptorBindingSampledImageUpdateAfterBind, ...StorageImage..., ...StorageBuffer...) flush() may run while
@@ -62,12 +65,19 @@ struct StorageViews {
62 VkImageView r32ui = VK_NULL_HANDLE; 65 VkImageView r32ui = VK_NULL_HANDLE;
63}; 66};
64 67
68namespace bindless {
69inline constexpr std::uint32_t binding_count = 26;
70constexpr std::array<std::uint32_t, binding_count> default_counts();
71} // namespace bindless
72
65struct BindlessFeatures { 73struct BindlessFeatures {
66 bool update_after_bind = false; 74 bool update_after_bind = false;
67 bool partially_bound = false; 75 bool partially_bound = false;
68 // Fallback sample counts for RGBA8_UNORM, R32_UINT, R32_SINT. A single sample omits that class's MS bindings. 76 // Fallback sample counts for RGBA8_UNORM, R32_UINT, R32_SINT. A single sample omits that class's MS bindings.
69 std::array<VkSampleCountFlagBits, 3> ms_samples{ 77 std::array<VkSampleCountFlagBits, 3> ms_samples{
70 VK_SAMPLE_COUNT_1_BIT, VK_SAMPLE_COUNT_1_BIT, VK_SAMPLE_COUNT_1_BIT}; 78 VK_SAMPLE_COUNT_1_BIT, VK_SAMPLE_COUNT_1_BIT, VK_SAMPLE_COUNT_1_BIT};
79 // Descriptors in each binding, by binding number: bindless::bindings by default, or what size_bindings() chose.
80 std::array<std::uint32_t, bindless::binding_count> counts = bindless::default_counts();
71}; 81};
72 82
73namespace bindless { 83namespace bindless {
@@ -79,7 +89,6 @@ struct Binding {
79 89
80inline constexpr std::uint32_t table_binding = 2; 90inline constexpr std::uint32_t table_binding = 2;
81inline constexpr std::uint32_t sampler_binding = 1; 91inline constexpr std::uint32_t sampler_binding = 1;
82inline constexpr std::uint32_t storage_indices = 256; // what every storage array of bindings 8-19 holds
83inline constexpr std::uint32_t first_ms_binding = 20; 92inline constexpr std::uint32_t first_ms_binding = 20;
84inline constexpr std::uint32_t no_binding = 0xffffffffu; 93inline constexpr std::uint32_t no_binding = 0xffffffffu;
85 94
@@ -100,6 +109,14 @@ inline constexpr std::array<Binding, 26> bindings = {{
100 {VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 256}, {VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 256}, 109 {VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 256}, {VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 256},
101}}; 110}};
102 111
112static_assert(bindings.size() == binding_count);
113
114constexpr std::array<std::uint32_t, binding_count> default_counts() {
115 std::array<std::uint32_t, binding_count> counts{};
116 for (std::uint32_t b = 0; b < binding_count; ++b) counts[b] = bindings[b].count;
117 return counts;
118}
119
103constexpr bool binding_enabled(std::uint32_t binding, const BindlessFeatures& features) { 120constexpr bool binding_enabled(std::uint32_t binding, const BindlessFeatures& features) {
104 return binding < first_ms_binding || features.ms_samples[(binding - first_ms_binding) / 2] != VK_SAMPLE_COUNT_1_BIT; 121 return binding < first_ms_binding || features.ms_samples[(binding - first_ms_binding) / 2] != VK_SAMPLE_COUNT_1_BIT;
105} 122}
@@ -108,15 +125,16 @@ constexpr bool binding_enabled(std::uint32_t binding, const BindlessFeatures& fe
108// per-stage or per-set limits have no room for additional pairs of MS arrays. 125// per-stage or per-set limits have no room for additional pairs of MS arrays.
109constexpr void limit_ms_bindings(BindlessFeatures& features, std::uint32_t sampled_limit, 126constexpr void limit_ms_bindings(BindlessFeatures& features, std::uint32_t sampled_limit,
110 std::uint32_t resource_limit) { 127 std::uint32_t resource_limit) {
128 const auto& counts = features.counts;
111 std::uint32_t sampled = 0, total = 0; 129 std::uint32_t sampled = 0, total = 0;
112 for (std::uint32_t b = 0; b < first_ms_binding; ++b) { 130 for (std::uint32_t b = 0; b < first_ms_binding; ++b) {
113 if (bindings[b].type == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) sampled += bindings[b].count; 131 if (bindings[b].type == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) sampled += counts[b];
114 if (bindings[b].type != VK_DESCRIPTOR_TYPE_SAMPLER) total += bindings[b].count; 132 if (bindings[b].type != VK_DESCRIPTOR_TYPE_SAMPLER) total += counts[b];
115 } 133 }
116 for (std::uint32_t c = 0; c < features.ms_samples.size(); ++c) { 134 for (std::uint32_t c = 0; c < features.ms_samples.size(); ++c) {
117 if (features.ms_samples[c] == VK_SAMPLE_COUNT_1_BIT) continue; 135 if (features.ms_samples[c] == VK_SAMPLE_COUNT_1_BIT) continue;
118 const auto b = first_ms_binding + 2 * c; 136 const auto b = first_ms_binding + 2 * c;
119 const auto pair = bindings[b].count + bindings[b + 1].count; 137 const auto pair = counts[b] + counts[b + 1];
120 if (sampled + pair > sampled_limit || total + pair > resource_limit) { 138 if (sampled + pair > sampled_limit || total + pair > resource_limit) {
121 features.ms_samples[c] = VK_SAMPLE_COUNT_1_BIT; 139 features.ms_samples[c] = VK_SAMPLE_COUNT_1_BIT;
122 } else { 140 } else {
@@ -126,23 +144,6 @@ constexpr void limit_ms_bindings(BindlessFeatures& features, std::uint32_t sampl
126 } 144 }
127} 145}
128 146
129inline void limit_ms_bindings(BindlessFeatures& features, const VkPhysicalDeviceLimits& limits,
130 const VkPhysicalDeviceVulkan12Properties& indexed) {
131 const auto sampled = features.update_after_bind
132 ? std::min(indexed.maxPerStageDescriptorUpdateAfterBindSampledImages,
133 indexed.maxDescriptorSetUpdateAfterBindSampledImages)
134 : std::min(limits.maxPerStageDescriptorSampledImages, limits.maxDescriptorSetSampledImages);
135 auto resources = features.update_after_bind ? indexed.maxPerStageUpdateAfterBindResources : limits.maxPerStageResources;
136 // Fragment outputs count as stage resources. D3D12 allows up to eight render targets.
137 resources -= std::min(resources, std::min(limits.maxColorAttachments, 8u));
138 if (features.update_after_bind) {
139 // Standalone samplers count in the pool, but do not count against the per-stage resource limit.
140 const auto pool = indexed.maxUpdateAfterBindDescriptorsInAllPools;
141 resources = std::min(resources, pool - std::min(pool, bindings[sampler_binding].count));
142 }
143 limit_ms_bindings(features, sampled, resources);
144}
145
146constexpr bool multisampled(ImageDimension dimension) { 147constexpr bool multisampled(ImageDimension dimension) {
147 return dimension == ImageDimension::dim_2d_ms || dimension == ImageDimension::dim_2d_ms_array; 148 return dimension == ImageDimension::dim_2d_ms || dimension == ImageDimension::dim_2d_ms_array;
148} 149}
@@ -161,8 +162,114 @@ constexpr std::uint32_t r32ui_binding(ImageDimension dimension) {
161 return dimension == ImageDimension::dim_2d ? 4 : dimension == ImageDimension::dim_3d ? 7 : no_binding; 162 return dimension == ImageDimension::dim_2d ? 4 : dimension == ImageDimension::dim_3d ? 7 : no_binding;
162} 163}
163 164
164// How many images of a dimension the set holds, the fallback included. 165// What size_bindings() grows to where the device's limits allow. At 32-64 bytes a descriptor the whole set is then
165constexpr std::uint32_t image_capacity(ImageDimension dimension) { return bindings[sampled_binding(dimension)].count; } 166// 3-6 MiB (93793 descriptors on an RTX 5070).
167inline constexpr std::uint32_t max_2d_images = 65536;
168inline constexpr std::uint32_t max_storage_indices = 4096; // in each storage array, at most its dimension's images
169// A full D3D12 shader-visible sampler heap (2048) and room for literal and static S#s, within what the device can
170// create (maxSamplerAllocationCount, at least 4000) less the samplers that are not in the set.
171inline constexpr std::uint32_t max_samplers = 4096;
172inline constexpr std::uint32_t reserved_samplers = 64;
173// Growth leaves this many descriptors of each limit to the other sets of a pipeline layout.
174inline constexpr std::uint32_t growth_headroom = 64;
175
176// Sizes the 2D image, sampler and storage arrays from the device's limits: the update-after-bind ones with
177// features.update_after_bind, the plain ones otherwise. Every binding is visible to every stage, so the per-stage
178// limits apply to the whole set; fragment outputs count as stage resources (D3D12 allows eight render targets) and
179// standalone samplers do not, though they count in an update-after-bind pool.
180// 1. The default counts, or as much of them as the device holds: samplers, then storage, then 2D images.
181// 2. The MS pairs that fit beside them (limit_ms_bindings, which may turn classes off).
182// 3. Growth towards the maximums above, in the same order, within maxPerSetDescriptors. That limit only says
183// what is sure to work (vkGetDescriptorSetLayoutSupport may allow more), so it never shrinks step 1.
184// A storage array holds the smaller of the storage count and its dimension's images: add_image never gives a
185// storage view an index past the sampled array. The other bindings keep their default counts.
186// Sets features.counts; returns false when a count is below its default because the device's limits are.
187inline bool size_bindings(BindlessFeatures& features, const VkPhysicalDeviceLimits& limits,
188 const VkPhysicalDeviceVulkan11Properties& v11,
189 const VkPhysicalDeviceVulkan12Properties& v12) {
190 const bool uab = features.update_after_bind;
191 const std::uint32_t sampled_limit =
192 uab ? std::min(v12.maxPerStageDescriptorUpdateAfterBindSampledImages,
193 v12.maxDescriptorSetUpdateAfterBindSampledImages)
194 : std::min(limits.maxPerStageDescriptorSampledImages, limits.maxDescriptorSetSampledImages);
195 const std::uint32_t sampler_limit =
196 uab ? std::min(v12.maxPerStageDescriptorUpdateAfterBindSamplers, v12.maxDescriptorSetUpdateAfterBindSamplers)
197 : std::min(limits.maxPerStageDescriptorSamplers, limits.maxDescriptorSetSamplers);
198 const std::uint32_t storage_limit =
199 uab ? std::min(v12.maxPerStageDescriptorUpdateAfterBindStorageImages,
200 v12.maxDescriptorSetUpdateAfterBindStorageImages)
201 : std::min(limits.maxPerStageDescriptorStorageImages, limits.maxDescriptorSetStorageImages);
202 std::uint32_t resource_limit = uab ? v12.maxPerStageUpdateAfterBindResources : limits.maxPerStageResources;
203 resource_limit -= std::min(resource_limit, std::min(limits.maxColorAttachments, 8u));
204 const std::uint32_t pool_limit = uab ? v12.maxUpdateAfterBindDescriptorsInAllPools : 0xffffffffu;
205
206 auto& counts = features.counts;
207 counts = default_counts();
208 std::uint32_t images = 1, samplers = 1, storage = 1;
209 // Until the end the 2D storage arrays are not capped by the 2D images, which grow after them: capping can only
210 // take descriptors away.
211 const auto apply = [&](bool final) {
212 counts[sampled_binding(ImageDimension::dim_2d)] = images;
213 counts[sampler_binding] = samplers;
214 for (std::uint32_t d = 0; d < 4; ++d) {
215 const auto dimension = ImageDimension(d);
216 const bool capped = final || dimension != ImageDimension::dim_2d;
217 const std::uint32_t held = capped ? std::min(storage, counts[sampled_binding(dimension)]) : storage;
218 for (std::uint32_t c = 0; c < 3; ++c) counts[storage_binding(dimension, c)] = held;
219 if (r32ui_binding(dimension) != no_binding) counts[r32ui_binding(dimension)] = held;
220 }
221 };
222 const auto fits = [&](std::uint32_t headroom, std::uint64_t set_limit) {
223 apply(false);
224 std::uint64_t sampled = 0, sampler = 0, stored = 0, buffers = 0;
225 for (std::uint32_t b = 0; b < binding_count; ++b) {
226 if (!binding_enabled(b, features)) continue;
227 const auto type = bindings[b].type;
228 (type == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE ? sampled
229 : type == VK_DESCRIPTOR_TYPE_SAMPLER ? sampler
230 : type == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE ? stored
231 : buffers) += counts[b];
232 }
233 const auto within = [&](std::uint64_t n, std::uint32_t limit) { return n + headroom <= limit; };
234 const std::uint64_t all = sampled + sampler + stored + buffers;
235 return within(sampled, sampled_limit) && within(sampler, sampler_limit) && within(stored, storage_limit) &&
236 within(sampled + stored + buffers, resource_limit) && all <= pool_limit && all <= set_limit;
237 };
238 // Raises n to the largest value up to `high` that fits; leaves it where it is when none does.
239 const auto grow = [&](std::uint32_t& n, std::uint32_t high, std::uint32_t headroom, std::uint64_t set_limit) {
240 std::uint32_t low = n;
241 while (low < high) {
242 n = low + (high - low + 1) / 2;
243 if (fits(headroom, set_limit)) low = n;
244 else high = n - 1;
245 }
246 n = low;
247 };
248
249 constexpr std::uint64_t no_limit = ~0ull;
250 const auto ms_samples = features.ms_samples;
251 features.ms_samples.fill(VK_SAMPLE_COUNT_1_BIT);
252 grow(samplers, bindings[sampler_binding].count, 0, no_limit);
253 grow(storage, bindings[storage_binding(ImageDimension::dim_2d, 0)].count, 0, no_limit);
254 grow(images, bindings[sampled_binding(ImageDimension::dim_2d)].count, 0, no_limit);
255 apply(false);
256 const bool full = images == bindings[0].count && samplers == bindings[sampler_binding].count &&
257 storage == bindings[storage_binding(ImageDimension::dim_2d, 0)].count;
258 features.ms_samples = ms_samples;
259 limit_ms_bindings(features, sampled_limit, std::min(resource_limit, pool_limit - std::min(pool_limit, samplers)));
260
261 std::uint64_t set_limit = 0;
262 for (std::uint32_t b = 0; b < binding_count; ++b)
263 if (binding_enabled(b, features)) set_limit += counts[b];
264 set_limit = std::max(set_limit, std::uint64_t(v11.maxPerSetDescriptors));
265 const std::uint32_t creatable =
266 limits.maxSamplerAllocationCount - std::min(limits.maxSamplerAllocationCount, reserved_samplers);
267 grow(samplers, std::max(samplers, std::min(max_samplers, creatable)), growth_headroom, set_limit);
268 grow(images, std::max(images, max_2d_images), growth_headroom, set_limit);
269 grow(storage, std::max(storage, max_storage_indices), growth_headroom, set_limit);
270 apply(true);
271 return full;
272}
166 273
167} // namespace bindless 274} // namespace bindless
168 275
@@ -194,6 +301,15 @@ public:
194 bool supports_ms_class(std::uint32_t component_class) const { 301 bool supports_ms_class(std::uint32_t component_class) const {
195 return component_class < classes && features_.ms_samples[component_class] != VK_SAMPLE_COUNT_1_BIT; 302 return component_class < classes && features_.ms_samples[component_class] != VK_SAMPLE_COUNT_1_BIT;
196 } 303 }
304 // How many images of a dimension the set holds, the fallback included, and how many of the lowest of those
305 // indices its storage arrays hold (0 for the MS dimensions, which have none). The same for samplers.
306 std::uint32_t image_capacity(ImageDimension dimension) const {
307 return features_.counts[bindless::sampled_binding(dimension)];
308 }
309 std::uint32_t storage_capacity(ImageDimension dimension) const {
310 return bindless::multisampled(dimension) ? 0 : features_.counts[bindless::storage_binding(dimension, 0)];
311 }
312 std::uint32_t sampler_capacity() const { return features_.counts[bindless::sampler_binding]; }
197 // Set 0 of every pipeline layout made for translated shaders. 313 // Set 0 of every pipeline layout made for translated shaders.
198 VkDescriptorSetLayout layout() const { return layout_; } 314 VkDescriptorSetLayout layout() const { return layout_; }
199 // Bound at set 0. The same set for the life of this object: flush() updates it in place. 315 // Bound at set 0. The same set for the life of this object: flush() updates it in place.
@@ -239,7 +355,7 @@ public:
239 const bool stores = storage.as_float || storage.as_uint || storage.as_sint || storage.r32ui; 355 const bool stores = storage.as_float || storage.as_uint || storage.as_sint || storage.r32ui;
240 if (bindless::multisampled(dimension) && (stores || !supports_ms_class(sampled_class))) return 0; 356 if (bindless::multisampled(dimension) && (stores || !supports_ms_class(sampled_class))) return 0;
241 auto& used = image_used_[std::uint32_t(dimension)]; 357 auto& used = image_used_[std::uint32_t(dimension)];
242 const std::uint32_t low_end = std::min(std::uint32_t(used.size()), bindless::storage_indices); 358 const std::uint32_t low_end = std::min(std::uint32_t(used.size()), storage_capacity(dimension));
243 std::uint32_t index = stores ? 0 : allocate(used, low_end, std::uint32_t(used.size())); 359 std::uint32_t index = stores ? 0 : allocate(used, low_end, std::uint32_t(used.size()));
244 if (!index) index = allocate(used, 1, low_end); 360 if (!index) index = allocate(used, 1, low_end);
245 if (index) write_image(dimension, index, sampled, sampled_layout, storage, sampled_class); 361 if (index) write_image(dimension, index, sampled, sampled_layout, storage, sampled_class);
@@ -422,10 +538,10 @@ private:
422 std::uint32_t count = 0; 538 std::uint32_t count = 0;
423 for (std::uint32_t b = 0; b < bindless::bindings.size(); ++b) { 539 for (std::uint32_t b = 0; b < bindless::bindings.size(); ++b) {
424 if (!bindless::binding_enabled(b, features_)) continue; 540 if (!bindless::binding_enabled(b, features_)) continue;
425 entries[count] = {b, bindless::bindings[b].type, bindless::bindings[b].count, VK_SHADER_STAGE_ALL, nullptr}; 541 entries[count] = {b, bindless::bindings[b].type, features_.counts[b], VK_SHADER_STAGE_ALL, nullptr};
426 flags[count] = (features_.update_after_bind ? VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT : 0) | 542 flags[count] = (features_.update_after_bind ? VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT : 0) |
427 (features_.partially_bound ? VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT : 0); 543 (features_.partially_bound ? VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT : 0);
428 sizes[count] = {bindless::bindings[b].type, bindless::bindings[b].count}; 544 sizes[count] = {bindless::bindings[b].type, features_.counts[b]};
429 ++count; 545 ++count;
430 } 546 }
431 VkDescriptorSetLayoutBindingFlagsCreateInfo flags_info{ 547 VkDescriptorSetLayoutBindingFlagsCreateInfo flags_info{
@@ -451,10 +567,10 @@ private:
451 if (vk_.vkAllocateDescriptorSets(device_, &set_info, &set_) != VK_SUCCESS) return false; 567 if (vk_.vkAllocateDescriptorSets(device_, &set_info, &set_) != VK_SUCCESS) return false;
452 568
453 for (std::uint32_t d = 0; d < dimensions; ++d) { 569 for (std::uint32_t d = 0; d < dimensions; ++d) {
454 image_used_[d].assign(bindless::image_capacity(ImageDimension(d)), 0); 570 image_used_[d].assign(image_capacity(ImageDimension(d)), 0);
455 image_used_[d][0] = 1; 571 image_used_[d][0] = 1;
456 } 572 }
457 sampler_used_.assign(bindless::bindings[bindless::sampler_binding].count, 0); 573 sampler_used_.assign(sampler_capacity(), 0);
458 sampler_used_[0] = 1; 574 sampler_used_[0] = 1;
459 return true; 575 return true;
460 } 576 }
@@ -716,7 +832,7 @@ private:
716 infos.reserve(bindless::bindings.size()); 832 infos.reserve(bindless::bindings.size());
717 for (std::uint32_t b = 0; b < bindless::bindings.size(); ++b) { 833 for (std::uint32_t b = 0; b < bindless::bindings.size(); ++b) {
718 if (b == bindless::table_binding || !bindless::binding_enabled(b, features_)) continue; 834 if (b == bindless::table_binding || !bindless::binding_enabled(b, features_)) continue;
719 const std::uint32_t count = features_.partially_bound ? 1 : bindless::bindings[b].count; 835 const std::uint32_t count = features_.partially_bound ? 1 : features_.counts[b];
720 infos.emplace_back(count, fallback_info(b)); 836 infos.emplace_back(count, fallback_info(b));
721 VkWriteDescriptorSet write{VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET}; 837 VkWriteDescriptorSet write{VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET};
722 write.dstSet = set_; 838 write.dstSet = set_;
@@ -762,7 +878,7 @@ private:
762 queue(sampled_at, index, 878 queue(sampled_at, index,
763 sampled ? VkDescriptorImageInfo{VK_NULL_HANDLE, sampled, sampled_layout} : fallback_info(sampled_at)); 879 sampled ? VkDescriptorImageInfo{VK_NULL_HANDLE, sampled, sampled_layout} : fallback_info(sampled_at));
764 const auto store = [&](std::uint32_t binding, VkImageView view) { 880 const auto store = [&](std::uint32_t binding, VkImageView view) {
765 if (binding == bindless::no_binding || index >= bindless::bindings[binding].count) return; 881 if (binding == bindless::no_binding || index >= features_.counts[binding]) return;
766 queue(binding, index, 882 queue(binding, index,
767 view ? VkDescriptorImageInfo{VK_NULL_HANDLE, view, VK_IMAGE_LAYOUT_GENERAL} : fallback_info(binding)); 883 view ? VkDescriptorImageInfo{VK_NULL_HANDLE, view, VK_IMAGE_LAYOUT_GENERAL} : fallback_info(binding));
768 }; 884 };