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 21:44:23 -0500
committerJan Trencansky <jan.trencansky@protonmail.com>2026-11-24 21:44:23 -0500
commitb8563e949ed389fff20be91c73687a70b5213469 (patch)
treed69c6817854ce0a14a67ff1fd0f1c39dec68a91f /runtime/test/bindless_sizing_test.cpp
parent00fc23b9a9eeb1a75f1fec2b58024bea15c26663 (diff)
parent7ae1dd3de34f1542242bc8ccfc80d9b97d20cc01 (diff)
Merge main into D3D-448-GRAPHICS (#974)
main already lays graphics root arguments out in the console layout (from s8, one dword per table: #939's graphics-root-layout patch in #984's form, pack_stage(Stage::Pixel), RootArgumentLayout::graphics_console, graphics_arguments_end, LEONIDA_GRAPHICS_STAGE_LAYOUT=0 for pack()). That form stays. What this pull request adds beyond it is carried onto it: the mesh-shader root window (translator, index "root_window", mesh_ok, the two refusals) and its tests. Its own graphics spill handling (Spill::block) and LEONIDA_GRAPHICS_ROOT_LAYOUT=pc are not carried: main keeps pack()'s s0 layout for a graphics signature past s31, and its switch does what =pc did. Conflicts: - runtime/src/root_signature.h, root_signature.cpp: main's pack_stage (compute spill array, spill_dword); the Spill enum, first_spilled and spilled_dwords dropped. The header keeps the PR's evidence note, with Stage::Pixel. - runtime/shims/d3d12_com.h: main's comment and members, with the mesh window described; mesh_ok added (false by default, set only for a console-layout signature that Stage::Mesh also places); the PR's second graphics_console dropped. - runtime/shims/d3d12_vulkan_device.cpp (CreateRootSignature): main's pixel/packed form; the PR's Stage::Mesh pack and its log line added, mesh_ok = pixel.ok && mesh.ok. The mesh-shader refusal without "root_window" (no conflict) stays. - runtime/shims/d3d12_com.cpp: DispatchMesh keeps main's any_nonempty_viewport() and graphics_user_data() after the PR's mesh_ok check; address() keeps main's comment. The PR's kNoSgpr guard in constants()/address() stays, reworded: in main a spilled compute parameter has first_sgpr kNoSgpr, and kNoSgpr + offset wrapped round to s0. - runtime/src/shader_library.h: both (main's wave64_graphics, the PR's root_window). - runtime/test/d3d12_mesh_test.cpp: main's mesh shader-kind byte on both containers (also the PR's ms_old); the PR's two-parameter signature replaces main's 25-dword padding onto the s0 layout; both test blocks kept (the PR's window refusals, main's DISPATCH_MESH command signature), each in its own scope. The =pc case is dropped (main's switch is read once per process). - runtime/CMakeLists.txt (no conflict): the mesh test uses ps_draw.spv again; the ps_draw_s0.spv rule is gone. - runtime/test/glsl/ps_draw.frag, vs_depth.vert, vs_draw.vert, vs_draw_int.vert, ps_depth_write.frag and runtime/test/shaders/ps_m15, ps_m2, ps_m2_array, ps_m2_literal, ps_m2_uoff, ps_m3, ps_m3_post, ps_m3_query, vs_m15, vs_m3 (.asm): main's (the same s8 rewrite done twice); ps_draw.frag's mesh-test note updated. - runtime/test/root_signature_test.cpp (no conflict): the Spill::block cases dropped, the window cases kept. - docs/design.md: main's rows (loop guard, direct resource heap) and the PR's user-data row. - docs/d3d12_vulkan.md (no conflict): section 3.5 and the CreateRootSignature bullet rewritten for main's form. 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));