From a66936d4118f04efee29f0c9f02f78be3a066606 Mon Sep 17 00:00:00 2001 From: swinston Date: Thu, 20 Aug 2026 16:21:20 -0700 Subject: [PATCH 1/2] Check presentation support in isDeviceSuitable across all chapters --- attachments/05_window_surface.cpp | 14 +++++++++++--- attachments/06_swap_chain_creation.cpp | 14 +++++++++++--- attachments/07_image_views.cpp | 14 +++++++++++--- attachments/08_graphics_pipeline.cpp | 14 +++++++++++--- attachments/09_shader_modules.cpp | 14 +++++++++++--- attachments/10_fixed_functions.cpp | 14 +++++++++++--- attachments/12_graphics_pipeline_complete.cpp | 14 +++++++++++--- attachments/14_command_buffers.cpp | 14 +++++++++++--- attachments/15_hello_triangle.cpp | 14 +++++++++++--- attachments/16_frames_in_flight.cpp | 14 +++++++++++--- attachments/17_swap_chain_recreation.cpp | 14 +++++++++++--- attachments/19_vertex_buffer.cpp | 14 +++++++++++--- attachments/20_staging_buffer.cpp | 14 +++++++++++--- attachments/21_index_buffer.cpp | 14 +++++++++++--- attachments/22_descriptor_layout.cpp | 14 +++++++++++--- attachments/23_descriptor_sets.cpp | 14 +++++++++++--- attachments/24_texture_image.cpp | 14 +++++++++++--- attachments/25_sampler.cpp | 14 +++++++++++--- attachments/26_texture_mapping.cpp | 14 +++++++++++--- attachments/27_depth_buffering.cpp | 14 +++++++++++--- attachments/28_model_loading.cpp | 14 +++++++++++--- attachments/29_mipmapping.cpp | 14 +++++++++++--- attachments/30_multisampling.cpp | 14 +++++++++++--- attachments/31_compute_shader.cpp | 14 +++++++++++--- attachments/32_ecosystem_utilities.cpp | 14 +++++++++++--- attachments/33_vulkan_profiles.cpp | 14 +++++++++++--- attachments/34_android.cpp | 14 +++++++++++--- attachments/35_gltf_ktx.cpp | 14 +++++++++++--- attachments/36_multiple_objects.cpp | 14 +++++++++++--- attachments/37_multithreading.cpp | 14 +++++++++++--- attachments/38_ray_tracing.cpp | 14 +++++++++++--- 31 files changed, 341 insertions(+), 93 deletions(-) diff --git a/attachments/05_window_surface.cpp b/attachments/05_window_surface.cpp index bb7b4bee..114e2765 100644 --- a/attachments/05_window_surface.cpp +++ b/attachments/05_window_surface.cpp @@ -166,9 +166,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -189,7 +197,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..2b506e61 100644 --- a/attachments/06_swap_chain_creation.cpp +++ b/attachments/06_swap_chain_creation.cpp @@ -174,9 +174,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -197,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/07_image_views.cpp b/attachments/07_image_views.cpp index a6cb5c23..33df59fb 100644 --- a/attachments/07_image_views.cpp +++ b/attachments/07_image_views.cpp @@ -175,9 +175,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -198,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/08_graphics_pipeline.cpp b/attachments/08_graphics_pipeline.cpp index 8705c201..99f15c8d 100644 --- a/attachments/08_graphics_pipeline.cpp +++ b/attachments/08_graphics_pipeline.cpp @@ -176,9 +176,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -199,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/09_shader_modules.cpp b/attachments/09_shader_modules.cpp index 5e9ed2b4..76ae4a1e 100644 --- a/attachments/09_shader_modules.cpp +++ b/attachments/09_shader_modules.cpp @@ -177,9 +177,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -200,7 +208,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..d60e0487 100644 --- a/attachments/10_fixed_functions.cpp +++ b/attachments/10_fixed_functions.cpp @@ -179,9 +179,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -202,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/12_graphics_pipeline_complete.cpp b/attachments/12_graphics_pipeline_complete.cpp index c8d7a47d..c2bd9618 100644 --- a/attachments/12_graphics_pipeline_complete.cpp +++ b/attachments/12_graphics_pipeline_complete.cpp @@ -180,9 +180,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -203,7 +211,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..29d12d14 100644 --- a/attachments/14_command_buffers.cpp +++ b/attachments/14_command_buffers.cpp @@ -185,9 +185,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -208,7 +216,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..c92a06db 100644 --- a/attachments/15_hello_triangle.cpp +++ b/attachments/15_hello_triangle.cpp @@ -193,9 +193,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -217,7 +225,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..e36a3297 100644 --- a/attachments/16_frames_in_flight.cpp +++ b/attachments/16_frames_in_flight.cpp @@ -196,9 +196,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -220,7 +228,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..fe844112 100644 --- a/attachments/17_swap_chain_recreation.cpp +++ b/attachments/17_swap_chain_recreation.cpp @@ -229,9 +229,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -253,7 +261,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..20669770 100644 --- a/attachments/19_vertex_buffer.cpp +++ b/attachments/19_vertex_buffer.cpp @@ -257,9 +257,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -281,7 +289,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..be28542d 100644 --- a/attachments/20_staging_buffer.cpp +++ b/attachments/20_staging_buffer.cpp @@ -257,9 +257,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -281,7 +289,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..4a2a880a 100644 --- a/attachments/21_index_buffer.cpp +++ b/attachments/21_index_buffer.cpp @@ -264,9 +264,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -288,7 +296,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..72773d30 100644 --- a/attachments/22_descriptor_layout.cpp +++ b/attachments/22_descriptor_layout.cpp @@ -282,9 +282,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -306,7 +314,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..e5b99365 100644 --- a/attachments/23_descriptor_sets.cpp +++ b/attachments/23_descriptor_sets.cpp @@ -287,9 +287,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -311,7 +319,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..45a7e499 100644 --- a/attachments/24_texture_image.cpp +++ b/attachments/24_texture_image.cpp @@ -294,9 +294,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -318,7 +326,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..de0ebcfd 100644 --- a/attachments/25_sampler.cpp +++ b/attachments/25_sampler.cpp @@ -298,9 +298,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -321,7 +329,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..d31ead52 100644 --- a/attachments/26_texture_mapping.cpp +++ b/attachments/26_texture_mapping.cpp @@ -299,9 +299,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -321,7 +329,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..3972ed7b 100644 --- a/attachments/27_depth_buffering.cpp +++ b/attachments/27_depth_buffering.cpp @@ -314,9 +314,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -336,7 +344,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..6ac28011 100644 --- a/attachments/28_model_loading.cpp +++ b/attachments/28_model_loading.cpp @@ -321,9 +321,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -343,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/29_mipmapping.cpp b/attachments/29_mipmapping.cpp index d80a73cb..3df5987a 100644 --- a/attachments/29_mipmapping.cpp +++ b/attachments/29_mipmapping.cpp @@ -322,9 +322,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -344,7 +352,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..4b4091bd 100644 --- a/attachments/30_multisampling.cpp +++ b/attachments/30_multisampling.cpp @@ -329,9 +329,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -351,7 +359,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..9c1e7d93 100644 --- a/attachments/31_compute_shader.cpp +++ b/attachments/31_compute_shader.cpp @@ -297,9 +297,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -321,7 +329,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..d62698a4 100644 --- a/attachments/32_ecosystem_utilities.cpp +++ b/attachments/32_ecosystem_utilities.cpp @@ -353,9 +353,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -367,7 +375,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..84edc357 100644 --- a/attachments/33_vulkan_profiles.cpp +++ b/attachments/33_vulkan_profiles.cpp @@ -361,9 +361,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -375,7 +383,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..6a7a163b 100644 --- a/attachments/34_android.cpp +++ b/attachments/34_android.cpp @@ -487,9 +487,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -501,7 +509,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..cd13f9b8 100644 --- a/attachments/35_gltf_ktx.cpp +++ b/attachments/35_gltf_ktx.cpp @@ -476,9 +476,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -497,7 +505,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..e311ba7f 100644 --- a/attachments/36_multiple_objects.cpp +++ b/attachments/36_multiple_objects.cpp @@ -549,9 +549,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -570,7 +578,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..97741f2a 100644 --- a/attachments/37_multithreading.cpp +++ b/attachments/37_multithreading.cpp @@ -592,9 +592,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -613,7 +621,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..a1ad25f1 100644 --- a/attachments/38_ray_tracing.cpp +++ b/attachments/38_ray_tracing.cpp @@ -405,9 +405,17 @@ 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 + // Check if any of the queue families support both graphics and presentation to our surface auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphics = std::ranges::any_of(queueFamilies, [](auto const &qfp) { return !!(qfp.queueFlags & vk::QueueFlagBits::eGraphics); }); + bool supportsGraphicsAndPresent = false; + for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) + { + if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) + { + supportsGraphicsAndPresent = true; + break; + } + } // Check if all required physicalDevice extensions are available auto availableDeviceExtensions = physicalDevice.enumerateDeviceExtensionProperties(); @@ -438,7 +446,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() From 0e39e559cdebaa07021b20b08b1bab9504f348ad Mon Sep 17 00:00:00 2001 From: swinston Date: Tue, 1 Sep 2026 12:08:35 -0700 Subject: [PATCH 2/2] Carry the any_of presentation-support refactor to all chapters --- attachments/05_window_surface.cpp | 19 +++++++++---------- attachments/06_swap_chain_creation.cpp | 19 +++++++++---------- attachments/07_image_views.cpp | 19 +++++++++---------- attachments/08_graphics_pipeline.cpp | 19 +++++++++---------- attachments/09_shader_modules.cpp | 19 +++++++++---------- attachments/10_fixed_functions.cpp | 19 +++++++++---------- attachments/12_graphics_pipeline_complete.cpp | 19 +++++++++---------- attachments/14_command_buffers.cpp | 19 +++++++++---------- attachments/15_hello_triangle.cpp | 19 +++++++++---------- attachments/16_frames_in_flight.cpp | 19 +++++++++---------- attachments/17_swap_chain_recreation.cpp | 19 +++++++++---------- attachments/19_vertex_buffer.cpp | 19 +++++++++---------- attachments/20_staging_buffer.cpp | 19 +++++++++---------- attachments/21_index_buffer.cpp | 19 +++++++++---------- attachments/22_descriptor_layout.cpp | 19 +++++++++---------- attachments/23_descriptor_sets.cpp | 19 +++++++++---------- attachments/24_texture_image.cpp | 19 +++++++++---------- attachments/25_sampler.cpp | 19 +++++++++---------- attachments/26_texture_mapping.cpp | 19 +++++++++---------- attachments/27_depth_buffering.cpp | 19 +++++++++---------- attachments/28_model_loading.cpp | 19 +++++++++---------- attachments/29_mipmapping.cpp | 19 +++++++++---------- attachments/30_multisampling.cpp | 19 +++++++++---------- attachments/31_compute_shader.cpp | 19 +++++++++---------- attachments/32_ecosystem_utilities.cpp | 19 +++++++++---------- attachments/33_vulkan_profiles.cpp | 19 +++++++++---------- attachments/34_android.cpp | 19 +++++++++---------- attachments/35_gltf_ktx.cpp | 19 +++++++++---------- attachments/36_multiple_objects.cpp | 19 +++++++++---------- attachments/37_multithreading.cpp | 19 +++++++++---------- attachments/38_ray_tracing.cpp | 19 +++++++++---------- 31 files changed, 279 insertions(+), 310 deletions(-) diff --git a/attachments/05_window_surface.cpp b/attachments/05_window_surface.cpp index 114e2765..d8b27fe4 100644 --- a/attachments/05_window_surface.cpp +++ b/attachments/05_window_surface.cpp @@ -167,16 +167,15 @@ class HelloTriangleApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/06_swap_chain_creation.cpp b/attachments/06_swap_chain_creation.cpp index 2b506e61..bbf7d8fb 100644 --- a/attachments/06_swap_chain_creation.cpp +++ b/attachments/06_swap_chain_creation.cpp @@ -175,16 +175,15 @@ class HelloTriangleApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/07_image_views.cpp b/attachments/07_image_views.cpp index 33df59fb..79839491 100644 --- a/attachments/07_image_views.cpp +++ b/attachments/07_image_views.cpp @@ -176,16 +176,15 @@ class HelloTriangleApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/08_graphics_pipeline.cpp b/attachments/08_graphics_pipeline.cpp index 99f15c8d..29ac55f8 100644 --- a/attachments/08_graphics_pipeline.cpp +++ b/attachments/08_graphics_pipeline.cpp @@ -177,16 +177,15 @@ class HelloTriangleApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/09_shader_modules.cpp b/attachments/09_shader_modules.cpp index 76ae4a1e..305979b4 100644 --- a/attachments/09_shader_modules.cpp +++ b/attachments/09_shader_modules.cpp @@ -178,16 +178,15 @@ class HelloTriangleApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/10_fixed_functions.cpp b/attachments/10_fixed_functions.cpp index d60e0487..7948f0b8 100644 --- a/attachments/10_fixed_functions.cpp +++ b/attachments/10_fixed_functions.cpp @@ -180,16 +180,15 @@ class HelloTriangleApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/12_graphics_pipeline_complete.cpp b/attachments/12_graphics_pipeline_complete.cpp index c2bd9618..2792364e 100644 --- a/attachments/12_graphics_pipeline_complete.cpp +++ b/attachments/12_graphics_pipeline_complete.cpp @@ -181,16 +181,15 @@ class HelloTriangleApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/14_command_buffers.cpp b/attachments/14_command_buffers.cpp index 29d12d14..f56c365a 100644 --- a/attachments/14_command_buffers.cpp +++ b/attachments/14_command_buffers.cpp @@ -186,16 +186,15 @@ class HelloTriangleApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/15_hello_triangle.cpp b/attachments/15_hello_triangle.cpp index c92a06db..e7bbada4 100644 --- a/attachments/15_hello_triangle.cpp +++ b/attachments/15_hello_triangle.cpp @@ -194,16 +194,15 @@ class HelloTriangleApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/16_frames_in_flight.cpp b/attachments/16_frames_in_flight.cpp index e36a3297..ad3476b8 100644 --- a/attachments/16_frames_in_flight.cpp +++ b/attachments/16_frames_in_flight.cpp @@ -197,16 +197,15 @@ class HelloTriangleApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/17_swap_chain_recreation.cpp b/attachments/17_swap_chain_recreation.cpp index fe844112..b613d802 100644 --- a/attachments/17_swap_chain_recreation.cpp +++ b/attachments/17_swap_chain_recreation.cpp @@ -230,16 +230,15 @@ class HelloTriangleApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/19_vertex_buffer.cpp b/attachments/19_vertex_buffer.cpp index 20669770..766b4ae2 100644 --- a/attachments/19_vertex_buffer.cpp +++ b/attachments/19_vertex_buffer.cpp @@ -258,16 +258,15 @@ class HelloTriangleApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/20_staging_buffer.cpp b/attachments/20_staging_buffer.cpp index be28542d..140f95e1 100644 --- a/attachments/20_staging_buffer.cpp +++ b/attachments/20_staging_buffer.cpp @@ -258,16 +258,15 @@ class HelloTriangleApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/21_index_buffer.cpp b/attachments/21_index_buffer.cpp index 4a2a880a..dc423f55 100644 --- a/attachments/21_index_buffer.cpp +++ b/attachments/21_index_buffer.cpp @@ -265,16 +265,15 @@ class HelloTriangleApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/22_descriptor_layout.cpp b/attachments/22_descriptor_layout.cpp index 72773d30..95331325 100644 --- a/attachments/22_descriptor_layout.cpp +++ b/attachments/22_descriptor_layout.cpp @@ -283,16 +283,15 @@ class HelloTriangleApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/23_descriptor_sets.cpp b/attachments/23_descriptor_sets.cpp index e5b99365..9f1818bd 100644 --- a/attachments/23_descriptor_sets.cpp +++ b/attachments/23_descriptor_sets.cpp @@ -288,16 +288,15 @@ class HelloTriangleApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/24_texture_image.cpp b/attachments/24_texture_image.cpp index 45a7e499..a02c97e5 100644 --- a/attachments/24_texture_image.cpp +++ b/attachments/24_texture_image.cpp @@ -295,16 +295,15 @@ class HelloTriangleApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/25_sampler.cpp b/attachments/25_sampler.cpp index de0ebcfd..40b03958 100644 --- a/attachments/25_sampler.cpp +++ b/attachments/25_sampler.cpp @@ -299,16 +299,15 @@ class HelloTriangleApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/26_texture_mapping.cpp b/attachments/26_texture_mapping.cpp index d31ead52..e8316b96 100644 --- a/attachments/26_texture_mapping.cpp +++ b/attachments/26_texture_mapping.cpp @@ -300,16 +300,15 @@ class HelloTriangleApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/27_depth_buffering.cpp b/attachments/27_depth_buffering.cpp index 3972ed7b..77959c0c 100644 --- a/attachments/27_depth_buffering.cpp +++ b/attachments/27_depth_buffering.cpp @@ -315,16 +315,15 @@ class HelloTriangleApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/28_model_loading.cpp b/attachments/28_model_loading.cpp index 6ac28011..e93c346e 100644 --- a/attachments/28_model_loading.cpp +++ b/attachments/28_model_loading.cpp @@ -322,16 +322,15 @@ class HelloTriangleApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/29_mipmapping.cpp b/attachments/29_mipmapping.cpp index 3df5987a..f9439f9d 100644 --- a/attachments/29_mipmapping.cpp +++ b/attachments/29_mipmapping.cpp @@ -323,16 +323,15 @@ class HelloTriangleApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/30_multisampling.cpp b/attachments/30_multisampling.cpp index 4b4091bd..e3b671ec 100644 --- a/attachments/30_multisampling.cpp +++ b/attachments/30_multisampling.cpp @@ -330,16 +330,15 @@ class HelloTriangleApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/31_compute_shader.cpp b/attachments/31_compute_shader.cpp index 9c1e7d93..0151fcbb 100644 --- a/attachments/31_compute_shader.cpp +++ b/attachments/31_compute_shader.cpp @@ -298,16 +298,15 @@ class ComputeShaderApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/32_ecosystem_utilities.cpp b/attachments/32_ecosystem_utilities.cpp index d62698a4..f1bb310c 100644 --- a/attachments/32_ecosystem_utilities.cpp +++ b/attachments/32_ecosystem_utilities.cpp @@ -354,16 +354,15 @@ class HelloTriangleApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/33_vulkan_profiles.cpp b/attachments/33_vulkan_profiles.cpp index 84edc357..521bde67 100644 --- a/attachments/33_vulkan_profiles.cpp +++ b/attachments/33_vulkan_profiles.cpp @@ -362,16 +362,15 @@ class HelloTriangleApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/34_android.cpp b/attachments/34_android.cpp index 6a7a163b..c503e259 100644 --- a/attachments/34_android.cpp +++ b/attachments/34_android.cpp @@ -488,16 +488,15 @@ class HelloTriangleApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/35_gltf_ktx.cpp b/attachments/35_gltf_ktx.cpp index cd13f9b8..7d22f5dc 100644 --- a/attachments/35_gltf_ktx.cpp +++ b/attachments/35_gltf_ktx.cpp @@ -477,16 +477,15 @@ class VulkanApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/36_multiple_objects.cpp b/attachments/36_multiple_objects.cpp index e311ba7f..22eb23db 100644 --- a/attachments/36_multiple_objects.cpp +++ b/attachments/36_multiple_objects.cpp @@ -550,16 +550,15 @@ class VulkanApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/37_multithreading.cpp b/attachments/37_multithreading.cpp index 97741f2a..1e02c461 100644 --- a/attachments/37_multithreading.cpp +++ b/attachments/37_multithreading.cpp @@ -593,16 +593,15 @@ class MultithreadedApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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(); diff --git a/attachments/38_ray_tracing.cpp b/attachments/38_ray_tracing.cpp index a1ad25f1..fd2bbc74 100644 --- a/attachments/38_ray_tracing.cpp +++ b/attachments/38_ray_tracing.cpp @@ -406,16 +406,15 @@ class VulkanRaytracingApplication bool supportsVulkan1_3 = physicalDevice.getProperties().apiVersion >= VK_API_VERSION_1_3; // Check if any of the queue families support both graphics and presentation to our surface - auto queueFamilies = physicalDevice.getQueueFamilyProperties(); - bool supportsGraphicsAndPresent = false; - for (uint32_t qfpIndex = 0; qfpIndex < queueFamilies.size(); qfpIndex++) - { - if ((queueFamilies[qfpIndex].queueFlags & vk::QueueFlagBits::eGraphics) && physicalDevice.getSurfaceSupportKHR(qfpIndex, *surface)) - { - supportsGraphicsAndPresent = true; - break; - } - } + 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();