Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-nested-loops-sample-opposite-corners.amber
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 SHADER vertex texgen_vert PASSTHROUGH
25
26 SHADER fragment texgen_frag GLSL
27 #version 430
28 precision highp float;
29
30 layout(location = 0) out vec4 _GLF_color;
31
32 void main()
33 {
34  _GLF_color = vec4(
35  floor(gl_FragCoord.x) * (1.0 / 255.0),
36  (int(gl_FragCoord.x) ^ int(gl_FragCoord.y)) * (1.0 / 255.0),
37  floor(gl_FragCoord.y) * (1.0 / 255.0),
38  1.0);
39 }
40 END
41 BUFFER default_texture FORMAT B8G8R8A8_UNORM
42
43 PIPELINE graphics texgen_pipeline
44   ATTACH texgen_vert
45   ATTACH texgen_frag
46   FRAMEBUFFER_SIZE 256 256
47   BIND BUFFER default_texture AS color LOCATION 0
48 END
49
50 CLEAR_COLOR texgen_pipeline 0 0 0 255
51 CLEAR texgen_pipeline
52 RUN texgen_pipeline DRAW_RECT POS 0 0  SIZE 256 256
53
54 SHADER vertex variant_vertex_shader PASSTHROUGH
55
56 # variant_fragment_shader is derived from the following GLSL:
57 # #version 320 es
58 # #define _int_0 _GLF_uniform_int_values[0]
59 # #define _int_1 _GLF_uniform_int_values[1]
60 # #define _int_4 _GLF_uniform_int_values[2]
61 # #define _float_0_0 _GLF_uniform_float_values[0]
62 # #define _float_1_0 _GLF_uniform_float_values[1]
63 # #define _float_255_0 _GLF_uniform_float_values[2]
64 # #define _float_256_0 _GLF_uniform_float_values[3]
65 #
66 # precision highp float;
67 # precision highp int;
68 #
69 # // Contents of _GLF_uniform_float_values: [0.0, 1.0, 255.0, 256.0]
70 # layout(set = 0, binding = 0) uniform buf0
71 # {
72 #     float _GLF_uniform_float_values[4];
73 # };
74 # // Contents of _GLF_uniform_int_values: [0, 1, 4]
75 # layout(set = 0, binding = 1) uniform buf1
76 # {
77 #     int _GLF_uniform_int_values[3];
78 # };
79 # // Contents of one: 1.0
80 # layout(push_constant) uniform buf_push
81 # {
82 #     float one;
83 # };
84 #
85 # layout(set = 0, binding = 2) uniform sampler2D tex;
86 # layout(location = 0) out vec4 _GLF_color;
87 #
88 # void main()
89 # {
90 #     vec2 coord = vec2(_float_0_0);
91 #     vec4 texel = texture(tex, coord);
92 #     _GLF_color = vec4(_int_0);
93 #
94 #     for(int i = _int_0; i < int(one); i++)
95 #     {
96 #         // Texture has a red channel that changes from zero to one in u direction.
97 #         // The first time it's sampled from u = 0 which gives a value of zero.
98 #         // The second time the sampled location has chaned to the other edge
99 #         // where it samples 1.0 and therefore exits the loop.
100 #         while(texel.x < _float_1_0)
101 #         {
102 #             for(int i = _int_0; i < _int_1; i ++)
103 #             {
104 #                 // Always true.
105 #                 if(gl_FragCoord.y > _float_0_0)
106 #                 {
107 #                 }
108 #                 else
109 #                 {
110 #                     // This branch is never executed.
111 #                     for(int i = _int_1; i > _int_0; i--)
112 #                     {
113 #                         for(int i = _int_0; i != _int_1; i++)
114 #                         {
115 #                             for(int i = _int_0; i < int(one); i++)
116 #                             {
117 #                                 if(gl_FragCoord.y > _float_0_0)
118 #                                 {
119 #                                 }
120 #                                 else
121 #                                 {
122 #                                     coord = vec2(_float_1_0);
123 #                                 }
124 #                             }
125 #                         }
126 #                     }
127 #                 }
128 #             }
129 #
130 #             // Jump to the opposite corner of the texture where
131 #             // it will sample 1.0 for the red channel.
132 #             coord = coord + _float_255_0 / _float_256_0;
133 #             for(int i = _int_0; i < _int_1; i ++)
134 #             {
135 #                 for(int i = _int_1; i != _int_0; i --)
136 #                 {
137 #                     texel = texture(tex, coord);
138 #                     _GLF_color = vec4(texel.x, _int_0, _int_0, _int_1);
139 #                 }
140 #             }
141 #
142 #             // This does nothing.
143 #             for(int i = _int_0; i < _int_1; i ++)
144 #             {
145 #                 for(int i = _int_0; i != _int_1; i ++)
146 #                 {
147 #                 }
148 #             }
149 #         }
150 #     }
151 # }
152 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
153 ; SPIR-V
154 ; Version: 1.0
155 ; Generator: Khronos Glslang Reference Front End; 10
156 ; Bound: 239
157 ; Schema: 0
158                OpCapability Shader
159           %1 = OpExtInstImport "GLSL.std.450"
160                OpMemoryModel Logical GLSL450
161                OpEntryPoint Fragment %4 "main" %33 %89
162                OpExecutionMode %4 OriginUpperLeft
163                OpSource ESSL 320
164                OpName %4 "main"
165                OpName %9 "coord"
166                OpName %13 "buf0"
167                OpMemberName %13 0 "_GLF_uniform_float_values"
168                OpName %15 ""
169                OpName %24 "texel"
170                OpName %28 "tex"
171                OpName %33 "_GLF_color"
172                OpName %36 "buf1"
173                OpMemberName %36 0 "_GLF_uniform_int_values"
174                OpName %38 ""
175                OpName %45 "i"
176                OpName %54 "buf_push"
177                OpMemberName %54 0 "one"
178                OpName %56 ""
179                OpName %76 "i"
180                OpName %89 "gl_FragCoord"
181                OpName %100 "i"
182                OpName %112 "i"
183                OpName %124 "i"
184                OpName %166 "i"
185                OpName %178 "i"
186                OpName %209 "i"
187                OpName %221 "i"
188                OpDecorate %12 ArrayStride 16
189                OpMemberDecorate %13 0 Offset 0
190                OpDecorate %13 Block
191                OpDecorate %15 DescriptorSet 0
192                OpDecorate %15 Binding 0
193                OpDecorate %28 RelaxedPrecision
194                OpDecorate %28 DescriptorSet 0
195                OpDecorate %28 Binding 2
196                OpDecorate %29 RelaxedPrecision
197                OpDecorate %31 RelaxedPrecision
198                OpDecorate %33 Location 0
199                OpDecorate %35 ArrayStride 16
200                OpMemberDecorate %36 0 Offset 0
201                OpDecorate %36 Block
202                OpDecorate %38 DescriptorSet 0
203                OpDecorate %38 Binding 1
204                OpMemberDecorate %54 0 Offset 0
205                OpDecorate %54 Block
206                OpDecorate %89 BuiltIn FragCoord
207                OpDecorate %190 RelaxedPrecision
208                OpDecorate %192 RelaxedPrecision
209           %2 = OpTypeVoid
210           %3 = OpTypeFunction %2
211           %6 = OpTypeFloat 32
212           %7 = OpTypeVector %6 2
213           %8 = OpTypePointer Function %7
214          %10 = OpTypeInt 32 0
215          %11 = OpConstant %10 4
216          %12 = OpTypeArray %6 %11
217          %13 = OpTypeStruct %12
218          %14 = OpTypePointer Uniform %13
219          %15 = OpVariable %14 Uniform
220          %16 = OpTypeInt 32 1
221          %17 = OpConstant %16 0
222          %18 = OpTypePointer Uniform %6
223          %22 = OpTypeVector %6 4
224          %23 = OpTypePointer Function %22
225          %25 = OpTypeImage %6 2D 0 0 0 1 Unknown
226          %26 = OpTypeSampledImage %25
227          %27 = OpTypePointer UniformConstant %26
228          %28 = OpVariable %27 UniformConstant
229          %32 = OpTypePointer Output %22
230          %33 = OpVariable %32 Output
231          %34 = OpConstant %10 3
232          %35 = OpTypeArray %16 %34
233          %36 = OpTypeStruct %35
234          %37 = OpTypePointer Uniform %36
235          %38 = OpVariable %37 Uniform
236          %39 = OpTypePointer Uniform %16
237          %44 = OpTypePointer Function %16
238          %54 = OpTypeStruct %6
239          %55 = OpTypePointer PushConstant %54
240          %56 = OpVariable %55 PushConstant
241          %57 = OpTypePointer PushConstant %6
242          %61 = OpTypeBool
243          %68 = OpConstant %10 0
244          %69 = OpTypePointer Function %6
245          %72 = OpConstant %16 1
246          %88 = OpTypePointer Input %22
247          %89 = OpVariable %88 Input
248          %90 = OpConstant %10 1
249          %91 = OpTypePointer Input %6
250         %157 = OpConstant %16 2
251         %160 = OpConstant %16 3
252           %4 = OpFunction %2 None %3
253           %5 = OpLabel
254           %9 = OpVariable %8 Function
255          %24 = OpVariable %23 Function
256          %45 = OpVariable %44 Function
257          %76 = OpVariable %44 Function
258         %100 = OpVariable %44 Function
259         %112 = OpVariable %44 Function
260         %124 = OpVariable %44 Function
261         %166 = OpVariable %44 Function
262         %178 = OpVariable %44 Function
263         %209 = OpVariable %44 Function
264         %221 = OpVariable %44 Function
265          %19 = OpAccessChain %18 %15 %17 %17
266          %20 = OpLoad %6 %19
267          %21 = OpCompositeConstruct %7 %20 %20
268                OpStore %9 %21
269          %29 = OpLoad %26 %28
270          %30 = OpLoad %7 %9
271          %31 = OpImageSampleImplicitLod %22 %29 %30
272                OpStore %24 %31
273          %40 = OpAccessChain %39 %38 %17 %17
274          %41 = OpLoad %16 %40
275          %42 = OpConvertSToF %6 %41
276          %43 = OpCompositeConstruct %22 %42 %42 %42 %42
277                OpStore %33 %43
278          %46 = OpAccessChain %39 %38 %17 %17
279          %47 = OpLoad %16 %46
280                OpStore %45 %47
281                OpBranch %48
282          %48 = OpLabel
283                OpLoopMerge %50 %51 None
284                OpBranch %52
285          %52 = OpLabel
286          %53 = OpLoad %16 %45
287          %58 = OpAccessChain %57 %56 %17
288          %59 = OpLoad %6 %58
289          %60 = OpConvertFToS %16 %59
290          %62 = OpSLessThan %61 %53 %60
291                OpBranchConditional %62 %49 %50
292          %49 = OpLabel
293                OpBranch %63
294          %63 = OpLabel
295                OpLoopMerge %65 %66 None
296                OpBranch %67
297          %67 = OpLabel
298          %70 = OpAccessChain %69 %24 %68
299          %71 = OpLoad %6 %70
300          %73 = OpAccessChain %18 %15 %17 %72
301          %74 = OpLoad %6 %73
302          %75 = OpFOrdLessThan %61 %71 %74
303                OpBranchConditional %75 %64 %65
304          %64 = OpLabel
305          %77 = OpAccessChain %39 %38 %17 %17
306          %78 = OpLoad %16 %77
307                OpStore %76 %78
308                OpBranch %79
309          %79 = OpLabel
310                OpLoopMerge %81 %82 None
311                OpBranch %83
312          %83 = OpLabel
313          %84 = OpLoad %16 %76
314          %85 = OpAccessChain %39 %38 %17 %72
315          %86 = OpLoad %16 %85
316          %87 = OpSLessThan %61 %84 %86
317                OpBranchConditional %87 %80 %81
318          %80 = OpLabel
319          %92 = OpAccessChain %91 %89 %90
320          %93 = OpLoad %6 %92
321          %94 = OpAccessChain %18 %15 %17 %17
322          %95 = OpLoad %6 %94
323          %96 = OpFOrdGreaterThan %61 %93 %95
324                OpSelectionMerge %98 None
325                OpBranchConditional %96 %97 %99
326          %97 = OpLabel
327                OpBranch %98
328          %99 = OpLabel
329         %101 = OpAccessChain %39 %38 %17 %72
330         %102 = OpLoad %16 %101
331                OpStore %100 %102
332                OpBranch %103
333         %103 = OpLabel
334                OpLoopMerge %105 %106 None
335                OpBranch %107
336         %107 = OpLabel
337         %108 = OpLoad %16 %100
338         %109 = OpAccessChain %39 %38 %17 %17
339         %110 = OpLoad %16 %109
340         %111 = OpSGreaterThan %61 %108 %110
341                OpBranchConditional %111 %104 %105
342         %104 = OpLabel
343         %113 = OpAccessChain %39 %38 %17 %17
344         %114 = OpLoad %16 %113
345                OpStore %112 %114
346                OpBranch %115
347         %115 = OpLabel
348                OpLoopMerge %117 %118 None
349                OpBranch %119
350         %119 = OpLabel
351         %120 = OpLoad %16 %112
352         %121 = OpAccessChain %39 %38 %17 %72
353         %122 = OpLoad %16 %121
354         %123 = OpINotEqual %61 %120 %122
355                OpBranchConditional %123 %116 %117
356         %116 = OpLabel
357         %125 = OpAccessChain %39 %38 %17 %17
358         %126 = OpLoad %16 %125
359                OpStore %124 %126
360                OpBranch %127
361         %127 = OpLabel
362                OpLoopMerge %129 %130 None
363                OpBranch %131
364         %131 = OpLabel
365         %132 = OpLoad %16 %124
366         %133 = OpAccessChain %57 %56 %17
367         %134 = OpLoad %6 %133
368         %135 = OpConvertFToS %16 %134
369         %136 = OpSLessThan %61 %132 %135
370                OpBranchConditional %136 %128 %129
371         %128 = OpLabel
372         %137 = OpAccessChain %91 %89 %90
373         %138 = OpLoad %6 %137
374         %139 = OpAccessChain %18 %15 %17 %17
375         %140 = OpLoad %6 %139
376         %141 = OpFOrdGreaterThan %61 %138 %140
377                OpSelectionMerge %143 None
378                OpBranchConditional %141 %142 %144
379         %142 = OpLabel
380                OpBranch %143
381         %144 = OpLabel
382         %145 = OpAccessChain %18 %15 %17 %72
383         %146 = OpLoad %6 %145
384         %147 = OpCompositeConstruct %7 %146 %146
385                OpStore %9 %147
386                OpBranch %143
387         %143 = OpLabel
388                OpBranch %130
389         %130 = OpLabel
390         %148 = OpLoad %16 %124
391         %149 = OpIAdd %16 %148 %72
392                OpStore %124 %149
393                OpBranch %127
394         %129 = OpLabel
395                OpBranch %118
396         %118 = OpLabel
397         %150 = OpLoad %16 %112
398         %151 = OpIAdd %16 %150 %72
399                OpStore %112 %151
400                OpBranch %115
401         %117 = OpLabel
402                OpBranch %106
403         %106 = OpLabel
404         %152 = OpLoad %16 %100
405         %153 = OpISub %16 %152 %72
406                OpStore %100 %153
407                OpBranch %103
408         %105 = OpLabel
409                OpBranch %98
410          %98 = OpLabel
411                OpBranch %82
412          %82 = OpLabel
413         %154 = OpLoad %16 %76
414         %155 = OpIAdd %16 %154 %72
415                OpStore %76 %155
416                OpBranch %79
417          %81 = OpLabel
418         %156 = OpLoad %7 %9
419         %158 = OpAccessChain %18 %15 %17 %157
420         %159 = OpLoad %6 %158
421         %161 = OpAccessChain %18 %15 %17 %160
422         %162 = OpLoad %6 %161
423         %163 = OpFDiv %6 %159 %162
424         %164 = OpCompositeConstruct %7 %163 %163
425         %165 = OpFAdd %7 %156 %164
426                OpStore %9 %165
427         %167 = OpAccessChain %39 %38 %17 %17
428         %168 = OpLoad %16 %167
429                OpStore %166 %168
430                OpBranch %169
431         %169 = OpLabel
432                OpLoopMerge %171 %172 None
433                OpBranch %173
434         %173 = OpLabel
435         %174 = OpLoad %16 %166
436         %175 = OpAccessChain %39 %38 %17 %72
437         %176 = OpLoad %16 %175
438         %177 = OpSLessThan %61 %174 %176
439                OpBranchConditional %177 %170 %171
440         %170 = OpLabel
441         %179 = OpAccessChain %39 %38 %17 %72
442         %180 = OpLoad %16 %179
443                OpStore %178 %180
444                OpBranch %181
445         %181 = OpLabel
446                OpLoopMerge %183 %184 None
447                OpBranch %185
448         %185 = OpLabel
449         %186 = OpLoad %16 %178
450         %187 = OpAccessChain %39 %38 %17 %17
451         %188 = OpLoad %16 %187
452         %189 = OpINotEqual %61 %186 %188
453                OpBranchConditional %189 %182 %183
454         %182 = OpLabel
455         %190 = OpLoad %26 %28
456         %191 = OpLoad %7 %9
457         %192 = OpImageSampleImplicitLod %22 %190 %191
458                OpStore %24 %192
459         %193 = OpAccessChain %69 %24 %68
460         %194 = OpLoad %6 %193
461         %195 = OpAccessChain %39 %38 %17 %17
462         %196 = OpLoad %16 %195
463         %197 = OpConvertSToF %6 %196
464         %198 = OpAccessChain %39 %38 %17 %17
465         %199 = OpLoad %16 %198
466         %200 = OpConvertSToF %6 %199
467         %201 = OpAccessChain %39 %38 %17 %72
468         %202 = OpLoad %16 %201
469         %203 = OpConvertSToF %6 %202
470         %204 = OpCompositeConstruct %22 %194 %197 %200 %203
471                OpStore %33 %204
472                OpBranch %184
473         %184 = OpLabel
474         %205 = OpLoad %16 %178
475         %206 = OpISub %16 %205 %72
476                OpStore %178 %206
477                OpBranch %181
478         %183 = OpLabel
479                OpBranch %172
480         %172 = OpLabel
481         %207 = OpLoad %16 %166
482         %208 = OpIAdd %16 %207 %72
483                OpStore %166 %208
484                OpBranch %169
485         %171 = OpLabel
486         %210 = OpAccessChain %39 %38 %17 %17
487         %211 = OpLoad %16 %210
488                OpStore %209 %211
489                OpBranch %212
490         %212 = OpLabel
491                OpLoopMerge %214 %215 None
492                OpBranch %216
493         %216 = OpLabel
494         %217 = OpLoad %16 %209
495         %218 = OpAccessChain %39 %38 %17 %72
496         %219 = OpLoad %16 %218
497         %220 = OpSLessThan %61 %217 %219
498                OpBranchConditional %220 %213 %214
499         %213 = OpLabel
500         %222 = OpAccessChain %39 %38 %17 %17
501         %223 = OpLoad %16 %222
502                OpStore %221 %223
503                OpBranch %224
504         %224 = OpLabel
505                OpLoopMerge %226 %227 None
506                OpBranch %228
507         %228 = OpLabel
508         %229 = OpLoad %16 %221
509         %230 = OpAccessChain %39 %38 %17 %72
510         %231 = OpLoad %16 %230
511         %232 = OpINotEqual %61 %229 %231
512                OpBranchConditional %232 %225 %226
513         %225 = OpLabel
514                OpBranch %227
515         %227 = OpLabel
516         %233 = OpLoad %16 %221
517         %234 = OpIAdd %16 %233 %72
518                OpStore %221 %234
519                OpBranch %224
520         %226 = OpLabel
521                OpBranch %215
522         %215 = OpLabel
523         %235 = OpLoad %16 %209
524         %236 = OpIAdd %16 %235 %72
525                OpStore %209 %236
526                OpBranch %212
527         %214 = OpLabel
528                OpBranch %66
529          %66 = OpLabel
530                OpBranch %63
531          %65 = OpLabel
532                OpBranch %51
533          %51 = OpLabel
534         %237 = OpLoad %16 %45
535         %238 = OpIAdd %16 %237 %72
536                OpStore %45 %238
537                OpBranch %48
538          %50 = OpLabel
539                OpReturn
540                OpFunctionEnd
541 END
542
543 # uniforms for variant
544
545 # tex
546 SAMPLER variant_tex
547
548 # one
549 BUFFER variant_one DATA_TYPE float STD140 DATA
550  1.0
551 END
552 # _GLF_uniform_int_values
553 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
554  0 1 4
555 END
556 # _GLF_uniform_float_values
557 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
558  0.0 1.0 255.0 256.0
559 END
560
561 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
562
563 PIPELINE graphics variant_pipeline
564   ATTACH variant_vertex_shader
565   ATTACH variant_fragment_shader
566   FRAMEBUFFER_SIZE 256 256
567   BIND BUFFER variant_framebuffer AS color LOCATION 0
568   BIND BUFFER default_texture AS combined_image_sampler SAMPLER variant_tex DESCRIPTOR_SET 0 BINDING 2
569   BIND BUFFER variant_one AS push_constant
570   BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
571   BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
572 END
573 CLEAR_COLOR variant_pipeline 0 0 0 255
574
575 CLEAR variant_pipeline
576 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
577
578 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255