upleb.uk

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

summaryrefslogtreecommitdiff
path: root/runtime/test/vk_bindless_test.cpp
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/test/vk_bindless_test.cpp
parentde4d3321a34a6c4bed5ba5afe5fb5328095ceab1 (diff)
parentea512f284ce3b58c144850d70371091e1522ce72 (diff)
Merge pull request #1199 from quackottu
Diffstat (limited to 'runtime/test/vk_bindless_test.cpp')
-rw-r--r--runtime/test/vk_bindless_test.cpp47
1 files changed, 35 insertions, 12 deletions
diff --git a/runtime/test/vk_bindless_test.cpp b/runtime/test/vk_bindless_test.cpp
index 61de1a91e..f1cc27637 100644
--- a/runtime/test/vk_bindless_test.cpp
+++ b/runtime/test/vk_bindless_test.cpp
@@ -166,7 +166,8 @@ int main(int argc, char** argv) {
166 return unsupported; 166 return unsupported;
167 } 167 }
168 VkPhysicalDeviceVulkan12Properties props12{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES}; 168 VkPhysicalDeviceVulkan12Properties props12{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES};
169 VkPhysicalDeviceProperties2 props{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, &props12}; 169 VkPhysicalDeviceVulkan11Properties props11{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_PROPERTIES, &props12};
170 VkPhysicalDeviceProperties2 props{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, &props11};
170 vkGetPhysicalDeviceProperties2(pd, &props); 171 vkGetPhysicalDeviceProperties2(pd, &props);
171 std::printf("device: %s%s\n", props.properties.deviceName, validation ? " (validation on)" : ""); 172 std::printf("device: %s%s\n", props.properties.deviceName, validation ? " (validation on)" : "");
172 // The pipeline layout pushes the 144-byte translated user-data block. A device with fewer push constant bytes 173 // The pipeline layout pushes the 144-byte translated user-data block. A device with fewer push constant bytes
@@ -462,7 +463,7 @@ int main(int argc, char** argv) {
462 std::uint32_t count = 0; 463 std::uint32_t count = 0;
463 for (std::uint32_t b = 0; b < bindless::bindings.size(); ++b) 464 for (std::uint32_t b = 0; b < bindless::bindings.size(); ++b)
464 if (bindless::bindings[b].type == type && bindless::binding_enabled(b, f)) 465 if (bindless::bindings[b].type == type && bindless::binding_enabled(b, f))
465 count += bindless::bindings[b].count; 466 count += f.counts[b];
466 return count; 467 return count;
467 }; 468 };
468 const auto fits = [&](const BindlessFeatures& f) { 469 const auto fits = [&](const BindlessFeatures& f) {
@@ -513,10 +514,11 @@ int main(int argc, char** argv) {
513 for (int configuration = 0; configuration < configuration_count; ++configuration) { 514 for (int configuration = 0; configuration < configuration_count; ++configuration) {
514 BindlessFeatures flags = configurations[configuration]; 515 BindlessFeatures flags = configurations[configuration];
515 flags.ms_samples[0] = VK_SAMPLE_COUNT_4_BIT; 516 flags.ms_samples[0] = VK_SAMPLE_COUNT_4_BIT;
516 bindless::limit_ms_bindings(flags, props.properties.limits, props12); 517 // A device below the default counts gets a smaller set; this test needs at least those.
518 const bool full = bindless::size_bindings(flags, props.properties.limits, props11, props12);
517 const char* name = flags.update_after_bind && flags.partially_bound ? "update after bind, partially bound" 519 const char* name = flags.update_after_bind && flags.partially_bound ? "update after bind, partially bound"
518 : flags.update_after_bind ? "update after bind" : flags.partially_bound ? "partially bound" : "no flags"; 520 : flags.update_after_bind ? "update after bind" : flags.partially_bound ? "partially bound" : "no flags";
519 if (!fits(flags)) { 521 if (!full || !fits(flags)) {
520 std::printf("%s: skipped, the set does not fit this device's descriptor limits\n", name); 522 std::printf("%s: skipped, the set does not fit this device's descriptor limits\n", name);
521 continue; 523 continue;
522 } 524 }
@@ -622,13 +624,13 @@ int main(int argc, char** argv) {
622 const std::uint32_t stored_index = set.add_image(ImageDimension::dim_2d, stored_view, VK_IMAGE_LAYOUT_GENERAL, as_storage); 624 const std::uint32_t stored_index = set.add_image(ImageDimension::dim_2d, stored_view, VK_IMAGE_LAYOUT_GENERAL, as_storage);
623 const std::uint32_t decoy_index = set.add_image(ImageDimension::dim_2d, decoy_view, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); 625 const std::uint32_t decoy_index = set.add_image(ImageDimension::dim_2d, decoy_view, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
624 const std::uint32_t gradient_index = set.add_image(ImageDimension::dim_2d, gradient_view, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); 626 const std::uint32_t gradient_index = set.add_image(ImageDimension::dim_2d, gradient_view, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
625 EXPECT(stored_index >= 1 && stored_index < bindless::storage_indices); 627 EXPECT(stored_index >= 1 && stored_index < set.storage_capacity(ImageDimension::dim_2d));
626 EXPECT(decoy_index >= bindless::storage_indices && gradient_index > decoy_index); 628 EXPECT(decoy_index >= set.storage_capacity(ImageDimension::dim_2d) && gradient_index > decoy_index);
627 EXPECT(gradient_index < bindless::image_capacity(ImageDimension::dim_2d)); 629 EXPECT(gradient_index < set.image_capacity(ImageDimension::dim_2d));
628 std::vector<std::uint32_t> filled; 630 std::vector<std::uint32_t> filled;
629 for (std::uint32_t i = 1; i < bindless::image_capacity(ImageDimension::dim_1d); ++i) 631 for (std::uint32_t i = 1; i < set.image_capacity(ImageDimension::dim_1d); ++i)
630 filled.push_back(set.add_image(ImageDimension::dim_1d, VK_NULL_HANDLE, VK_IMAGE_LAYOUT_GENERAL)); 632 filled.push_back(set.add_image(ImageDimension::dim_1d, VK_NULL_HANDLE, VK_IMAGE_LAYOUT_GENERAL));
631 EXPECT(filled.front() == 1 && filled.back() == bindless::image_capacity(ImageDimension::dim_1d) - 1); 633 EXPECT(filled.front() == 1 && filled.back() == set.image_capacity(ImageDimension::dim_1d) - 1);
632 EXPECT(set.add_image(ImageDimension::dim_1d, VK_NULL_HANDLE, VK_IMAGE_LAYOUT_GENERAL) == 0); 634 EXPECT(set.add_image(ImageDimension::dim_1d, VK_NULL_HANDLE, VK_IMAGE_LAYOUT_GENERAL) == 0);
633 set.remove_image(ImageDimension::dim_1d, 7); 635 set.remove_image(ImageDimension::dim_1d, 7);
634 EXPECT(set.add_image(ImageDimension::dim_1d, VK_NULL_HANDLE, VK_IMAGE_LAYOUT_GENERAL) == 7); 636 EXPECT(set.add_image(ImageDimension::dim_1d, VK_NULL_HANDLE, VK_IMAGE_LAYOUT_GENERAL) == 7);
@@ -651,7 +653,8 @@ int main(int argc, char** argv) {
651 StorageViews brief_storage; 653 StorageViews brief_storage;
652 brief_storage.as_float = brief; 654 brief_storage.as_float = brief;
653 const std::uint32_t brief_index = set.add_image(ImageDimension::dim_2d, brief, VK_IMAGE_LAYOUT_GENERAL, brief_storage); 655 const std::uint32_t brief_index = set.add_image(ImageDimension::dim_2d, brief, VK_IMAGE_LAYOUT_GENERAL, brief_storage);
654 EXPECT(brief_index >= 1 && brief_index < bindless::storage_indices && brief_index != stored_index); 656 EXPECT(brief_index >= 1 && brief_index < set.storage_capacity(ImageDimension::dim_2d) &&
657 brief_index != stored_index);
655 set.remove_image(ImageDimension::dim_2d, brief_index); 658 set.remove_image(ImageDimension::dim_2d, brief_index);
656 vkDestroyImageView(dev, brief, nullptr); 659 vkDestroyImageView(dev, brief, nullptr);
657 } 660 }
@@ -755,10 +758,30 @@ int main(int argc, char** argv) {
755 compare("8 removed", zeros); 758 compare("8 removed", zeros);
756 EXPECT(set.add_image(ImageDimension::dim_2d, gradient_view, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL) == gradient_index); 759 EXPECT(set.add_image(ImageDimension::dim_2d, gradient_view, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL) == gradient_index);
757 760
761 // 9. More than 4096 2D images and more than a full D3D12 sampler heap (2048): the gradient and the S#
762 // through the last indices of both arrays, where the device's limits gave the set room for them.
763 std::uint32_t far_image = 0, far_sampler = 0;
764 if (set.image_capacity(ImageDimension::dim_2d) > 5000 + 8 && set.sampler_capacity() > 2100 + 8) {
765 for (std::uint32_t i = 0; i < 5000; ++i)
766 EXPECT(set.add_image(ImageDimension::dim_2d, VK_NULL_HANDLE, VK_IMAGE_LAYOUT_GENERAL) != 0);
767 far_image = set.add_image(ImageDimension::dim_2d, gradient_view, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
768 for (std::uint32_t i = 0; i < 2100; ++i) far_sampler = set.add_sampler(nearest);
769 EXPECT(far_image > 5000 && far_sampler > 2100);
770 set.insert_key(tsharp, far_image);
771 set.insert_key(make_ssharp_key(ssharp.data()), far_sampler);
772 EXPECT(flush());
773 CHECK(draw());
774 compare("9 past 4096 images and 2048 samplers", nullptr);
775 } else {
776 std::printf("%s: no room past 5000 2D images and 2100 samplers on this device; step 9 skipped\n", name);
777 }
778
758 std::printf("%s: descriptor table in %s memory\n", name, 779 std::printf("%s: descriptor table in %s memory\n", name,
759 set.table_in_device_local_memory() ? "device-local" : "host-visible"); 780 set.table_in_device_local_memory() ? "device-local" : "host-visible");
760 std::printf("%s: gradient at the %uth slot probed, miss, table grown %u -> %u slots, rebound, restored, other view, removed\n", name, 781 std::printf("%s: gradient at the %uth slot probed, miss, table grown %u -> %u slots, rebound, restored, "
761 depth + 1, slots, slot_count()); 782 "other view, removed, index %u of %u 2D images and %u of %u samplers\n", name, depth + 1, slots,
783 slot_count(), far_image, set.image_capacity(ImageDimension::dim_2d), far_sampler,
784 set.sampler_capacity());
762 ++runs; 785 ++runs;
763 vkDeviceWaitIdle(dev); 786 vkDeviceWaitIdle(dev);
764 vkDestroyPipeline(dev, pipeline, nullptr); 787 vkDestroyPipeline(dev, pipeline, nullptr);