• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2
3# Copyright 2022 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# #define _int_10 _GLF_uniform_int_values[0]
35# #define _int_1 _GLF_uniform_int_values[1]
36# #define _int_0 _GLF_uniform_int_values[2]
37# #define _int_2 _GLF_uniform_int_values[3]
38# #define _int_3 _GLF_uniform_int_values[4]
39# #define _int_4 _GLF_uniform_int_values[5]
40# #define _int_5 _GLF_uniform_int_values[6]
41# #define _int_6 _GLF_uniform_int_values[7]
42# #define _int_7 _GLF_uniform_int_values[8]
43# #define _int_8 _GLF_uniform_int_values[9]
44# #define _int_9 _GLF_uniform_int_values[10]
45# #define _int_11 _GLF_uniform_int_values[11]
46# #define _int_12 _GLF_uniform_int_values[12]
47# #define _int_13 _GLF_uniform_int_values[13]
48# #define _int_14 _GLF_uniform_int_values[14]
49# #define _int_15 _GLF_uniform_int_values[15]
50# #define _int_16 _GLF_uniform_int_values[16]
51# #define _int_17 _GLF_uniform_int_values[17]
52# #define _int_18 _GLF_uniform_int_values[18]
53# #define _int_19 _GLF_uniform_int_values[19]
54#
55# precision highp float;
56# precision highp int;
57#
58# // Contents of _GLF_uniform_int_values: [10, 1, 0, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19]
59# layout(set = 0, binding = 0) uniform buf0
60# {
61#     int _GLF_uniform_int_values[20];
62# };
63#
64# layout(location = 0) out vec4 _GLF_color;
65#
66# void main()
67# {
68#     int data0[10] = int[10](_int_0, _int_1, _int_2, _int_3, _int_4, _int_5, _int_6, _int_7, _int_8, _int_9);
69#     int data1[10] = int[10](_int_10, _int_11, _int_12, _int_13, _int_14, _int_15, _int_16, _int_17, _int_18, _int_19);
70#
71#     data1[_int_1] = data0[_int_1];
72#
73#     for(int i = _int_2; i < _int_10; i += _int_2)
74#     {
75#         for(int j = _int_1; j < _int_10; j += (i / _int_2))
76#         {
77#             // Iterates once with k = j if j <= 5.
78#             for(int k = j; k <= min(j, 5); k ++)
79#             {
80#                 data0[k] = data1[k];
81#             }
82#         }
83#     }
84#
85#     _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
86#
87#     // Compare against reference values and set output to black if failed.
88#     int ref[10] = int[10](_int_0, _int_1, _int_12, _int_13, _int_14, _int_15, _int_6, _int_7, _int_8, _int_9);
89#
90#     for(int i = _int_0; i < _int_10; i ++)
91#     {
92#         if(data0[i] != ref[i])
93#         {
94#             _GLF_color = vec4(_int_0);
95#         }
96#     }
97# }
98SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
99; SPIR-V
100; Version: 1.0
101; Generator: Khronos Glslang Reference Front End; 10
102; Bound: 214
103; Schema: 0
104               OpCapability Shader
105          %1 = OpExtInstImport "GLSL.std.450"
106               OpMemoryModel Logical GLSL450
107               OpEntryPoint Fragment %4 "main" %145
108               OpExecutionMode %4 OriginUpperLeft
109               OpSource ESSL 320
110               OpName %4 "main"
111               OpName %11 "data0"
112               OpName %14 "buf0"
113               OpMemberName %14 0 "_GLF_uniform_int_values"
114               OpName %16 ""
115               OpName %50 "data1"
116               OpName %145 "_GLF_color"
117               OpName %159 "ref"
118               OpDecorate %13 ArrayStride 16
119               OpMemberDecorate %14 0 Offset 0
120               OpDecorate %14 Block
121               OpDecorate %16 DescriptorSet 0
122               OpDecorate %16 Binding 0
123               OpDecorate %145 Location 0
124          %2 = OpTypeVoid
125          %3 = OpTypeFunction %2
126          %6 = OpTypeInt 32 1
127          %7 = OpTypeInt 32 0
128          %8 = OpConstant %7 10
129          %9 = OpTypeArray %6 %8
130         %10 = OpTypePointer Function %9
131         %12 = OpConstant %7 20
132         %13 = OpTypeArray %6 %12
133         %14 = OpTypeStruct %13
134         %15 = OpTypePointer Uniform %14
135         %16 = OpVariable %15 Uniform
136         %17 = OpConstant %6 0
137         %18 = OpConstant %6 2
138         %19 = OpTypePointer Uniform %6
139         %22 = OpConstant %6 1
140         %25 = OpConstant %6 3
141         %28 = OpConstant %6 4
142         %31 = OpConstant %6 5
143         %34 = OpConstant %6 6
144         %37 = OpConstant %6 7
145         %40 = OpConstant %6 8
146         %43 = OpConstant %6 9
147         %46 = OpConstant %6 10
148         %53 = OpConstant %6 11
149         %56 = OpConstant %6 12
150         %59 = OpConstant %6 13
151         %62 = OpConstant %6 14
152         %65 = OpConstant %6 15
153         %68 = OpConstant %6 16
154         %71 = OpConstant %6 17
155         %74 = OpConstant %6 18
156         %77 = OpConstant %6 19
157         %85 = OpTypePointer Function %6
158        %100 = OpTypeBool
159        %142 = OpTypeFloat 32
160        %143 = OpTypeVector %142 4
161        %144 = OpTypePointer Output %143
162        %145 = OpVariable %144 Output
163          %4 = OpFunction %2 None %3
164          %5 = OpLabel
165         %11 = OpVariable %10 Function
166         %50 = OpVariable %10 Function
167        %159 = OpVariable %10 Function
168         %20 = OpAccessChain %19 %16 %17 %18
169         %21 = OpLoad %6 %20
170         %23 = OpAccessChain %19 %16 %17 %22
171         %24 = OpLoad %6 %23
172         %26 = OpAccessChain %19 %16 %17 %25
173         %27 = OpLoad %6 %26
174         %29 = OpAccessChain %19 %16 %17 %28
175         %30 = OpLoad %6 %29
176         %32 = OpAccessChain %19 %16 %17 %31
177         %33 = OpLoad %6 %32
178         %35 = OpAccessChain %19 %16 %17 %34
179         %36 = OpLoad %6 %35
180         %38 = OpAccessChain %19 %16 %17 %37
181         %39 = OpLoad %6 %38
182         %41 = OpAccessChain %19 %16 %17 %40
183         %42 = OpLoad %6 %41
184         %44 = OpAccessChain %19 %16 %17 %43
185         %45 = OpLoad %6 %44
186         %47 = OpAccessChain %19 %16 %17 %46
187         %48 = OpLoad %6 %47
188         %49 = OpCompositeConstruct %9 %21 %24 %27 %30 %33 %36 %39 %42 %45 %48
189               OpStore %11 %49
190         %51 = OpAccessChain %19 %16 %17 %17
191         %52 = OpLoad %6 %51
192         %54 = OpAccessChain %19 %16 %17 %53
193         %55 = OpLoad %6 %54
194         %57 = OpAccessChain %19 %16 %17 %56
195         %58 = OpLoad %6 %57
196         %60 = OpAccessChain %19 %16 %17 %59
197         %61 = OpLoad %6 %60
198         %63 = OpAccessChain %19 %16 %17 %62
199         %64 = OpLoad %6 %63
200         %66 = OpAccessChain %19 %16 %17 %65
201         %67 = OpLoad %6 %66
202         %69 = OpAccessChain %19 %16 %17 %68
203         %70 = OpLoad %6 %69
204         %72 = OpAccessChain %19 %16 %17 %71
205         %73 = OpLoad %6 %72
206         %75 = OpAccessChain %19 %16 %17 %74
207         %76 = OpLoad %6 %75
208         %78 = OpAccessChain %19 %16 %17 %77
209         %79 = OpLoad %6 %78
210         %80 = OpCompositeConstruct %9 %52 %55 %58 %61 %64 %67 %70 %73 %76 %79
211               OpStore %50 %80
212         %86 = OpAccessChain %85 %11 %24
213         %87 = OpLoad %6 %86
214         %88 = OpAccessChain %85 %50 %24
215               OpStore %88 %87
216               OpBranch %92
217         %92 = OpLabel
218        %208 = OpPhi %6 %27 %5 %141 %95
219        %101 = OpSLessThan %100 %208 %52
220               OpLoopMerge %94 %95 None
221               OpBranchConditional %101 %93 %94
222         %93 = OpLabel
223               OpBranch %105
224        %105 = OpLabel
225        %211 = OpPhi %6 %24 %93 %137 %108
226        %113 = OpSLessThan %100 %211 %52
227               OpLoopMerge %107 %108 None
228               OpBranchConditional %113 %106 %107
229        %106 = OpLabel
230               OpBranch %116
231        %116 = OpLabel
232        %213 = OpPhi %6 %211 %106 %131 %117
233        %123 = OpExtInst %6 %1 SMin %211 %31
234        %124 = OpSLessThanEqual %100 %213 %123
235               OpLoopMerge %118 %117 None
236               OpBranchConditional %124 %117 %118
237        %117 = OpLabel
238        %127 = OpAccessChain %85 %50 %213
239        %128 = OpLoad %6 %127
240        %129 = OpAccessChain %85 %11 %213
241               OpStore %129 %128
242        %131 = OpIAdd %6 %213 %22
243               OpBranch %116
244        %118 = OpLabel
245               OpBranch %108
246        %108 = OpLabel
247        %135 = OpSDiv %6 %208 %27
248        %137 = OpIAdd %6 %211 %135
249               OpBranch %105
250        %107 = OpLabel
251               OpBranch %95
252         %95 = OpLabel
253        %141 = OpIAdd %6 %208 %27
254               OpBranch %92
255         %94 = OpLabel
256        %148 = OpConvertSToF %142 %24
257        %151 = OpConvertSToF %142 %21
258        %158 = OpCompositeConstruct %143 %148 %151 %151 %148
259               OpStore %145 %158
260        %180 = OpCompositeConstruct %9 %21 %24 %58 %61 %64 %67 %39 %42 %45 %48
261               OpStore %159 %180
262               OpBranch %184
263        %184 = OpLabel
264        %209 = OpPhi %6 %21 %94 %207 %187
265        %192 = OpSLessThan %100 %209 %52
266               OpLoopMerge %186 %187 None
267               OpBranchConditional %192 %185 %186
268        %185 = OpLabel
269        %194 = OpAccessChain %85 %11 %209
270        %195 = OpLoad %6 %194
271        %197 = OpAccessChain %85 %159 %209
272        %198 = OpLoad %6 %197
273        %199 = OpINotEqual %100 %195 %198
274               OpSelectionMerge %201 None
275               OpBranchConditional %199 %200 %201
276        %200 = OpLabel
277        %205 = OpCompositeConstruct %143 %151 %151 %151 %151
278               OpStore %145 %205
279               OpBranch %201
280        %201 = OpLabel
281               OpBranch %187
282        %187 = OpLabel
283        %207 = OpIAdd %6 %209 %22
284               OpBranch %184
285        %186 = OpLabel
286               OpReturn
287               OpFunctionEnd
288END
289
290# uniforms for variant
291
292# _GLF_uniform_int_values
293BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
294 10 1 0 2 3 4 5 6 7 8 9 11 12 13 14 15 16 17 18 19
295END
296
297BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
298
299PIPELINE graphics variant_pipeline
300  ATTACH variant_vertex_shader
301  ATTACH variant_fragment_shader
302  FRAMEBUFFER_SIZE 32 32
303  BIND BUFFER variant_framebuffer AS color LOCATION 0
304  BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
305END
306CLEAR_COLOR variant_pipeline 0 0 0 255
307
308CLEAR variant_pipeline
309RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
310
311EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255
312