diff --git a/attachments/05_window_surface.cpp b/attachments/05_window_surface.cpp index bb7b4bee..d8b27fe4 100644 --- a/attachments/05_window_surface.cpp +++ b/attachments/05_window_surface.cpp @@ -166,9 +166,16 @@ class HelloTriangleApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -189,7 +196,7 @@ class HelloTriangleApplication features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice() diff --git a/attachments/06_swap_chain_creation.cpp b/attachments/06_swap_chain_creation.cpp index d6bb7724..bbf7d8fb 100644 --- a/attachments/06_swap_chain_creation.cpp +++ b/attachments/06_swap_chain_creation.cpp @@ -174,9 +174,16 @@ class HelloTriangleApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -197,7 +204,7 @@ class HelloTriangleApplication features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice() diff --git a/attachments/07_image_views.cpp b/attachments/07_image_views.cpp index a6cb5c23..79839491 100644 --- a/attachments/07_image_views.cpp +++ b/attachments/07_image_views.cpp @@ -175,9 +175,16 @@ class HelloTriangleApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -198,7 +205,7 @@ class HelloTriangleApplication features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice() diff --git a/attachments/08_graphics_pipeline.cpp b/attachments/08_graphics_pipeline.cpp index 8705c201..29ac55f8 100644 --- a/attachments/08_graphics_pipeline.cpp +++ b/attachments/08_graphics_pipeline.cpp @@ -176,9 +176,16 @@ class HelloTriangleApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -199,7 +206,7 @@ class HelloTriangleApplication features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice() diff --git a/attachments/09_shader_modules.cpp b/attachments/09_shader_modules.cpp index 5e9ed2b4..305979b4 100644 --- a/attachments/09_shader_modules.cpp +++ b/attachments/09_shader_modules.cpp @@ -177,9 +177,16 @@ class HelloTriangleApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -200,7 +207,7 @@ class HelloTriangleApplication features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice() diff --git a/attachments/10_fixed_functions.cpp b/attachments/10_fixed_functions.cpp index 2998d3ae..7948f0b8 100644 --- a/attachments/10_fixed_functions.cpp +++ b/attachments/10_fixed_functions.cpp @@ -179,9 +179,16 @@ class HelloTriangleApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -202,7 +209,7 @@ class HelloTriangleApplication features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice() diff --git a/attachments/12_graphics_pipeline_complete.cpp b/attachments/12_graphics_pipeline_complete.cpp index c8d7a47d..2792364e 100644 --- a/attachments/12_graphics_pipeline_complete.cpp +++ b/attachments/12_graphics_pipeline_complete.cpp @@ -180,9 +180,16 @@ class HelloTriangleApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -203,7 +210,7 @@ class HelloTriangleApplication features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice() diff --git a/attachments/14_command_buffers.cpp b/attachments/14_command_buffers.cpp index badf1d53..f56c365a 100644 --- a/attachments/14_command_buffers.cpp +++ b/attachments/14_command_buffers.cpp @@ -185,9 +185,16 @@ class HelloTriangleApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -208,7 +215,7 @@ class HelloTriangleApplication features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice() diff --git a/attachments/15_hello_triangle.cpp b/attachments/15_hello_triangle.cpp index 91f0e5c8..e7bbada4 100644 --- a/attachments/15_hello_triangle.cpp +++ b/attachments/15_hello_triangle.cpp @@ -193,9 +193,16 @@ class HelloTriangleApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -217,7 +224,7 @@ class HelloTriangleApplication features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice() diff --git a/attachments/16_frames_in_flight.cpp b/attachments/16_frames_in_flight.cpp index 189c1133..ad3476b8 100644 --- a/attachments/16_frames_in_flight.cpp +++ b/attachments/16_frames_in_flight.cpp @@ -196,9 +196,16 @@ class HelloTriangleApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -220,7 +227,7 @@ class HelloTriangleApplication features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice() diff --git a/attachments/17_swap_chain_recreation.cpp b/attachments/17_swap_chain_recreation.cpp index fcd6df65..b613d802 100644 --- a/attachments/17_swap_chain_recreation.cpp +++ b/attachments/17_swap_chain_recreation.cpp @@ -229,9 +229,16 @@ class HelloTriangleApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -253,7 +260,7 @@ class HelloTriangleApplication features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice() diff --git a/attachments/19_vertex_buffer.cpp b/attachments/19_vertex_buffer.cpp index 77721ad6..766b4ae2 100644 --- a/attachments/19_vertex_buffer.cpp +++ b/attachments/19_vertex_buffer.cpp @@ -257,9 +257,16 @@ class HelloTriangleApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -281,7 +288,7 @@ class HelloTriangleApplication features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice() diff --git a/attachments/20_staging_buffer.cpp b/attachments/20_staging_buffer.cpp index 64980f7f..140f95e1 100644 --- a/attachments/20_staging_buffer.cpp +++ b/attachments/20_staging_buffer.cpp @@ -257,9 +257,16 @@ class HelloTriangleApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -281,7 +288,7 @@ class HelloTriangleApplication features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice() diff --git a/attachments/21_index_buffer.cpp b/attachments/21_index_buffer.cpp index 957b735a..dc423f55 100644 --- a/attachments/21_index_buffer.cpp +++ b/attachments/21_index_buffer.cpp @@ -264,9 +264,16 @@ class HelloTriangleApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -288,7 +295,7 @@ class HelloTriangleApplication features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice() diff --git a/attachments/22_descriptor_layout.cpp b/attachments/22_descriptor_layout.cpp index 83355311..95331325 100644 --- a/attachments/22_descriptor_layout.cpp +++ b/attachments/22_descriptor_layout.cpp @@ -282,9 +282,16 @@ class HelloTriangleApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -306,7 +313,7 @@ class HelloTriangleApplication features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice() diff --git a/attachments/23_descriptor_sets.cpp b/attachments/23_descriptor_sets.cpp index 881abc5c..9f1818bd 100644 --- a/attachments/23_descriptor_sets.cpp +++ b/attachments/23_descriptor_sets.cpp @@ -287,9 +287,16 @@ class HelloTriangleApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -311,7 +318,7 @@ class HelloTriangleApplication features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice() diff --git a/attachments/24_texture_image.cpp b/attachments/24_texture_image.cpp index b8d61315..a02c97e5 100644 --- a/attachments/24_texture_image.cpp +++ b/attachments/24_texture_image.cpp @@ -294,9 +294,16 @@ class HelloTriangleApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -318,7 +325,7 @@ class HelloTriangleApplication features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice() diff --git a/attachments/25_sampler.cpp b/attachments/25_sampler.cpp index 0608f172..40b03958 100644 --- a/attachments/25_sampler.cpp +++ b/attachments/25_sampler.cpp @@ -298,9 +298,16 @@ class HelloTriangleApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -321,7 +328,7 @@ class HelloTriangleApplication features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice() diff --git a/attachments/26_texture_mapping.cpp b/attachments/26_texture_mapping.cpp index 26811191..e8316b96 100644 --- a/attachments/26_texture_mapping.cpp +++ b/attachments/26_texture_mapping.cpp @@ -299,9 +299,16 @@ class HelloTriangleApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -321,7 +328,7 @@ class HelloTriangleApplication features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice() diff --git a/attachments/27_depth_buffering.cpp b/attachments/27_depth_buffering.cpp index dfb24250..77959c0c 100644 --- a/attachments/27_depth_buffering.cpp +++ b/attachments/27_depth_buffering.cpp @@ -314,9 +314,16 @@ class HelloTriangleApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -336,7 +343,7 @@ class HelloTriangleApplication features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice() diff --git a/attachments/28_model_loading.cpp b/attachments/28_model_loading.cpp index fe4ada52..e93c346e 100644 --- a/attachments/28_model_loading.cpp +++ b/attachments/28_model_loading.cpp @@ -321,9 +321,16 @@ class HelloTriangleApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -343,7 +350,7 @@ class HelloTriangleApplication features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice() diff --git a/attachments/29_mipmapping.cpp b/attachments/29_mipmapping.cpp index d80a73cb..f9439f9d 100644 --- a/attachments/29_mipmapping.cpp +++ b/attachments/29_mipmapping.cpp @@ -322,9 +322,16 @@ class HelloTriangleApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -344,7 +351,7 @@ class HelloTriangleApplication features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice() diff --git a/attachments/30_multisampling.cpp b/attachments/30_multisampling.cpp index 9a312fa2..e3b671ec 100644 --- a/attachments/30_multisampling.cpp +++ b/attachments/30_multisampling.cpp @@ -329,9 +329,16 @@ class HelloTriangleApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -351,7 +358,7 @@ class HelloTriangleApplication features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice() diff --git a/attachments/31_compute_shader.cpp b/attachments/31_compute_shader.cpp index 67ffe943..0151fcbb 100644 --- a/attachments/31_compute_shader.cpp +++ b/attachments/31_compute_shader.cpp @@ -297,9 +297,16 @@ class ComputeShaderApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -321,7 +328,7 @@ class ComputeShaderApplication features.template get().timelineSemaphore; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice() diff --git a/attachments/32_ecosystem_utilities.cpp b/attachments/32_ecosystem_utilities.cpp index a0a4c2d2..f1bb310c 100644 --- a/attachments/32_ecosystem_utilities.cpp +++ b/attachments/32_ecosystem_utilities.cpp @@ -353,9 +353,16 @@ class HelloTriangleApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -367,7 +374,7 @@ class HelloTriangleApplication }); // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions; } void pickPhysicalDevice() diff --git a/attachments/33_vulkan_profiles.cpp b/attachments/33_vulkan_profiles.cpp index 4b1268e5..521bde67 100644 --- a/attachments/33_vulkan_profiles.cpp +++ b/attachments/33_vulkan_profiles.cpp @@ -361,9 +361,16 @@ class HelloTriangleApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -375,7 +382,7 @@ class HelloTriangleApplication }); // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions; } void pickPhysicalDevice() diff --git a/attachments/34_android.cpp b/attachments/34_android.cpp index c32c6361..c503e259 100644 --- a/attachments/34_android.cpp +++ b/attachments/34_android.cpp @@ -487,9 +487,16 @@ class HelloTriangleApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -501,7 +508,7 @@ class HelloTriangleApplication }); // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions; } void pickPhysicalDevice() diff --git a/attachments/35_gltf_ktx.cpp b/attachments/35_gltf_ktx.cpp index 777010f4..7d22f5dc 100644 --- a/attachments/35_gltf_ktx.cpp +++ b/attachments/35_gltf_ktx.cpp @@ -476,9 +476,16 @@ class VulkanApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -497,7 +504,7 @@ class VulkanApplication features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice() diff --git a/attachments/36_multiple_objects.cpp b/attachments/36_multiple_objects.cpp index 9afc9003..22eb23db 100644 --- a/attachments/36_multiple_objects.cpp +++ b/attachments/36_multiple_objects.cpp @@ -549,9 +549,16 @@ class VulkanApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -570,7 +577,7 @@ class VulkanApplication features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice() diff --git a/attachments/37_multithreading.cpp b/attachments/37_multithreading.cpp index aa443369..1e02c461 100644 --- a/attachments/37_multithreading.cpp +++ b/attachments/37_multithreading.cpp @@ -592,9 +592,16 @@ class MultithreadedApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -613,7 +620,7 @@ class MultithreadedApplication features.template get().extendedDynamicState; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice() diff --git a/attachments/38_ray_tracing.cpp b/attachments/38_ray_tracing.cpp index e0843931..fd2bbc74 100644 --- a/attachments/38_ray_tracing.cpp +++ b/attachments/38_ray_tracing.cpp @@ -405,9 +405,16 @@ class VulkanRaytracingApplication // Check if the physicalDevice supports the Vulkan 1.3 API version bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; - // Check if any of the queue families support graphics operations - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + // Check if any of the queue families support both graphics and presentation to our surface + auto queueFamilies = physicalDevice.getQueueFamilyProperties(); + uint32_t qfpIndex = 0; + bool supportsGraphicsAndPresent = + std::ranges::any_of(queueFamilies, + [&physicalDevice, &surface = this->surface, &qfpIndex](auto const &qfp) { + bool const suitable = (qfp.queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface); + qfpIndex++; + return suitable; + }); // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -438,7 +445,7 @@ class VulkanRaytracingApplication features.template get().rayQuery; // Return true if the physicalDevice meets all the criteria - return supportsVulkan1_3 && supportsGraphics && supportsAllRequiredExtensions && supportsRequiredFeatures; + return supportsVulkan1_3 && supportsGraphicsAndPresent && supportsAllRequiredExtensions && supportsRequiredFeatures; } void pickPhysicalDevice()