diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/Device.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/Device.cpp index 159f55e9d0..ff7eb7f4c0 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/Device.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/Device.cpp @@ -163,21 +163,23 @@ namespace AZ uint32_t minorVersion = VK_VERSION_MINOR(physicalProperties.apiVersion); // unbounded array functionality - VkPhysicalDeviceDescriptorIndexingFeatures descriptorIndexingFeatures = {}; + VkPhysicalDeviceDescriptorIndexingFeaturesEXT descriptorIndexingFeatures = {}; descriptorIndexingFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES; - descriptorIndexingFeatures.shaderInputAttachmentArrayDynamicIndexing = VK_TRUE; - descriptorIndexingFeatures.shaderUniformTexelBufferArrayDynamicIndexing = VK_TRUE; - descriptorIndexingFeatures.shaderStorageTexelBufferArrayDynamicIndexing = VK_TRUE; - descriptorIndexingFeatures.shaderUniformBufferArrayNonUniformIndexing = VK_TRUE; - descriptorIndexingFeatures.shaderSampledImageArrayNonUniformIndexing = VK_TRUE; - descriptorIndexingFeatures.shaderStorageBufferArrayNonUniformIndexing = VK_TRUE; - descriptorIndexingFeatures.shaderStorageImageArrayNonUniformIndexing = VK_TRUE; - descriptorIndexingFeatures.shaderInputAttachmentArrayNonUniformIndexing = VK_TRUE; - descriptorIndexingFeatures.shaderUniformTexelBufferArrayNonUniformIndexing = VK_TRUE; - descriptorIndexingFeatures.shaderStorageTexelBufferArrayNonUniformIndexing = VK_TRUE; - descriptorIndexingFeatures.descriptorBindingPartiallyBound = VK_TRUE; - descriptorIndexingFeatures.descriptorBindingVariableDescriptorCount = VK_TRUE; - descriptorIndexingFeatures.runtimeDescriptorArray = VK_TRUE; + const VkPhysicalDeviceDescriptorIndexingFeaturesEXT& physicalDeviceDescriptorIndexingFeatures = + physicalDevice.GetPhysicalDeviceDescriptorIndexingFeatures(); + descriptorIndexingFeatures.shaderInputAttachmentArrayDynamicIndexing = physicalDeviceDescriptorIndexingFeatures.shaderInputAttachmentArrayDynamicIndexing; + descriptorIndexingFeatures.shaderUniformTexelBufferArrayDynamicIndexing = physicalDeviceDescriptorIndexingFeatures.shaderUniformTexelBufferArrayDynamicIndexing; + descriptorIndexingFeatures.shaderStorageTexelBufferArrayDynamicIndexing = physicalDeviceDescriptorIndexingFeatures.shaderStorageTexelBufferArrayDynamicIndexing; + descriptorIndexingFeatures.shaderUniformBufferArrayNonUniformIndexing = physicalDeviceDescriptorIndexingFeatures.shaderUniformBufferArrayNonUniformIndexing; + descriptorIndexingFeatures.shaderSampledImageArrayNonUniformIndexing = physicalDeviceDescriptorIndexingFeatures.shaderSampledImageArrayNonUniformIndexing; + descriptorIndexingFeatures.shaderStorageBufferArrayNonUniformIndexing = physicalDeviceDescriptorIndexingFeatures.shaderStorageBufferArrayNonUniformIndexing; + descriptorIndexingFeatures.shaderStorageImageArrayNonUniformIndexing = physicalDeviceDescriptorIndexingFeatures.shaderStorageImageArrayNonUniformIndexing; + descriptorIndexingFeatures.shaderInputAttachmentArrayNonUniformIndexing = physicalDeviceDescriptorIndexingFeatures.shaderInputAttachmentArrayNonUniformIndexing; + descriptorIndexingFeatures.shaderUniformTexelBufferArrayNonUniformIndexing = physicalDeviceDescriptorIndexingFeatures.shaderUniformTexelBufferArrayNonUniformIndexing; + descriptorIndexingFeatures.shaderStorageTexelBufferArrayNonUniformIndexing = physicalDeviceDescriptorIndexingFeatures.shaderStorageTexelBufferArrayNonUniformIndexing; + descriptorIndexingFeatures.descriptorBindingPartiallyBound = physicalDeviceDescriptorIndexingFeatures.shaderStorageTexelBufferArrayNonUniformIndexing; + descriptorIndexingFeatures.descriptorBindingVariableDescriptorCount = physicalDeviceDescriptorIndexingFeatures.descriptorBindingVariableDescriptorCount; + descriptorIndexingFeatures.runtimeDescriptorArray = physicalDeviceDescriptorIndexingFeatures.runtimeDescriptorArray; VkPhysicalDeviceDepthClipEnableFeaturesEXT depthClipEnabled = {}; depthClipEnabled.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_ENABLE_FEATURES_EXT; @@ -196,7 +198,7 @@ namespace AZ // If we are running Vulkan >= 1.2, then we must use VkPhysicalDeviceVulkan12Features instead // of VkPhysicalDeviceShaderFloat16Int8FeaturesKHR or VkPhysicalDeviceSeparateDepthStencilLayoutsFeaturesKHR. if (majorVersion >= 1 && minorVersion >= 2) - { + { vulkan12Features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES; vulkan12Features.drawIndirectCount = physicalDevice.GetPhysicalDeviceVulkan12Features().drawIndirectCount; vulkan12Features.shaderFloat16 = physicalDevice.GetPhysicalDeviceVulkan12Features().shaderFloat16; @@ -205,7 +207,7 @@ namespace AZ robustness2.pNext = &vulkan12Features; } else - { + { float16Int8.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES_KHR; float16Int8.shaderFloat16 = physicalDevice.GetPhysicalDeviceFloat16Int8Features().shaderFloat16; diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PhysicalDevice.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PhysicalDevice.cpp index 81669ef73d..e3367b078a 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PhysicalDevice.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PhysicalDevice.cpp @@ -133,6 +133,11 @@ namespace AZ return m_float16Int8Features; } + const VkPhysicalDeviceDescriptorIndexingFeaturesEXT& PhysicalDevice::GetPhysicalDeviceDescriptorIndexingFeatures() const + { + return m_descriptorIndexingFeatures; + } + const VkPhysicalDeviceVulkan12Features& PhysicalDevice::GetPhysicalDeviceVulkan12Features() const { return m_vulkan12Features; @@ -233,6 +238,7 @@ namespace AZ m_features.set(static_cast(DeviceFeature::SeparateDepthStencil), (m_separateDepthStencilFeatures.separateDepthStencilLayouts && VK_DEVICE_EXTENSION_SUPPORTED(KHR_separate_depth_stencil_layouts)) || (m_vulkan12Features.separateDepthStencilLayouts)); + m_features.set(static_cast(DeviceFeature::DescriptorIndexing), VK_DEVICE_EXTENSION_SUPPORTED(EXT_descriptor_indexing)); } void PhysicalDevice::CompileMemoryStatistics(RHI::MemoryStatisticsBuilder& builder) const @@ -266,9 +272,14 @@ namespace AZ if (VK_INSTANCE_EXTENSION_SUPPORTED(KHR_get_physical_device_properties2)) { // features + VkPhysicalDeviceDescriptorIndexingFeaturesEXT& descriptorIndexingFeatures = m_descriptorIndexingFeatures; + descriptorIndexingFeatures = {}; + descriptorIndexingFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES_EXT; + VkPhysicalDeviceDepthClipEnableFeaturesEXT& dephClipEnableFeatures = m_dephClipEnableFeatures; dephClipEnableFeatures = {}; dephClipEnableFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_ENABLE_FEATURES_EXT; + descriptorIndexingFeatures.pNext = &dephClipEnableFeatures; VkPhysicalDeviceRobustness2FeaturesEXT& robustness2Feature = m_robutness2Features; robustness2Feature = {}; @@ -292,7 +303,7 @@ namespace AZ VkPhysicalDeviceFeatures2 deviceFeatures2 = {}; deviceFeatures2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; - deviceFeatures2.pNext = &dephClipEnableFeatures; + deviceFeatures2.pNext = &descriptorIndexingFeatures; vkGetPhysicalDeviceFeatures2KHR(vkPhysicalDevice, &deviceFeatures2); m_deviceFeatures = deviceFeatures2.features; @@ -302,7 +313,7 @@ namespace AZ m_conservativeRasterProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONSERVATIVE_RASTERIZATION_PROPERTIES_EXT; deviceProps2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR; deviceProps2.pNext = &m_conservativeRasterProperties; - + m_rayTracingPipelineProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_PROPERTIES_KHR; m_conservativeRasterProperties.pNext = &m_rayTracingPipelineProperties; diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PhysicalDevice.h b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PhysicalDevice.h index bd01a2e884..9667e03d3b 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PhysicalDevice.h +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PhysicalDevice.h @@ -34,6 +34,7 @@ namespace AZ DrawIndirectCount, NullDescriptor, SeparateDepthStencil, + DescriptorIndexing, Count // Must be last }; @@ -57,6 +58,7 @@ namespace AZ const VkPhysicalDeviceDepthClipEnableFeaturesEXT& GetPhysicalDeviceDepthClipEnableFeatures() const; const VkPhysicalDeviceRobustness2FeaturesEXT& GetPhysicalDeviceRobutness2Features() const; const VkPhysicalDeviceShaderFloat16Int8FeaturesKHR& GetPhysicalDeviceFloat16Int8Features() const; + const VkPhysicalDeviceDescriptorIndexingFeaturesEXT& GetPhysicalDeviceDescriptorIndexingFeatures() const; const VkPhysicalDeviceVulkan12Features& GetPhysicalDeviceVulkan12Features() const; const VkPhysicalDeviceSeparateDepthStencilLayoutsFeaturesKHR& GetPhysicalDeviceSeparateDepthStencilFeatures() const; const VkPhysicalDeviceAccelerationStructurePropertiesKHR& GetPhysicalDeviceAccelerationStructureProperties() const; @@ -70,7 +72,6 @@ namespace AZ private: PhysicalDevice() = default; - void Init(VkPhysicalDevice vkPhysicalDevice); /////////////////////////////////////////////////////////////////// @@ -88,6 +89,7 @@ namespace AZ VkPhysicalDeviceDepthClipEnableFeaturesEXT m_dephClipEnableFeatures{}; VkPhysicalDeviceRobustness2FeaturesEXT m_robutness2Features{}; VkPhysicalDeviceShaderFloat16Int8FeaturesKHR m_float16Int8Features{}; + VkPhysicalDeviceDescriptorIndexingFeaturesEXT m_descriptorIndexingFeatures{}; VkPhysicalDeviceSeparateDepthStencilLayoutsFeaturesKHR m_separateDepthStencilFeatures{}; VkPhysicalDeviceAccelerationStructurePropertiesKHR m_accelerationStructureProperties{}; VkPhysicalDeviceRayTracingPipelinePropertiesKHR m_rayTracingPipelineProperties{};