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_1 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
30 # #define _float_0_0 _GLF_uniform_float_values[0]
32 # precision highp float;
33 # precision highp int;
35 # // Contents of _GLF_uniform_float_values: 0.0
36 # layout(set = 0, binding = 0) uniform buf0
38 # float _GLF_uniform_float_values[1];
41 # // Contents of _GLF_uniform_int_values: [1, 0]
42 # layout(set = 0, binding = 1) uniform buf1
44 # int _GLF_uniform_int_values[2];
47 # // Contents of one: [1.0]
48 # layout(set = 0, binding = 2) uniform buf2
53 # const int _GLF_global_loop_bound = 10;
54 # int _GLF_global_loop_count = 0;
56 # layout(location = 0) out vec4 _GLF_color;
64 # _GLF_global_loop_count++;
66 # if(one > _float_0_0)
68 # // a < a is always false.
69 # for(a = 0; a < a && _GLF_global_loop_count < _GLF_global_loop_bound; a++)
71 # _GLF_global_loop_count ++;
75 # // Always false: a is 0.
81 # while(_GLF_global_loop_count < _GLF_global_loop_bound);
86 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
90 # _GLF_color = vec4(_int_0);
93 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
96 ; Generator: Khronos Glslang Reference Front End; 10
100 %1 = OpExtInstImport "GLSL.std.450"
101 OpMemoryModel Logical GLSL450
102 OpEntryPoint Fragment %4 "main" %81
103 OpExecutionMode %4 OriginUpperLeft
106 OpName %8 "_GLF_global_loop_count"
109 OpMemberName %15 0 "_GLF_uniform_int_values"
112 OpMemberName %29 0 "one"
115 OpMemberName %37 0 "_GLF_uniform_float_values"
117 OpName %81 "_GLF_color"
118 OpDecorate %14 ArrayStride 16
119 OpMemberDecorate %15 0 Offset 0
121 OpDecorate %17 DescriptorSet 0
122 OpDecorate %17 Binding 1
123 OpMemberDecorate %29 0 Offset 0
125 OpDecorate %31 DescriptorSet 0
126 OpDecorate %31 Binding 2
127 OpDecorate %36 ArrayStride 16
128 OpMemberDecorate %37 0 Offset 0
130 OpDecorate %39 DescriptorSet 0
131 OpDecorate %39 Binding 0
132 OpDecorate %81 Location 0
134 %3 = OpTypeFunction %2
136 %7 = OpTypePointer Private %6
137 %8 = OpVariable %7 Private
139 %10 = OpTypePointer Function %6
141 %13 = OpConstant %12 2
142 %14 = OpTypeArray %6 %13
143 %15 = OpTypeStruct %14
144 %16 = OpTypePointer Uniform %15
145 %17 = OpVariable %16 Uniform
146 %18 = OpTypePointer Uniform %6
147 %26 = OpConstant %6 1
149 %29 = OpTypeStruct %28
150 %30 = OpTypePointer Uniform %29
151 %31 = OpVariable %30 Uniform
152 %32 = OpTypePointer Uniform %28
153 %35 = OpConstant %12 1
154 %36 = OpTypeArray %28 %35
155 %37 = OpTypeStruct %36
156 %38 = OpTypePointer Uniform %37
157 %39 = OpVariable %38 Uniform
159 %55 = OpConstant %6 10
160 %79 = OpTypeVector %28 4
161 %80 = OpTypePointer Output %79
162 %81 = OpVariable %80 Output
163 %4 = OpFunction %2 None %3
165 %11 = OpVariable %10 Function
167 %19 = OpAccessChain %18 %17 %9 %9
172 OpLoopMerge %23 %24 None
176 %27 = OpIAdd %6 %25 %26
178 %33 = OpAccessChain %32 %31 %9
180 %40 = OpAccessChain %32 %39 %9 %9
182 %43 = OpFOrdGreaterThan %42 %34 %41
183 OpSelectionMerge %45 None
184 OpBranchConditional %43 %44 %45
189 OpLoopMerge %48 %49 None
194 %53 = OpSLessThan %42 %51 %52
196 %56 = OpSLessThan %42 %54 %55
197 %57 = OpLogicalAnd %42 %53 %56
198 OpBranchConditional %57 %47 %48
201 %59 = OpIAdd %6 %58 %26
206 %61 = OpIAdd %6 %60 %26
214 %64 = OpIAdd %6 %62 %63
215 %65 = OpAccessChain %18 %17 %9 %9
217 %67 = OpSGreaterThan %42 %64 %66
218 OpSelectionMerge %69 None
219 OpBranchConditional %67 %68 %69
226 %72 = OpSLessThan %42 %71 %55
227 OpBranchConditional %72 %21 %23
230 %74 = OpAccessChain %18 %17 %9 %26
232 %76 = OpIEqual %42 %73 %75
233 OpSelectionMerge %78 None
234 OpBranchConditional %76 %77 %95
236 %82 = OpAccessChain %18 %17 %9 %9
238 %84 = OpConvertSToF %28 %83
239 %85 = OpAccessChain %18 %17 %9 %26
241 %87 = OpConvertSToF %28 %86
242 %88 = OpAccessChain %18 %17 %9 %26
244 %90 = OpConvertSToF %28 %89
245 %91 = OpAccessChain %18 %17 %9 %9
247 %93 = OpConvertSToF %28 %92
248 %94 = OpCompositeConstruct %79 %84 %87 %90 %93
252 %96 = OpAccessChain %18 %17 %9 %26
254 %98 = OpConvertSToF %28 %97
255 %99 = OpCompositeConstruct %79 %98 %98 %98 %98
263 # uniforms for variant
266 BUFFER variant_one DATA_TYPE float STD140 DATA
269 # _GLF_uniform_int_values
270 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
273 # _GLF_uniform_float_values
274 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
278 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
280 PIPELINE graphics variant_pipeline
281 ATTACH variant_vertex_shader
282 ATTACH variant_fragment_shader
283 FRAMEBUFFER_SIZE 32 32
284 BIND BUFFER variant_framebuffer AS color LOCATION 0
285 BIND BUFFER variant_one AS uniform DESCRIPTOR_SET 0 BINDING 2
286 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
287 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
289 CLEAR_COLOR variant_pipeline 0 0 0 255
291 CLEAR variant_pipeline
292 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
294 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255