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 bug found by GraphicsFuzz.
20 # Short description: Cosh returns inf for one component which is never used
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;
29 # precision highp int;
31 # layout(location = 0) out vec4 _GLF_color;
33 # layout(set = 0, binding = 0) uniform buf0
38 # // Returns 3.0 if b > 1, otherwise returns 5.0.
41 # for (int ndx = 0; ndx < 2; ndx++)
44 # if (gl_FragCoord.x < 0.0)
46 # for (int i = 0; i < 2; i++)
49 # if (int(cosh(vec2(1, 800)).x) <= 1)
59 # if (gl_FragCoord.x < 0.0)
60 # _GLF_color = vec4(0);
67 # _GLF_color = vec4(1);
73 # if (int(_GLF_color.y) < 0)
76 # f = func(int(zero)); // f == 5.0
79 # if (int(_GLF_color.y) > 65)
82 # for (int x = 0; x < int(zero) + 1; x++)
84 # f = func(x + 10); // f == 3.0
87 # } while (int(zero) > 1); // Always false.
90 # _GLF_color = vec4(1, 0, 0, 1);
92 # _GLF_color = vec4(0);
94 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
97 ; Generator: Khronos Glslang Reference Front End; 8
101 %1 = OpExtInstImport "GLSL.std.450"
102 OpMemoryModel Logical GLSL450
103 OpEntryPoint Fragment %4 "main" %26 %72
104 OpExecutionMode %4 OriginUpperLeft
107 OpName %11 "func(i1;"
110 OpName %26 "gl_FragCoord"
112 OpName %72 "_GLF_color"
115 OpMemberName %94 0 "zero"
120 OpDecorate %26 BuiltIn FragCoord
121 OpDecorate %72 Location 0
122 OpMemberDecorate %94 0 Offset 0
124 OpDecorate %96 DescriptorSet 0
125 OpDecorate %96 Binding 0
127 %3 = OpTypeFunction %2
129 %7 = OpTypePointer Function %6
131 %9 = OpTypeFunction %8 %7
132 %14 = OpConstant %6 0
133 %21 = OpConstant %6 2
135 %24 = OpTypeVector %8 4
136 %25 = OpTypePointer Input %24
137 %26 = OpVariable %25 Input
139 %28 = OpConstant %27 0
140 %29 = OpTypePointer Input %8
141 %32 = OpConstant %8 0
142 %44 = OpTypeVector %8 2
143 %45 = OpConstant %8 1
144 %46 = OpConstant %8 800
145 %47 = OpConstantComposite %44 %45 %46
146 %51 = OpConstant %6 1
147 %64 = OpConstant %8 3
148 %71 = OpTypePointer Output %24
149 %72 = OpVariable %71 Output
150 %73 = OpConstantComposite %24 %32 %32 %32 %32
151 %74 = OpConstant %8 5
152 %77 = OpConstantComposite %24 %45 %45 %45 %45
153 %78 = OpTypePointer Function %8
154 %84 = OpConstant %27 1
155 %85 = OpTypePointer Output %8
156 %94 = OpTypeStruct %8
157 %95 = OpTypePointer Uniform %94
158 %96 = OpVariable %95 Uniform
159 %97 = OpTypePointer Uniform %8
160 %106 = OpConstant %6 65
161 %124 = OpConstant %6 10
162 %138 = OpConstantComposite %24 %45 %32 %32 %45
163 %4 = OpFunction %2 None %3
165 %79 = OpVariable %78 Function
166 %101 = OpVariable %7 Function
167 %111 = OpVariable %7 Function
168 %126 = OpVariable %7 Function
173 OpLoopMerge %82 %83 None
176 %86 = OpAccessChain %85 %72 %84
178 %88 = OpConvertFToS %6 %87
179 %89 = OpSLessThan %22 %88 %14
180 OpSelectionMerge %91 None
181 OpBranchConditional %89 %90 %93
185 %98 = OpAccessChain %97 %96 %14
187 %100 = OpConvertFToS %6 %99
189 %102 = OpFunctionCall %8 %11 %101
193 %103 = OpAccessChain %85 %72 %84
194 %104 = OpLoad %8 %103
195 %105 = OpConvertFToS %6 %104
196 %107 = OpSGreaterThan %22 %105 %106
197 OpSelectionMerge %109 None
198 OpBranchConditional %107 %108 %109
205 OpLoopMerge %114 %115 None
208 %117 = OpLoad %6 %111
209 %118 = OpAccessChain %97 %96 %14
210 %119 = OpLoad %8 %118
211 %120 = OpConvertFToS %6 %119
212 %121 = OpIAdd %6 %120 %51
213 %122 = OpSLessThan %22 %117 %121
214 OpBranchConditional %122 %113 %114
216 %123 = OpLoad %6 %111
217 %125 = OpIAdd %6 %123 %124
219 %127 = OpFunctionCall %8 %11 %126
223 %128 = OpLoad %6 %111
224 %129 = OpIAdd %6 %128 %51
230 %130 = OpAccessChain %97 %96 %14
231 %131 = OpLoad %8 %130
232 %132 = OpConvertFToS %6 %131
233 %133 = OpSGreaterThan %22 %132 %51
234 OpBranchConditional %133 %80 %82
237 %135 = OpFOrdEqual %22 %134 %64
238 OpSelectionMerge %137 None
239 OpBranchConditional %135 %136 %139
249 %11 = OpFunction %8 None %9
250 %10 = OpFunctionParameter %7
252 %13 = OpVariable %7 Function
253 %36 = OpVariable %7 Function
257 OpLoopMerge %17 %18 None
261 %23 = OpSLessThan %22 %20 %21
262 OpBranchConditional %23 %16 %17
264 %30 = OpAccessChain %29 %26 %28
266 %33 = OpFOrdLessThan %22 %31 %32
267 OpSelectionMerge %35 None
268 OpBranchConditional %33 %34 %35
273 OpLoopMerge %39 %40 None
277 %43 = OpSLessThan %22 %42 %21
278 OpBranchConditional %43 %38 %39
280 %48 = OpExtInst %44 %1 Cosh %47
281 %49 = OpCompositeExtract %8 %48 0
282 %50 = OpConvertFToS %6 %49
283 %52 = OpSLessThanEqual %22 %50 %51
284 OpSelectionMerge %54 None
285 OpBranchConditional %52 %53 %54
292 %57 = OpIAdd %6 %56 %51
301 %59 = OpIAdd %6 %58 %51
306 %61 = OpSGreaterThan %22 %60 %51
307 OpSelectionMerge %63 None
308 OpBranchConditional %61 %62 %63
312 %66 = OpAccessChain %29 %26 %28
314 %68 = OpFOrdLessThan %22 %67 %32
315 OpSelectionMerge %70 None
316 OpBranchConditional %68 %69 %70
325 # uniforms for variant
328 BUFFER variant_zero DATA_TYPE float DATA
332 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
334 PIPELINE graphics variant_pipeline
335 ATTACH variant_vertex_shader
336 ATTACH variant_fragment_shader
337 FRAMEBUFFER_SIZE 256 256
338 BIND BUFFER variant_framebuffer AS color LOCATION 0
339 BIND BUFFER variant_zero AS uniform DESCRIPTOR_SET 0 BINDING 0
341 CLEAR_COLOR variant_pipeline 0 0 0 255
343 CLEAR variant_pipeline
344 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
346 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255