diff --git a/src/VkBootstrap.cpp b/src/VkBootstrap.cpp index 4c53f17..5034618 100644 --- a/src/VkBootstrap.cpp +++ b/src/VkBootstrap.cpp @@ -768,6 +768,19 @@ InstanceBuilder& InstanceBuilder::enable_extension(const char* extension_name) { info.extensions.push_back(extension_name); return *this; } +InstanceBuilder& InstanceBuilder::enable_extensions(std::vector const& extensions) { + for (const auto extension : extensions) { + info.extensions.push_back(extension); + } + return *this; +} +InstanceBuilder& InstanceBuilder::enable_extensions(size_t count, const char* const* extensions) { + if (!extensions || count == 0) return *this; + for (size_t i = 0; i < count; i++) { + info.extensions.push_back(extensions[i]); + } + return *this; +} InstanceBuilder& InstanceBuilder::enable_validation_layers(bool enable_validation) { info.enable_validation_layers = enable_validation; return *this; @@ -1286,12 +1299,19 @@ PhysicalDeviceSelector& PhysicalDeviceSelector::add_required_extension(const cha criteria.required_extensions.push_back(extension); return *this; } -PhysicalDeviceSelector& PhysicalDeviceSelector::add_required_extensions(std::vector extensions) { +PhysicalDeviceSelector& PhysicalDeviceSelector::add_required_extensions(std::vector const& extensions) { for (const auto& ext : extensions) { criteria.required_extensions.push_back(ext); } return *this; } +PhysicalDeviceSelector& PhysicalDeviceSelector::add_required_extensions(size_t count, const char* const* extensions) { + if (!extensions || count == 0) return *this; + for (size_t i = 0; i < count; i++) { + criteria.required_extensions.push_back(extensions[i]); + } + return *this; +} PhysicalDeviceSelector& PhysicalDeviceSelector::add_desired_extension(const char* extension) { criteria.desired_extensions.push_back(extension); return *this; diff --git a/src/VkBootstrap.h b/src/VkBootstrap.h index c2ee696..5af5f1d 100644 --- a/src/VkBootstrap.h +++ b/src/VkBootstrap.h @@ -377,6 +377,8 @@ class InstanceBuilder { InstanceBuilder& enable_layer(const char* layer_name); // Adds an extension to be enabled. Will fail to create an instance if the extension isn't available. InstanceBuilder& enable_extension(const char* extension_name); + InstanceBuilder& enable_extensions(std::vector const& extensions); + InstanceBuilder& enable_extensions(size_t count, const char* const* extensions); // Headless Mode does not load the required extensions for presentation. Defaults to true. InstanceBuilder& set_headless(bool headless = true); @@ -590,7 +592,8 @@ class PhysicalDeviceSelector { // Require a physical device which supports a specific extension. PhysicalDeviceSelector& add_required_extension(const char* extension); // Require a physical device which supports a set of extensions. - PhysicalDeviceSelector& add_required_extensions(std::vector extensions); + PhysicalDeviceSelector& add_required_extensions(std::vector const& extensions); + PhysicalDeviceSelector& add_required_extensions(size_t count, const char* const* extensions); // Prefer a physical device which supports a specific extension. [[deprecated]] PhysicalDeviceSelector& add_desired_extension(const char* extension);