diff options
| author | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-24 21:55:03 -0500 |
|---|---|---|
| committer | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-24 21:55:03 -0500 |
| commit | 50740a1bc541b2d007f87cad86f7a776f994f3e7 (patch) | |
| tree | 8a0baed3231cd9ccc85987ba5e2ee7d4173dd0f8 /runtime/test/bindless_sizing_test.cpp | |
| parent | e39adc942cfe473f3febbf9ff30a6787baa705bb (diff) | |
| parent | f78385646c5483d8bcd7d4161ee5dcd48d2b7fb3 (diff) | |
Merge main into carry/old-9921-ms-compressed-exports
The "Mesh shaders" row of docs/design.md changed on main (#802); the
compressed-export sentence is added to main's version of the row.
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.cpp | 61 |
1 files changed, 53 insertions, 8 deletions
diff --git a/runtime/test/bindless_sizing_test.cpp b/runtime/test/bindless_sizing_test.cpp index 4553f25b6..b7d501aab 100644 --- a/runtime/test/bindless_sizing_test.cpp +++ b/runtime/test/bindless_sizing_test.cpp | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | // bindless::size_bindings with synthetic device limits: no GPU. The counts of set 0 come from the device's descriptor | 1 | // bindless::size_bindings with synthetic device limits: no GPU. The counts of set 0 come from the device's descriptor |
| 2 | // limits (vulkan_bindless.h): today's sizes where a device is at them, larger 2D, sampler and storage arrays where it | 2 | // limits (vulkan_bindless.h): today's sizes where a device is at them, larger image, sampler and storage arrays where |
| 3 | // has room, and less where it is below them. | 3 | // it has room, and less where it is below them. |
| 4 | #ifndef VK_NO_PROTOTYPES | 4 | #ifndef VK_NO_PROTOTYPES |
| 5 | #define VK_NO_PROTOTYPES | 5 | #define VK_NO_PROTOTYPES |
| 6 | #endif | 6 | #endif |
| @@ -84,6 +84,13 @@ bool storage_consistent(const BindlessFeatures& f) { | |||
| 84 | f.counts[bindless::r32ui_binding(dimension)] != held) | 84 | f.counts[bindless::r32ui_binding(dimension)] != held) |
| 85 | return false; | 85 | return false; |
| 86 | } | 86 | } |
| 87 | // 1D arrays have no sampled capacity, but all three storage classes are always present. | ||
| 88 | const auto array = ImageDimension::dim_1d_array; | ||
| 89 | const auto held = storage(f, array); | ||
| 90 | for (std::uint32_t c = 0; c < 3; ++c) { | ||
| 91 | const auto binding = bindless::storage_binding(array, c); | ||
| 92 | if (!held || !bindless::binding_enabled(binding, f) || f.counts[binding] != held) return false; | ||
| 93 | } | ||
| 87 | return true; | 94 | return true; |
| 88 | } | 95 | } |
| 89 | 96 | ||
| @@ -93,6 +100,33 @@ int main() { | |||
| 93 | using D = ImageDimension; | 100 | using D = ImageDimension; |
| 94 | constexpr auto defaults = bindless::default_counts(); | 101 | constexpr auto defaults = bindless::default_counts(); |
| 95 | static_assert(defaults[0] == 4096 && defaults[bindless::sampler_binding] == 1024 && defaults[8] == 256); | 102 | static_assert(defaults[0] == 4096 && defaults[bindless::sampler_binding] == 1024 && defaults[8] == 256); |
| 103 | static_assert(bindless::sampled_binding(D::dim_1d_array) == bindless::no_binding); | ||
| 104 | static_assert(bindless::storage_binding(D::dim_1d_array, 0) == 26 && | ||
| 105 | bindless::storage_binding(D::dim_1d_array, 1) == 27 && | ||
| 106 | bindless::storage_binding(D::dim_1d_array, 2) == 28); | ||
| 107 | static_assert(bindless::sampled_binding(D::dim_2d_ms, 0) == 20 && | ||
| 108 | bindless::sampled_binding(D::dim_2d_ms_array, 0) == 21 && | ||
| 109 | bindless::sampled_binding(D::dim_2d_ms, 1) == 22 && | ||
| 110 | bindless::sampled_binding(D::dim_2d_ms_array, 1) == 23 && | ||
| 111 | bindless::sampled_binding(D::dim_2d_ms, 2) == 24 && | ||
| 112 | bindless::sampled_binding(D::dim_2d_ms_array, 2) == 25); | ||
| 113 | |||
| 114 | // SetLayout compacts disabled MS pairs without renumbering either the enabled pair or the storage-only tail. | ||
| 115 | { | ||
| 116 | BindlessFeatures f{}; | ||
| 117 | f.update_after_bind = f.partially_bound = true; | ||
| 118 | f.ms_samples[1] = VK_SAMPLE_COUNT_4_BIT; | ||
| 119 | const bindless::SetLayout layout(f); | ||
| 120 | EXPECT(layout.info.bindingCount == 25 && layout.flags_info.bindingCount == 25); | ||
| 121 | EXPECT(layout.entries[20].binding == 22 && layout.entries[21].binding == 23); | ||
| 122 | for (std::uint32_t c = 0; c < 3; ++c) { | ||
| 123 | const auto& entry = layout.entries[22 + c]; | ||
| 124 | EXPECT(entry.binding == 26 + c && entry.descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE && | ||
| 125 | entry.descriptorCount == 256); | ||
| 126 | EXPECT(layout.flags[22 + c] == | ||
| 127 | (VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT | VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT)); | ||
| 128 | } | ||
| 129 | } | ||
| 96 | 130 | ||
| 97 | // An RTX 5070 (driver 621.24): 1048576 of each descriptor type, update-after-bind or not, 4000 samplers. | 131 | // An RTX 5070 (driver 621.24): 1048576 of each descriptor type, update-after-bind or not, 4000 samplers. |
| 98 | for (const bool update_after_bind : {true, false}) { | 132 | for (const bool update_after_bind : {true, false}) { |
| @@ -103,8 +137,14 @@ int main() { | |||
| 103 | EXPECT(f.counts[bindless::sampler_binding] == 4000 - bindless::reserved_samplers); | 137 | EXPECT(f.counts[bindless::sampler_binding] == 4000 - bindless::reserved_samplers); |
| 104 | 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 |
| 105 | EXPECT(storage(f, D::dim_2d) == bindless::max_storage_indices); | 139 | EXPECT(storage(f, D::dim_2d) == bindless::max_storage_indices); |
| 106 | EXPECT(storage(f, D::dim_2d_array) == 1024 && storage(f, D::dim_3d) == 256 && storage(f, D::dim_1d) == 256); | 140 | // The other dimensions grow too (a title's cube maps, texture arrays and 1D lookups outnumber the defaults); |
| 107 | EXPECT(count(f, D::dim_2d_array) == 1024 && count(f, D::dim_3d) == 256 && count(f, D::dim_1d) == 256); | 141 | // their 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 && | ||
| 143 | count(f, D::dim_3d) == bindless::max_3d_images && count(f, D::dim_1d) == bindless::max_1d_images); | ||
| 144 | EXPECT(storage(f, D::dim_2d_array) == bindless::max_storage_indices && | ||
| 145 | storage(f, D::dim_3d) == 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); | ||
| 108 | 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); |
| 109 | EXPECT(storage_consistent(f)); | 149 | EXPECT(storage_consistent(f)); |
| 110 | if (update_after_bind) | 150 | if (update_after_bind) |
| @@ -112,12 +152,12 @@ int main() { | |||
| 112 | 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); |
| 113 | } | 153 | } |
| 114 | 154 | ||
| 115 | // At today's sizes exactly (5632 sampled images, 1024 samplers, 3584 storage images): today's set, no MS pairs. | 155 | // At today's sizes exactly (5632 sampled images, 1024 samplers, 4352 storage images): no MS pairs. |
| 116 | { | 156 | { |
| 117 | Device d = uniform(1048576, 1048576); | 157 | Device d = uniform(1048576, 1048576); |
| 118 | d.v12.maxPerStageDescriptorUpdateAfterBindSampledImages = 5632; | 158 | d.v12.maxPerStageDescriptorUpdateAfterBindSampledImages = 5632; |
| 119 | d.v12.maxPerStageDescriptorUpdateAfterBindSamplers = 1024; | 159 | d.v12.maxPerStageDescriptorUpdateAfterBindSamplers = 1024; |
| 120 | d.v12.maxPerStageDescriptorUpdateAfterBindStorageImages = 3584; | 160 | d.v12.maxPerStageDescriptorUpdateAfterBindStorageImages = 4352; |
| 121 | BindlessFeatures f = with_ms(true); | 161 | BindlessFeatures f = with_ms(true); |
| 122 | EXPECT(bindless::size_bindings(f, d.limits, d.v11, d.v12)); | 162 | EXPECT(bindless::size_bindings(f, d.limits, d.v11, d.v12)); |
| 123 | EXPECT(count(f, D::dim_2d) == 4096 && f.counts[bindless::sampler_binding] == 1024 && | 163 | EXPECT(count(f, D::dim_2d) == 4096 && f.counts[bindless::sampler_binding] == 1024 && |
| @@ -125,6 +165,7 @@ int main() { | |||
| 125 | for (std::uint32_t b = 0; b < bindless::first_ms_binding; ++b) | 165 | for (std::uint32_t b = 0; b < bindless::first_ms_binding; ++b) |
| 126 | if (bindless::bindings[b].type != VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) EXPECT(f.counts[b] == defaults[b]); | 166 | if (bindless::bindings[b].type != VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) EXPECT(f.counts[b] == defaults[b]); |
| 127 | EXPECT(f.ms_samples == (std::array{VK_SAMPLE_COUNT_1_BIT, VK_SAMPLE_COUNT_1_BIT, VK_SAMPLE_COUNT_1_BIT})); | 167 | EXPECT(f.ms_samples == (std::array{VK_SAMPLE_COUNT_1_BIT, VK_SAMPLE_COUNT_1_BIT, VK_SAMPLE_COUNT_1_BIT})); |
| 168 | EXPECT(totals(f).storage == 4352 && storage(f, D::dim_1d_array) == 256); | ||
| 128 | EXPECT(storage_consistent(f)); | 169 | EXPECT(storage_consistent(f)); |
| 129 | } | 170 | } |
| 130 | 171 | ||
| @@ -178,15 +219,19 @@ int main() { | |||
| 178 | Device d = uniform(1048576, 1048576); | 219 | Device d = uniform(1048576, 1048576); |
| 179 | d.v11.maxPerSetDescriptors = 6159; | 220 | d.v11.maxPerSetDescriptors = 6159; |
| 180 | d.limits.maxSamplerAllocationCount = 4000; | 221 | d.limits.maxSamplerAllocationCount = 4000; |
| 181 | unsigned asked = 0, asked_within = 0; | 222 | unsigned asked = 0, asked_within = 0, missing_storage = 0; |
| 182 | const auto all_supported = [&](const BindlessFeatures& candidate) { | 223 | const auto all_supported = [&](const BindlessFeatures& candidate) { |
| 183 | ++asked; | 224 | ++asked; |
| 184 | asked_within += totals(candidate).all <= 6159; | 225 | asked_within += totals(candidate).all <= 6159; |
| 226 | const bindless::SetLayout layout(candidate); | ||
| 227 | const auto& last = layout.entries[layout.info.bindingCount - 1]; | ||
| 228 | missing_storage += last.binding != 28 || last.descriptorType != VK_DESCRIPTOR_TYPE_STORAGE_IMAGE || | ||
| 229 | last.descriptorCount != storage(candidate, D::dim_1d_array); | ||
| 185 | return true; | 230 | return true; |
| 186 | }; | 231 | }; |
| 187 | BindlessFeatures f = with_ms(true); | 232 | BindlessFeatures f = with_ms(true); |
| 188 | EXPECT(bindless::size_bindings(f, d.limits, d.v11, d.v12, all_supported)); | 233 | EXPECT(bindless::size_bindings(f, d.limits, d.v11, d.v12, all_supported)); |
| 189 | EXPECT(asked > 0 && asked_within == 0); | 234 | EXPECT(asked > 0 && asked_within == 0 && missing_storage == 0); |
| 190 | EXPECT(count(f, D::dim_2d) == bindless::max_2d_images && | 235 | EXPECT(count(f, D::dim_2d) == bindless::max_2d_images && |
| 191 | f.counts[bindless::sampler_binding] == 4000 - bindless::reserved_samplers); | 236 | f.counts[bindless::sampler_binding] == 4000 - bindless::reserved_samplers); |
| 192 | EXPECT(storage(f, D::dim_2d) == bindless::max_storage_indices && storage_consistent(f)); | 237 | EXPECT(storage(f, D::dim_2d) == bindless::max_storage_indices && storage_consistent(f)); |