Skip to content
Snippets Groups Projects
Commit 9beed6c5 authored by Katharina Krämer's avatar Katharina Krämer
Browse files

[#7] replaced queue priority array by a std::vector

parent 0e8cdfb5
No related branches found
No related tags found
1 merge request!2Resolve "Context Functionality"
This commit is part of merge request !2. Comments created here will be created in the context of that merge request.
...@@ -87,8 +87,12 @@ namespace vkcv { ...@@ -87,8 +87,12 @@ namespace vkcv {
throw std::runtime_error("The requested device extensions are not supported by the physical device!"); 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 // 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::DeviceCreateInfo deviceCreateInfo(
vk::DeviceCreateFlags(), vk::DeviceCreateFlags(),
...@@ -200,7 +204,7 @@ namespace vkcv { ...@@ -200,7 +204,7 @@ namespace vkcv {
/// <param name="queueCount">The amount of queues to be created</param> /// <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> /// <param name="queueFlags">The abilities which have to be supported by any created queue</param>
/// <returns></returns> /// <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::DeviceQueueCreateInfo> queueCreateInfos;
std::vector<vk::QueueFamilyProperties> qFamilyProperties = physicalDevice.getQueueFamilyProperties(); std::vector<vk::QueueFamilyProperties> qFamilyProperties = physicalDevice.getQueueFamilyProperties();
std::vector<vk::QueueFamilyProperties> qFamilyCandidates; std::vector<vk::QueueFamilyProperties> qFamilyCandidates;
...@@ -218,14 +222,12 @@ namespace vkcv { ...@@ -218,14 +222,12 @@ namespace vkcv {
uint32_t create = queueCount; uint32_t create = queueCount;
for (int i = 0; i < qFamilyCandidates.size() && create > 0; i++) { for (int i = 0; i < qFamilyCandidates.size() && create > 0; i++) {
const int maxCreatableQueues = std::min(create, qFamilyCandidates[i].queueCount); 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
vk::DeviceQueueCreateInfo qCreateInfo( vk::DeviceQueueCreateInfo qCreateInfo(
vk::DeviceQueueCreateFlags(), vk::DeviceQueueCreateFlags(),
i, i,
maxCreatableQueues, maxCreatableQueues,
qPriorities qPriorities.data()
); );
queueCreateInfos.push_back(qCreateInfo); queueCreateInfos.push_back(qCreateInfo);
create -= maxCreatableQueues; create -= maxCreatableQueues;
......
...@@ -38,7 +38,7 @@ namespace vkcv { ...@@ -38,7 +38,7 @@ namespace vkcv {
static std::vector<const char*> getRequiredExtensions(); static std::vector<const char*> getRequiredExtensions();
static vk::PhysicalDevice pickPhysicalDevice(vk::Instance& instance); static vk::PhysicalDevice pickPhysicalDevice(vk::Instance& instance);
static int deviceScore(const vk::PhysicalDevice &physicalDevice); 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);
}; };
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment