Fixed issue with queue priorities

Before it only had 1 priority even if there were multiple queues.
Now it creates a vector of priorities so it shouldn't cause issues.
It also means logic to setup actual priority values can be put in place
in the future
This commit is contained in:
Charles Giessen 2020-02-04 10:26:46 -07:00
parent 02e44adf1f
commit 4851a5bec9

View File

@ -767,7 +767,7 @@ void destroy_device (Device device) { vkDestroyDevice (device.device, device.all
struct QueueFamily struct QueueFamily
{ {
int32_t family; int32_t family;
uint32_t count; std::vector<float> priorities;
}; };
DeviceBuilder::DeviceBuilder (PhysicalDevice phys_device) DeviceBuilder::DeviceBuilder (PhysicalDevice phys_device)
{ {
@ -779,23 +779,25 @@ detail::Expected<Device, VkResult> DeviceBuilder::build ()
{ {
auto& queue_properties = info.physical_device.queue_family_properties; auto& queue_properties = info.physical_device.queue_family_properties;
std::vector<QueueFamily> families; std::vector<QueueFamily> families;
families.push_back ({ queue_properties.graphics, queue_properties.count_graphics }); families.push_back ({ queue_properties.graphics, std::vector<float> (queue_properties.count_graphics) });
if (queue_properties.compute != -1 && queue_properties.compute != queue_properties.graphics) if (queue_properties.compute != -1 && queue_properties.compute != queue_properties.graphics)
families.push_back ({ queue_properties.compute, queue_properties.count_compute }); families.push_back ({ queue_properties.compute, std::vector<float> (queue_properties.count_compute) });
if (queue_properties.transfer != -1 && queue_properties.transfer != queue_properties.graphics) if (queue_properties.transfer != -1 && queue_properties.transfer != queue_properties.graphics &&
families.push_back ({ queue_properties.transfer, queue_properties.count_transfer }); queue_properties.transfer != queue_properties.compute)
if (queue_properties.sparse != -1) families.push_back ({ queue_properties.transfer, std::vector<float> (queue_properties.count_transfer) });
families.push_back ({ queue_properties.sparse, queue_properties.count_sparse }); if (queue_properties.sparse != -1 && queue_properties.sparse != queue_properties.graphics &&
queue_properties.sparse != queue_properties.compute &&
queue_properties.sparse != queue_properties.transfer)
families.push_back ({ queue_properties.sparse, std::vector<float> (queue_properties.count_sparse) });
std::vector<VkDeviceQueueCreateInfo> queueCreateInfos; std::vector<VkDeviceQueueCreateInfo> queueCreateInfos;
float queuePriority = 1.0f;
for (auto& queue : families) for (auto& queue : families)
{ {
VkDeviceQueueCreateInfo queue_create_info = {}; VkDeviceQueueCreateInfo queue_create_info = {};
queue_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; queue_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
queue_create_info.queueFamilyIndex = static_cast<uint32_t> (queue.family); queue_create_info.queueFamilyIndex = static_cast<uint32_t> (queue.family);
queue_create_info.queueCount = queue.count; queue_create_info.queueCount = queue.priorities.size ();
queue_create_info.pQueuePriorities = &queuePriority; queue_create_info.pQueuePriorities = queue.priorities.data ();
queueCreateInfos.push_back (queue_create_info); queueCreateInfos.push_back (queue_create_info);
} }