• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2
3# Copyright 2021 Google LLC
4#
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
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
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.
16
17
18# A test for a coverage-gap found by the GraphicsFuzz project.
19
20# Short description: A fragment shader that covers specific LLVM code paths
21
22# The test passes because the shader always writes red.
23
24# Optimized using spirv-opt with the following arguments:
25# '--redundancy-elimination'
26# '--vector-dce'
27# '--redundancy-elimination'
28# '--convert-local-access-chains'
29# '--eliminate-dead-inserts'
30# '--ccp'
31# '--eliminate-dead-branches'
32# '--merge-blocks'
33# '--scalar-replacement=100'
34# '--scalar-replacement=100'
35# '--scalar-replacement=100'
36# '--if-conversion'
37# '--vector-dce'
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'
44# '--ccp'
45# '--convert-local-access-chains'
46# '--scalar-replacement=100'
47# '--if-conversion'
48# '--eliminate-dead-branches'
49# '--merge-blocks'
50# '--eliminate-dead-branches'
51# '--merge-return'
52# '--eliminate-local-single-store'
53# '--eliminate-dead-inserts'
54# '--eliminate-dead-branches'
55# '--merge-blocks'
56# '--private-to-local'
57# '--eliminate-dead-branches'
58# spirv-opt commit hash: a0370efd589be33d5d9a85cfde2f85841b3755af
59
60
61
62SHADER vertex variant_vertex_shader PASSTHROUGH
63
64# variant_fragment_shader is derived from the following GLSL:
65# #version 320 es
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]
69#
70# precision highp float;
71# precision highp int;
72#
73# // Contents of _GLF_uniform_int_values: [10, 1, 0]
74# layout(set = 0, binding = 0) uniform buf0
75# {
76#     int _GLF_uniform_int_values[3];
77# };
78#
79# const int _GLF_global_loop_bound = 10;
80# int _GLF_global_loop_count = 0;
81#
82# layout(location = 0) out vec4 _GLF_color;
83#
84# void main()
85# {
86#     while(_GLF_global_loop_count < _GLF_global_loop_bound)
87#     {
88#         _GLF_global_loop_count++;
89#
90#         while(_GLF_global_loop_count < _GLF_global_loop_bound)
91#         {
92#             _GLF_global_loop_count ++;
93#
94#             // Always false.
95#             if(gl_FragCoord.y < 0.0)
96#             {
97#                 continue;
98#             }
99#
100#             // Always false.
101#             if(gl_FragCoord.y < 0.0)
102#             {
103#                 return;
104#             }
105#
106#             do
107#             {
108#                 // Always false.
109#                 if(gl_FragCoord.y < 0.0)
110#                 {
111#                     return;
112#                 }
113#             }
114#             while(false);
115#         }
116#     }
117#
118#     // Always true.
119#     if(_GLF_global_loop_count == _int_10)
120#     {
121#         _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
122#     }
123#     else
124#     {
125#         _GLF_color = vec4(_int_0);
126#     }
127# }
128SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
129; SPIR-V
130; Version: 1.0
131; Generator: Khronos Glslang Reference Front End; 10
132; Bound: 108
133; Schema: 0
134               OpCapability Shader
135          %1 = OpExtInstImport "GLSL.std.450"
136               OpMemoryModel Logical GLSL450
137               OpEntryPoint Fragment %4 "main" %34 %75
138               OpExecutionMode %4 OriginUpperLeft
139               OpSource ESSL 320
140               OpName %4 "main"
141               OpName %8 "_GLF_global_loop_count"
142               OpName %34 "gl_FragCoord"
143               OpName %65 "buf0"
144               OpMemberName %65 0 "_GLF_uniform_int_values"
145               OpName %67 ""
146               OpName %75 "_GLF_color"
147               OpDecorate %34 BuiltIn FragCoord
148               OpDecorate %64 ArrayStride 16
149               OpMemberDecorate %65 0 Offset 0
150               OpDecorate %65 Block
151               OpDecorate %67 DescriptorSet 0
152               OpDecorate %67 Binding 0
153               OpDecorate %75 Location 0
154          %2 = OpTypeVoid
155          %3 = OpTypeFunction %2
156          %6 = OpTypeInt 32 1
157          %7 = OpTypePointer Private %6
158          %9 = OpConstant %6 0
159         %16 = OpConstant %6 10
160         %17 = OpTypeBool
161         %20 = OpConstant %6 1
162         %31 = OpTypeFloat 32
163         %32 = OpTypeVector %31 4
164         %33 = OpTypePointer Input %32
165         %34 = OpVariable %33 Input
166         %35 = OpTypeInt 32 0
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
185          %5 = OpLabel
186          %8 = OpVariable %107 Function
187         %99 = OpVariable %98 Function %61
188               OpSelectionMerge %95 None
189               OpSwitch %97 %96
190         %96 = OpLabel
191               OpStore %8 %9
192               OpBranch %10
193         %10 = OpLabel
194         %15 = OpLoad %6 %8
195         %18 = OpSLessThan %17 %15 %16
196               OpLoopMerge %12 %13 None
197               OpBranchConditional %18 %11 %12
198         %11 = OpLabel
199         %19 = OpLoad %6 %8
200         %21 = OpIAdd %6 %19 %20
201               OpStore %8 %21
202               OpBranch %22
203         %22 = OpLabel
204         %27 = OpLoad %6 %8
205         %28 = OpSLessThan %17 %27 %16
206               OpLoopMerge %24 %25 None
207               OpBranchConditional %28 %23 %24
208         %23 = OpLabel
209         %29 = OpLoad %6 %8
210         %30 = OpIAdd %6 %29 %20
211               OpStore %8 %30
212         %38 = OpAccessChain %37 %34 %36
213         %39 = OpLoad %31 %38
214         %41 = OpFOrdLessThan %17 %39 %40
215               OpSelectionMerge %43 None
216               OpBranchConditional %41 %42 %43
217         %42 = OpLabel
218               OpBranch %25
219         %43 = OpLabel
220               OpSelectionMerge %49 None
221               OpBranchConditional %41 %48 %49
222         %48 = OpLabel
223               OpStore %99 %100
224               OpBranch %24
225         %49 = OpLabel
226               OpBranch %51
227         %51 = OpLabel
228               OpLoopMerge %53 %54 None
229               OpBranch %52
230         %52 = OpLabel
231               OpSelectionMerge %59 None
232               OpBranchConditional %41 %58 %59
233         %58 = OpLabel
234               OpStore %99 %100
235               OpBranch %53
236         %59 = OpLabel
237               OpBranch %54
238         %54 = OpLabel
239               OpBranchConditional %61 %51 %53
240         %53 = OpLabel
241        %106 = OpLoad %17 %99
242               OpSelectionMerge %105 None
243               OpBranchConditional %106 %24 %105
244        %105 = OpLabel
245               OpBranch %25
246         %25 = OpLabel
247               OpBranch %22
248         %24 = OpLabel
249        %102 = OpLoad %17 %99
250               OpSelectionMerge %101 None
251               OpBranchConditional %102 %12 %101
252        %101 = OpLabel
253               OpBranch %13
254         %13 = OpLabel
255               OpBranch %10
256         %12 = OpLabel
257        %104 = OpLoad %17 %99
258               OpSelectionMerge %103 None
259               OpBranchConditional %104 %95 %103
260        %103 = OpLabel
261         %62 = OpLoad %6 %8
262         %69 = OpAccessChain %68 %67 %9 %9
263         %70 = OpLoad %6 %69
264         %71 = OpIEqual %17 %62 %70
265               OpSelectionMerge %73 None
266               OpBranchConditional %71 %72 %90
267         %72 = OpLabel
268         %76 = OpAccessChain %68 %67 %9 %20
269         %77 = OpLoad %6 %76
270         %78 = OpConvertSToF %31 %77
271         %80 = OpAccessChain %68 %67 %9 %79
272         %81 = OpLoad %6 %80
273         %82 = OpConvertSToF %31 %81
274         %89 = OpCompositeConstruct %32 %78 %82 %82 %78
275               OpStore %75 %89
276               OpBranch %73
277         %90 = OpLabel
278         %91 = OpAccessChain %68 %67 %9 %79
279         %92 = OpLoad %6 %91
280         %93 = OpConvertSToF %31 %92
281         %94 = OpCompositeConstruct %32 %93 %93 %93 %93
282               OpStore %75 %94
283               OpBranch %73
284         %73 = OpLabel
285               OpStore %99 %100
286               OpBranch %95
287         %95 = OpLabel
288               OpReturn
289               OpFunctionEnd
290END
291
292# uniforms for variant
293
294# _GLF_uniform_int_values
295BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
296 10 1 0
297END
298
299BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
300
301PIPELINE 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
307END
308CLEAR_COLOR variant_pipeline 0 0 0 255
309
310CLEAR variant_pipeline
311RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
312
313EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
314