diff --git a/src/vkcv/Context.cpp b/src/vkcv/Context.cpp index 48ce7c3e7002a882fcff693b272835d1f0ed27f7..e4950161cc5cc990829720586c1eb41e58051312 100644 --- a/src/vkcv/Context.cpp +++ b/src/vkcv/Context.cpp @@ -87,8 +87,12 @@ namespace vkcv { throw std::runtime_error("The requested device extensions are not supported by the physical device!"); } + //vector to define the queue priorities + std::vector<float> qPriorities; + qPriorities.resize(queueCount, 1.f); // all queues have the same priorities + // create required queues - std::vector<vk::DeviceQueueCreateInfo> qCreateInfos = getQueueCreateInfos(physicalDevice, queueCount, queueFlags); + std::vector<vk::DeviceQueueCreateInfo> qCreateInfos = getQueueCreateInfos(physicalDevice, queueCount, qPriorities,queueFlags); vk::DeviceCreateInfo deviceCreateInfo( vk::DeviceCreateFlags(), @@ -200,7 +204,7 @@ namespace vkcv { /// <param name="queueCount">The amount of queues to be created</param> /// <param name="queueFlags">The abilities which have to be supported by any created queue</param> /// <returns></returns> - std::vector<vk::DeviceQueueCreateInfo> Context::getQueueCreateInfos(vk::PhysicalDevice& physicalDevice, uint32_t queueCount, std::vector<vk::QueueFlagBits>& queueFlags) { + std::vector<vk::DeviceQueueCreateInfo> Context::getQueueCreateInfos(vk::PhysicalDevice& physicalDevice, uint32_t queueCount,std::vector<float> &qPriorities, std::vector<vk::QueueFlagBits>& queueFlags) { std::vector<vk::DeviceQueueCreateInfo> queueCreateInfos; std::vector<vk::QueueFamilyProperties> qFamilyProperties = physicalDevice.getQueueFamilyProperties(); std::vector<vk::QueueFamilyProperties> qFamilyCandidates; @@ -218,14 +222,12 @@ namespace vkcv { uint32_t create = queueCount; for (int i = 0; i < qFamilyCandidates.size() && create > 0; i++) { - const int maxCreatableQueues = std::min(create, qFamilyCandidates[i].queueCount); - float* qPriorities = new float[maxCreatableQueues]; // TO CHECK: this seems to solve validation layer errors but the array pointer will not be deleted - std::fill_n(qPriorities, maxCreatableQueues, 1.f); // all queues have the same priorities + const int maxCreatableQueues = std::min(create, qFamilyCandidates[i].queueCount); vk::DeviceQueueCreateInfo qCreateInfo( vk::DeviceQueueCreateFlags(), i, maxCreatableQueues, - qPriorities + qPriorities.data() ); queueCreateInfos.push_back(qCreateInfo); create -= maxCreatableQueues; diff --git a/src/vkcv/Context.hpp b/src/vkcv/Context.hpp index e27c766b21ec9354be87ef81c8610734903c93b0..779c5b8551c32b5938a95eddb3727e1ded995a1b 100644 --- a/src/vkcv/Context.hpp +++ b/src/vkcv/Context.hpp @@ -38,7 +38,7 @@ namespace vkcv { static std::vector<const char*> getRequiredExtensions(); static vk::PhysicalDevice pickPhysicalDevice(vk::Instance& instance); static int deviceScore(const vk::PhysicalDevice &physicalDevice); - static std::vector<vk::DeviceQueueCreateInfo> getQueueCreateInfos(vk::PhysicalDevice& physicalDevice, uint32_t queueCount, std::vector<vk::QueueFlagBits> &queueFlags); + static std::vector<vk::DeviceQueueCreateInfo> getQueueCreateInfos(vk::PhysicalDevice& physicalDevice, uint32_t queueCount, std::vector<float>& qPriorities, std::vector<vk::QueueFlagBits> &queueFlags); }; }