diff --git a/src/VkBootstrap.cpp b/src/VkBootstrap.cpp index d349556..b04dbd3 100644 --- a/src/VkBootstrap.cpp +++ b/src/VkBootstrap.cpp @@ -722,7 +722,8 @@ PhysicalDeviceSelector::Suitable PhysicalDeviceSelector::is_device_suitable (Phy if (criteria.require_dedicated_transfer_queue && !dedicated_transfer) return Suitable::no; if (criteria.require_separate_compute_queue && !separate_compute) return Suitable::no; if (criteria.require_separate_transfer_queue && !separate_transfer) return Suitable::no; - if (criteria.require_present && !present_queue) return Suitable::no; + if (criteria.require_present && !present_queue && !criteria.defer_surface_initialization) + return Suitable::no; auto required_extensions_supported = detail::check_device_extension_support (pd.phys_device, criteria.required_extensions); @@ -835,6 +836,7 @@ detail::Expected> PhysicalDev out_device.properties = selected_device.device_properties; out_device.memory_properties = selected_device.mem_properties; out_device.queue_families = selected_device.queue_families; + out_device.defer_surface_initialization = criteria.defer_surface_initialization; out_device.extensions_to_enable.insert (out_device.extensions_to_enable.end (), criteria.required_extensions.begin (), @@ -1020,6 +1022,7 @@ DeviceBuilder::DeviceBuilder (PhysicalDevice phys_device) { info.queue_families = phys_device.queue_families; info.features = phys_device.features; info.extensions_to_enable = phys_device.extensions_to_enable; + info.defer_surface_initialization = phys_device.defer_surface_initialization; } detail::Expected> DeviceBuilder::build () const { @@ -1045,7 +1048,8 @@ detail::Expected> DeviceBuilder::build () con } std::vector extensions = info.extensions_to_enable; - if (info.surface != VK_NULL_HANDLE) extensions.push_back ({ VK_KHR_SWAPCHAIN_EXTENSION_NAME }); + if (info.surface != VK_NULL_HANDLE || info.defer_surface_initialization) + extensions.push_back ({ VK_KHR_SWAPCHAIN_EXTENSION_NAME }); // VUID-VkDeviceCreateInfo-pNext-00373 - don't add pEnabledFeatures if the phys_dev_features_2 is present bool has_phys_dev_features_2 = false; diff --git a/src/VkBootstrap.h b/src/VkBootstrap.h index 1593128..79220d1 100644 --- a/src/VkBootstrap.h +++ b/src/VkBootstrap.h @@ -317,6 +317,7 @@ struct PhysicalDevice { private: std::vector extensions_to_enable; std::vector queue_families; + bool defer_surface_initialization = false; friend class PhysicalDeviceSelector; friend class DeviceBuilder; }; @@ -398,9 +399,9 @@ class PhysicalDeviceSelector { VkPhysicalDevice phys_device = VK_NULL_HANDLE; std::vector queue_families; - VkPhysicalDeviceFeatures device_features; - VkPhysicalDeviceProperties device_properties; - VkPhysicalDeviceMemoryProperties mem_properties; + VkPhysicalDeviceFeatures device_features{}; + VkPhysicalDeviceProperties device_properties{}; + VkPhysicalDeviceMemoryProperties mem_properties{}; }; PhysicalDeviceDesc populate_device_details (VkPhysicalDevice phys_device) const; @@ -489,9 +490,10 @@ class DeviceBuilder { VkDeviceCreateFlags flags = 0; std::vector pNext_chain; PhysicalDevice physical_device; - VkSurfaceKHR surface; + VkSurfaceKHR surface = VK_NULL_HANDLE; + bool defer_surface_initialization = false; std::vector queue_families; - VkPhysicalDeviceFeatures features; + VkPhysicalDeviceFeatures features{}; std::vector extensions_to_enable; std::vector queue_descriptions; VkAllocationCallbacks* allocation_callbacks = VK_NULL_HANDLE;