--- /dev/null
+# Copyright 2019 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# A test for a bug found by GraphicsFuzz.
+
+# Short description: A fragment shader with unreachable loops in a switch
+
+# The test passes because the fragment shader writes a red pixel, and then
+# terminates without further output manipulation
+
+# Derived from the following GLSL.
+
+# Fragment shader GLSL:
+# #version 310 es
+#
+# precision highp float;
+#
+# layout(location = 0) out vec4 _GLF_color;
+#
+# void main()
+# {
+# _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
+# float data[1];
+# for(int i = 0; i < 1; i++) {
+# if(data[i] < data[0]) {
+# if(false) {
+# if(float(i) >= 1.0) { }
+# }
+# switch(0) {
+# case 1:
+# for(; 1 > 0;) { }
+# for(;;) { }
+# case 0:
+# data[0] = 2.0;
+# break;
+# }
+# }
+# }
+# }
+
+[require]
+fbsize 256 256
+
+[vertex shader passthrough]
+
+[fragment shader spirv]
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 67
+; Schema: 0
+ OpCapability Shader
+ %1 = OpExtInstImport "GLSL.std.450"
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Fragment %4 "main" %9
+ OpExecutionMode %4 OriginUpperLeft
+ OpSource ESSL 310
+ OpName %4 "main"
+ OpName %9 "_GLF_color"
+ OpName %15 "i"
+ OpName %30 "data"
+ OpDecorate %9 Location 0
+ OpDecorate %15 RelaxedPrecision
+ OpDecorate %22 RelaxedPrecision
+ OpDecorate %31 RelaxedPrecision
+ OpDecorate %43 RelaxedPrecision
+ OpDecorate %65 RelaxedPrecision
+ OpDecorate %66 RelaxedPrecision
+ %2 = OpTypeVoid
+ %3 = OpTypeFunction %2
+ %6 = OpTypeFloat 32
+ %7 = OpTypeVector %6 4
+ %8 = OpTypePointer Output %7
+ %9 = OpVariable %8 Output
+ %10 = OpConstant %6 1
+ %11 = OpConstant %6 0
+ %12 = OpConstantComposite %7 %10 %11 %11 %10
+ %13 = OpTypeInt 32 1
+ %14 = OpTypePointer Function %13
+ %16 = OpConstant %13 0
+ %23 = OpConstant %13 1
+ %24 = OpTypeBool
+ %26 = OpTypeInt 32 0
+ %27 = OpConstant %26 1
+ %28 = OpTypeArray %6 %27
+ %29 = OpTypePointer Function %28
+ %32 = OpTypePointer Function %6
+ %40 = OpConstantFalse %24
+ %56 = OpConstantTrue %24
+ %61 = OpConstant %6 2
+ %4 = OpFunction %2 None %3
+ %5 = OpLabel
+ %15 = OpVariable %14 Function
+ %30 = OpVariable %29 Function
+ OpStore %9 %12
+ OpStore %15 %16
+ OpBranch %17
+ %17 = OpLabel
+ OpLoopMerge %19 %20 None
+ OpBranch %21
+ %21 = OpLabel
+ %22 = OpLoad %13 %15
+ %25 = OpSLessThan %24 %22 %23
+ OpBranchConditional %25 %18 %19
+ %18 = OpLabel
+ %31 = OpLoad %13 %15
+ %33 = OpAccessChain %32 %30 %31
+ %34 = OpLoad %6 %33
+ %35 = OpAccessChain %32 %30 %16
+ %36 = OpLoad %6 %35
+ %37 = OpFOrdLessThan %24 %34 %36
+ OpSelectionMerge %39 None
+ OpBranchConditional %37 %38 %39
+ %38 = OpLabel
+ OpSelectionMerge %42 None
+ OpBranchConditional %40 %41 %42
+ %41 = OpLabel
+ %43 = OpLoad %13 %15
+ %44 = OpConvertSToF %6 %43
+ %45 = OpFOrdGreaterThanEqual %24 %44 %10
+ OpSelectionMerge %47 None
+ OpBranchConditional %45 %46 %47
+ %46 = OpLabel
+ OpBranch %47
+ %47 = OpLabel
+ OpBranch %42
+ %42 = OpLabel
+ OpSelectionMerge %50 None
+ OpSwitch %16 %50 1 %48 0 %49
+ %48 = OpLabel
+ OpBranch %51
+ %51 = OpLabel
+ OpLoopMerge %53 %54 None
+ OpBranch %55
+ %55 = OpLabel
+ OpBranchConditional %56 %52 %53
+ %52 = OpLabel
+ OpBranch %54
+ %54 = OpLabel
+ OpBranch %51
+ %53 = OpLabel
+ OpBranch %57
+ %57 = OpLabel
+ OpLoopMerge %59 %60 None
+ OpBranch %58
+ %58 = OpLabel
+ OpBranch %60
+ %60 = OpLabel
+ OpBranch %57
+ %59 = OpLabel
+ OpBranch %49
+ %49 = OpLabel
+ %62 = OpAccessChain %32 %30 %16
+ OpStore %62 %61
+ OpBranch %50
+ %50 = OpLabel
+ OpBranch %39
+ %39 = OpLabel
+ OpBranch %20
+ %20 = OpLabel
+ %65 = OpLoad %13 %15
+ %66 = OpIAdd %13 %65 %23
+ OpStore %15 %66
+ OpBranch %17
+ %19 = OpLabel
+ OpReturn
+ OpFunctionEnd
+
+
+[test]
+draw rect -1 -1 2 2
+probe rgba (0, 0) (1, 0, 0, 1)