Fix undefined behaviour by allowing NaNs
authorMarcin Kańtoch <marcin.kantoch@amd.com>
Tue, 26 Jul 2022 15:25:41 +0000 (17:25 +0200)
committerMatthew Netsch <quic_mnetsch@quicinc.com>
Thu, 4 Aug 2022 16:21:28 +0000 (16:21 +0000)
One graphicsfuzz test contains computations with the float constant 0x1.8p+128.
This constant represents a NaN value. The computation with undef in the test
allows any optimization/triggers undefined behavior and the driver is free
to crash. Adding OpExecutionMode %4 SignedZeroInfNanPreserve 32 to the CTS fixes
this by allowing NaNs.

Affects:
dEQP-VK.graphicsfuzz.cov-instruction-simplify-atanh-log-undefined

Components: Vulkan

VK-GL-CTS issue: 3787

Change-Id: Id7140deddec240fdc5d9b1712c974199fa06b250

external/vulkancts/data/vulkan/amber/graphicsfuzz/cov-instruction-simplify-atanh-log-undefined.amber

index 52fe7d5..267b7ff 100644 (file)
@@ -56,6 +56,7 @@ SHADER vertex variant_vertex_shader PASSTHROUGH
 #         _GLF_color.g = _float_0_0;
 #     }
 # }
+DEVICE_EXTENSION VK_KHR_shader_float_controls
 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
 ; SPIR-V
 ; Version: 1.0
@@ -63,10 +64,13 @@ SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
 ; Bound: 57
 ; Schema: 0
                OpCapability Shader
+               OpCapability SignedZeroInfNanPreserve
+               OpExtension "SPV_KHR_float_controls"
           %1 = OpExtInstImport "GLSL.std.450"
                OpMemoryModel Logical GLSL450
                OpEntryPoint Fragment %4 "main" %9
                OpExecutionMode %4 OriginUpperLeft
+               OpExecutionMode %4 SignedZeroInfNanPreserve 32
                OpSource ESSL 310
                OpName %4 "main"
                OpName %9 "_GLF_color"