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>
Fri, 2 Sep 2022 23:26:15 +0000 (23:26 +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: I2442bc4f50add8b8f779dbfae3c5fe2be8fd85f4

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

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"
index 1b5110c..2935b5d 100644 (file)
 {      "cov-inst-peephole-optimizer-acosh.amber",                                                                                                      "cov-inst-peephole-optimizer-acosh",                                                                                            "A fragment shader that covers a specific peephole optimizer code path"                         },
 {      "cov-inst-value-tracking-inversesqrt.amber",                                                                                            "cov-inst-value-tracking-inversesqrt",                                                                                          "A fragment shader that covers a specific value tracking path"                                          },
 {      "cov-instr-emitter-pow-asinh.amber",                                                                                                            "cov-instr-emitter-pow-asinh",                                                                                                          "A fragment shader that covers a specific instruction emitter code path"                        },
-{      "cov-instruction-simplify-atanh-log-undefined.amber",                                                                           "cov-instruction-simplify-atanh-log-undefined",                                                                         "A fragment shader that covers a specific instruction simplification path"                      },
+{      "cov-instruction-simplify-atanh-log-undefined.amber",                                                                           "cov-instruction-simplify-atanh-log-undefined",                                                                         "A fragment shader that covers a specific instruction simplification path",                     "VK_KHR_shader_float_controls"},
 {      "cov-instruction-simplify-bit-shifting.amber",                                                                                          "cov-instruction-simplify-bit-shifting",                                                                                        "A fragment shader that covers a specific instruction simplification path"                      },
 {      "cov-instruction-simplify-inclusive-or.amber",                                                                                          "cov-instruction-simplify-inclusive-or",                                                                                        "A fragment shader that covers a specific instruction simplification path"                      },
 {      "cov-instruction-simplify-inst-combine-calls-for-compare-function-call-result.amber",           "cov-instruction-simplify-inst-combine-calls-for-compare-function-call-result",         "A fragment shader that covers a specific instruction simplification path"                      },