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-24 22:12:48 -0500
committerJan Trencansky <jan.trencansky@protonmail.com>2026-11-24 22:13:02 -0500
commit3ee0037fd3accba459d0d5ecd8acad831174d4d7 (patch)
tree55953ce44091103e4f7c4a2f45490be961282b27 /runtime/test/bindless_sizing_test.cpp
parent9b8707c03dabb59ba2e29b9b0749d3c3eb1f3903 (diff)
parent5115f0887940595aa0f46fed7fc9db28b64151ff (diff)
Merge main into RT-DIRECT-HEAP-GRAPHICS (#1232)
This merges #1064 as prepared (its head + a merge of main), so it brings #1232 up to date with main and with #1064. #1232's branch carried #974 (merged into main since) and an older head of #1064 (7c47fd946). main already supplies the directly indexed heaps to graphics draws (integration #984): graphics_user_data() on DrawInstanced, DrawIndexedInstanced and DispatchMesh, at RootArgumentLayout::graphics_arguments_end (pack_stage(Stage::Pixel)'s end_sgpr, set when the console layout places the signature), LEONIDA_GRAPHICS_DIRECT_HEAPS=0, its notes for a signature on the s0 layout or one that fills s31, and d3d12_graphics_direct_heaps_test (recorded draws and the VS/PS GPU reads). That form stays. What this pull request adds beyond it is carried onto it: the mesh case. Conflicts (all taken from #1064's merged branch, then the PR's mesh parts carried over): - runtime/shims/d3d12_com.cpp: main's graphics_user_data()/with_direct_heaps() and notes. The PR's own graphics_user_data(), GetEnvironmentVariableA switch and no-room notes are main's in another form and dropped. Carried: the comment says a mesh shader reads push dword d as s(d + 8) through #974's window, so it gets the heaps after its arguments from s16 (main's comment still said the mesh stage gets none); and DispatchMesh reports once when a heap falls past the mesh window (push dword 24 and up, s32 for the mesh shader), the case raised in the review of #1232 (mesh_ok accepts arguments up to push dword 24). - runtime/shims/d3d12_com.h, runtime/shims/d3d12_vulkan_device.cpp: main's (graphics_arguments_end from pixel.end_sgpr; the PR set it from its Spill::block form, which main did not take from #974). - runtime/test/glsl/cs_user_data.comp: main's (identical direct-indexing mode). - docs/d3d12_vulkan.md: main's section 3.4 with #1064's compute paragraph; the graphics paragraph's "a mesh shader ... is not modelled" replaced by the mesh window position, cited to issue #14 comment 7143020922 as a report not reproduced here, the window-overflow note and the mesh test. - runtime/test/d3d12_mesh_test.cpp (no conflict): the PR's recorded-argument checks kept (vertex and mesh draw with 4 constants, resource-only rebind, 23 constants, 30 constants); the 30-constant comment now says it keeps pack()'s s0 layout on main. 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.cpp61
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));