From 834960e58f8128d8b750b091f095b7be816202a5 Mon Sep 17 00:00:00 2001 From: Nicholaus Clark Date: Sat, 7 Oct 2023 18:17:16 -0400 Subject: [PATCH] Fix API of CustomQueueDescription --- src/VkBootstrap.cpp | 10 ++++------ src/VkBootstrap.h | 3 +-- tests/bootstrap_tests.cpp | 12 ++++++------ 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/VkBootstrap.cpp b/src/VkBootstrap.cpp index 75f854a..2566c59 100644 --- a/src/VkBootstrap.cpp +++ b/src/VkBootstrap.cpp @@ -1437,10 +1437,8 @@ DispatchTable Device::make_table() const { return { device, fp_vkGetDeviceProcAd Device::operator VkDevice() const { return this->device; } -CustomQueueDescription::CustomQueueDescription(uint32_t index, uint32_t count, std::vector priorities) -: index(index), count(count), priorities(priorities) { - assert(count == priorities.size()); -} +CustomQueueDescription::CustomQueueDescription(uint32_t index, std::vector priorities) +: index(index), priorities(priorities) {} void destroy_device(Device device) { device.internal_table.fp_vkDestroyDevice(device.device, device.allocation_callbacks); @@ -1455,7 +1453,7 @@ Result DeviceBuilder::build() const { if (queue_descriptions.size() == 0) { for (uint32_t i = 0; i < physical_device.queue_families.size(); i++) { - queue_descriptions.push_back(CustomQueueDescription{ i, 1, std::vector{ 1.0f } }); + queue_descriptions.push_back(CustomQueueDescription{ i, std::vector{ 1.0f } }); } } @@ -1464,7 +1462,7 @@ Result DeviceBuilder::build() const { VkDeviceQueueCreateInfo queue_create_info = {}; queue_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; queue_create_info.queueFamilyIndex = desc.index; - queue_create_info.queueCount = desc.count; + queue_create_info.queueCount = static_cast(desc.priorities.size()); queue_create_info.pQueuePriorities = desc.priorities.data(); queueCreateInfos.push_back(queue_create_info); } diff --git a/src/VkBootstrap.h b/src/VkBootstrap.h index e0de398..f655d91 100644 --- a/src/VkBootstrap.h +++ b/src/VkBootstrap.h @@ -719,9 +719,8 @@ struct Device { // For advanced device queue setup struct CustomQueueDescription { - explicit CustomQueueDescription(uint32_t index, uint32_t count, std::vector priorities); + explicit CustomQueueDescription(uint32_t index, std::vector priorities); uint32_t index = 0; - uint32_t count = 0; std::vector priorities; }; diff --git a/tests/bootstrap_tests.cpp b/tests/bootstrap_tests.cpp index 48a99c6..7531540 100644 --- a/tests/bootstrap_tests.cpp +++ b/tests/bootstrap_tests.cpp @@ -209,8 +209,8 @@ TEST_CASE("Device Configuration", "[VkBootstrap.bootstrap]") { auto queue_families = phys_device.get_queue_families(); for (uint32_t i = 0; i < (uint32_t)queue_families.size(); i++) { if (queue_families[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) { - queue_descriptions.push_back(vkb::CustomQueueDescription( - i, queue_families[i].queueCount, std::vector(queue_families[i].queueCount, 1.0f))); + queue_descriptions.push_back( + vkb::CustomQueueDescription(i, std::vector(queue_families[i].queueCount, 1.0f))); } } if (phys_device.has_dedicated_compute_queue()) { @@ -218,15 +218,15 @@ TEST_CASE("Device Configuration", "[VkBootstrap.bootstrap]") { if ((queue_families[i].queueFlags & VK_QUEUE_COMPUTE_BIT) && (queue_families[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) == 0 && (queue_families[i].queueFlags & VK_QUEUE_TRANSFER_BIT) == 0) - queue_descriptions.push_back(vkb::CustomQueueDescription( - i, queue_families[i].queueCount, std::vector(queue_families[i].queueCount, 1.0f))); + queue_descriptions.push_back( + vkb::CustomQueueDescription(i, std::vector(queue_families[i].queueCount, 1.0f))); } } else if (phys_device.has_separate_compute_queue()) { for (uint32_t i = 0; i < (uint32_t)queue_families.size(); i++) { if ((queue_families[i].queueFlags & VK_QUEUE_COMPUTE_BIT) && ((queue_families[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) == 0)) { - queue_descriptions.push_back(vkb::CustomQueueDescription( - i, queue_families[i].queueCount, std::vector(queue_families[i].queueCount, 1.0f))); + queue_descriptions.push_back( + vkb::CustomQueueDescription(i, std::vector(queue_families[i].queueCount, 1.0f))); } } }