diff --git a/include/vkcv/FeatureManager.hpp b/include/vkcv/FeatureManager.hpp index 9b4ad2b991f43c443d39be0a75228b2ce2b4a36b..b4d690bc855ca5ce80ddd8e2735513e48422efca 100644 --- a/include/vkcv/FeatureManager.hpp +++ b/include/vkcv/FeatureManager.hpp @@ -9,6 +9,9 @@ namespace vkcv { + /** + * Class to manage extension and feature requirements, support and usage. + */ class FeatureManager { private: /** @@ -330,7 +333,7 @@ namespace vkcv { /** * @brief Request specific features for optional or required usage. - * @tparam T Template parameter to use specific base structure types. + * @tparam T Template parameter to use specific base structure types * @param featureFunction Function or lambda to request specific features * @param required True, if the @p features are required, else false * @return @p True, if the requested features could be activated, else @p false diff --git a/include/vkcv/Features.hpp b/include/vkcv/Features.hpp index 6ef3fa28be912627b4495c66427336dfaa51beff..540827d8d50a99027d6db63f7093be9a163eb51c 100644 --- a/include/vkcv/Features.hpp +++ b/include/vkcv/Features.hpp @@ -8,30 +8,84 @@ namespace vkcv { + /** + * Abstract function type to request a feature via the feature manager. + */ typedef std::function<bool(FeatureManager&)> Feature; + /** + * Class to manage a list of feature requests at once. + */ class Features { private: + /** + * List of feature requests. + */ std::vector<Feature> m_features; public: + /** + * @brief Constructor of a features instance. + */ Features() = default; + /** + * @brief Constructor of a features instance with a given list of extension identifier strings. + * @param list List of extension identifier strings + */ Features(const std::initializer_list<std::string>& list); + /** + * @brief Copy-constructor of a features instance. + * @param other Other features instance + */ Features(const Features& other) = default; + + /** + * @brief Move-constructor of a features instance. + * @param other Other features instance + */ Features(Features&& other) = default; + /** + * @brief Destructor of a features instance. + */ ~Features() = default; + /** + * @brief Copy-operator of a features instance. + * @param other Other features instance + * @return Reference to the features instance itself + */ Features& operator=(const Features& other) = default; + + /** + * @brief Move-operator of a features instance. + * @param other Other features instance + * @return Reference to the features instance itself + */ Features& operator=(Features&& other) = default; + /** + * @brief Request a specific extension as required. + * @param extension Extension identifier string + */ void requireExtension(const std::string& extension); + /** + * @brief Request a specific extension and some of its features as required ( only core Vulkan 1.0 ). + * @param extension Extension identifier string + * @param featureFunction + */ void requireExtensionFeature(const std::string& extension, const std::function<void(vk::PhysicalDeviceFeatures&)>& featureFunction); + /** + * @brief Request a specific extension and some of its features as required. + * @tparam T Template parameter to use specific base structure types + * @param extension Extension identifier string + * @param featureFunction Function or lambda to request specific features + */ template<typename T> void requireExtensionFeature(const std::string& extension, const std::function<void(T&)>& featureFunction) { m_features.emplace_back([extension, featureFunction](FeatureManager& featureManager) { @@ -43,8 +97,17 @@ namespace vkcv { }); } + /** + * @brief Request a specific set of features as required ( only core Vulkan 1.0 ). + * @param featureFunction Function or lambda to request specific features + */ void requireFeature(const std::function<void(vk::PhysicalDeviceFeatures&)>& featureFunction); + /** + * @brief Request a specific set of features as required. + * @tparam T Template parameter to use specific base structure types + * @param featureFunction Function or lambda to request specific features + */ template<typename T> void requireFeature(const std::function<void(T&)>& featureFunction) { m_features.emplace_back([featureFunction](FeatureManager& featureManager) { @@ -52,11 +115,26 @@ namespace vkcv { }); } + /** + * @brief Request a specific extension as optional. + * @param extension Extension identifier string + */ void tryExtension(const std::string& extension); + /** + * @brief Request a specific extension and some of its features as optional ( only core Vulkan 1.0 ). + * @param extension Extension identifier string + * @param featureFunction Function or lambda to request specific features + */ void tryExtensionFeature(const std::string& extension, const std::function<void(vk::PhysicalDeviceFeatures&)>& featureFunction); + /** + * @brief Request a specific extension and some of its features as optional. + * @tparam T Template parameter to use specific base structure types + * @param extension Extension identifier string + * @param featureFunction Function or lambda to request specific features + */ template<typename T> void tryExtensionFeature(const std::string& extension, const std::function<void(T&)>& featureFunction) { m_features.emplace_back([extension, featureFunction](FeatureManager& featureManager) { @@ -68,8 +146,17 @@ namespace vkcv { }); } + /** + * @brief Request a specific set of features as optional ( only core Vulkan 1.0 ). + * @param featureFunction Function or lambda to request specific features + */ void tryFeature(const std::function<void(vk::PhysicalDeviceFeatures&)>& featureFunction); + /** + * @brief Request a specific set of features as optional. + * @tparam T Template parameter to use specific base structure types + * @param featureFunction Function or lambda to request specific features + */ template<typename T> void tryFeature(const std::function<void(T&)>& featureFunction) { m_features.emplace_back([featureFunction](FeatureManager& featureManager) { @@ -77,6 +164,10 @@ namespace vkcv { }); } + /** + * @brief Return list of feature requests. + * @return List of feature requests + */ [[nodiscard]] const std::vector<Feature>& getList() const;