Skip to content

Commit

Permalink
Reapply "Vulkan: Expose float control properties as angle features"
Browse files Browse the repository at this point in the history
This reverts commit 5a8eab9.

This relands the commit 027cbe1
with the below changes
  - add back needed suppressions that were removed erroneously
```
    // https://anglebug.com/361600662
    "VUID-RuntimeSpirv-OpEntryPoint-08743",
    "VUID-RuntimeSpirv-OpEntryPoint-07754",
    "VUID-RuntimeSpirv-maintenance4-06817",
```

Bug: angleproject:360031000
Change-Id: I74ed80b459466bdd8ae638ff875677b089aaa360
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5818733
Reviewed-by: Charlie Lao <[email protected]>
Reviewed-by: Shahbaz Youssefi <[email protected]>
Commit-Queue: Shahbaz Youssefi <[email protected]>
  • Loading branch information
gowtham-sarc authored and Angle LUCI CQ committed Aug 29, 2024
1 parent c094d4b commit 79729f7
Show file tree
Hide file tree
Showing 6 changed files with 324 additions and 1 deletion.
105 changes: 105 additions & 0 deletions include/platform/autogen/FeaturesVk_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
120 changes: 120 additions & 0 deletions include/platform/vk_features.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
69 changes: 68 additions & 1 deletion src/libANGLE/renderer/vulkan/vk_renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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());

Expand Down
1 change: 1 addition & 0 deletions src/libANGLE/renderer/vulkan/vk_renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,7 @@ class Renderer : angle::NonCopyable
VkPhysicalDevice16BitStorageFeatures m16BitStorageFeatures;
VkPhysicalDeviceSynchronization2Features mSynchronization2Features;
VkPhysicalDeviceVariablePointersFeatures mVariablePointersFeatures;
VkPhysicalDeviceFloatControlsProperties mFloatControlProperties;

uint32_t mLegacyDitheringVersion = 0;

Expand Down
Loading

0 comments on commit 79729f7

Please sign in to comment.