• 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# '-O'
26# spirv-opt commit hash: a0370efd589be33d5d9a85cfde2f85841b3755af
27
28
29
30SHADER vertex variant_vertex_shader PASSTHROUGH
31
32# variant_fragment_shader is derived from the following GLSL:
33# #version 320 es
34#
35# #define _int_5 _GLF_uniform_int_values[0]
36# #define _int_1 _GLF_uniform_int_values[1]
37# #define _int_0 _GLF_uniform_int_values[2]
38# #define _float_21_0 _GLF_uniform_float_values[0]
39# #define _float_1_0 _GLF_uniform_float_values[1]
40# #define _float_0_0 _GLF_uniform_float_values[2]
41#
42# precision highp float;
43# precision highp int;
44#
45# // Contents of _GLF_uniform_float_values: [21.0, 1.0, 0.0]
46# layout(set = 0, binding = 0) uniform buf0
47# {
48#     float _GLF_uniform_float_values[3];
49# };
50# // Contents of _GLF_uniform_int_values: [5, 1, 0]
51# layout(set = 0, binding = 1) uniform buf1
52# {
53#     int _GLF_uniform_int_values[3];
54# };
55# // Contents of injectionSwitch: [0.0, 1.0]
56# layout(push_constant) uniform buf_push
57# {
58#     highp vec2 injectionSwitch;
59# };
60# layout(location = 0) out vec4 _GLF_color;
61#
62# void main()
63# {
64#     float arr[9] = float[9](_float_1_0, _float_1_0, _float_1_0, _float_1_0, _float_1_0, _float_1_0, _float_1_0, _float_1_0, _float_1_0);
65#
66#     for(int i = _int_0; i < _int_5; i ++)
67#     {
68#         for(int j = 0; j < 4; j ++)
69#         {
70#             // Always true.
71#             if(!(injectionSwitch.x > injectionSwitch.y))
72#             {
73#                 do
74#                 {
75#                     // Always true.
76#                     if(!(injectionSwitch.x > injectionSwitch.y))
77#                     {
78#                         // Always true.
79#                         if(!(gl_FragCoord.x < 0.0))
80#                         {
81#                             // Iterated 20 times.
82#                             arr[_int_1] += _float_1_0;
83#                         }
84#                     }
85#                 }
86#                 while(gl_FragCoord.y < _float_0_0); // Always false.
87#             }
88#         }
89#     }
90#
91#     // Always true.
92#     if(arr[_int_1] == _float_21_0)
93#     {
94#         _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
95#     }
96#     else
97#     {
98#         _GLF_color = vec4(_int_0);
99#     }
100# }
101SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
102; SPIR-V
103; Version: 1.0
104; Generator: Khronos Glslang Reference Front End; 10
105; Bound: 156
106; Schema: 0
107               OpCapability Shader
108          %1 = OpExtInstImport "GLSL.std.450"
109               OpMemoryModel Logical GLSL450
110               OpEntryPoint Fragment %4 "main" %98 %135
111               OpExecutionMode %4 OriginUpperLeft
112               OpSource ESSL 320
113               OpName %4 "main"
114               OpName %11 "arr"
115               OpName %14 "buf0"
116               OpMemberName %14 0 "_GLF_uniform_float_values"
117               OpName %16 ""
118               OpName %43 "buf1"
119               OpMemberName %43 0 "_GLF_uniform_int_values"
120               OpName %45 ""
121               OpName %70 "buf_push"
122               OpMemberName %70 0 "injectionSwitch"
123               OpName %72 ""
124               OpName %98 "gl_FragCoord"
125               OpName %135 "_GLF_color"
126               OpDecorate %13 ArrayStride 16
127               OpMemberDecorate %14 0 Offset 0
128               OpDecorate %14 Block
129               OpDecorate %16 DescriptorSet 0
130               OpDecorate %16 Binding 0
131               OpDecorate %42 ArrayStride 16
132               OpMemberDecorate %43 0 Offset 0
133               OpDecorate %43 Block
134               OpDecorate %45 DescriptorSet 0
135               OpDecorate %45 Binding 1
136               OpMemberDecorate %70 0 Offset 0
137               OpDecorate %70 Block
138               OpDecorate %98 BuiltIn FragCoord
139               OpDecorate %135 Location 0
140          %2 = OpTypeVoid
141          %3 = OpTypeFunction %2
142          %6 = OpTypeFloat 32
143          %7 = OpTypeInt 32 0
144          %8 = OpConstant %7 9
145          %9 = OpTypeArray %6 %8
146         %10 = OpTypePointer Function %9
147         %12 = OpConstant %7 3
148         %13 = OpTypeArray %6 %12
149         %14 = OpTypeStruct %13
150         %15 = OpTypePointer Uniform %14
151         %16 = OpVariable %15 Uniform
152         %17 = OpTypeInt 32 1
153         %18 = OpConstant %17 0
154         %19 = OpConstant %17 1
155         %20 = OpTypePointer Uniform %6
156         %42 = OpTypeArray %17 %12
157         %43 = OpTypeStruct %42
158         %44 = OpTypePointer Uniform %43
159         %45 = OpVariable %44 Uniform
160         %46 = OpConstant %17 2
161         %47 = OpTypePointer Uniform %17
162         %58 = OpTypeBool
163         %67 = OpConstant %17 4
164         %69 = OpTypeVector %6 2
165         %70 = OpTypeStruct %69
166         %71 = OpTypePointer PushConstant %70
167         %72 = OpVariable %71 PushConstant
168         %73 = OpConstant %7 0
169         %74 = OpTypePointer PushConstant %6
170         %77 = OpConstant %7 1
171         %96 = OpTypeVector %6 4
172         %97 = OpTypePointer Input %96
173         %98 = OpVariable %97 Input
174         %99 = OpTypePointer Input %6
175        %102 = OpConstant %6 0
176        %111 = OpTypePointer Function %6
177        %134 = OpTypePointer Output %96
178        %135 = OpVariable %134 Output
179          %4 = OpFunction %2 None %3
180          %5 = OpLabel
181         %11 = OpVariable %10 Function
182         %21 = OpAccessChain %20 %16 %18 %19
183         %22 = OpLoad %6 %21
184         %39 = OpCompositeConstruct %9 %22 %22 %22 %22 %22 %22 %22 %22 %22
185               OpStore %11 %39
186         %48 = OpAccessChain %47 %45 %18 %46
187         %49 = OpLoad %17 %48
188               OpBranch %50
189         %50 = OpLabel
190        %154 = OpPhi %17 %49 %5 %124 %53
191         %56 = OpAccessChain %47 %45 %18 %18
192         %57 = OpLoad %17 %56
193         %59 = OpSLessThan %58 %154 %57
194               OpLoopMerge %52 %53 None
195               OpBranchConditional %59 %51 %52
196         %51 = OpLabel
197               OpBranch %61
198         %61 = OpLabel
199        %155 = OpPhi %17 %18 %51 %122 %64
200         %68 = OpSLessThan %58 %155 %67
201               OpLoopMerge %63 %64 None
202               OpBranchConditional %68 %62 %63
203         %62 = OpLabel
204         %75 = OpAccessChain %74 %72 %18 %73
205         %76 = OpLoad %6 %75
206         %78 = OpAccessChain %74 %72 %18 %77
207         %79 = OpLoad %6 %78
208         %80 = OpFOrdGreaterThan %58 %76 %79
209         %81 = OpLogicalNot %58 %80
210               OpSelectionMerge %83 None
211               OpBranchConditional %81 %82 %83
212         %82 = OpLabel
213               OpBranch %84
214         %84 = OpLabel
215               OpLoopMerge %86 %87 None
216               OpBranch %85
217         %85 = OpLabel
218               OpSelectionMerge %95 None
219               OpBranchConditional %81 %94 %95
220         %94 = OpLabel
221        %100 = OpAccessChain %99 %98 %73
222        %101 = OpLoad %6 %100
223        %103 = OpFOrdLessThan %58 %101 %102
224        %104 = OpLogicalNot %58 %103
225               OpSelectionMerge %106 None
226               OpBranchConditional %104 %105 %106
227        %105 = OpLabel
228        %107 = OpAccessChain %47 %45 %18 %19
229        %108 = OpLoad %17 %107
230        %112 = OpAccessChain %111 %11 %108
231        %113 = OpLoad %6 %112
232        %114 = OpFAdd %6 %113 %22
233               OpStore %112 %114
234               OpBranch %106
235        %106 = OpLabel
236               OpBranch %95
237         %95 = OpLabel
238               OpBranch %87
239         %87 = OpLabel
240        %116 = OpAccessChain %99 %98 %77
241        %117 = OpLoad %6 %116
242        %118 = OpAccessChain %20 %16 %18 %46
243        %119 = OpLoad %6 %118
244        %120 = OpFOrdLessThan %58 %117 %119
245               OpBranchConditional %120 %84 %86
246         %86 = OpLabel
247               OpBranch %83
248         %83 = OpLabel
249               OpBranch %64
250         %64 = OpLabel
251        %122 = OpIAdd %17 %155 %19
252               OpBranch %61
253         %63 = OpLabel
254               OpBranch %53
255         %53 = OpLabel
256        %124 = OpIAdd %17 %154 %19
257               OpBranch %50
258         %52 = OpLabel
259        %125 = OpAccessChain %47 %45 %18 %19
260        %126 = OpLoad %17 %125
261        %127 = OpAccessChain %111 %11 %126
262        %128 = OpLoad %6 %127
263        %129 = OpAccessChain %20 %16 %18 %18
264        %130 = OpLoad %6 %129
265        %131 = OpFOrdEqual %58 %128 %130
266               OpSelectionMerge %133 None
267               OpBranchConditional %131 %132 %149
268        %132 = OpLabel
269        %138 = OpConvertSToF %6 %126
270        %141 = OpConvertSToF %6 %49
271        %148 = OpCompositeConstruct %96 %138 %141 %141 %138
272               OpStore %135 %148
273               OpBranch %133
274        %149 = OpLabel
275        %152 = OpConvertSToF %6 %49
276        %153 = OpCompositeConstruct %96 %152 %152 %152 %152
277               OpStore %135 %153
278               OpBranch %133
279        %133 = OpLabel
280               OpReturn
281               OpFunctionEnd
282END
283
284# uniforms for variant
285
286# injectionSwitch
287BUFFER variant_injectionSwitch DATA_TYPE vec2<float> STD140 DATA
288 0.0 1.0
289END
290# _GLF_uniform_int_values
291BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
292 5 1 0
293END
294# _GLF_uniform_float_values
295BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
296 21.0 1.0 0.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 16 16
305  BIND BUFFER variant_framebuffer AS color LOCATION 0
306  BIND BUFFER variant_injectionSwitch AS push_constant
307  BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
308  BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
309END
310CLEAR_COLOR variant_pipeline 0 0 0 255
311
312CLEAR variant_pipeline
313RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16
314
315EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255
316