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:35:34 -0500
committerJan Trencansky <jan.trencansky@protonmail.com>2026-11-24 22:35:34 -0500
commit6ed716a99a7416f1e8a60c2e38e128876ab752ec (patch)
tree3c35526aa8b96594252c82c278ab19b9aa3a98ba /runtime/test/bindless_sizing_test.cpp
parent028a414fade7058a96e5933d1325f374a0026588 (diff)
parentbfef489cb6307fa4e1dc6ed2c40bfc0ce120d066 (diff)
Merge main into RT-QUEUE-SIGNAL (#430)
Everything below this rung (#414, #416, #427) and the rung's own routing are in main already, through #984 and #939, in main's form; what is left of #430 is its test of queue slot 17, ported onto main's layout detection. Conflicts, all resolved to main's form: - runtime/shims/d3d12_xs_device.cpp: main's queue slot 16/17 rule (a fence there is the newer layout's Signal/Wait, for any caller) replaces the rung's caller-gated rule; main's PresentX routing (slot 30, or 32 once the newer layout is detected, LEONIDA_XS_PRESENT_X_SLOT) and lazily built presenter replace the fixed slot 32 of #414; main's list proxy already translates the CPU handles of console list slots 50 to 54 (#416) and drops unordered access from a depth-stencil texture at slot 76 (#427). - runtime/shims/d3d12_xs_device.h, runtime/shims/xbox_present.cpp, runtime/shims/xbox_present.h, runtime/src/frame_pacer.h: main's shared FrameTokenSource (Logan's piece of #414, as #984 carried it). - runtime/shims/d3d12_xs_desc_clean.h, runtime/test/device_proxy_test.cpp: main's without_depth_stencil_uav and its slot 25/76 test (#427). - runtime/test/xs_proxy_mock_test.cpp: main's file, which already has check_list_cpu_handles (#416's cases and more); the rung's slot 16/17 case is ported to main's form at the end of check_xbox_queue_slots: slot 16 and 17 with a fence reach PC Signal and Wait with the real fence, not the PC getters, and the fence proxy's vtable pointer is unchanged. The rung's host-caller and no-fence expectations are dropped: under main's rule a fence at 16 proves the newer layout, after which those calls answer S_OK. Auto-merged, then set to main's content: - runtime/test/queue_proxy_test.cpp: #414's call of queue slot 32 as an overridden slot; on main slot 32 is routed only on the newer layout and the sweep of the console tail already calls it. 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));