diff --git a/src/VkBootstrap.cpp b/src/VkBootstrap.cpp index 941c421..b124d1a 100644 --- a/src/VkBootstrap.cpp +++ b/src/VkBootstrap.cpp @@ -960,8 +960,10 @@ void destroy_device (Device device) { DeviceBuilder::DeviceBuilder (PhysicalDevice phys_device) { info.physical_device = phys_device; - info.extensions = phys_device.extensions_to_enable; + info.surface = phys_device.surface; info.queue_families = phys_device.queue_families; + info.features = phys_device.features; + info.extensions_to_enable = phys_device.extensions_to_enable; } detail::Expected> DeviceBuilder::build () { @@ -986,11 +988,8 @@ detail::Expected> DeviceBuilder::build () { queueCreateInfos.push_back (queue_create_info); } - std::vector extensions; - for (auto& ext : info.extensions) - extensions.push_back (ext); - if (info.physical_device.surface != VK_NULL_HANDLE) - extensions.push_back ({ VK_KHR_SWAPCHAIN_EXTENSION_NAME }); + std::vector extensions = info.extensions_to_enable; + if (info.surface != VK_NULL_HANDLE) extensions.push_back ({ VK_KHR_SWAPCHAIN_EXTENSION_NAME }); VkDeviceCreateInfo device_create_info = {}; device_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; @@ -1000,7 +999,7 @@ detail::Expected> DeviceBuilder::build () { device_create_info.pQueueCreateInfos = queueCreateInfos.data (); device_create_info.enabledExtensionCount = static_cast (extensions.size ()); device_create_info.ppEnabledExtensionNames = extensions.data (); - device_create_info.pEnabledFeatures = &info.physical_device.features; + device_create_info.pEnabledFeatures = &info.features; Device device; VkResult res = vkCreateDevice ( @@ -1009,7 +1008,7 @@ detail::Expected> DeviceBuilder::build () { return detail::Error{ DeviceError::failed_create_device, res }; } device.physical_device = info.physical_device; - device.surface = info.physical_device.surface; + device.surface = info.surface; device.queue_families = info.queue_families; device.allocation_callbacks = info.allocation_callbacks; return device; diff --git a/src/VkBootstrap.h b/src/VkBootstrap.h index 0d81092..ed4acf0 100644 --- a/src/VkBootstrap.h +++ b/src/VkBootstrap.h @@ -445,6 +445,7 @@ struct CustomQueueDescription { class DeviceBuilder { public: + // Any features and extensions that are requested/required in PhysicalDeviceSelector are automatically enabled. DeviceBuilder (PhysicalDevice physical_device); detail::Expected> build (); @@ -465,8 +466,10 @@ class DeviceBuilder { VkDeviceCreateFlags flags = 0; std::vector pNext_chain; PhysicalDevice physical_device; - std::vector extensions; + VkSurfaceKHR surface; std::vector queue_families; + VkPhysicalDeviceFeatures features; + std::vector extensions_to_enable; std::vector queue_descriptions; VkAllocationCallbacks* allocation_callbacks = VK_NULL_HANDLE; } info; @@ -522,9 +525,9 @@ class SwapchainBuilder { std::vector desired_present_modes; uint32_t desired_width = 256; uint32_t desired_height = 256; - std::vector pNext_elements; uint32_t graphics_queue_index = 0; uint32_t present_queue_index = 0; + std::vector pNext_elements; VkAllocationCallbacks* allocation_callbacks = VK_NULL_HANDLE; } info; };