Fixed missing setup for deferred surface init

It needed to add the surface extension and not check for present
support.
This commit is contained in:
Charles Giessen 2020-04-19 00:52:31 -06:00
parent 00b6a74aa8
commit 959979b07a
2 changed files with 13 additions and 7 deletions

View File

@ -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<PhysicalDevice, detail::Error<PhysicalDeviceError>> 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<Device, detail::Error<DeviceError>> DeviceBuilder::build () const {
@ -1045,7 +1048,8 @@ detail::Expected<Device, detail::Error<DeviceError>> DeviceBuilder::build () con
}
std::vector<const char*> 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;

View File

@ -317,6 +317,7 @@ struct PhysicalDevice {
private:
std::vector<const char*> extensions_to_enable;
std::vector<VkQueueFamilyProperties> 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<VkQueueFamilyProperties> 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<VkBaseOutStructure*> pNext_chain;
PhysicalDevice physical_device;
VkSurfaceKHR surface;
VkSurfaceKHR surface = VK_NULL_HANDLE;
bool defer_surface_initialization = false;
std::vector<VkQueueFamilyProperties> queue_families;
VkPhysicalDeviceFeatures features;
VkPhysicalDeviceFeatures features{};
std::vector<const char*> extensions_to_enable;
std::vector<CustomQueueDescription> queue_descriptions;
VkAllocationCallbacks* allocation_callbacks = VK_NULL_HANDLE;