diff --git a/include/platform/autogen/FeaturesVk_autogen.h b/include/platform/autogen/FeaturesVk_autogen.h index 025e855c11c..8129e25b540 100644 --- a/include/platform/autogen/FeaturesVk_autogen.h +++ b/include/platform/autogen/FeaturesVk_autogen.h @@ -1509,6 +1509,111 @@ struct FeaturesVk : FeatureSetBase &members, "https://issuetracker.google.com/347601787" }; + FeatureInfo supportsRoundingModeRteFp16 = { + "supportsRoundingModeRteFp16", + FeatureCategory::VulkanFeatures, + "VkDevice supports the RTEFloat16 rounding mode from VK_KHR_shader_float_controls extension", + &members, "https://anglebug.com/360031000" + }; + + FeatureInfo supportsRoundingModeRteFp32 = { + "supportsRoundingModeRteFp32", + FeatureCategory::VulkanFeatures, + "VkDevice supports the RTEFloat32 rounding mode from VK_KHR_shader_float_controls extension", + &members, "https://anglebug.com/360031000" + }; + + FeatureInfo supportsRoundingModeRteFp64 = { + "supportsRoundingModeRteFp64", + FeatureCategory::VulkanFeatures, + "VkDevice supports the RTEFloat64 rounding mode from VK_KHR_shader_float_controls extension", + &members, "https://anglebug.com/360031000" + }; + + FeatureInfo supportsRoundingModeRtzFp16 = { + "supportsRoundingModeRtzFp16", + FeatureCategory::VulkanFeatures, + "VkDevice supports the RTZFloat16 rounding mode from VK_KHR_shader_float_controls extension", + &members, "https://anglebug.com/360031000" + }; + + FeatureInfo supportsRoundingModeRtzFp32 = { + "supportsRoundingModeRtzFp32", + FeatureCategory::VulkanFeatures, + "VkDevice supports the RTZFloat32 rounding mode from VK_KHR_shader_float_controls extension", + &members, "https://anglebug.com/360031000" + }; + + FeatureInfo supportsRoundingModeRtzFp64 = { + "supportsRoundingModeRtzFp64", + FeatureCategory::VulkanFeatures, + "VkDevice supports the RTZFloat64 rounding mode from VK_KHR_shader_float_controls extension", + &members, "https://anglebug.com/360031000" + }; + + FeatureInfo supportsDenormPreserveFp16 = { + "supportsDenormPreserveFp16", + FeatureCategory::VulkanFeatures, + "VkDevice supports the DenormPreserveFloat16 mode from VK_KHR_shader_float_controls extension", + &members, "https://anglebug.com/360031000" + }; + + FeatureInfo supportsDenormPreserveFp32 = { + "supportsDenormPreserveFp32", + FeatureCategory::VulkanFeatures, + "VkDevice supports the DenormPreserveFloat32 mode from VK_KHR_shader_float_controls extension", + &members, "https://anglebug.com/360031000" + }; + + FeatureInfo supportsDenormPreserveFp64 = { + "supportsDenormPreserveFp64", + FeatureCategory::VulkanFeatures, + "VkDevice supports the DenormPreserveFloat64 mode from VK_KHR_shader_float_controls extension", + &members, "https://anglebug.com/360031000" + }; + + FeatureInfo supportsDenormFtzFp16 = { + "supportsDenormFtzFp16", + FeatureCategory::VulkanFeatures, + "VkDevice supports the DenormFlushToZeroFloat16 mode from VK_KHR_shader_float_controls extension", + &members, "https://anglebug.com/360031000" + }; + + FeatureInfo supportsDenormFtzFp32 = { + "supportsDenormFtzFp32", + FeatureCategory::VulkanFeatures, + "VkDevice supports the DenormFlushToZeroFloat32 mode from VK_KHR_shader_float_controls extension", + &members, "https://anglebug.com/360031000" + }; + + FeatureInfo supportsDenormFtzFp64 = { + "supportsDenormFtzFp64", + FeatureCategory::VulkanFeatures, + "VkDevice supports the DenormFlushToZeroFloat64 mode from VK_KHR_shader_float_controls extension", + &members, "https://anglebug.com/360031000" + }; + + FeatureInfo supportsSignedZeroInfNanPreserveFp16 = { + "supportsSignedZeroInfNanPreserveFp16", + FeatureCategory::VulkanFeatures, + "VkDevice supports SignedZeroInfNanPreserve execution mode for 16-bit floating point from VK_KHR_shader_float_controls extension", + &members, "https://anglebug.com/360031000" + }; + + FeatureInfo supportsSignedZeroInfNanPreserveFp32 = { + "supportsSignedZeroInfNanPreserveFp32", + FeatureCategory::VulkanFeatures, + "VkDevice supports SignedZeroInfNanPreserve execution mode for 32-bit floating point from VK_KHR_shader_float_controls extension", + &members, "https://anglebug.com/360031000" + }; + + FeatureInfo supportsSignedZeroInfNanPreserveFp64 = { + "supportsSignedZeroInfNanPreserveFp64", + FeatureCategory::VulkanFeatures, + "VkDevice supports SignedZeroInfNanPreserve execution mode for 64-bit floating point from VK_KHR_shader_float_controls extension", + &members, "https://anglebug.com/360031000" + }; + }; inline FeaturesVk::FeaturesVk() = default; diff --git a/include/platform/vk_features.json b/include/platform/vk_features.json index cbc228e24e7..8e75675cf67 100644 --- a/include/platform/vk_features.json +++ b/include/platform/vk_features.json @@ -1649,6 +1649,126 @@ "Prefer host cached + non-coherent memory for buffers with dynamic/stream usage." ], "issue": "https://issuetracker.google.com/347601787" + }, + { + "name": "supports_rounding_mode_rte_fp16", + "category": "Features", + "description": [ + "VkDevice supports the RTEFloat16 rounding mode from VK_KHR_shader_float_controls extension" + ], + "issue": "https://anglebug.com/360031000" + }, + { + "name": "supports_rounding_mode_rte_fp32", + "category": "Features", + "description": [ + "VkDevice supports the RTEFloat32 rounding mode from VK_KHR_shader_float_controls extension" + ], + "issue": "https://anglebug.com/360031000" + }, + { + "name": "supports_rounding_mode_rte_fp64", + "category": "Features", + "description": [ + "VkDevice supports the RTEFloat64 rounding mode from VK_KHR_shader_float_controls extension" + ], + "issue": "https://anglebug.com/360031000" + }, + { + "name": "supports_rounding_mode_rtz_fp16", + "category": "Features", + "description": [ + "VkDevice supports the RTZFloat16 rounding mode from VK_KHR_shader_float_controls extension" + ], + "issue": "https://anglebug.com/360031000" + }, + { + "name": "supports_rounding_mode_rtz_fp32", + "category": "Features", + "description": [ + "VkDevice supports the RTZFloat32 rounding mode from VK_KHR_shader_float_controls extension" + ], + "issue": "https://anglebug.com/360031000" + }, + { + "name": "supports_rounding_mode_rtz_fp64", + "category": "Features", + "description": [ + "VkDevice supports the RTZFloat64 rounding mode from VK_KHR_shader_float_controls extension" + ], + "issue": "https://anglebug.com/360031000" + }, + { + "name": "supports_denorm_preserve_fp16", + "category": "Features", + "description": [ + "VkDevice supports the DenormPreserveFloat16 mode from VK_KHR_shader_float_controls extension" + ], + "issue": "https://anglebug.com/360031000" + }, + { + "name": "supports_denorm_preserve_fp32", + "category": "Features", + "description": [ + "VkDevice supports the DenormPreserveFloat32 mode from VK_KHR_shader_float_controls extension" + ], + "issue": "https://anglebug.com/360031000" + }, + { + "name": "supports_denorm_preserve_fp64", + "category": "Features", + "description": [ + "VkDevice supports the DenormPreserveFloat64 mode from VK_KHR_shader_float_controls extension" + ], + "issue": "https://anglebug.com/360031000" + }, + { + "name": "supports_denorm_ftz_fp16", + "category": "Features", + "description": [ + "VkDevice supports the DenormFlushToZeroFloat16 mode from VK_KHR_shader_float_controls extension" + ], + "issue": "https://anglebug.com/360031000" + }, + { + "name": "supports_denorm_ftz_fp32", + "category": "Features", + "description": [ + "VkDevice supports the DenormFlushToZeroFloat32 mode from VK_KHR_shader_float_controls extension" + ], + "issue": "https://anglebug.com/360031000" + }, + { + "name": "supports_denorm_ftz_fp64", + "category": "Features", + "description": [ + "VkDevice supports the DenormFlushToZeroFloat64 mode from VK_KHR_shader_float_controls extension" + ], + "issue": "https://anglebug.com/360031000" + }, + { + "name": "supports_signed_zero_inf_nan_preserve_fp16", + "category": "Features", + "description": [ + "VkDevice supports SignedZeroInfNanPreserve execution mode for 16-bit floating point from VK_KHR_shader_float_controls extension" + ], + "issue": "https://anglebug.com/360031000" + }, + { + "name": "supports_signed_zero_inf_nan_preserve_fp32", + "category": "Features", + "description": [ + "VkDevice supports SignedZeroInfNanPreserve execution mode for 32-bit floating point from VK_KHR_shader_float_controls extension" + ], + "issue": "https://anglebug.com/360031000" + }, + { + "name": "supports_signed_zero_inf_nan_preserve_fp64", + "category": "Features", + "description": [ + "VkDevice supports SignedZeroInfNanPreserve execution mode for 64-bit floating point from VK_KHR_shader_float_controls extension" + ], + "issue": "https://anglebug.com/360031000" } ] } diff --git a/src/libANGLE/renderer/vulkan/vk_renderer.cpp b/src/libANGLE/renderer/vulkan/vk_renderer.cpp index 9ac38f2b133..11eb2dfebb3 100644 --- a/src/libANGLE/renderer/vulkan/vk_renderer.cpp +++ b/src/libANGLE/renderer/vulkan/vk_renderer.cpp @@ -2518,6 +2518,21 @@ void Renderer::appendDeviceExtensionFeaturesPromotedTo11( // - VK_KHR_8bit_storage storageBuffer8BitAccess (feature) // uniformAndStorageBuffer8BitAccess (feature) // storagePushConstant8 (feature) +// - VK_KHR_shader_float_controls shaderRoundingModeRTEFloat16 (property) +// shaderRoundingModeRTEFloat32 (property) +// shaderRoundingModeRTEFloat64 (property) +// shaderRoundingModeRTZFloat16 (property) +// shaderRoundingModeRTZFloat32 (property) +// shaderRoundingModeRTZFloat64 (property) +// shaderDenormPreserveFloat16 (property) +// shaderDenormPreserveFloat16 (property) +// shaderDenormPreserveFloat16 (property) +// shaderDenormFlushToZeroFloat16 (property) +// shaderDenormFlushToZeroFloat32 (property) +// shaderDenormFlushToZeroFloat64 (property) +// shaderSignedZeroInfNanPreserveFloat16 (property) +// shaderSignedZeroInfNanPreserveFloat32 (property) +// shaderSignedZeroInfNanPreserveFloat64 (property) // // Note that supportedDepthResolveModes is used just to check if the property struct is populated. // ANGLE always uses VK_RESOLVE_MODE_SAMPLE_ZERO_BIT for both depth and stencil, and support for @@ -2528,6 +2543,11 @@ void Renderer::appendDeviceExtensionFeaturesPromotedTo12( VkPhysicalDeviceFeatures2KHR *deviceFeatures, VkPhysicalDeviceProperties2 *deviceProperties) { + if (ExtensionFound(VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME, deviceExtensionNames)) + { + vk::AddToPNextChain(deviceProperties, &mFloatControlProperties); + } + if (ExtensionFound(VK_KHR_SHADER_FLOAT16_INT8_EXTENSION_NAME, deviceExtensionNames)) { vk::AddToPNextChain(deviceFeatures, &mShaderFloat16Int8Features); @@ -2808,6 +2828,10 @@ void Renderer::queryDeviceExtensionFeatures(const vk::ExtensionNameList &deviceE mVariablePointersFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES_KHR; + // Rounding and denormal caps from VK_KHR_float_controls_properties + mFloatControlProperties = {}; + mFloatControlProperties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES; + #if defined(ANGLE_PLATFORM_ANDROID) mExternalFormatResolveFeatures = {}; mExternalFormatResolveFeatures.sType = @@ -2889,6 +2913,7 @@ void Renderer::queryDeviceExtensionFeatures(const vk::ExtensionNameList &deviceE mSynchronization2Features.pNext = nullptr; mBlendOperationAdvancedFeatures.pNext = nullptr; mVariablePointersFeatures.pNext = nullptr; + mFloatControlProperties.pNext = nullptr; #if defined(ANGLE_PLATFORM_ANDROID) mExternalFormatResolveFeatures.pNext = nullptr; mExternalFormatResolveProperties.pNext = nullptr; @@ -3283,9 +3308,16 @@ void Renderer::enableDeviceExtensionsPromotedTo12(const vk::ExtensionNameList &d mEnabledDeviceExtensions.push_back(VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME); } - if (mFeatures.supportsSPIRV14.enabled) + // There are several FP related modes defined as properties from + // VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION, and there could be a scenario where the extension is + // supported but none of the modes are supported. Here we enable the extension if it is found. + if (ExtensionFound(VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME, deviceExtensionNames)) { mEnabledDeviceExtensions.push_back(VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME); + } + + if (mFeatures.supportsSPIRV14.enabled) + { mEnabledDeviceExtensions.push_back(VK_KHR_SPIRV_1_4_EXTENSION_NAME); } @@ -4929,6 +4961,41 @@ void Renderer::initFeatures(const vk::ExtensionNameList &deviceExtensionNames, !isQualcommProprietary && !(isARM && armDriverVersion < ARMDriverVersion(47, 0, 0))); + // Rounding features from VK_KHR_float_controls extension + ANGLE_FEATURE_CONDITION(&mFeatures, supportsDenormFtzFp16, + mFloatControlProperties.shaderDenormFlushToZeroFloat16 == VK_TRUE); + ANGLE_FEATURE_CONDITION(&mFeatures, supportsDenormFtzFp32, + mFloatControlProperties.shaderDenormFlushToZeroFloat32 == VK_TRUE); + ANGLE_FEATURE_CONDITION(&mFeatures, supportsDenormFtzFp64, + mFloatControlProperties.shaderDenormFlushToZeroFloat64 == VK_TRUE); + ANGLE_FEATURE_CONDITION(&mFeatures, supportsDenormPreserveFp16, + mFloatControlProperties.shaderDenormPreserveFloat16 == VK_TRUE); + ANGLE_FEATURE_CONDITION(&mFeatures, supportsDenormPreserveFp32, + mFloatControlProperties.shaderDenormPreserveFloat32 == VK_TRUE); + ANGLE_FEATURE_CONDITION(&mFeatures, supportsDenormPreserveFp64, + mFloatControlProperties.shaderDenormPreserveFloat64 == VK_TRUE); + ANGLE_FEATURE_CONDITION(&mFeatures, supportsRoundingModeRteFp16, + mFloatControlProperties.shaderRoundingModeRTEFloat16 == VK_TRUE); + ANGLE_FEATURE_CONDITION(&mFeatures, supportsRoundingModeRteFp32, + mFloatControlProperties.shaderRoundingModeRTEFloat32 == VK_TRUE); + ANGLE_FEATURE_CONDITION(&mFeatures, supportsRoundingModeRteFp64, + mFloatControlProperties.shaderRoundingModeRTEFloat64 == VK_TRUE); + ANGLE_FEATURE_CONDITION(&mFeatures, supportsRoundingModeRtzFp16, + mFloatControlProperties.shaderRoundingModeRTZFloat16 == VK_TRUE); + ANGLE_FEATURE_CONDITION(&mFeatures, supportsRoundingModeRtzFp32, + mFloatControlProperties.shaderRoundingModeRTZFloat32 == VK_TRUE); + ANGLE_FEATURE_CONDITION(&mFeatures, supportsRoundingModeRtzFp64, + mFloatControlProperties.shaderRoundingModeRTZFloat64 == VK_TRUE); + ANGLE_FEATURE_CONDITION( + &mFeatures, supportsSignedZeroInfNanPreserveFp16, + mFloatControlProperties.shaderSignedZeroInfNanPreserveFloat16 == VK_TRUE); + ANGLE_FEATURE_CONDITION( + &mFeatures, supportsSignedZeroInfNanPreserveFp32, + mFloatControlProperties.shaderSignedZeroInfNanPreserveFloat32 == VK_TRUE); + ANGLE_FEATURE_CONDITION( + &mFeatures, supportsSignedZeroInfNanPreserveFp64, + mFloatControlProperties.shaderSignedZeroInfNanPreserveFloat64 == VK_TRUE); + // Retain debug info in SPIR-V blob. ANGLE_FEATURE_CONDITION(&mFeatures, retainSPIRVDebugInfo, getEnableValidationLayers()); diff --git a/src/libANGLE/renderer/vulkan/vk_renderer.h b/src/libANGLE/renderer/vulkan/vk_renderer.h index 58ed3dec898..3ff0e26eaca 100644 --- a/src/libANGLE/renderer/vulkan/vk_renderer.h +++ b/src/libANGLE/renderer/vulkan/vk_renderer.h @@ -963,6 +963,7 @@ class Renderer : angle::NonCopyable VkPhysicalDevice16BitStorageFeatures m16BitStorageFeatures; VkPhysicalDeviceSynchronization2Features mSynchronization2Features; VkPhysicalDeviceVariablePointersFeatures mVariablePointersFeatures; + VkPhysicalDeviceFloatControlsProperties mFloatControlProperties; uint32_t mLegacyDitheringVersion = 0; diff --git a/util/autogen/angle_features_autogen.cpp b/util/autogen/angle_features_autogen.cpp index 9aa64b40263..56c9ce9a119 100644 --- a/util/autogen/angle_features_autogen.cpp +++ b/util/autogen/angle_features_autogen.cpp @@ -305,6 +305,12 @@ constexpr PackedEnumMap kFeatureNames = {{ {Feature::SupportsColorWriteEnable, "supportsColorWriteEnable"}, {Feature::SupportsComputeTranscodeEtcToBc, "supportsComputeTranscodeEtcToBc"}, {Feature::SupportsCustomBorderColor, "supportsCustomBorderColor"}, + {Feature::SupportsDenormFtzFp16, "supportsDenormFtzFp16"}, + {Feature::SupportsDenormFtzFp32, "supportsDenormFtzFp32"}, + {Feature::SupportsDenormFtzFp64, "supportsDenormFtzFp64"}, + {Feature::SupportsDenormPreserveFp16, "supportsDenormPreserveFp16"}, + {Feature::SupportsDenormPreserveFp32, "supportsDenormPreserveFp32"}, + {Feature::SupportsDenormPreserveFp64, "supportsDenormPreserveFp64"}, {Feature::SupportsDepthClampZeroOne, "supportsDepthClampZeroOne"}, {Feature::SupportsDepthClipControl, "supportsDepthClipControl"}, {Feature::SupportsDepthStencilIndependentResolveNone, "supportsDepthStencilIndependentResolveNone"}, @@ -366,6 +372,12 @@ constexpr PackedEnumMap kFeatureNames = {{ {Feature::SupportsRenderpass2, "supportsRenderpass2"}, {Feature::SupportsRenderPassLoadStoreOpNone, "supportsRenderPassLoadStoreOpNone"}, {Feature::SupportsRenderPassStoreOpNone, "supportsRenderPassStoreOpNone"}, + {Feature::SupportsRoundingModeRteFp16, "supportsRoundingModeRteFp16"}, + {Feature::SupportsRoundingModeRteFp32, "supportsRoundingModeRteFp32"}, + {Feature::SupportsRoundingModeRteFp64, "supportsRoundingModeRteFp64"}, + {Feature::SupportsRoundingModeRtzFp16, "supportsRoundingModeRtzFp16"}, + {Feature::SupportsRoundingModeRtzFp32, "supportsRoundingModeRtzFp32"}, + {Feature::SupportsRoundingModeRtzFp64, "supportsRoundingModeRtzFp64"}, {Feature::SupportsSampler2dViewOf3d, "supportsSampler2dViewOf3d"}, {Feature::SupportsSamplerMirrorClampToEdge, "supportsSamplerMirrorClampToEdge"}, {Feature::SupportsShaderFloat16, "supportsShaderFloat16"}, @@ -379,6 +391,9 @@ constexpr PackedEnumMap kFeatureNames = {{ {Feature::SupportsShaderPixelLocalStorageEXT, "supportsShaderPixelLocalStorageEXT"}, {Feature::SupportsShaderStencilExport, "supportsShaderStencilExport"}, {Feature::SupportsSharedPresentableImageExtension, "supportsSharedPresentableImageExtension"}, + {Feature::SupportsSignedZeroInfNanPreserveFp16, "supportsSignedZeroInfNanPreserveFp16"}, + {Feature::SupportsSignedZeroInfNanPreserveFp32, "supportsSignedZeroInfNanPreserveFp32"}, + {Feature::SupportsSignedZeroInfNanPreserveFp64, "supportsSignedZeroInfNanPreserveFp64"}, {Feature::SupportsSPIRV14, "supportsSPIRV14"}, {Feature::SupportsSurfaceCapabilities2Extension, "supportsSurfaceCapabilities2Extension"}, {Feature::SupportsSurfacelessQueryExtension, "supportsSurfacelessQueryExtension"}, diff --git a/util/autogen/angle_features_autogen.h b/util/autogen/angle_features_autogen.h index 93ec45c2dcc..ecce984db52 100644 --- a/util/autogen/angle_features_autogen.h +++ b/util/autogen/angle_features_autogen.h @@ -305,6 +305,12 @@ enum class Feature SupportsColorWriteEnable, SupportsComputeTranscodeEtcToBc, SupportsCustomBorderColor, + SupportsDenormFtzFp16, + SupportsDenormFtzFp32, + SupportsDenormFtzFp64, + SupportsDenormPreserveFp16, + SupportsDenormPreserveFp32, + SupportsDenormPreserveFp64, SupportsDepthClampZeroOne, SupportsDepthClipControl, SupportsDepthStencilIndependentResolveNone, @@ -366,6 +372,12 @@ enum class Feature SupportsRenderpass2, SupportsRenderPassLoadStoreOpNone, SupportsRenderPassStoreOpNone, + SupportsRoundingModeRteFp16, + SupportsRoundingModeRteFp32, + SupportsRoundingModeRteFp64, + SupportsRoundingModeRtzFp16, + SupportsRoundingModeRtzFp32, + SupportsRoundingModeRtzFp64, SupportsSampler2dViewOf3d, SupportsSamplerMirrorClampToEdge, SupportsShaderFloat16, @@ -379,6 +391,9 @@ enum class Feature SupportsShaderPixelLocalStorageEXT, SupportsShaderStencilExport, SupportsSharedPresentableImageExtension, + SupportsSignedZeroInfNanPreserveFp16, + SupportsSignedZeroInfNanPreserveFp32, + SupportsSignedZeroInfNanPreserveFp64, SupportsSPIRV14, SupportsSurfaceCapabilities2Extension, SupportsSurfacelessQueryExtension,