Commit 0063ecae by Sean Risser

Implement VK_KHR_shader_float_controls

This extension allows users to query and specify how the implementation handles floats. SwiftShader does not allow users to modify floating point behavior at this time, and its default behavior may be inconsistent due to operating across several architectures. Bug: b/171498580 Change-Id: I2926f015bdccad0ca2a4cfae195eeeba09781f07 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/49728 Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarSean Risser <srisser@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent ca8a16ef
......@@ -717,6 +717,7 @@ SpirvShader::SpirvShader(
if(!strcmp(ext, "SPV_KHR_device_group")) break;
if(!strcmp(ext, "SPV_KHR_multiview")) break;
if(!strcmp(ext, "SPV_EXT_shader_stencil_export")) break;
if(!strcmp(ext, "SPV_KHR_float_controls")) break;
UNSUPPORTED("SPIR-V Extension: %s", ext);
break;
}
......
......@@ -701,6 +701,38 @@ void PhysicalDevice::getProperties(VkPhysicalDeviceProvokingVertexPropertiesEXT
properties->provokingVertexModePerPipeline = VK_TRUE;
}
void PhysicalDevice::getProperties(VkPhysicalDeviceFloatControlsProperties *properties) const
{
// The spec states:
// shaderSignedZeroInfNanPreserveFloat32 is a boolean value indicating whether
// sign of a zero, Nans and ±∞ can be preserved in 32-bit floating-point
// computations. It also indicates whether the SignedZeroInfNanPreserve execution
// mode can be used for 32-bit floating-point types.
//
// There are similar clauses for all the shader* bools present here.
//
// It does not state that an implementation must report its default behavior using
// these variables. At this time SwiftShader does not expose any preserve, denormal,
// or rounding controls.
properties->denormBehaviorIndependence = VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_NONE;
properties->roundingModeIndependence = VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_NONE;
properties->shaderSignedZeroInfNanPreserveFloat16 = VK_FALSE;
properties->shaderSignedZeroInfNanPreserveFloat32 = VK_FALSE;
properties->shaderSignedZeroInfNanPreserveFloat64 = VK_FALSE;
properties->shaderDenormPreserveFloat16 = VK_FALSE;
properties->shaderDenormPreserveFloat32 = VK_FALSE;
properties->shaderDenormPreserveFloat64 = VK_FALSE;
properties->shaderDenormFlushToZeroFloat16 = VK_FALSE;
properties->shaderDenormFlushToZeroFloat32 = VK_FALSE;
properties->shaderDenormFlushToZeroFloat64 = VK_FALSE;
properties->shaderRoundingModeRTZFloat16 = VK_FALSE;
properties->shaderRoundingModeRTZFloat32 = VK_FALSE;
properties->shaderRoundingModeRTZFloat64 = VK_FALSE;
properties->shaderRoundingModeRTEFloat16 = VK_FALSE;
properties->shaderRoundingModeRTEFloat32 = VK_FALSE;
properties->shaderRoundingModeRTEFloat64 = VK_FALSE;
}
bool PhysicalDevice::hasFeatures(const VkPhysicalDeviceFeatures &requestedFeatures) const
{
const VkPhysicalDeviceFeatures &supportedFeatures = getFeatures();
......
......@@ -59,6 +59,7 @@ public:
void getProperties(VkPhysicalDeviceDriverPropertiesKHR *properties) const;
void getProperties(VkPhysicalDeviceLineRasterizationPropertiesEXT *properties) const;
void getProperties(VkPhysicalDeviceProvokingVertexPropertiesEXT *properties) const;
void getProperties(VkPhysicalDeviceFloatControlsProperties *) const;
static void GetFormatProperties(Format format, VkFormatProperties *pFormatProperties);
void getImageFormatProperties(Format format, VkImageType type, VkImageTiling tiling,
......
......@@ -392,6 +392,7 @@ static const VkExtensionProperties deviceExtensionProperties[] = {
// Vulkan 1.2 promoted extensions
{ VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME, VK_KHR_IMAGE_FORMAT_LIST_SPEC_VERSION },
{ VK_KHR_IMAGELESS_FRAMEBUFFER_EXTENSION_NAME, VK_KHR_IMAGELESS_FRAMEBUFFER_SPEC_VERSION },
{ VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME, VK_KHR_SHADER_FLOAT_CONTROLS_SPEC_VERSION },
{ VK_KHR_SHADER_SUBGROUP_EXTENDED_TYPES_EXTENSION_NAME, VK_KHR_SHADER_SUBGROUP_EXTENDED_TYPES_SPEC_VERSION }
};
......@@ -2929,6 +2930,12 @@ VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties2(VkPhysicalDevice physi
vk::Cast(physicalDevice)->getProperties(properties);
}
break;
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES_KHR:
{
auto properties = reinterpret_cast<VkPhysicalDeviceFloatControlsProperties *>(extensionProperties);
vk::Cast(physicalDevice)->getProperties(properties);
}
break;
default:
// "the [driver] must skip over, without processing (other than reading the sType and pNext members) any structures in the chain with sType values not defined by [supported extenions]"
LOG_TRAP("pProperties->pNext sType = %s", vk::Stringify(extensionProperties->sType).c_str());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment