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