3 # Copyright 2020 Google LLC
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
18 # A test for a coverage-gap found by GraphicsFuzz.
20 # Short description: A fragment shader that covers a specific instruction folding path.
22 # The test passes because shader always writes red.
24 SHADER vertex variant_vertex_shader PASSTHROUGH
26 # variant_fragment_shader is derived from the following GLSL:
28 # precision highp float;
30 # layout(location = 0) out vec4 _GLF_color;
36 # // A single loop with i = 1.
37 # for(int i = 1; i > 0; i--)
39 # float a = 1.0 + float(i);
41 # // If condition is always true.
46 # // If condition is always true.
48 # _GLF_color = vec4(1, 0, 0, 1);
50 # _GLF_color = vec4(0);
52 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
55 ; Generator: Khronos Glslang Reference Front End; 8
59 %1 = OpExtInstImport "GLSL.std.450"
60 OpMemoryModel Logical GLSL450
61 OpEntryPoint Fragment %4 "main" %44
62 OpExecutionMode %4 OriginUpperLeft
68 OpName %44 "_GLF_color"
69 OpDecorate %12 RelaxedPrecision
70 OpDecorate %19 RelaxedPrecision
71 OpDecorate %26 RelaxedPrecision
72 OpDecorate %37 RelaxedPrecision
73 OpDecorate %38 RelaxedPrecision
74 OpDecorate %44 Location 0
76 %3 = OpTypeFunction %2
78 %7 = OpTypePointer Function %6
79 %9 = OpConstantFalse %6
81 %11 = OpTypePointer Function %10
82 %13 = OpConstant %10 1
83 %20 = OpConstant %10 0
85 %23 = OpTypePointer Function %22
86 %25 = OpConstant %22 1
87 %29 = OpConstant %22 2
88 %32 = OpConstant %22 0
89 %36 = OpConstantTrue %6
90 %42 = OpTypeVector %22 4
91 %43 = OpTypePointer Output %42
92 %44 = OpVariable %43 Output
93 %45 = OpConstantComposite %42 %25 %32 %32 %25
94 %47 = OpConstantComposite %42 %32 %32 %32 %32
95 %4 = OpFunction %2 None %3
97 %8 = OpVariable %7 Function
98 %12 = OpVariable %11 Function
99 %24 = OpVariable %23 Function
104 OpLoopMerge %16 %17 None
108 %21 = OpSGreaterThan %6 %19 %20
109 OpBranchConditional %21 %15 %16
112 %27 = OpConvertSToF %22 %26
113 %28 = OpFAdd %22 %25 %27
116 %31 = OpFSub %22 %29 %30
117 %33 = OpFOrdEqual %6 %31 %32
118 OpSelectionMerge %35 None
119 OpBranchConditional %33 %34 %35
127 %38 = OpISub %10 %37 %13
132 OpSelectionMerge %41 None
133 OpBranchConditional %39 %40 %46
146 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
148 PIPELINE graphics variant_pipeline
149 ATTACH variant_vertex_shader
150 ATTACH variant_fragment_shader
151 FRAMEBUFFER_SIZE 256 256
152 BIND BUFFER variant_framebuffer AS color LOCATION 0
154 CLEAR_COLOR variant_pipeline 0 0 0 255
156 CLEAR variant_pipeline
157 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
159 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255