1#!amber
2
3# Copyright 2020 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 bug found by the GraphicsFuzz project.
19
20# Short description: Equivalent shaders, one with additional memory usage
21
22# The test passes because both shaders render the same image.
23
24SHADER vertex reference_vertex_shader PASSTHROUGH
25
26SHADER fragment reference_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
27; SPIR-V
28; Version: 1.0
29; Generator: Khronos Glslang Reference Front End; 7
30; Bound: 272
31; Schema: 0
32               OpCapability Shader
33          %1 = OpExtInstImport "GLSL.std.450"
34               OpMemoryModel Logical GLSL450
35               OpEntryPoint Fragment %4 "main" %246 %268
36               OpExecutionMode %4 OriginUpperLeft
37               OpSource ESSL 320
38               OpName %4 "main"
39               OpName %13 "trace(vi2;"
40               OpName %12 "pos"
41               OpName %194 "indexable"
42               OpName %205 "indexable"
43               OpName %214 "p"
44               OpName %220 "indexable"
45               OpName %244 "pos"
46               OpName %246 "gl_FragCoord"
47               OpName %249 "buf0"
48               OpMemberName %249 0 "resolution"
49               OpName %251 ""
50               OpName %256 "ipos"
51               OpName %268 "_GLF_color"
52               OpName %269 "param"
53               OpDecorate %246 BuiltIn FragCoord
54               OpMemberDecorate %249 0 Offset 0
55               OpDecorate %249 Block
56               OpDecorate %251 DescriptorSet 0
57               OpDecorate %251 Binding 0
58               OpDecorate %268 Location 0
59          %2 = OpTypeVoid
60          %3 = OpTypeFunction %2
61          %6 = OpTypeInt 32 1
62          %7 = OpTypeVector %6 2
63          %8 = OpTypePointer Function %7
64          %9 = OpTypeFloat 32
65         %10 = OpTypeVector %9 4
66         %11 = OpTypeFunction %10 %8
67         %20 = OpTypeInt 32 0
68         %21 = OpConstant %20 1
69         %22 = OpTypePointer Function %6
70         %25 = OpConstant %6 256
71         %26 = OpTypeBool
72         %28 = OpConstant %20 0
73         %31 = OpConstant %20 256
74         %32 = OpTypeArray %6 %31
75         %33 = OpConstant %6 115
76         %34 = OpConstant %6 133
77         %35 = OpConstant %6 150
78         %36 = OpConstant %6 164
79         %37 = OpConstant %6 176
80         %38 = OpConstant %6 184
81         %39 = OpConstant %6 190
82         %40 = OpConstant %6 192
83         %41 = OpConstant %6 191
84         %42 = OpConstant %6 187
85         %43 = OpConstant %6 181
86         %44 = OpConstant %6 172
87         %45 = OpConstant %6 163
88         %46 = OpConstant %6 153
89         %47 = OpConstant %6 143
90         %48 = OpConstant %6 134
91         %49 = OpConstant %6 126
92         %50 = OpConstant %6 120
93         %51 = OpConstant %6 116
94         %52 = OpConstant %6 114
95         %53 = OpConstant %6 117
96         %54 = OpConstant %6 121
97         %55 = OpConstant %6 127
98         %56 = OpConstant %6 141
99         %57 = OpConstant %6 148
100         %58 = OpConstant %6 154
101         %59 = OpConstant %6 159
102         %60 = OpConstant %6 162
103         %61 = OpConstant %6 161
104         %62 = OpConstant %6 157
105         %63 = OpConstant %6 151
106         %64 = OpConstant %6 124
107         %65 = OpConstant %6 113
108         %66 = OpConstant %6 103
109         %67 = OpConstant %6 94
110         %68 = OpConstant %6 87
111         %69 = OpConstant %6 82
112         %70 = OpConstant %6 79
113         %71 = OpConstant %6 80
114         %72 = OpConstant %6 84
115         %73 = OpConstant %6 91
116         %74 = OpConstant %6 101
117         %75 = OpConstant %6 130
118         %76 = OpConstant %6 146
119         %77 = OpConstant %6 182
120         %78 = OpConstant %6 199
121         %79 = OpConstant %6 215
122         %80 = OpConstant %6 229
123         %81 = OpConstant %6 240
124         %82 = OpConstant %6 249
125         %83 = OpConstant %6 254
126         %84 = OpConstant %6 250
127         %85 = OpConstant %6 243
128         %86 = OpConstant %6 233
129         %87 = OpConstant %6 223
130         %88 = OpConstant %6 212
131         %89 = OpConstant %6 200
132         %90 = OpConstant %6 180
133         %91 = OpConstant %6 166
134         %92 = OpConstant %6 169
135         %93 = OpConstant %6 174
136         %94 = OpConstant %6 179
137         %95 = OpConstant %6 185
138         %96 = OpConstant %6 193
139         %97 = OpConstant %6 195
140         %98 = OpConstant %6 188
141         %99 = OpConstant %6 171
142        %100 = OpConstant %6 149
143        %101 = OpConstant %6 137
144        %102 = OpConstant %6 125
145        %103 = OpConstant %6 105
146        %104 = OpConstant %6 97
147        %105 = OpConstant %6 93
148        %106 = OpConstant %6 98
149        %107 = OpConstant %6 106
150        %108 = OpConstant %6 145
151        %109 = OpConstant %6 177
152        %110 = OpConstant %6 208
153        %111 = OpConstant %6 221
154        %112 = OpConstant %6 231
155        %113 = OpConstant %6 239
156        %114 = OpConstant %6 244
157        %115 = OpConstant %6 242
158        %116 = OpConstant %6 236
159        %117 = OpConstant %6 228
160        %118 = OpConstant %6 218
161        %119 = OpConstant %6 207
162        %120 = OpConstant %6 194
163        %121 = OpConstant %6 158
164        %122 = OpConstant %6 135
165        %123 = OpConstant %6 132
166        %124 = OpConstant %6 131
167        %125 = OpConstant %6 138
168        %126 = OpConstant %6 147
169        %127 = OpConstant %6 155
170        %128 = OpConstant %6 152
171        %129 = OpConstant %6 139
172        %130 = OpConstant %6 129
173        %131 = OpConstant %6 118
174        %132 = OpConstant %6 68
175        %133 = OpConstant %6 58
176        %134 = OpConstant %6 49
177        %135 = OpConstant %6 43
178        %136 = OpConstant %6 40
179        %137 = OpConstant %6 41
180        %138 = OpConstant %6 44
181        %139 = OpConstant %6 51
182        %140 = OpConstant %6 61
183        %141 = OpConstant %6 73
184        %142 = OpConstant %6 119
185        %143 = OpConstant %6 173
186        %144 = OpConstant %6 186
187        %145 = OpConstant %6 128
188        %146 = OpConstant %6 104
189        %147 = OpConstant %6 86
190        %148 = OpConstant %6 81
191        %149 = OpConstant %6 77
192        %150 = OpConstant %6 76
193        %151 = OpConstant %6 89
194        %152 = OpConstant %6 102
195        %153 = OpConstant %6 92
196        %154 = OpConstant %6 83
197        %155 = OpConstant %6 62
198        %156 = OpConstant %6 50
199        %157 = OpConstant %6 38
200        %158 = OpConstant %6 26
201        %159 = OpConstant %6 16
202        %160 = OpConstant %6 8
203        %161 = OpConstant %6 2
204        %162 = OpConstant %6 0
205        %163 = OpConstant %6 4
206        %164 = OpConstant %6 11
207        %165 = OpConstant %6 21
208        %166 = OpConstant %6 33
209        %167 = OpConstant %6 48
210        %168 = OpConstant %6 64
211        %169 = OpConstant %6 144
212        %170 = OpConstant %6 123
213        %171 = OpConstant %6 112
214        %172 = OpConstant %6 100
215        %173 = OpConstant %6 90
216        %174 = OpConstant %6 65
217        %175 = OpConstant %6 67
218        %176 = OpConstant %6 70
219        %177 = OpConstant %6 75
220        %178 = OpConstant %6 95
221        %179 = OpConstant %6 88
222        %180 = OpConstant %6 69
223        %181 = OpConstant %6 47
224        %182 = OpConstant %6 36
225        %183 = OpConstant %6 18
226        %184 = OpConstant %6 13
227        %185 = OpConstant %6 15
228        %186 = OpConstant %6 22
229        %187 = OpConstant %6 32
230        %188 = OpConstant %6 45
231        %189 = OpConstant %6 60
232        %190 = OpConstantComposite %32 %33 %34 %35 %36 %37 %38 %39 %40 %41 %42 %43 %44 %45 %46 %47 %48 %49 %50 %51 %52 %52 %53 %54 %55 %48 %56 %57 %58 %59 %60 %45 %61 %62 %63 %47 %48 %64 %65 %66 %67 %68 %69 %70 %71 %72 %73 %74 %52 %75 %76 %36 %77 %78 %79 %80 %81 %82 %83 %25 %83 %84 %85 %86 %87 %88 %89 %39 %90 %44 %91 %45 %61 %60 %36 %92 %93 %94 %95 %39 %96 %97 %97 %40 %98 %90 %99 %61 %100 %101 %102 %52 %103 %104 %105 %73 %105 %106 %107 %53 %75 %108 %61 %109 %96 %110 %111 %112 %113 %85 %114 %115 %116 %117 %118 %119 %120 %43 %92 %121 %57 %56 %122 %123 %124 %123 %122 %125 %47 %126 %63 %58 %127 %127 %128 %76 %129 %130 %131 %107 %105 %71 %132 %133 %134 %135 %136 %137 %138 %139 %140 %141 %68 %66 %142 %48 %100 %60 %143 %43 %144 %98 %144 %43 %93 %36 %46 %56 %145 %51 %146 %67 %147 %148 %149 %150 %149 %71 %72 %151 %67 %106 %152 %146 %146 %152 %106 %153 %154 %141 %155 %156 %157 %158 %159 %160 %161 %162 %162 %163 %164 %165 %166 %167 %168 %148 %106 %52 %130 %56 %63 %121 %61 %61 %121 %128 %169 %48 %170 %171 %172 %173 %148 %141 %132 %174 %174 %175 %176 %177 %148 %68 %153 %104 %74 %66 %152 %172 %178 %179 %70 %180 %133 %181 %182 %158 %183 %184 %164 %164 %185 %186 %187 %188 %189 %149 %67
233        %193 = OpTypePointer Function %32
234        %213 = OpTypePointer Function %9
235        %215 = OpConstant %9 15
236        %231 = OpConstant %9 1
237        %236 = OpConstant %6 1
238        %238 = OpConstant %9 0
239        %239 = OpConstantComposite %10 %238 %238 %238 %231
240        %242 = OpTypeVector %9 2
241        %243 = OpTypePointer Function %242
242        %245 = OpTypePointer Input %10
243        %246 = OpVariable %245 Input
244        %249 = OpTypeStruct %242
245        %250 = OpTypePointer Uniform %249
246        %251 = OpVariable %250 Uniform
247        %252 = OpTypePointer Uniform %242
248        %259 = OpConstant %9 256
249        %267 = OpTypePointer Output %10
250        %268 = OpVariable %267 Output
251          %4 = OpFunction %2 None %3
252          %5 = OpLabel
253        %244 = OpVariable %243 Function
254        %256 = OpVariable %8 Function
255        %269 = OpVariable %8 Function
256        %247 = OpLoad %10 %246
257        %248 = OpVectorShuffle %242 %247 %247 0 1
258        %253 = OpAccessChain %252 %251 %162
259        %254 = OpLoad %242 %253
260        %255 = OpFDiv %242 %248 %254
261               OpStore %244 %255
262        %257 = OpAccessChain %213 %244 %28
263        %258 = OpLoad %9 %257
264        %260 = OpFMul %9 %258 %259
265        %261 = OpConvertFToS %6 %260
266        %262 = OpAccessChain %213 %244 %21
267        %263 = OpLoad %9 %262
268        %264 = OpFMul %9 %263 %259
269        %265 = OpConvertFToS %6 %264
270        %266 = OpCompositeConstruct %7 %261 %265
271               OpStore %256 %266
272        %270 = OpLoad %7 %256
273               OpStore %269 %270
274        %271 = OpFunctionCall %10 %13 %269
275               OpStore %268 %271
276               OpReturn
277               OpFunctionEnd
278         %13 = OpFunction %10 None %11
279         %12 = OpFunctionParameter %8
280         %14 = OpLabel
281        %194 = OpVariable %193 Function
282        %205 = OpVariable %193 Function
283        %214 = OpVariable %213 Function
284        %220 = OpVariable %193 Function
285               OpBranch %15
286         %15 = OpLabel
287               OpLoopMerge %17 %18 None
288               OpBranch %19
289         %19 = OpLabel
290         %23 = OpAccessChain %22 %12 %21
291         %24 = OpLoad %6 %23
292         %27 = OpINotEqual %26 %24 %25
293               OpBranchConditional %27 %16 %17
294         %16 = OpLabel
295         %29 = OpAccessChain %22 %12 %28
296         %30 = OpLoad %6 %29
297        %191 = OpAccessChain %22 %12 %21
298        %192 = OpLoad %6 %191
299               OpStore %194 %190
300        %195 = OpAccessChain %22 %194 %192
301        %196 = OpLoad %6 %195
302        %197 = OpIAdd %6 %196 %185
303        %198 = OpSLessThan %26 %30 %197
304               OpSelectionMerge %200 None
305               OpBranchConditional %198 %199 %200
306        %199 = OpLabel
307        %201 = OpAccessChain %22 %12 %28
308        %202 = OpLoad %6 %201
309        %203 = OpAccessChain %22 %12 %21
310        %204 = OpLoad %6 %203
311               OpStore %205 %190
312        %206 = OpAccessChain %22 %205 %204
313        %207 = OpLoad %6 %206
314        %208 = OpISub %6 %207 %185
315        %209 = OpSGreaterThan %26 %202 %208
316               OpBranch %200
317        %200 = OpLabel
318        %210 = OpPhi %26 %198 %16 %209 %199
319               OpSelectionMerge %212 None
320               OpBranchConditional %210 %211 %212
321        %211 = OpLabel
322        %216 = OpAccessChain %22 %12 %28
323        %217 = OpLoad %6 %216
324        %218 = OpAccessChain %22 %12 %21
325        %219 = OpLoad %6 %218
326               OpStore %220 %190
327        %221 = OpAccessChain %22 %220 %219
328        %222 = OpLoad %6 %221
329        %223 = OpISub %6 %217 %222
330        %224 = OpConvertSToF %9 %223
331        %225 = OpExtInst %9 %1 FAbs %224
332        %226 = OpFSub %9 %215 %225
333        %227 = OpFDiv %9 %226 %215
334               OpStore %214 %227
335        %228 = OpLoad %9 %214
336        %229 = OpLoad %9 %214
337        %230 = OpLoad %9 %214
338        %232 = OpCompositeConstruct %10 %228 %229 %230 %231
339               OpReturnValue %232
340        %212 = OpLabel
341        %234 = OpAccessChain %22 %12 %21
342        %235 = OpLoad %6 %234
343        %237 = OpIAdd %6 %235 %236
344               OpStore %234 %237
345               OpBranch %18
346         %18 = OpLabel
347               OpBranch %15
348         %17 = OpLabel
349               OpReturnValue %239
350               OpFunctionEnd
351END
352
353# uniforms for reference
354
355# resolution
356BUFFER reference_resolution DATA_TYPE vec2<float> STD140 DATA
357 32.0 16.0
358END
359
360BUFFER reference_framebuffer FORMAT B8G8R8A8_UNORM
361
362PIPELINE graphics reference_pipeline
363  ATTACH reference_vertex_shader
364  ATTACH reference_fragment_shader
365  FRAMEBUFFER_SIZE 32 16
366  BIND BUFFER reference_framebuffer AS color LOCATION 0
367  BIND BUFFER reference_resolution AS uniform DESCRIPTOR_SET 0 BINDING 0
368END
369CLEAR_COLOR reference_pipeline 0 0 0 255
370
371CLEAR reference_pipeline
372RUN reference_pipeline DRAW_RECT POS 0 0 SIZE 32 16
373
374
375SHADER vertex variant_vertex_shader PASSTHROUGH
376
377SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
378; SPIR-V
379; Version: 1.0
380; Generator: Khronos Glslang Reference Front End; 7
381; Bound: 472
382; Schema: 0
383               OpCapability Shader
384          %1 = OpExtInstImport "GLSL.std.450"
385               OpMemoryModel Logical GLSL450
386               OpEntryPoint Fragment %4 "main" %246 %268
387               OpExecutionMode %4 OriginUpperLeft
388               OpSource ESSL 320
389               OpName %4 "main"
390               OpName %13 "trace(vi2;"
391               OpName %12 "pos"
392               OpName %194 "indexable"
393               OpName %205 "indexable"
394               OpName %214 "p"
395               OpName %220 "indexable"
396               OpName %244 "pos"
397               OpName %246 "gl_FragCoord"
398               OpName %249 "buf0"
399               OpMemberName %249 0 "resolution"
400               OpName %251 ""
401               OpName %256 "ipos"
402               OpName %268 "_GLF_color"
403               OpName %269 "param"
404               OpDecorate %246 BuiltIn FragCoord
405               OpMemberDecorate %249 0 Offset 0
406               OpDecorate %249 Block
407               OpDecorate %251 DescriptorSet 0
408               OpDecorate %251 Binding 0
409               OpDecorate %268 Location 0
410          %2 = OpTypeVoid
411          %3 = OpTypeFunction %2
412          %6 = OpTypeInt 32 1
413          %7 = OpTypeVector %6 2
414          %8 = OpTypePointer Function %7
415          %9 = OpTypeFloat 32
416         %10 = OpTypeVector %9 4
417         %11 = OpTypeFunction %10 %8
418         %20 = OpTypeInt 32 0
419         %21 = OpConstant %20 1
420         %22 = OpTypePointer Function %6
421         %25 = OpConstant %6 256
422         %26 = OpTypeBool
423         %28 = OpConstant %20 0
424         %31 = OpConstant %20 256
425         %32 = OpTypeArray %6 %31
426         %33 = OpConstant %6 115
427         %34 = OpConstant %6 133
428         %35 = OpConstant %6 150
429         %36 = OpConstant %6 164
430         %37 = OpConstant %6 176
431         %38 = OpConstant %6 184
432         %39 = OpConstant %6 190
433         %40 = OpConstant %6 192
434         %41 = OpConstant %6 191
435         %42 = OpConstant %6 187
436         %43 = OpConstant %6 181
437         %44 = OpConstant %6 172
438         %45 = OpConstant %6 163
439         %46 = OpConstant %6 153
440         %47 = OpConstant %6 143
441         %48 = OpConstant %6 134
442         %49 = OpConstant %6 126
443         %50 = OpConstant %6 120
444         %51 = OpConstant %6 116
445         %52 = OpConstant %6 114
446         %53 = OpConstant %6 117
447         %54 = OpConstant %6 121
448         %55 = OpConstant %6 127
449         %56 = OpConstant %6 141
450         %57 = OpConstant %6 148
451         %58 = OpConstant %6 154
452         %59 = OpConstant %6 159
453         %60 = OpConstant %6 162
454         %61 = OpConstant %6 161
455         %62 = OpConstant %6 157
456         %63 = OpConstant %6 151
457         %64 = OpConstant %6 124
458         %65 = OpConstant %6 113
459         %66 = OpConstant %6 103
460         %67 = OpConstant %6 94
461         %68 = OpConstant %6 87
462         %69 = OpConstant %6 82
463         %70 = OpConstant %6 79
464         %71 = OpConstant %6 80
465         %72 = OpConstant %6 84
466         %73 = OpConstant %6 91
467         %74 = OpConstant %6 101
468         %75 = OpConstant %6 130
469         %76 = OpConstant %6 146
470         %77 = OpConstant %6 182
471         %78 = OpConstant %6 199
472         %79 = OpConstant %6 215
473         %80 = OpConstant %6 229
474         %81 = OpConstant %6 240
475         %82 = OpConstant %6 249
476         %83 = OpConstant %6 254
477         %84 = OpConstant %6 250
478         %85 = OpConstant %6 243
479         %86 = OpConstant %6 233
480         %87 = OpConstant %6 223
481         %88 = OpConstant %6 212
482         %89 = OpConstant %6 200
483         %90 = OpConstant %6 180
484         %91 = OpConstant %6 166
485         %92 = OpConstant %6 169
486         %93 = OpConstant %6 174
487         %94 = OpConstant %6 179
488         %95 = OpConstant %6 185
489         %96 = OpConstant %6 193
490         %97 = OpConstant %6 195
491         %98 = OpConstant %6 188
492         %99 = OpConstant %6 171
493        %100 = OpConstant %6 149
494        %101 = OpConstant %6 137
495        %102 = OpConstant %6 125
496        %103 = OpConstant %6 105
497        %104 = OpConstant %6 97
498        %105 = OpConstant %6 93
499        %106 = OpConstant %6 98
500        %107 = OpConstant %6 106
501        %108 = OpConstant %6 145
502        %109 = OpConstant %6 177
503        %110 = OpConstant %6 208
504        %111 = OpConstant %6 221
505        %112 = OpConstant %6 231
506        %113 = OpConstant %6 239
507        %114 = OpConstant %6 244
508        %115 = OpConstant %6 242
509        %116 = OpConstant %6 236
510        %117 = OpConstant %6 228
511        %118 = OpConstant %6 218
512        %119 = OpConstant %6 207
513        %120 = OpConstant %6 194
514        %121 = OpConstant %6 158
515        %122 = OpConstant %6 135
516        %123 = OpConstant %6 132
517        %124 = OpConstant %6 131
518        %125 = OpConstant %6 138
519        %126 = OpConstant %6 147
520        %127 = OpConstant %6 155
521        %128 = OpConstant %6 152
522        %129 = OpConstant %6 139
523        %130 = OpConstant %6 129
524        %131 = OpConstant %6 118
525        %132 = OpConstant %6 68
526        %133 = OpConstant %6 58
527        %134 = OpConstant %6 49
528        %135 = OpConstant %6 43
529        %136 = OpConstant %6 40
530        %137 = OpConstant %6 41
531        %138 = OpConstant %6 44
532        %139 = OpConstant %6 51
533        %140 = OpConstant %6 61
534        %141 = OpConstant %6 73
535        %142 = OpConstant %6 119
536        %143 = OpConstant %6 173
537        %144 = OpConstant %6 186
538        %145 = OpConstant %6 128
539        %146 = OpConstant %6 104
540        %147 = OpConstant %6 86
541        %148 = OpConstant %6 81
542        %149 = OpConstant %6 77
543        %150 = OpConstant %6 76
544        %151 = OpConstant %6 89
545        %152 = OpConstant %6 102
546        %153 = OpConstant %6 92
547        %154 = OpConstant %6 83
548        %155 = OpConstant %6 62
549        %156 = OpConstant %6 50
550        %157 = OpConstant %6 38
551        %158 = OpConstant %6 26
552        %159 = OpConstant %6 16
553        %160 = OpConstant %6 8
554        %161 = OpConstant %6 2
555        %162 = OpConstant %6 0
556        %163 = OpConstant %6 4
557        %164 = OpConstant %6 11
558        %165 = OpConstant %6 21
559        %166 = OpConstant %6 33
560        %167 = OpConstant %6 48
561        %168 = OpConstant %6 64
562        %169 = OpConstant %6 144
563        %170 = OpConstant %6 123
564        %171 = OpConstant %6 112
565        %172 = OpConstant %6 100
566        %173 = OpConstant %6 90
567        %174 = OpConstant %6 65
568        %175 = OpConstant %6 67
569        %176 = OpConstant %6 70
570        %177 = OpConstant %6 75
571        %178 = OpConstant %6 95
572        %179 = OpConstant %6 88
573        %180 = OpConstant %6 69
574        %181 = OpConstant %6 47
575        %182 = OpConstant %6 36
576        %183 = OpConstant %6 18
577        %184 = OpConstant %6 13
578        %185 = OpConstant %6 15
579        %186 = OpConstant %6 22
580        %187 = OpConstant %6 32
581        %188 = OpConstant %6 45
582        %189 = OpConstant %6 60
583        %190 = OpConstantComposite %32 %33 %34 %35 %36 %37 %38 %39 %40 %41 %42 %43 %44 %45 %46 %47 %48 %49 %50 %51 %52 %52 %53 %54 %55 %48 %56 %57 %58 %59 %60 %45 %61 %62 %63 %47 %48 %64 %65 %66 %67 %68 %69 %70 %71 %72 %73 %74 %52 %75 %76 %36 %77 %78 %79 %80 %81 %82 %83 %25 %83 %84 %85 %86 %87 %88 %89 %39 %90 %44 %91 %45 %61 %60 %36 %92 %93 %94 %95 %39 %96 %97 %97 %40 %98 %90 %99 %61 %100 %101 %102 %52 %103 %104 %105 %73 %105 %106 %107 %53 %75 %108 %61 %109 %96 %110 %111 %112 %113 %85 %114 %115 %116 %117 %118 %119 %120 %43 %92 %121 %57 %56 %122 %123 %124 %123 %122 %125 %47 %126 %63 %58 %127 %127 %128 %76 %129 %130 %131 %107 %105 %71 %132 %133 %134 %135 %136 %137 %138 %139 %140 %141 %68 %66 %142 %48 %100 %60 %143 %43 %144 %98 %144 %43 %93 %36 %46 %56 %145 %51 %146 %67 %147 %148 %149 %150 %149 %71 %72 %151 %67 %106 %152 %146 %146 %152 %106 %153 %154 %141 %155 %156 %157 %158 %159 %160 %161 %162 %162 %163 %164 %165 %166 %167 %168 %148 %106 %52 %130 %56 %63 %121 %61 %61 %121 %128 %169 %48 %170 %171 %172 %173 %148 %141 %132 %174 %174 %175 %176 %177 %148 %68 %153 %104 %74 %66 %152 %172 %178 %179 %70 %180 %133 %181 %182 %158 %183 %184 %164 %164 %185 %186 %187 %188 %189 %149 %67
584        %193 = OpTypePointer Function %32
585        %213 = OpTypePointer Function %9
586        %215 = OpConstant %9 15
587        %231 = OpConstant %9 1
588        %236 = OpConstant %6 1
589        %238 = OpConstant %9 0
590        %239 = OpConstantComposite %10 %238 %238 %238 %231
591        %242 = OpTypeVector %9 2
592        %243 = OpTypePointer Function %242
593        %245 = OpTypePointer Input %10
594        %246 = OpVariable %245 Input
595        %249 = OpTypeStruct %242
596        %250 = OpTypePointer Uniform %249
597        %251 = OpVariable %250 Uniform
598        %252 = OpTypePointer Uniform %242
599        %259 = OpConstant %9 256
600        %267 = OpTypePointer Output %10
601        %268 = OpVariable %267 Output
602        %372 = OpConstant %6 0
603        %391 = OpConstantComposite %32 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372 %372
604          %4 = OpFunction %2 None %3
605          %5 = OpLabel
606        %244 = OpVariable %243 Function
607        %256 = OpVariable %8 Function
608        %269 = OpVariable %8 Function
609        %247 = OpLoad %10 %246
610        %248 = OpVectorShuffle %242 %247 %247 0 1
611        %253 = OpAccessChain %252 %251 %162
612        %254 = OpLoad %242 %253
613        %255 = OpFDiv %242 %248 %254
614               OpStore %244 %255
615        %257 = OpAccessChain %213 %244 %28
616        %258 = OpLoad %9 %257
617        %260 = OpFMul %9 %258 %259
618        %261 = OpConvertFToS %6 %260
619        %262 = OpAccessChain %213 %244 %21
620        %263 = OpLoad %9 %262
621        %264 = OpFMul %9 %263 %259
622        %265 = OpConvertFToS %6 %264
623        %266 = OpCompositeConstruct %7 %261 %265
624               OpStore %256 %266
625        %270 = OpLoad %7 %256
626               OpStore %269 %270
627        %271 = OpFunctionCall %10 %13 %269
628               OpStore %268 %271
629               OpReturn
630               OpFunctionEnd
631         %13 = OpFunction %10 None %11
632         %12 = OpFunctionParameter %8
633         %14 = OpLabel
634        %194 = OpVariable %193 Function
635        %205 = OpVariable %193 Function
636        %214 = OpVariable %213 Function
637        %220 = OpVariable %193 Function
638               OpBranch %15
639         %15 = OpLabel
640               OpLoopMerge %17 %18 None
641               OpBranch %19
642         %19 = OpLabel
643         %23 = OpAccessChain %22 %12 %21
644         %24 = OpLoad %6 %23
645         %27 = OpINotEqual %26 %24 %25
646               OpBranchConditional %27 %16 %17
647         %16 = OpLabel
648         %29 = OpAccessChain %22 %12 %28
649         %30 = OpLoad %6 %29
650        %191 = OpAccessChain %22 %12 %21
651        %192 = OpLoad %6 %191
652               OpStore %194 %190
653        %195 = OpAccessChain %22 %194 %192
654        %196 = OpLoad %6 %195
655        %397 = OpLoad %32 %194
656               OpStore %194 %391
657        %471 = OpLoad %6 %23
658               OpStore %23 %372
659               OpStore %23 %471
660               OpStore %194 %397 Volatile|Nontemporal
661        %197 = OpIAdd %6 %196 %185
662        %198 = OpSLessThan %26 %30 %197
663               OpSelectionMerge %200 None
664               OpBranchConditional %198 %199 %200
665        %199 = OpLabel
666        %201 = OpAccessChain %22 %12 %28
667        %202 = OpLoad %6 %201
668        %203 = OpAccessChain %22 %12 %21
669        %204 = OpLoad %6 %203
670               OpStore %205 %190
671        %206 = OpAccessChain %22 %205 %204
672        %207 = OpLoad %6 %206
673        %208 = OpISub %6 %207 %185
674        %209 = OpSGreaterThan %26 %202 %208
675               OpBranch %200
676        %200 = OpLabel
677        %210 = OpPhi %26 %198 %16 %209 %199
678               OpSelectionMerge %212 None
679               OpBranchConditional %210 %211 %212
680        %211 = OpLabel
681        %216 = OpAccessChain %22 %12 %28
682        %217 = OpLoad %6 %216
683        %218 = OpAccessChain %22 %12 %21
684        %219 = OpLoad %6 %218
685               OpStore %220 %190
686        %221 = OpAccessChain %22 %220 %219
687        %222 = OpLoad %6 %221
688        %223 = OpISub %6 %217 %222
689        %224 = OpConvertSToF %9 %223
690        %225 = OpExtInst %9 %1 FAbs %224
691        %226 = OpFSub %9 %215 %225
692        %227 = OpFDiv %9 %226 %215
693               OpStore %214 %227
694        %228 = OpLoad %9 %214
695        %229 = OpLoad %9 %214
696        %230 = OpLoad %9 %214
697        %232 = OpCompositeConstruct %10 %228 %229 %230 %231
698               OpReturnValue %232
699        %212 = OpLabel
700        %234 = OpAccessChain %22 %12 %21
701        %235 = OpLoad %6 %234
702        %237 = OpIAdd %6 %235 %236
703               OpStore %234 %237
704               OpBranch %18
705         %18 = OpLabel
706               OpBranch %15
707         %17 = OpLabel
708               OpReturnValue %239
709               OpFunctionEnd
710END
711
712# uniforms for variant
713
714# resolution
715BUFFER variant_resolution DATA_TYPE vec2<float> STD140 DATA
716 32.0 16.0
717END
718
719BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
720
721PIPELINE graphics variant_pipeline
722  ATTACH variant_vertex_shader
723  ATTACH variant_fragment_shader
724  FRAMEBUFFER_SIZE 32 16
725  BIND BUFFER variant_framebuffer AS color LOCATION 0
726  BIND BUFFER variant_resolution AS uniform DESCRIPTOR_SET 0 BINDING 0
727END
728CLEAR_COLOR variant_pipeline 0 0 0 255
729
730CLEAR variant_pipeline
731RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 16
732
733EXPECT reference_framebuffer EQ_HISTOGRAM_EMD_BUFFER variant_framebuffer TOLERANCE 0.005
734