3 # Copyright 2021 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 # Optimized using spirv-opt with the following arguments:
25 # '--redundancy-elimination'
27 # '--redundancy-elimination'
28 # '--convert-local-access-chains'
29 # '--eliminate-dead-inserts'
31 # '--eliminate-dead-branches'
33 # '--scalar-replacement=100'
34 # '--scalar-replacement=100'
35 # '--scalar-replacement=100'
38 # '--inline-entry-points-exhaustive'
39 # '--scalar-replacement=100'
40 # '--simplify-instructions'
41 # '--eliminate-dead-code-aggressive'
42 # '--eliminate-dead-code-aggressive'
43 # '--eliminate-local-multi-store'
45 # '--convert-local-access-chains'
46 # '--scalar-replacement=100'
48 # '--eliminate-dead-branches'
50 # '--eliminate-dead-branches'
52 # '--eliminate-local-single-store'
53 # '--eliminate-dead-inserts'
54 # '--eliminate-dead-branches'
56 # '--private-to-local'
57 # '--eliminate-dead-branches'
58 # spirv-opt commit hash: a0370efd589be33d5d9a85cfde2f85841b3755af
62 SHADER vertex variant_vertex_shader PASSTHROUGH
64 # variant_fragment_shader is derived from the following GLSL:
66 # #define _int_10 _GLF_uniform_int_values[0]
67 # #define _int_1 _GLF_uniform_int_values[1]
68 # #define _int_0 _GLF_uniform_int_values[2]
70 # precision highp float;
71 # precision highp int;
73 # // Contents of _GLF_uniform_int_values: [10, 1, 0]
74 # layout(set = 0, binding = 0) uniform buf0
76 # int _GLF_uniform_int_values[3];
79 # const int _GLF_global_loop_bound = 10;
80 # int _GLF_global_loop_count = 0;
82 # layout(location = 0) out vec4 _GLF_color;
86 # while(_GLF_global_loop_count < _GLF_global_loop_bound)
88 # _GLF_global_loop_count++;
90 # while(_GLF_global_loop_count < _GLF_global_loop_bound)
92 # _GLF_global_loop_count ++;
95 # if(gl_FragCoord.y < 0.0)
101 # if(gl_FragCoord.y < 0.0)
109 # if(gl_FragCoord.y < 0.0)
119 # if(_GLF_global_loop_count == _int_10)
121 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
125 # _GLF_color = vec4(_int_0);
128 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
131 ; Generator: Khronos Glslang Reference Front End; 10
135 %1 = OpExtInstImport "GLSL.std.450"
136 OpMemoryModel Logical GLSL450
137 OpEntryPoint Fragment %4 "main" %34 %75
138 OpExecutionMode %4 OriginUpperLeft
141 OpName %8 "_GLF_global_loop_count"
142 OpName %34 "gl_FragCoord"
144 OpMemberName %65 0 "_GLF_uniform_int_values"
146 OpName %75 "_GLF_color"
147 OpDecorate %34 BuiltIn FragCoord
148 OpDecorate %64 ArrayStride 16
149 OpMemberDecorate %65 0 Offset 0
151 OpDecorate %67 DescriptorSet 0
152 OpDecorate %67 Binding 0
153 OpDecorate %75 Location 0
155 %3 = OpTypeFunction %2
157 %7 = OpTypePointer Private %6
159 %16 = OpConstant %6 10
161 %20 = OpConstant %6 1
163 %32 = OpTypeVector %31 4
164 %33 = OpTypePointer Input %32
165 %34 = OpVariable %33 Input
167 %36 = OpConstant %35 1
168 %37 = OpTypePointer Input %31
169 %40 = OpConstant %31 0
170 %61 = OpConstantFalse %17
171 %63 = OpConstant %35 3
172 %64 = OpTypeArray %6 %63
173 %65 = OpTypeStruct %64
174 %66 = OpTypePointer Uniform %65
175 %67 = OpVariable %66 Uniform
176 %68 = OpTypePointer Uniform %6
177 %74 = OpTypePointer Output %32
178 %75 = OpVariable %74 Output
179 %79 = OpConstant %6 2
180 %97 = OpConstant %35 0
181 %98 = OpTypePointer Function %17
182 %100 = OpConstantTrue %17
183 %107 = OpTypePointer Function %6
184 %4 = OpFunction %2 None %3
186 %8 = OpVariable %107 Function
187 %99 = OpVariable %98 Function %61
188 OpSelectionMerge %95 None
195 %18 = OpSLessThan %17 %15 %16
196 OpLoopMerge %12 %13 None
197 OpBranchConditional %18 %11 %12
200 %21 = OpIAdd %6 %19 %20
205 %28 = OpSLessThan %17 %27 %16
206 OpLoopMerge %24 %25 None
207 OpBranchConditional %28 %23 %24
210 %30 = OpIAdd %6 %29 %20
212 %38 = OpAccessChain %37 %34 %36
214 %41 = OpFOrdLessThan %17 %39 %40
215 OpSelectionMerge %43 None
216 OpBranchConditional %41 %42 %43
220 OpSelectionMerge %49 None
221 OpBranchConditional %41 %48 %49
228 OpLoopMerge %53 %54 None
231 OpSelectionMerge %59 None
232 OpBranchConditional %41 %58 %59
239 OpBranchConditional %61 %51 %53
241 %106 = OpLoad %17 %99
242 OpSelectionMerge %105 None
243 OpBranchConditional %106 %24 %105
249 %102 = OpLoad %17 %99
250 OpSelectionMerge %101 None
251 OpBranchConditional %102 %12 %101
257 %104 = OpLoad %17 %99
258 OpSelectionMerge %103 None
259 OpBranchConditional %104 %95 %103
262 %69 = OpAccessChain %68 %67 %9 %9
264 %71 = OpIEqual %17 %62 %70
265 OpSelectionMerge %73 None
266 OpBranchConditional %71 %72 %90
268 %76 = OpAccessChain %68 %67 %9 %20
270 %78 = OpConvertSToF %31 %77
271 %80 = OpAccessChain %68 %67 %9 %79
273 %82 = OpConvertSToF %31 %81
274 %89 = OpCompositeConstruct %32 %78 %82 %82 %78
278 %91 = OpAccessChain %68 %67 %9 %79
280 %93 = OpConvertSToF %31 %92
281 %94 = OpCompositeConstruct %32 %93 %93 %93 %93
292 # uniforms for variant
294 # _GLF_uniform_int_values
295 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
299 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
301 PIPELINE graphics variant_pipeline
302 ATTACH variant_vertex_shader
303 ATTACH variant_fragment_shader
304 FRAMEBUFFER_SIZE 256 256
305 BIND BUFFER variant_framebuffer AS color LOCATION 0
306 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
308 CLEAR_COLOR variant_pipeline 0 0 0 255
310 CLEAR variant_pipeline
311 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
313 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255