3 # Copyright 2022 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 the GraphicsFuzz project.
20 # Short description: A fragment shader that covers specific LLVM code paths
22 # The test passes because the shader always writes red.
24 SHADER vertex variant_vertex_shader PASSTHROUGH
26 # variant_fragment_shader is derived from the following GLSL:
28 # #define _int_20 _GLF_uniform_int_values[0]
29 # #define _int_1 _GLF_uniform_int_values[1]
30 # #define _int_0 _GLF_uniform_int_values[2]
31 # #define _int_5 _GLF_uniform_int_values[3]
32 # #define _int_3 _GLF_uniform_int_values[4]
33 # #define _float_0_0 _GLF_uniform_float_values[0]
35 # precision highp float;
36 # precision highp int;
38 # // Contents of _GLF_uniform_float_values: 0.0
39 # layout(set = 0, binding = 0) uniform buf0
41 # float _GLF_uniform_float_values[1];
44 # // Contents of _GLF_uniform_int_values: [20, 1, 0, 5, 3]
45 # layout(set = 0, binding = 1) uniform buf1
47 # int _GLF_uniform_int_values[5];
50 # const int _GLF_global_loop_bound = 10;
51 # int _GLF_global_loop_count = 0;
53 # layout(location = 0) out vec4 _GLF_color;
59 # for(int i = _int_0; i < _int_3; i++)
62 # if(gl_FragCoord.x > _float_0_0)
68 # while(_GLF_global_loop_count < _GLF_global_loop_bound)
70 # _GLF_global_loop_count ++;
72 # // Breaks when a is five.
73 # if(a * a + _int_1 > _int_20)
84 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
88 # _GLF_color = vec4(_int_0);
91 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
94 ; Generator: Khronos Glslang Reference Front End; 10
98 %1 = OpExtInstImport "GLSL.std.450"
99 OpMemoryModel Logical GLSL450
100 OpEntryPoint Fragment %4 "main" %40 %92
101 OpExecutionMode %4 OriginUpperLeft
104 OpName %8 "_GLF_global_loop_count"
107 OpMemberName %15 0 "_GLF_uniform_int_values"
110 OpName %40 "gl_FragCoord"
112 OpMemberName %47 0 "_GLF_uniform_float_values"
114 OpName %92 "_GLF_color"
115 OpDecorate %14 ArrayStride 16
116 OpMemberDecorate %15 0 Offset 0
118 OpDecorate %17 DescriptorSet 0
119 OpDecorate %17 Binding 1
120 OpDecorate %40 BuiltIn FragCoord
121 OpDecorate %46 ArrayStride 16
122 OpMemberDecorate %47 0 Offset 0
124 OpDecorate %49 DescriptorSet 0
125 OpDecorate %49 Binding 0
126 OpDecorate %92 Location 0
128 %3 = OpTypeFunction %2
130 %7 = OpTypePointer Private %6
131 %8 = OpVariable %7 Private
133 %10 = OpTypePointer Function %6
135 %13 = OpConstant %12 5
136 %14 = OpTypeArray %6 %13
137 %15 = OpTypeStruct %14
138 %16 = OpTypePointer Uniform %15
139 %17 = OpVariable %16 Uniform
140 %18 = OpConstant %6 1
141 %19 = OpTypePointer Uniform %6
142 %23 = OpConstant %6 2
143 %32 = OpConstant %6 4
146 %38 = OpTypeVector %37 4
147 %39 = OpTypePointer Input %38
148 %40 = OpVariable %39 Input
149 %41 = OpConstant %12 0
150 %42 = OpTypePointer Input %37
151 %45 = OpConstant %12 1
152 %46 = OpTypeArray %37 %45
153 %47 = OpTypeStruct %46
154 %48 = OpTypePointer Uniform %47
155 %49 = OpVariable %48 Uniform
156 %50 = OpTypePointer Uniform %37
157 %66 = OpConstant %6 10
158 %85 = OpConstant %6 3
159 %91 = OpTypePointer Output %38
160 %92 = OpVariable %91 Output
161 %4 = OpFunction %2 None %3
163 %11 = OpVariable %10 Function
164 %22 = OpVariable %10 Function
166 %20 = OpAccessChain %19 %17 %9 %18
169 %24 = OpAccessChain %19 %17 %9 %23
174 OpLoopMerge %28 %29 None
178 %33 = OpAccessChain %19 %17 %9 %32
180 %36 = OpSLessThan %35 %31 %34
181 OpBranchConditional %36 %27 %28
183 %43 = OpAccessChain %42 %40 %41
185 %51 = OpAccessChain %50 %49 %9 %9
187 %53 = OpFOrdGreaterThan %35 %44 %52
188 OpSelectionMerge %55 None
189 OpBranchConditional %53 %54 %55
192 %57 = OpIAdd %6 %56 %18
199 %59 = OpIAdd %6 %58 %18
205 OpLoopMerge %62 %63 None
209 %67 = OpSLessThan %35 %65 %66
210 OpBranchConditional %67 %61 %62
213 %69 = OpIAdd %6 %68 %18
217 %72 = OpIMul %6 %70 %71
218 %73 = OpAccessChain %19 %17 %9 %18
220 %75 = OpIAdd %6 %72 %74
221 %76 = OpAccessChain %19 %17 %9 %9
223 %78 = OpSGreaterThan %35 %75 %77
224 OpSelectionMerge %80 None
225 OpBranchConditional %78 %79 %80
230 %83 = OpIAdd %6 %82 %18
237 %86 = OpAccessChain %19 %17 %9 %85
239 %88 = OpIEqual %35 %84 %87
240 OpSelectionMerge %90 None
241 OpBranchConditional %88 %89 %106
243 %93 = OpAccessChain %19 %17 %9 %18
245 %95 = OpConvertSToF %37 %94
246 %96 = OpAccessChain %19 %17 %9 %23
248 %98 = OpConvertSToF %37 %97
249 %99 = OpAccessChain %19 %17 %9 %23
251 %101 = OpConvertSToF %37 %100
252 %102 = OpAccessChain %19 %17 %9 %18
253 %103 = OpLoad %6 %102
254 %104 = OpConvertSToF %37 %103
255 %105 = OpCompositeConstruct %38 %95 %98 %101 %104
259 %107 = OpAccessChain %19 %17 %9 %23
260 %108 = OpLoad %6 %107
261 %109 = OpConvertSToF %37 %108
262 %110 = OpCompositeConstruct %38 %109 %109 %109 %109
270 # uniforms for variant
272 # _GLF_uniform_int_values
273 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
276 # _GLF_uniform_float_values
277 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
281 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
283 PIPELINE graphics variant_pipeline
284 ATTACH variant_vertex_shader
285 ATTACH variant_fragment_shader
286 FRAMEBUFFER_SIZE 32 32
287 BIND BUFFER variant_framebuffer AS color LOCATION 0
288 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
289 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
291 CLEAR_COLOR variant_pipeline 0 0 0 255
293 CLEAR variant_pipeline
294 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
296 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255