diff options
| author | Quentin LADEVIE <qladevie@wanadev.fr> | 2022-02-24 12:42:53 +0100 |
|---|---|---|
| committer | Quentin LADEVIE <qladevie@wanadev.fr> | 2022-02-24 12:42:53 +0100 |
| commit | b088d17e07dc68ff81830f40f4a49eda4f93dc13 (patch) | |
| tree | 10b04b1a7e214f686a7aaa967bbf49c5a4b9980c | |
| parent | 5b87100b8ca9953832086f392ee60e1421654b3b (diff) | |
Choose a device queue based on queue usages
| -rw-r--r-- | include/vk-context.hpp | 2 | ||||
| -rw-r--r-- | src/vk-context.cpp | 7 |
2 files changed, 5 insertions, 4 deletions
diff --git a/include/vk-context.hpp b/include/vk-context.hpp index 7b7f6bf..c7dd0f2 100644 --- a/include/vk-context.hpp +++ b/include/vk-context.hpp @@ -33,7 +33,7 @@ class vkcontext { void select_physical_device(); - void select_queue(); + void select_queue(VkQueueFlags queueUsage); void check_available_instance_layers(std::vector<const char*>& needed_layers); diff --git a/src/vk-context.cpp b/src/vk-context.cpp index 52edc09..b539194 100644 --- a/src/vk-context.cpp +++ b/src/vk-context.cpp @@ -3,6 +3,7 @@ #include "vk-context.hpp" #include "vulkan-loader.hpp" +#include "vulkan/vulkan_core.h" #define VMA_IMPLEMENTATION #include "thirdparty/vk_mem_alloc.h" @@ -108,7 +109,7 @@ void vkcontext::create_debugger() { void vkcontext::create_device() { select_physical_device(); - select_queue(); + select_queue(VK_QUEUE_COMPUTE_BIT | VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_TRANSFER_BIT); VkDeviceQueueCreateInfo queue_create_info = {}; queue_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; @@ -189,7 +190,7 @@ void vkcontext::select_physical_device() { assert(physical_device != VK_NULL_HANDLE); } -void vkcontext::select_queue() { +void vkcontext::select_queue(VkQueueFlags queueUsage) { uint32_t queue_properties_count = 0; vkGetPhysicalDeviceQueueFamilyProperties(physical_device, &queue_properties_count, nullptr); @@ -197,7 +198,7 @@ void vkcontext::select_queue() { vkGetPhysicalDeviceQueueFamilyProperties(physical_device, &queue_properties_count, queue_properties.data()); for (uint32_t properties_index = 0; properties_index < queue_properties_count; properties_index++) { - if (queue_properties[properties_index].queueFlags & VK_QUEUE_COMPUTE_BIT) { + if (queue_properties[properties_index].queueFlags & queueUsage) { queue_index = properties_index; return; } |
