From a66936d4118f04efee29f0c9f02f78be3a066606 Mon Sep 17 00:00:00 2001 From: swinston Date: Thu, 20 Aug 2026 16:21:20 -0700 Subject: [PATCH] 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()