From b022602d1914f87174533b5fb1a302caf8f57343 Mon Sep 17 00:00:00 2001
From: Tobias Frisch <tfrisch@uni-koblenz.de>
Date: Fri, 14 Oct 2022 17:09:30 +0200
Subject: [PATCH] Add support for shader termination via discard

Signed-off-by: Tobias Frisch <tfrisch@uni-koblenz.de>
---
 include/vkcv/FeatureManager.hpp | 10 ++++++++++
 src/vkcv/FeatureManager.cpp     |  9 +++++++++
 2 files changed, 19 insertions(+)

diff --git a/include/vkcv/FeatureManager.hpp b/include/vkcv/FeatureManager.hpp
index 9ccc9880..fa9f77be 100644
--- a/include/vkcv/FeatureManager.hpp
+++ b/include/vkcv/FeatureManager.hpp
@@ -354,6 +354,16 @@ namespace vkcv {
 		 */
 		[[nodiscard]] bool checkSupport(const vk::PhysicalDeviceIndexTypeUint8FeaturesEXT &features,
 										bool required) const;
+		
+		/**
+		 * @brief Checks support of the @p vk::PhysicalDeviceShaderTerminateInvocationFeatures.
+		 *
+		 * @param[in] features The features
+		 * @param[in] required True, if the @p features are required, else false
+		 * @return @p True, if the @p features are supported, else @p false
+		 */
+		[[nodiscard]] bool checkSupport(const vk::PhysicalDeviceShaderTerminateInvocationFeatures &features,
+										bool required) const;
 
 		/**
 		 * @brief Searches for a base structure of a given structure type.
diff --git a/src/vkcv/FeatureManager.cpp b/src/vkcv/FeatureManager.cpp
index afb2ff8c..ab8e20dd 100644
--- a/src/vkcv/FeatureManager.cpp
+++ b/src/vkcv/FeatureManager.cpp
@@ -504,6 +504,15 @@ namespace vkcv {
 		
 		return true;
 	}
+	
+	bool FeatureManager::checkSupport(const vk::PhysicalDeviceShaderTerminateInvocationFeatures &features,
+									  bool required) const {
+		vkcv_check_init_features2(vk::PhysicalDeviceShaderTerminateInvocationFeatures);
+		
+		vkcv_check_feature(shaderTerminateInvocation);
+		
+		return true;
+	}
 
 	vk::BaseOutStructure* FeatureManager::findFeatureStructure(vk::StructureType type) const {
 		for (auto &base : m_featuresExtensions) {
-- 
GitLab