diff --git a/include/merian/vk/extension/extension.hpp b/include/merian/vk/extension/extension.hpp index a725ef5..f80c029 100644 --- a/include/merian/vk/extension/extension.hpp +++ b/include/merian/vk/extension/extension.hpp @@ -72,9 +72,10 @@ class Extension { } /* Custom check for compatibility after the physical device is ready. - * If this method returns false, it is guaranteed that on_unsupported is called. + * At this time the structs wired up in pnext_get_features_2 is valid, you can use those to + * check if features are available. * - * At this time the structs wired up in pnext_get_features_2 is valid. + * If this method returns false, it is guaranteed that on_unsupported is called. */ virtual bool extension_supported(const Context::PhysicalDeviceContainer& /*unused*/) { return true; @@ -96,8 +97,8 @@ class Extension { return p_next; } /* Do not change pNext. You can use pnext_device_create_info for that. */ - virtual void enable_device_features(const Context::FeaturesContainer& /*unused*/, - Context::FeaturesContainer& /*unused*/) {} + virtual void enable_device_features(const Context::FeaturesContainer& /*supportedFeatures*/, + Context::FeaturesContainer& /*enableFeatures*/) {} virtual void on_device_created(const vk::Device& /*unused*/) {} /* Called right before context constructor returns. */ virtual void on_context_created(const ContextHandle& /*unused*/) {} @@ -117,7 +118,8 @@ class Extension { // return strings that should be defined when compiling shaders with Merians shader compiler. // Note that device, instance and Merian context extensions are automatically defined as - // MERIAN_DEVICE_EXT_ENABLED_, MERIAN_INSTANCE_EXT_ENABLED_, MERIAN_CONTEXT_EXT_ENABLED_ + // MERIAN_DEVICE_EXT_ENABLED_, MERIAN_INSTANCE_EXT_ENABLED_, + // MERIAN_CONTEXT_EXT_ENABLED_ virtual std::map shader_macro_definitions() { return {}; } diff --git a/include/merian/vk/extension/extension_vk_acceleration_structure.hpp b/include/merian/vk/extension/extension_vk_acceleration_structure.hpp index c36d6aa..e393df0 100644 --- a/include/merian/vk/extension/extension_vk_acceleration_structure.hpp +++ b/include/merian/vk/extension/extension_vk_acceleration_structure.hpp @@ -7,14 +7,12 @@ namespace merian { /** * @brief This class describes an extension to access * VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME. - * + * * Note that you must enable Ray Query or Ray Tracing Pipeline extension for this to work. */ class ExtensionVkAccelerationStructure : public Extension { public: - ExtensionVkAccelerationStructure() : Extension("ExtensionVkAccelerationStructure") { - acceleration_structure_features.accelerationStructure = VK_TRUE; - } + ExtensionVkAccelerationStructure() : Extension("ExtensionVkAccelerationStructure") {} ~ExtensionVkAccelerationStructure() {} std::vector required_device_extension_names(vk::PhysicalDevice) const override { @@ -32,6 +30,16 @@ class ExtensionVkAccelerationStructure : public Extension { props2.pNext = &acceleration_structure_properties; pd_container.physical_device.getProperties2(&props2); } + + void* pnext_get_features_2(void* const p_next) override { + acceleration_structure_features.setPNext(p_next); + return &acceleration_structure_features; + } + + bool extension_supported(const Context::PhysicalDeviceContainer& /*unused*/) override { + return acceleration_structure_features.accelerationStructure == VK_TRUE; + } + void* pnext_device_create_info(void* const p_next) override { acceleration_structure_features.pNext = p_next; return &acceleration_structure_features; diff --git a/include/merian/vk/extension/extension_vk_debug_utils.hpp b/include/merian/vk/extension/extension_vk_debug_utils.hpp index e03ffbe..838906b 100644 --- a/include/merian/vk/extension/extension_vk_debug_utils.hpp +++ b/include/merian/vk/extension/extension_vk_debug_utils.hpp @@ -3,8 +3,8 @@ #include "merian/vk/context.hpp" #include "merian/vk/extension/extension.hpp" -#include #include +#include namespace merian { @@ -48,9 +48,9 @@ class ExtensionVkDebugUtils : public Extension { // Own methods template void set_object_name(vk::Device& device, T handle, std::string name) { - vk::DebugUtilsObjectNameInfoEXT infoEXT( + vk::DebugUtilsObjectNameInfoEXT info_ext( handle.objectType, uint64_t(static_cast(handle)), name.c_str()); - device.setDebugUtilsObjectNameEXT(infoEXT); + device.setDebugUtilsObjectNameEXT(info_ext); } void cmd_begin_label(const vk::CommandBuffer& cmd, const std::string& name) { diff --git a/include/merian/vk/extension/extension_vk_filter_cubic.hpp b/include/merian/vk/extension/extension_vk_filter_cubic.hpp index 79bf471..df4e19b 100644 --- a/include/merian/vk/extension/extension_vk_filter_cubic.hpp +++ b/include/merian/vk/extension/extension_vk_filter_cubic.hpp @@ -8,7 +8,8 @@ class ExtensionVkFilterCubic : public Extension { public: ExtensionVkFilterCubic() : Extension("ExtensionVkFilterCubic") {} ~ExtensionVkFilterCubic() {} - std::vector required_device_extension_names(vk::PhysicalDevice) const override { + std::vector + required_device_extension_names(vk::PhysicalDevice /*unused*/) const override { return {VK_EXT_FILTER_CUBIC_EXTENSION_NAME}; } }; diff --git a/include/merian/vk/extension/extension_vk_float_atomics.hpp b/include/merian/vk/extension/extension_vk_float_atomics.hpp index c43d7b7..58ae09f 100644 --- a/include/merian/vk/extension/extension_vk_float_atomics.hpp +++ b/include/merian/vk/extension/extension_vk_float_atomics.hpp @@ -20,16 +20,16 @@ class ExtensionVkFloatAtomics : public Extension { } void* pnext_device_create_info(void* const p_next) override { - if (supported_atomic_features.shaderImageFloat32Atomics) { + if (supported_atomic_features.shaderImageFloat32Atomics == VK_TRUE) { SPDLOG_DEBUG("shaderImageFloat32Atomics supported. Enabling feature"); - enable_atomic_features.shaderImageFloat32Atomics = true; + enable_atomic_features.shaderImageFloat32Atomics = VK_TRUE; } else { SPDLOG_WARN("shaderImageFloat32Atomics not supported"); } - if (supported_atomic_features.shaderImageFloat32AtomicAdd) { + if (supported_atomic_features.shaderImageFloat32AtomicAdd == VK_TRUE) { SPDLOG_DEBUG("shaderImageFloat32AtomicAdd supported. Enabling feature"); - enable_atomic_features.shaderImageFloat32AtomicAdd = true; + enable_atomic_features.shaderImageFloat32AtomicAdd = VK_TRUE; } else { SPDLOG_WARN("shaderImageFloat32AtomicAdd not supported"); } diff --git a/include/merian/vk/extension/extension_vk_nv_compute_shader_derivatives.hpp b/include/merian/vk/extension/extension_vk_nv_compute_shader_derivatives.hpp index 31632b3..df65ca3 100644 --- a/include/merian/vk/extension/extension_vk_nv_compute_shader_derivatives.hpp +++ b/include/merian/vk/extension/extension_vk_nv_compute_shader_derivatives.hpp @@ -8,7 +8,7 @@ class ExtensionVkNvComputeShaderDerivatives : public Extension { public: ExtensionVkNvComputeShaderDerivatives() : Extension("ExtensionVkNvComputeShaderDerivatives") {} ~ExtensionVkNvComputeShaderDerivatives() {} - std::vector required_device_extension_names(vk::PhysicalDevice) const override { + std::vector required_device_extension_names(vk::PhysicalDevice /*unused*/) const override { return {VK_NV_COMPUTE_SHADER_DERIVATIVES_EXTENSION_NAME}; } @@ -17,16 +17,21 @@ class ExtensionVkNvComputeShaderDerivatives : public Extension { return &supported_features; } + bool extension_supported(const Context::PhysicalDeviceContainer& /*unused*/) override { + return supported_features.computeDerivativeGroupLinear == VK_TRUE || + supported_features.computeDerivativeGroupQuads == VK_TRUE; + } + void* pnext_device_create_info(void* const p_next) override { - if (supported_features.computeDerivativeGroupQuads) { + if (supported_features.computeDerivativeGroupQuads == VK_TRUE) { SPDLOG_DEBUG("computeDerivativeGroupQuads supported. Enabling feature"); - enabled_features.computeDerivativeGroupQuads = true; + enabled_features.computeDerivativeGroupQuads = VK_TRUE; } else { SPDLOG_ERROR("computeDerivativeGroupQuads requested but not supported"); } - if (supported_features.computeDerivativeGroupLinear) { + if (supported_features.computeDerivativeGroupLinear == VK_TRUE) { SPDLOG_DEBUG("computeDerivativeGroupLinear supported. Enabling feature"); - enabled_features.computeDerivativeGroupLinear = true; + enabled_features.computeDerivativeGroupLinear = VK_TRUE; } else { SPDLOG_ERROR("computeDerivativeGroupLinear requested but not supported"); } diff --git a/include/merian/vk/extension/extension_vk_ray_query.hpp b/include/merian/vk/extension/extension_vk_ray_query.hpp index a5aeca0..ca98a6b 100644 --- a/include/merian/vk/extension/extension_vk_ray_query.hpp +++ b/include/merian/vk/extension/extension_vk_ray_query.hpp @@ -12,19 +12,30 @@ namespace merian { */ class ExtensionVkRayQuery : public Extension { public: - ExtensionVkRayQuery() : Extension("ExtensionVkRaytraceQuery") { - physical_device_ray_query_features.rayQuery = VK_TRUE; - } + ExtensionVkRayQuery() : Extension("ExtensionVkRaytraceQuery") {} ~ExtensionVkRayQuery() {} - std::vector required_device_extension_names(vk::PhysicalDevice) const override { + + std::vector + required_device_extension_names(vk::PhysicalDevice /*unused*/) const override { return { - VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME, + VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, + VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, // intel doesn't have it pre 2015 (hd 520) - VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME, VK_KHR_RAY_QUERY_EXTENSION_NAME, + VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME, + VK_KHR_RAY_QUERY_EXTENSION_NAME, }; } // LIFECYCLE + void* pnext_get_features_2(void* const p_next) override { + physical_device_ray_query_features.setPNext(p_next); + return &physical_device_ray_query_features; + } + + bool extension_supported(const Context::PhysicalDeviceContainer& /*unused*/) override { + return physical_device_ray_query_features.rayQuery == VK_TRUE; + } + void* pnext_device_create_info(void* const p_next) override { physical_device_ray_query_features.pNext = p_next; return &physical_device_ray_query_features; diff --git a/include/merian/vk/extension/extension_vk_ray_tracing_pipeline.hpp b/include/merian/vk/extension/extension_vk_ray_tracing_pipeline.hpp index 379856d..6732022 100644 --- a/include/merian/vk/extension/extension_vk_ray_tracing_pipeline.hpp +++ b/include/merian/vk/extension/extension_vk_ray_tracing_pipeline.hpp @@ -13,11 +13,12 @@ namespace merian { */ class ExtensionVkRayTracingPipeline : public Extension { public: - ExtensionVkRayTracingPipeline() : Extension("ExtensionVkRayTracingPipeline") { - ray_tracing_pipeline_features.rayTracingPipeline = VK_TRUE; - } + ExtensionVkRayTracingPipeline() : Extension("ExtensionVkRayTracingPipeline") {} + ~ExtensionVkRayTracingPipeline() {} - std::vector required_device_extension_names(vk::PhysicalDevice) const override { + + std::vector + required_device_extension_names(vk::PhysicalDevice /*unused*/) const override { return { VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME, @@ -29,12 +30,22 @@ class ExtensionVkRayTracingPipeline : public Extension { // LIFECYCLE + void* pnext_get_features_2(void* const p_next) override { + ray_tracing_pipeline_features.setPNext(p_next); + return &ray_tracing_pipeline_features; + } + + bool extension_supported(const Context::PhysicalDeviceContainer& /*unused*/) override { + return ray_tracing_pipeline_features.rayTracingPipeline == VK_TRUE; + } + void on_physical_device_selected(const Context::PhysicalDeviceContainer& pd_container) override { vk::PhysicalDeviceProperties2KHR props2; props2.pNext = &ray_tracing_pipeline_properties; pd_container.physical_device.getProperties2(&props2); } + void* pnext_device_create_info(void* const p_next) override { ray_tracing_pipeline_features.pNext = p_next; return &ray_tracing_pipeline_features; diff --git a/include/merian/vk/extension/extension_vk_ray_tracing_position_fetch.hpp b/include/merian/vk/extension/extension_vk_ray_tracing_position_fetch.hpp index 8bb3397..32f1ed7 100644 --- a/include/merian/vk/extension/extension_vk_ray_tracing_position_fetch.hpp +++ b/include/merian/vk/extension/extension_vk_ray_tracing_position_fetch.hpp @@ -8,7 +8,8 @@ class ExtensionVkRayTracingPositionFetch : public Extension { public: ExtensionVkRayTracingPositionFetch() : Extension("ExtensionVkRayTracingPositionFetch") {} ~ExtensionVkRayTracingPositionFetch() {} - std::vector required_device_extension_names(vk::PhysicalDevice) const override { + std::vector + required_device_extension_names(vk::PhysicalDevice /*unused*/) const override { return {VK_KHR_RAY_TRACING_POSITION_FETCH_EXTENSION_NAME}; } @@ -17,10 +18,14 @@ class ExtensionVkRayTracingPositionFetch : public Extension { return &supported_features; } + bool extension_supported(const Context::PhysicalDeviceContainer& /*unused*/) override { + return supported_features.rayTracingPositionFetch == VK_TRUE; + } + void* pnext_device_create_info(void* const p_next) override { - if (supported_features.rayTracingPositionFetch) { + if (supported_features.rayTracingPositionFetch == VK_TRUE) { SPDLOG_DEBUG("rayTracingPositionFetch supported. Enabling feature"); - enabled_features.rayTracingPositionFetch = true; + enabled_features.rayTracingPositionFetch = VK_TRUE; } else { SPDLOG_ERROR("rayTracingPositionFetch requested but not supported"); } diff --git a/include/merian/vk/extension/extension_vk_robustness_2.hpp b/include/merian/vk/extension/extension_vk_robustness_2.hpp index a33d6cd..d4385b8 100644 --- a/include/merian/vk/extension/extension_vk_robustness_2.hpp +++ b/include/merian/vk/extension/extension_vk_robustness_2.hpp @@ -18,23 +18,23 @@ class ExtensionVkRobustnessAccess2 : public Extension { } void* pnext_device_create_info(void* const p_next) override { - if (supported_image_robustness_features.robustImageAccess2) { + if (supported_image_robustness_features.robustImageAccess2 == VK_TRUE) { SPDLOG_DEBUG("robustImageAccess2 supported. Enabling feature"); - enable_image_robustness_features.robustImageAccess2 = true; + enable_image_robustness_features.robustImageAccess2 = VK_TRUE; } else { SPDLOG_WARN("robustImageAccess2 requested but not supported"); } - if (supported_image_robustness_features.robustBufferAccess2) { + if (supported_image_robustness_features.robustBufferAccess2 == VK_TRUE) { SPDLOG_DEBUG("robustBufferAccess2 supported. Enabling feature"); - enable_image_robustness_features.robustBufferAccess2 = true; + enable_image_robustness_features.robustBufferAccess2 = VK_TRUE; } else { SPDLOG_WARN("robustBufferAccess2 requested but not supported"); } - if (supported_image_robustness_features.nullDescriptor) { + if (supported_image_robustness_features.nullDescriptor == VK_TRUE) { SPDLOG_DEBUG("nullDescriptor supported. Enabling feature"); - enable_image_robustness_features.nullDescriptor = true; + enable_image_robustness_features.nullDescriptor = VK_TRUE; } else { SPDLOG_WARN("nullDescriptor requested but not supported"); } diff --git a/include/merian/vk/extension/extension_vk_shader_maximal_reconvergence.hpp b/include/merian/vk/extension/extension_vk_shader_maximal_reconvergence.hpp index 3c661b8..180c345 100644 --- a/include/merian/vk/extension/extension_vk_shader_maximal_reconvergence.hpp +++ b/include/merian/vk/extension/extension_vk_shader_maximal_reconvergence.hpp @@ -8,7 +8,8 @@ class ExtensionVkShaderMaximalReconvergence : public Extension { public: ExtensionVkShaderMaximalReconvergence() : Extension("ExtensionVkShaderMaximalReconvergence") {} ~ExtensionVkShaderMaximalReconvergence() {} - std::vector required_device_extension_names(vk::PhysicalDevice) const override { + std::vector + required_device_extension_names(vk::PhysicalDevice /*unused*/) const override { return {VK_KHR_SHADER_MAXIMAL_RECONVERGENCE_EXTENSION_NAME}; } @@ -18,9 +19,9 @@ class ExtensionVkShaderMaximalReconvergence : public Extension { } void* pnext_device_create_info(void* const p_next) override { - if (supported_features.shaderMaximalReconvergence) { + if (supported_features.shaderMaximalReconvergence == VK_TRUE) { SPDLOG_DEBUG("shaderMaximalReconvergence supported. Enabling feature"); - enabled_features.shaderMaximalReconvergence = true; + enabled_features.shaderMaximalReconvergence = VK_TRUE; } else { SPDLOG_ERROR("shaderMaximalReconvergence requested but not supported"); } @@ -29,6 +30,10 @@ class ExtensionVkShaderMaximalReconvergence : public Extension { return &enabled_features; } + bool extension_supported(const Context::PhysicalDeviceContainer& /*unused*/) override { + return supported_features.shaderMaximalReconvergence == VK_TRUE; + } + private: vk::PhysicalDeviceShaderMaximalReconvergenceFeaturesKHR supported_features; vk::PhysicalDeviceShaderMaximalReconvergenceFeaturesKHR enabled_features;