diff --git a/src/VkBootstrap.cpp b/src/VkBootstrap.cpp index b04dbd3..4398b39 100644 --- a/src/VkBootstrap.cpp +++ b/src/VkBootstrap.cpp @@ -1192,16 +1192,19 @@ SwapchainBuilder::SwapchainBuilder (Device const& device) { info.present_queue_index = graphics.value (); } -SwapchainBuilder::SwapchainBuilder (VkPhysicalDevice const physical_device, - VkDevice const device, - VkSurfaceKHR const surface, - uint32_t graphics_queue_index, - uint32_t present_queue_index) { +SwapchainBuilder::SwapchainBuilder ( + VkPhysicalDevice const physical_device, VkDevice const device, VkSurfaceKHR const surface) { info.physical_device = physical_device; info.device = device; info.surface = surface; - info.graphics_queue_index = graphics_queue_index; - info.present_queue_index = present_queue_index; + auto queue_families = detail::get_vector_noerror ( + vkGetPhysicalDeviceQueueFamilyProperties, physical_device); + + int graphics_queue_index = detail::get_graphics_queue_index (queue_families); + int present_queue_index = detail::get_present_queue_index (physical_device, surface, queue_families); + // TODO: handle queue indexes being below zero + info.graphics_queue_index = static_cast (graphics_queue_index); + info.present_queue_index = static_cast (present_queue_index); } detail::Expected> SwapchainBuilder::build () const { return build (VK_NULL_HANDLE); diff --git a/src/VkBootstrap.h b/src/VkBootstrap.h index 79220d1..93bec53 100644 --- a/src/VkBootstrap.h +++ b/src/VkBootstrap.h @@ -523,11 +523,7 @@ void destroy_swapchain (Swapchain const& swapchain); class SwapchainBuilder { public: SwapchainBuilder (Device const& device); - SwapchainBuilder (VkPhysicalDevice const physical_device, - VkDevice const device, - VkSurfaceKHR const surface, - uint32_t graphics_queue_index, - uint32_t present_queue_index); + SwapchainBuilder (VkPhysicalDevice const physical_device, VkDevice const device, VkSurfaceKHR const surface); detail::Expected> build () const; detail::Expected> recreate (Swapchain const& swapchain) const;