From 41757d7140c41daa63d44055830dafb67735aa97 Mon Sep 17 00:00:00 2001
From: Vanessa Karolek <vaka1997@uni-koblenz.de>
Date: Wed, 1 Sep 2021 14:47:55 +0200
Subject: [PATCH] [#92] add feature functions to FeatureManager for RTX
 Features

---
 include/vkcv/FeatureManager.hpp |  12 ++++
 src/vkcv/FeatureManager.cpp     | 103 +++++++++++++++++++++++++++++++-
 2 files changed, 113 insertions(+), 2 deletions(-)

diff --git a/include/vkcv/FeatureManager.hpp b/include/vkcv/FeatureManager.hpp
index cf945d74..99d7e7ab 100644
--- a/include/vkcv/FeatureManager.hpp
+++ b/include/vkcv/FeatureManager.hpp
@@ -78,6 +78,18 @@ namespace vkcv {
 		
 		[[nodiscard]]
 		bool checkSupport(const vk::PhysicalDeviceMeshShaderFeaturesNV& features, bool required) const;
+
+		[[nodiscard]]
+		bool checkSupport(const vk::PhysicalDeviceVulkan12Features& features, bool required) const;
+
+		[[nodiscard]]
+		bool checkSupport(const vk::PhysicalDeviceVulkan11Features& features, bool required) const;
+
+		[[nodiscard]]
+		bool checkSupport(const vk::PhysicalDeviceAccelerationStructureFeaturesKHR& features, bool required) const;
+
+		[[nodiscard]]
+		bool checkSupport(const vk::PhysicalDeviceRayTracingPipelineFeaturesKHR& features, bool required) const;
 		
 		vk::BaseOutStructure* findFeatureStructure(vk::StructureType type) const;
 	
diff --git a/src/vkcv/FeatureManager.cpp b/src/vkcv/FeatureManager.cpp
index 18307999..614e48cb 100644
--- a/src/vkcv/FeatureManager.cpp
+++ b/src/vkcv/FeatureManager.cpp
@@ -156,7 +156,7 @@ m_physicalDevice.getFeatures2(&query)
 		vkcv_check_init_features2(vk::PhysicalDeviceHostQueryResetFeatures);
 		
 		vkcv_check_feature(hostQueryReset);
-		
+
 		return true;
 	}
 	
@@ -258,7 +258,7 @@ m_physicalDevice.getFeatures2(&query)
 		vkcv_check_init_features2(vk::PhysicalDeviceUniformBufferStandardLayoutFeatures);
 		
 		vkcv_check_feature(uniformBufferStandardLayout);
-		
+
 		return true;
 	}
 	
@@ -291,6 +291,105 @@ m_physicalDevice.getFeatures2(&query)
 		
 		return true;
 	}
+
+	bool FeatureManager::checkSupport(const vk::PhysicalDeviceVulkan12Features &features, bool required) const {
+	    vkcv_check_init_features2(vk::PhysicalDeviceVulkan12Features);
+
+	    vkcv_check_feature(samplerMirrorClampToEdge);
+	    vkcv_check_feature(drawIndirectCount);
+	    vkcv_check_feature(storageBuffer8BitAccess);
+	    vkcv_check_feature(uniformAndStorageBuffer8BitAccess);
+	    vkcv_check_feature(storagePushConstant8);
+	    vkcv_check_feature(shaderBufferInt64Atomics);
+	    vkcv_check_feature(shaderSharedInt64Atomics);
+	    vkcv_check_feature(shaderFloat16);
+	    vkcv_check_feature(shaderInt8);
+	    vkcv_check_feature(descriptorIndexing);
+	    vkcv_check_feature(shaderInputAttachmentArrayDynamicIndexing);
+	    vkcv_check_feature(shaderUniformTexelBufferArrayDynamicIndexing);
+	    vkcv_check_feature(shaderStorageTexelBufferArrayDynamicIndexing);
+	    vkcv_check_feature(shaderUniformBufferArrayNonUniformIndexing);
+	    vkcv_check_feature(shaderSampledImageArrayNonUniformIndexing);
+	    vkcv_check_feature(shaderStorageBufferArrayNonUniformIndexing);
+	    vkcv_check_feature(shaderStorageImageArrayNonUniformIndexing);
+	    vkcv_check_feature(shaderInputAttachmentArrayNonUniformIndexing);
+	    vkcv_check_feature(shaderUniformTexelBufferArrayNonUniformIndexing);
+	    vkcv_check_feature(shaderStorageTexelBufferArrayNonUniformIndexing);
+	    vkcv_check_feature(descriptorBindingUniformBufferUpdateAfterBind);
+	    vkcv_check_feature(descriptorBindingSampledImageUpdateAfterBind);
+	    vkcv_check_feature(descriptorBindingStorageImageUpdateAfterBind);
+	    vkcv_check_feature(descriptorBindingStorageBufferUpdateAfterBind);
+	    vkcv_check_feature(descriptorBindingUniformTexelBufferUpdateAfterBind);
+	    vkcv_check_feature(descriptorBindingStorageTexelBufferUpdateAfterBind);
+	    vkcv_check_feature(descriptorBindingUpdateUnusedWhilePending);
+	    vkcv_check_feature(descriptorBindingPartiallyBound);
+	    vkcv_check_feature(descriptorBindingVariableDescriptorCount);
+	    vkcv_check_feature(runtimeDescriptorArray);
+	    vkcv_check_feature(samplerFilterMinmax);
+	    vkcv_check_feature(scalarBlockLayout);
+	    vkcv_check_feature(imagelessFramebuffer);
+	    vkcv_check_feature(uniformBufferStandardLayout);
+	    vkcv_check_feature(shaderSubgroupExtendedTypes);
+	    vkcv_check_feature(separateDepthStencilLayouts);
+	    vkcv_check_feature(hostQueryReset);
+	    vkcv_check_feature(timelineSemaphore);
+	    vkcv_check_feature(bufferDeviceAddress);
+	    vkcv_check_feature(bufferDeviceAddressCaptureReplay);
+	    vkcv_check_feature(bufferDeviceAddressMultiDevice);
+	    vkcv_check_feature(vulkanMemoryModel);
+	    vkcv_check_feature(vulkanMemoryModelDeviceScope);
+	    vkcv_check_feature(vulkanMemoryModelAvailabilityVisibilityChains);
+	    vkcv_check_feature(shaderOutputViewportIndex);
+	    vkcv_check_feature(shaderOutputLayer);
+	    vkcv_check_feature(subgroupBroadcastDynamicId);
+
+	    return true;
+	}
+
+	bool FeatureManager::checkSupport(const vk::PhysicalDeviceVulkan11Features &features, bool required) const {
+	    vkcv_check_init_features2(vk::PhysicalDeviceVulkan11Features);
+
+	    vkcv_check_feature(multiview);
+	    vkcv_check_feature(multiviewGeometryShader);
+	    vkcv_check_feature(multiviewTessellationShader);
+	    vkcv_check_feature(protectedMemory);
+	    vkcv_check_feature(samplerYcbcrConversion);
+	    vkcv_check_feature(shaderDrawParameters);
+	    vkcv_check_feature(storageBuffer16BitAccess);
+	    vkcv_check_feature(storageInputOutput16);
+	    vkcv_check_feature(storagePushConstant16);
+	    vkcv_check_feature(uniformAndStorageBuffer16BitAccess);
+	    vkcv_check_feature(variablePointers);
+	    vkcv_check_feature(variablePointersStorageBuffer);
+
+	    // TODO: (Validation Error) if using VulkanFeatures11, disable VkPhysicalDevice16BitStorageFeatures
+
+	    return true;
+	}
+
+	bool FeatureManager::checkSupport(const vk::PhysicalDeviceAccelerationStructureFeaturesKHR &features, bool required) const {
+	    vkcv_check_init_features2(vk::PhysicalDeviceAccelerationStructureFeaturesKHR);
+
+	    vkcv_check_feature(accelerationStructure);
+	    vkcv_check_feature(accelerationStructureCaptureReplay);
+	    vkcv_check_feature(accelerationStructureIndirectBuild);
+	    vkcv_check_feature(accelerationStructureHostCommands);
+	    vkcv_check_feature(descriptorBindingAccelerationStructureUpdateAfterBind);
+
+	    return true;
+	}
+
+	bool FeatureManager::checkSupport(const vk::PhysicalDeviceRayTracingPipelineFeaturesKHR &features, bool required) const {
+	    vkcv_check_init_features2(vk::PhysicalDeviceRayTracingPipelineFeaturesKHR);
+
+	    vkcv_check_feature(rayTracingPipeline);
+	    vkcv_check_feature(rayTracingPipelineShaderGroupHandleCaptureReplay);
+	    vkcv_check_feature(rayTracingPipelineShaderGroupHandleCaptureReplayMixed);
+	    vkcv_check_feature(rayTracingPipelineTraceRaysIndirect);
+	    vkcv_check_feature(rayTraversalPrimitiveCulling);
+
+	    return true;
+	}
 	
 	vk::BaseOutStructure* FeatureManager::findFeatureStructure(vk::StructureType type) const {
 		for (auto& base : m_featuresExtensions) {
-- 
GitLab