Make swapchain builder find queues if none were provided

This commit is contained in:
Charles Giessen 2020-10-26 13:17:52 -06:00
parent e2a09c9b35
commit 988c0ea4e4
2 changed files with 12 additions and 12 deletions

View File

@ -1541,19 +1541,20 @@ SwapchainBuilder::SwapchainBuilder (Device const& device, VkSurfaceKHR const sur
info.graphics_queue_index = present.value ();
info.present_queue_index = graphics.value ();
}
SwapchainBuilder::SwapchainBuilder (VkPhysicalDevice const physical_device, VkDevice const device, VkSurfaceKHR const surface, uint32_t graphics_queue_index){
SwapchainBuilder::SwapchainBuilder (VkPhysicalDevice const physical_device, VkDevice const device, VkSurfaceKHR const surface, int32_t graphics_queue_index, int32_t present_queue_index){
info.physical_device = physical_device;
info.device = device;
info.surface = surface;
info.graphics_queue_index = graphics_queue_index;
info.present_queue_index = graphics_queue_index;
}
SwapchainBuilder::SwapchainBuilder (VkPhysicalDevice const physical_device, VkDevice const device, VkSurfaceKHR const surface, uint32_t graphics_queue_index, uint32_t present_queue_index){
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;
info.graphics_queue_index = static_cast<uint32_t>(graphics_queue_index);
info.present_queue_index = static_cast<uint32_t>(present_queue_index);
if (graphics_queue_index < 0 || present_queue_index < 0) {
auto queue_families = detail::get_vector_noerror<VkQueueFamilyProperties> (
detail::vulkan_functions().fp_vkGetPhysicalDeviceQueueFamilyProperties, physical_device);
if (graphics_queue_index < 0)
info.graphics_queue_index = static_cast<uint32_t>(detail::get_graphics_queue_index (queue_families));
if (present_queue_index < 0)
info.present_queue_index = static_cast<uint32_t>(detail::get_present_queue_index (physical_device, surface, queue_families));
}
}
detail::Result<Swapchain> SwapchainBuilder::build () const {
if (info.surface == VK_NULL_HANDLE) {

View File

@ -556,8 +556,7 @@ class SwapchainBuilder {
public:
explicit SwapchainBuilder (Device const& device);
explicit SwapchainBuilder (Device const& device, VkSurfaceKHR const surface);
explicit SwapchainBuilder (VkPhysicalDevice const physical_device, VkDevice const device, VkSurfaceKHR const surface, uint32_t graphics_queue_index);
explicit SwapchainBuilder (VkPhysicalDevice const physical_device, VkDevice const device, VkSurfaceKHR const surface, uint32_t graphics_queue_index, uint32_t present_queue_index);
explicit SwapchainBuilder (VkPhysicalDevice const physical_device, VkDevice const device, VkSurfaceKHR const surface, int32_t graphics_queue_index = -1, int32_t present_queue_index = -1);
detail::Result<Swapchain> build () const;