From 92dc5971849ec983625f5abd655633470dfe5e89 Mon Sep 17 00:00:00 2001 From: n0F4x Date: Tue, 30 Apr 2024 17:58:02 +0200 Subject: [PATCH] Add `are_extension_features_present` to `PhysicalDevice` --- src/VkBootstrap.cpp | 7 +++++++ src/VkBootstrap.h | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/src/VkBootstrap.cpp b/src/VkBootstrap.cpp index f85cdd4..d444ffc 100644 --- a/src/VkBootstrap.cpp +++ b/src/VkBootstrap.cpp @@ -1508,6 +1508,13 @@ bool PhysicalDevice::enable_features_if_present(const VkPhysicalDeviceFeatures& return required_features_supported; } +bool PhysicalDevice::is_features_node_present(detail::GenericFeaturesPNextNode const& node) const { + detail::GenericFeatureChain requested_features; + requested_features.nodes.push_back(node); + + return detail::supports_features({}, {}, extended_features_chain, requested_features); +} + bool PhysicalDevice::enable_features_node_if_present(detail::GenericFeaturesPNextNode const& node) { VkPhysicalDeviceFeatures2 actual_pdf2{}; diff --git a/src/VkBootstrap.h b/src/VkBootstrap.h index 5025d3a..68ff6c8 100644 --- a/src/VkBootstrap.h +++ b/src/VkBootstrap.h @@ -528,6 +528,11 @@ struct PhysicalDevice { // Returns true if an extension should be enabled on the device bool is_extension_present(const char* extension) const; + // Returns true if all of the features are present + template bool are_extension_features_present(T const& features) const { + return is_features_node_present(detail::GenericFeaturesPNextNode(features)); + } + // If the given extension is present, make the extension be enabled on the device. // Returns true the extension is present. bool enable_extension_if_present(const char* extension); @@ -564,6 +569,7 @@ struct PhysicalDevice { friend class PhysicalDeviceSelector; friend class DeviceBuilder; + bool is_features_node_present(detail::GenericFeaturesPNextNode const& node) const; bool enable_features_node_if_present(detail::GenericFeaturesPNextNode const& node); };