diff --git a/src/tz/gl/impl/vulkan/detail/extensions.hpp b/src/tz/gl/impl/vulkan/detail/extensions.hpp index 72362b0b07..00ecc0a381 100644 --- a/src/tz/gl/impl/vulkan/detail/extensions.hpp +++ b/src/tz/gl/impl/vulkan/detail/extensions.hpp @@ -32,6 +32,7 @@ namespace tz::gl::vk2 /// - Enables Swapchain operations (required to create a swapchain and present images) Swapchain, ShaderDebugPrint, + DynamicRendering, Count }; @@ -46,11 +47,11 @@ namespace tz::gl::vk2 namespace util { constexpr std::array(InstanceExtension::Count)> instance_extension_tz_names{"Debug Messenger"}; - constexpr std::array(DeviceExtension::Count)> device_extension_tz_names{"Swapchain", "Shader Debug Print"}; + constexpr std::array(DeviceExtension::Count)> device_extension_tz_names{"Swapchain", "Shader Debug Print", "Dynamic Rendering"}; using VkExtension = const char*; constexpr std::array(InstanceExtension::Count)> instance_extension_names{VK_EXT_DEBUG_UTILS_EXTENSION_NAME}; - constexpr std::array(DeviceExtension::Count)> device_extension_names{VK_KHR_SWAPCHAIN_EXTENSION_NAME, VK_KHR_SHADER_NON_SEMANTIC_INFO_EXTENSION_NAME}; + constexpr std::array(DeviceExtension::Count)> device_extension_names{VK_KHR_SWAPCHAIN_EXTENSION_NAME, VK_KHR_SHADER_NON_SEMANTIC_INFO_EXTENSION_NAME, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME}; constexpr VkExtension to_vk_extension(InstanceExtension extension) { diff --git a/src/tz/gl/impl/vulkan/detail/features.hpp b/src/tz/gl/impl/vulkan/detail/features.hpp index a3dc1f1d03..6f748c60c4 100644 --- a/src/tz/gl/impl/vulkan/detail/features.hpp +++ b/src/tz/gl/impl/vulkan/detail/features.hpp @@ -34,7 +34,9 @@ namespace tz::gl::vk2 /// - Enables vertex, geometry, and tessellation shaders to write to storage buffers. VertexPipelineResourceWrite, /// - Enables fragment shaders to write to storage buffers. - FragmentShaderResourceWrite + FragmentShaderResourceWrite, + /// - Enables dynamic rendering. this is not optional. + DynamicRendering }; using DeviceFeatureField = tz::enum_field; @@ -49,10 +51,11 @@ namespace tz::gl::vk2 return feats; } - constexpr VkPhysicalDeviceVulkan12Features empty_12_features() + constexpr VkPhysicalDeviceVulkan12Features empty_12_features(VkPhysicalDeviceDynamicRenderingFeaturesKHR& next) { VkPhysicalDeviceVulkan12Features feats{}; feats.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES; + feats.pNext = &next; return feats; } @@ -64,9 +67,17 @@ namespace tz::gl::vk2 return feats; } + constexpr VkPhysicalDeviceDynamicRenderingFeaturesKHR empty_dynamic_rendering_features() + { + VkPhysicalDeviceDynamicRenderingFeaturesKHR feats{}; + feats.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES; + return feats; + } + struct DeviceFeatureInfo { - VkPhysicalDeviceVulkan12Features features12 = empty_12_features(); + VkPhysicalDeviceDynamicRenderingFeaturesKHR features_dr = empty_dynamic_rendering_features(); + VkPhysicalDeviceVulkan12Features features12 = empty_12_features(features_dr); VkPhysicalDeviceVulkan11Features features11 = empty_11_features(features12); VkPhysicalDeviceFeatures2 features = empty_features2(features11); }; diff --git a/src/tz/gl/impl/vulkan/detail/hardware/physical_device.cpp b/src/tz/gl/impl/vulkan/detail/hardware/physical_device.cpp index 974ea608d7..1b7052c180 100644 --- a/src/tz/gl/impl/vulkan/detail/hardware/physical_device.cpp +++ b/src/tz/gl/impl/vulkan/detail/hardware/physical_device.cpp @@ -84,6 +84,10 @@ namespace tz::gl::vk2 { ret |= DeviceFeature::FragmentShaderResourceWrite; } + if(features.features_dr.dynamicRendering) + { + ret |= DeviceFeature::DynamicRendering; + } return ret; } @@ -111,6 +115,8 @@ namespace tz::gl::vk2 info.features12.descriptorBindingVariableDescriptorCount = VK_TRUE; info.features12.runtimeDescriptorArray = VK_TRUE; } + + info.features_dr.dynamicRendering = feature_field.contains(DeviceFeature::DynamicRendering); return info; } diff --git a/src/tz/gl/impl/vulkan/device.cpp b/src/tz/gl/impl/vulkan/device.cpp index ea1e0d4782..583f16784d 100644 --- a/src/tz/gl/impl/vulkan/device.cpp +++ b/src/tz/gl/impl/vulkan/device.cpp @@ -463,10 +463,11 @@ namespace tz::gl vk2::DeviceFeature::TessellationShaders, vk2::DeviceFeature::VertexPipelineResourceWrite, vk2::DeviceFeature::FragmentShaderResourceWrite, - vk2::DeviceFeature::TimelineSemaphores + vk2::DeviceFeature::TimelineSemaphores, + vk2::DeviceFeature::DynamicRendering }; tz::assert(pdev.get_supported_features().contains(dev_feats), "One or both of DeviceFeatures 'BindlessDescriptors' and 'ColourBlendLogicalOperations' are not supported by this machine/driver. Please ensure your machine meets the system requirements."); - dev_exts = {vk2::DeviceExtension::Swapchain}; + dev_exts = {vk2::DeviceExtension::Swapchain, vk2::DeviceExtension::DynamicRendering}; #if TZ_DEBUG dev_exts |= vk2::DeviceExtension::ShaderDebugPrint; #endif diff --git a/src/tz/gl/impl/vulkan/device2.cpp b/src/tz/gl/impl/vulkan/device2.cpp index 47cb1167ac..063172cc7f 100644 --- a/src/tz/gl/impl/vulkan/device2.cpp +++ b/src/tz/gl/impl/vulkan/device2.cpp @@ -449,10 +449,11 @@ namespace tz::gl vk2::DeviceFeature::TessellationShaders, vk2::DeviceFeature::VertexPipelineResourceWrite, vk2::DeviceFeature::FragmentShaderResourceWrite, - vk2::DeviceFeature::TimelineSemaphores + vk2::DeviceFeature::TimelineSemaphores, + vk2::DeviceFeature::DynamicRendering }; tz::assert(pdev.get_supported_features().contains(dev_feats), "One or both of DeviceFeatures 'BindlessDescriptors' and 'ColourBlendLogicalOperations' are not supported by this machine/driver. Please ensure your machine meets the system requirements."); - dev_exts = {vk2::DeviceExtension::Swapchain}; + dev_exts = {vk2::DeviceExtension::Swapchain, vk2::DeviceExtension::DynamicRendering}; #if TZ_DEBUG dev_exts |= vk2::DeviceExtension::ShaderDebugPrint; #endif