diff --git a/instance.cpp b/instance.cpp index 5013bf1..cf54e01 100644 --- a/instance.cpp +++ b/instance.cpp @@ -83,17 +83,14 @@ instance::instance (const create_info_t &info): std::set instance::extensions (void) const { - uint32_t expected = 0; - error::try_code (vkEnumerateInstanceExtensionProperties (nullptr, &expected, nullptr)); + auto values = error::try_values ( + vkEnumerateInstanceExtensionProperties, nullptr + ); - VkExtensionProperties props[expected]; - uint32_t found = expected; - error::try_code (vkEnumerateInstanceExtensionProperties (nullptr, &found, props)); - - std::set ext; - for (const auto &i: props) - ext.insert (i.extensionName); - return ext; + std::set strings; + for (const auto &i: values) + strings.insert (i.extensionName); + return strings; } @@ -101,11 +98,5 @@ instance::extensions (void) const std::vector instance::available_layers (void) { - - uint32_t count; - vk::error::try_code (vkEnumerateInstanceLayerProperties (&count, nullptr)); - - std::vector layers (count); - vk::error::try_code (vkEnumerateInstanceLayerProperties (&count, layers.data ())); - return layers; + return error::try_values (vkEnumerateInstanceLayerProperties); } diff --git a/physical_device.cpp b/physical_device.cpp index 85e9b7e..1c9f136 100644 --- a/physical_device.cpp +++ b/physical_device.cpp @@ -27,19 +27,17 @@ using cruft::vk::physical_device; std::set physical_device::extensions (void) const { - uint32_t expected = 0; - error::try_code (vkEnumerateDeviceExtensionProperties (native (), nullptr, &expected, nullptr)); + auto values = error::try_values ( + vkEnumerateDeviceExtensionProperties, native (), nullptr + ); - VkExtensionProperties props[expected]; - uint32_t found = expected; - error::try_code (vkEnumerateDeviceExtensionProperties (native (), nullptr, &found, props)); - - std::set ext; - for (const auto &i: props) - ext.insert (i.extensionName); - return ext; + std::set strings; + for (const auto &i: values) + strings.emplace (i.extensionName); + return strings; } + /////////////////////////////////////////////////////////////////////////////// VkPhysicalDeviceProperties physical_device::properties (void) const