diff --git a/Graphics/GraphicsEngine/interface/APIInfo.h b/Graphics/GraphicsEngine/interface/APIInfo.h index 4731f7d9a..dd74c7ea7 100644 --- a/Graphics/GraphicsEngine/interface/APIInfo.h +++ b/Graphics/GraphicsEngine/interface/APIInfo.h @@ -30,7 +30,7 @@ /// \file /// Diligent API information -#define DILIGENT_API_VERSION 256017 +#define DILIGENT_API_VERSION 256018 #include "../../../Primitives/interface/BasicTypes.h" diff --git a/Graphics/GraphicsEngine/interface/GraphicsTypes.h b/Graphics/GraphicsEngine/interface/GraphicsTypes.h index 1138c9358..c222c1ffc 100644 --- a/Graphics/GraphicsEngine/interface/GraphicsTypes.h +++ b/Graphics/GraphicsEngine/interface/GraphicsTypes.h @@ -1867,6 +1867,13 @@ struct DeviceFeatures /// Not supported by D3D11, D3D12, OpenGL, or Metal backends. DEVICE_FEATURE_STATE SpecializationConstants DEFAULT_INITIALIZER(DEVICE_FEATURE_STATE_DISABLED); + /// Indicates if device supports native 64-bit float operations. + DEVICE_FEATURE_STATE ShaderFloat64 DEFAULT_INITIALIZER(DEVICE_FEATURE_STATE_DISABLED); + + /// Indicates if device supports access to barycentric coordinates in the shaders + /// during the rasterization phase. + DEVICE_FEATURE_STATE ShaderBarycentrics DEFAULT_INITIALIZER(DEVICE_FEATURE_STATE_DISABLED); + #if DILIGENT_CPP_INTERFACE constexpr DeviceFeatures() noexcept {} @@ -1918,11 +1925,13 @@ struct DeviceFeatures Handler(NativeMultiDraw) \ Handler(AsyncShaderCompilation) \ Handler(FormattedBuffers) \ - Handler(SpecializationConstants) + Handler(SpecializationConstants) \ + Handler(ShaderFloat64) \ + Handler(ShaderBarycentrics) explicit constexpr DeviceFeatures(DEVICE_FEATURE_STATE State) noexcept { - static_assert(sizeof(*this) == 48, "Did you add a new feature to DeviceFeatures? Please add it to ENUMERATE_DEVICE_FEATURES."); + static_assert(sizeof(*this) == 50, "Did you add a new feature to DeviceFeatures? Please add it to ENUMERATE_DEVICE_FEATURES."); #define INIT_FEATURE(Feature) Feature = State; ENUMERATE_DEVICE_FEATURES(INIT_FEATURE) #undef INIT_FEATURE diff --git a/Graphics/GraphicsEngine/src/RenderDeviceBase.cpp b/Graphics/GraphicsEngine/src/RenderDeviceBase.cpp index 4e471599c..e42670146 100644 --- a/Graphics/GraphicsEngine/src/RenderDeviceBase.cpp +++ b/Graphics/GraphicsEngine/src/RenderDeviceBase.cpp @@ -121,9 +121,11 @@ DeviceFeatures EnableDeviceFeatures(const DeviceFeatures& SupportedFeatures, ENABLE_FEATURE(AsyncShaderCompilation, "Async shader compilation is"); ENABLE_FEATURE(FormattedBuffers, "Formatted buffers are"); ENABLE_FEATURE(SpecializationConstants, "Specialization constants are"); + ENABLE_FEATURE(ShaderFloat64, "64-bit float shader operations are"); + ENABLE_FEATURE(ShaderBarycentrics, "Shader barycentrics are"); // clang-format on - ASSERT_SIZEOF(DeviceFeatures, 48, "Did you add a new feature to DeviceFeatures? Please handle its status here (if necessary)."); + ASSERT_SIZEOF(DeviceFeatures, 50, "Did you add a new feature to DeviceFeatures? Please handle its status here (if necessary)."); return EnabledFeatures; } diff --git a/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp b/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp index f4e2887d2..91accabe8 100644 --- a/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp +++ b/Graphics/GraphicsEngineD3D11/src/EngineFactoryD3D11.cpp @@ -490,7 +490,15 @@ GraphicsAdapterInfo EngineFactoryD3D11Impl::GetGraphicsAdapterInfo(void* Features.ShaderFloat16 = ShaderFloat16Supported ? DEVICE_FEATURE_STATE_ENABLED : DEVICE_FEATURE_STATE_DISABLED; } - ASSERT_SIZEOF(Features, 48, "Did you add a new feature to DeviceFeatures? Please handle its status here."); + { + D3D11_FEATURE_DATA_DOUBLES d3d11Doubles{}; + if (SUCCEEDED(pd3d11Device->CheckFeatureSupport(D3D11_FEATURE_DOUBLES, &d3d11Doubles, sizeof(d3d11Doubles)))) + { + Features.ShaderFloat64 = (d3d11Doubles.DoublePrecisionFloatShaderOps != FALSE) ? DEVICE_FEATURE_STATE_ENABLED : DEVICE_FEATURE_STATE_DISABLED; + } + } + + ASSERT_SIZEOF(Features, 50, "Did you add a new feature to DeviceFeatures? Please handle its status here."); // Texture properties { diff --git a/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp index 2864808e3..2736bc0f7 100644 --- a/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp +++ b/Graphics/GraphicsEngineD3D12/src/EngineFactoryD3D12.cpp @@ -905,6 +905,11 @@ GraphicsAdapterInfo EngineFactoryD3D12Impl::GetGraphicsAdapterInfo(void* ASSERT_SIZEOF(SparseRes, 32, "Did you add a new member to SparseResourceProperties? Please initialize it here."); } + + if (d3d12Features.DoublePrecisionFloatShaderOps != FALSE) + { + Features.ShaderFloat64 = DEVICE_FEATURE_STATE_ENABLED; + } } D3D12_FEATURE_DATA_D3D12_OPTIONS1 d3d12Features1 = {}; @@ -931,6 +936,9 @@ GraphicsAdapterInfo EngineFactoryD3D12Impl::GetGraphicsAdapterInfo(void* { if (d3d12Features3.CopyQueueTimestampQueriesSupported) Features.TransferQueueTimestampQueries = DEVICE_FEATURE_STATE_ENABLED; + + if (d3d12Features3.BarycentricsSupported) + Features.ShaderBarycentrics = DEVICE_FEATURE_STATE_ENABLED; } D3D12_FEATURE_DATA_D3D12_OPTIONS4 d3d12Features4{}; @@ -1108,7 +1116,7 @@ GraphicsAdapterInfo EngineFactoryD3D12Impl::GetGraphicsAdapterInfo(void* ASSERT_SIZEOF(DrawCommandProps, 12, "Did you add a new member to DrawCommandProperties? Please initialize it here."); } - ASSERT_SIZEOF(DeviceFeatures, 48, "Did you add a new feature to DeviceFeatures? Please handle its status here."); + ASSERT_SIZEOF(DeviceFeatures, 50, "Did you add a new feature to DeviceFeatures? Please handle its status here."); return AdapterInfo; } diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp index 5497cbe7d..90d196470 100644 --- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp @@ -903,6 +903,8 @@ void RenderDeviceGLImpl::InitAdapterInfo() ENABLE_FEATURE(NativeMultiDraw, IsGL46OrAbove || CheckExtension("GL_ARB_shader_draw_parameters")); // Requirements for gl_DrawID ENABLE_FEATURE(AsyncShaderCompilation, CheckExtension("GL_KHR_parallel_shader_compile")); ENABLE_FEATURE(FormattedBuffers, IsGL40OrAbove); + ENABLE_FEATURE(ShaderFloat64, CheckExtension("GL_EXT_shader_explicit_arithmetic_types_float64")); + ENABLE_FEATURE(ShaderBarycentrics, CheckExtension("GL_EXT_fragment_shader_barycentric") || CheckExtension("GL_NV_fragment_shader_barycentric")); // clang-format on TexProps.MaxTexture1DDimension = MaxTextureSize; @@ -984,6 +986,8 @@ void RenderDeviceGLImpl::InitAdapterInfo() ENABLE_FEATURE(NativeMultiDraw, strstr(Extensions, "multi_draw")); ENABLE_FEATURE(AsyncShaderCompilation, strstr(Extensions, "parallel_shader_compile")); ENABLE_FEATURE(FormattedBuffers, IsGLES32OrAbove); + ENABLE_FEATURE(ShaderFloat64, strstr(Extensions, "shader_explicit_arithmetic_types_float64")); + ENABLE_FEATURE(ShaderBarycentrics, strstr(Extensions, "fragment_shader_barycentric")); // clang-format on TexProps.MaxTexture1DDimension = 0; // Not supported in GLES 3.2 @@ -1161,7 +1165,7 @@ void RenderDeviceGLImpl::InitAdapterInfo() m_AdapterInfo.Queues[0].TextureCopyGranularity[2] = 1; } - ASSERT_SIZEOF(DeviceFeatures, 48, "Did you add a new feature to DeviceFeatures? Please handle its status here."); + ASSERT_SIZEOF(DeviceFeatures, 50, "Did you add a new feature to DeviceFeatures? Please handle its status here."); } void RenderDeviceGLImpl::FlagSupportedTexFormats() diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/PhysicalDevice.hpp b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/PhysicalDevice.hpp index e27715414..6ccdb85bd 100644 --- a/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/PhysicalDevice.hpp +++ b/Graphics/GraphicsEngineVulkan/include/VulkanUtilities/PhysicalDevice.hpp @@ -48,27 +48,28 @@ class PhysicalDevice struct ExtensionFeatures { - VkPhysicalDeviceMeshShaderFeaturesEXT MeshShader = {}; - VkPhysicalDevice16BitStorageFeaturesKHR Storage16Bit = {}; - VkPhysicalDevice8BitStorageFeaturesKHR Storage8Bit = {}; - VkPhysicalDeviceShaderFloat16Int8FeaturesKHR ShaderFloat16Int8 = {}; - VkPhysicalDeviceAccelerationStructureFeaturesKHR AccelStruct = {}; - VkPhysicalDeviceRayTracingPipelineFeaturesKHR RayTracingPipeline = {}; - VkPhysicalDeviceRayQueryFeaturesKHR RayQuery = {}; - VkPhysicalDeviceBufferDeviceAddressFeaturesKHR BufferDeviceAddress = {}; - VkPhysicalDeviceDescriptorIndexingFeaturesEXT DescriptorIndexing = {}; - VkPhysicalDevicePortabilitySubsetFeaturesKHR PortabilitySubset = {}; - VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT VertexAttributeDivisor = {}; - VkPhysicalDeviceTimelineSemaphoreFeaturesKHR TimelineSemaphore = {}; - VkPhysicalDeviceHostQueryResetFeatures HostQueryReset = {}; - VkPhysicalDeviceFragmentShadingRateFeaturesKHR ShadingRate = {}; - VkPhysicalDeviceFragmentDensityMapFeaturesEXT FragmentDensityMap = {}; // Only for desktop devices - VkPhysicalDeviceFragmentDensityMap2FeaturesEXT FragmentDensityMap2 = {}; // Only for mobile devices - VkPhysicalDeviceMultiviewFeaturesKHR Multiview = {}; // Required for RenderPass2 - VkPhysicalDeviceMultiDrawFeaturesEXT MultiDraw = {}; - VkPhysicalDeviceShaderDrawParametersFeatures ShaderDrawParameters = {}; - VkPhysicalDeviceDynamicRenderingFeaturesKHR DynamicRendering = {}; - VkPhysicalDeviceHostImageCopyFeaturesEXT HostImageCopy = {}; + VkPhysicalDeviceMeshShaderFeaturesEXT MeshShader = {}; + VkPhysicalDevice16BitStorageFeaturesKHR Storage16Bit = {}; + VkPhysicalDevice8BitStorageFeaturesKHR Storage8Bit = {}; + VkPhysicalDeviceShaderFloat16Int8FeaturesKHR ShaderFloat16Int8 = {}; + VkPhysicalDeviceAccelerationStructureFeaturesKHR AccelStruct = {}; + VkPhysicalDeviceRayTracingPipelineFeaturesKHR RayTracingPipeline = {}; + VkPhysicalDeviceRayQueryFeaturesKHR RayQuery = {}; + VkPhysicalDeviceBufferDeviceAddressFeaturesKHR BufferDeviceAddress = {}; + VkPhysicalDeviceDescriptorIndexingFeaturesEXT DescriptorIndexing = {}; + VkPhysicalDevicePortabilitySubsetFeaturesKHR PortabilitySubset = {}; + VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT VertexAttributeDivisor = {}; + VkPhysicalDeviceTimelineSemaphoreFeaturesKHR TimelineSemaphore = {}; + VkPhysicalDeviceHostQueryResetFeatures HostQueryReset = {}; + VkPhysicalDeviceFragmentShadingRateFeaturesKHR ShadingRate = {}; + VkPhysicalDeviceFragmentDensityMapFeaturesEXT FragmentDensityMap = {}; // Only for desktop devices + VkPhysicalDeviceFragmentDensityMap2FeaturesEXT FragmentDensityMap2 = {}; // Only for mobile devices + VkPhysicalDeviceMultiviewFeaturesKHR Multiview = {}; // Required for RenderPass2 + VkPhysicalDeviceMultiDrawFeaturesEXT MultiDraw = {}; + VkPhysicalDeviceShaderDrawParametersFeatures ShaderDrawParameters = {}; + VkPhysicalDeviceDynamicRenderingFeaturesKHR DynamicRendering = {}; + VkPhysicalDeviceHostImageCopyFeaturesEXT HostImageCopy = {}; + VkPhysicalDeviceFragmentShaderBarycentricFeaturesKHR FragmentShaderBarycentric = {}; bool Spirv14 = false; // Ray tracing requires Vulkan 1.2 or SPIRV 1.4 extension @@ -81,21 +82,22 @@ class PhysicalDevice struct ExtensionProperties { - VkPhysicalDeviceMeshShaderPropertiesEXT MeshShader = {}; - VkPhysicalDeviceAccelerationStructurePropertiesKHR AccelStruct = {}; - VkPhysicalDeviceRayTracingPipelinePropertiesKHR RayTracingPipeline = {}; - VkPhysicalDeviceDescriptorIndexingPropertiesEXT DescriptorIndexing = {}; - VkPhysicalDevicePortabilitySubsetPropertiesKHR PortabilitySubset = {}; - VkPhysicalDeviceSubgroupProperties Subgroup = {}; - VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT VertexAttributeDivisor = {}; - VkPhysicalDeviceTimelineSemaphorePropertiesKHR TimelineSemaphore = {}; - VkPhysicalDeviceFragmentShadingRatePropertiesKHR ShadingRate = {}; - VkPhysicalDeviceFragmentDensityMapPropertiesEXT FragmentDensityMap = {}; - VkPhysicalDeviceMultiviewPropertiesKHR Multiview = {}; - VkPhysicalDeviceMaintenance3Properties Maintenance3 = {}; - VkPhysicalDeviceFragmentDensityMap2PropertiesEXT FragmentDensityMap2 = {}; - VkPhysicalDeviceMultiDrawPropertiesEXT MultiDraw = {}; - VkPhysicalDeviceHostImageCopyPropertiesEXT HostImageCopy = {}; + VkPhysicalDeviceMeshShaderPropertiesEXT MeshShader = {}; + VkPhysicalDeviceAccelerationStructurePropertiesKHR AccelStruct = {}; + VkPhysicalDeviceRayTracingPipelinePropertiesKHR RayTracingPipeline = {}; + VkPhysicalDeviceDescriptorIndexingPropertiesEXT DescriptorIndexing = {}; + VkPhysicalDevicePortabilitySubsetPropertiesKHR PortabilitySubset = {}; + VkPhysicalDeviceSubgroupProperties Subgroup = {}; + VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT VertexAttributeDivisor = {}; + VkPhysicalDeviceTimelineSemaphorePropertiesKHR TimelineSemaphore = {}; + VkPhysicalDeviceFragmentShadingRatePropertiesKHR ShadingRate = {}; + VkPhysicalDeviceFragmentDensityMapPropertiesEXT FragmentDensityMap = {}; + VkPhysicalDeviceMultiviewPropertiesKHR Multiview = {}; + VkPhysicalDeviceMaintenance3Properties Maintenance3 = {}; + VkPhysicalDeviceFragmentDensityMap2PropertiesEXT FragmentDensityMap2 = {}; + VkPhysicalDeviceMultiDrawPropertiesEXT MultiDraw = {}; + VkPhysicalDeviceHostImageCopyPropertiesEXT HostImageCopy = {}; + VkPhysicalDeviceFragmentShaderBarycentricPropertiesKHR FragmentShaderBarycentric = {}; std::unique_ptr HostImageCopyLayouts; }; diff --git a/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp b/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp index e2a9ded0a..e0fc76960 100644 --- a/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp +++ b/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp @@ -881,6 +881,7 @@ void EngineFactoryVkImpl::CreateDeviceAndContextsVk(const EngineVkCreateInfo& En ENABLE_VKFEATURE(vertexPipelineStoresAndAtomics, EnabledFeatures.VertexPipelineUAVWritesAndAtomics); ENABLE_VKFEATURE(fragmentStoresAndAtomics, EnabledFeatures.PixelUAVWritesAndAtomics); ENABLE_VKFEATURE(shaderStorageImageExtendedFormats, EnabledFeatures.TextureUAVExtendedFormats); + ENABLE_VKFEATURE(shaderFloat64, EnabledFeatures.ShaderFloat64); // clang-format on #undef ENABLE_VKFEATURE @@ -1248,6 +1249,17 @@ void EngineFactoryVkImpl::CreateDeviceAndContextsVk(const EngineVkCreateInfo& En NextExt = &EnabledExtFeats.ShaderDrawParameters.pNext; } + if (EnabledFeatures.ShaderBarycentrics != DEVICE_FEATURE_STATE_DISABLED) + { + VERIFY_EXPR(PhysicalDevice->IsExtensionSupported(VK_KHR_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME)); + DeviceExtensions.push_back(VK_KHR_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME); + + EnabledExtFeats.FragmentShaderBarycentric = DeviceExtFeatures.FragmentShaderBarycentric; + + *NextExt = &EnabledExtFeats.FragmentShaderBarycentric; + NextExt = &EnabledExtFeats.FragmentShaderBarycentric.pNext; + } + if (EnabledFeaturesVk.DynamicRendering) { VERIFY_EXPR(PhysicalDevice->IsExtensionSupported(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME)); @@ -1308,7 +1320,7 @@ void EngineFactoryVkImpl::CreateDeviceAndContextsVk(const EngineVkCreateInfo& En } } - ASSERT_SIZEOF(DeviceFeatures, 48, "Did you add a new feature to DeviceFeatures? Please handle its status here."); + ASSERT_SIZEOF(DeviceFeatures, 50, "Did you add a new feature to DeviceFeatures? Please handle its status here."); for (Uint32 i = 0; i < EngineCI.DeviceExtensionCount; ++i) { diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp index 3cc581239..d521fa9cc 100644 --- a/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp +++ b/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp @@ -1991,6 +1991,7 @@ DeviceFeatures VkFeaturesToDeviceFeatures(uint32_t INIT_FEATURE(PixelUAVWritesAndAtomics, vkFeatures.fragmentStoresAndAtomics); INIT_FEATURE(TextureUAVExtendedFormats, vkFeatures.shaderStorageImageExtendedFormats); INIT_FEATURE(SparseResources, vkFeatures.sparseBinding && (vkFeatures.sparseResidencyBuffer || vkFeatures.sparseResidencyImage2D)); // requires support for resident resources + INIT_FEATURE(ShaderFloat64, vkFeatures.shaderFloat64); // clang-format on const VkPhysicalDeviceMeshShaderFeaturesEXT& MeshShaderFeats = ExtFeatures.MeshShader; @@ -2060,9 +2061,12 @@ DeviceFeatures VkFeaturesToDeviceFeatures(uint32_t INIT_FEATURE(NativeMultiDraw, ExtFeatures.MultiDraw.multiDraw != VK_FALSE && ExtFeatures.ShaderDrawParameters.shaderDrawParameters != VK_FALSE); + INIT_FEATURE(ShaderBarycentrics, ExtFeatures.FragmentShaderBarycentric.fragmentShaderBarycentric != VK_FALSE); + // clang-format on + #undef INIT_FEATURE - ASSERT_SIZEOF(DeviceFeatures, 48, "Did you add a new feature to DeviceFeatures? Please handle its status here (if necessary)."); + ASSERT_SIZEOF(DeviceFeatures, 50, "Did you add a new feature to DeviceFeatures? Please handle its status here (if necessary)."); return Features; } diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/PhysicalDevice.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/PhysicalDevice.cpp index b6dc4289c..eb67d7c06 100644 --- a/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/PhysicalDevice.cpp +++ b/Graphics/GraphicsEngineVulkan/src/VulkanUtilities/PhysicalDevice.cpp @@ -343,6 +343,14 @@ PhysicalDevice::PhysicalDevice(const CreateInfo& CI) : m_ExtFeatures.DynamicRendering.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES_KHR; } + if (IsExtensionSupported(VK_KHR_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME)) + { + *NextFeat = &m_ExtFeatures.FragmentShaderBarycentric; + NextFeat = &m_ExtFeatures.FragmentShaderBarycentric.pNext; + + m_ExtFeatures.FragmentShaderBarycentric.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_KHR; + } + const bool HostImageCopySupported = IsExtensionSupported(VK_EXT_HOST_IMAGE_COPY_EXTENSION_NAME); if (HostImageCopySupported) {