Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-nested-loops-global-loop-counter-output-color-from-backup.amber
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 SHADER vertex variant_vertex_shader PASSTHROUGH
25
26 # variant_fragment_shader is derived from the following GLSL:
27 # #version 320 es
28 # #define _int_1 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
30 #
31 # precision highp float;
32 # precision highp int;
33 #
34 # // Contents of _GLF_uniform_int_values: [1, 0]
35 # layout(set = 0, binding = 0) uniform buf0 {
36 #     int _GLF_uniform_int_values[2];
37 # };
38 #
39 # const int _GLF_global_loop_bound = 10;
40 # int _GLF_global_loop_count = 0;
41 #
42 # layout(location = 0) out vec4 _GLF_color;
43 #
44 # void main()
45 # {
46 #     _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
47 #
48 #     // Iterated once.
49 #     for(int i = _int_1; i > _int_0 && _GLF_global_loop_count < _GLF_global_loop_bound; i--)
50 #     {
51 #         // Iterated once.
52 #         for(int i = _int_1; i != _int_0 && _GLF_global_loop_count < _GLF_global_loop_bound; i--)
53 #         {
54 #             // Uninitialized here, but this gets a value in the while loop below.
55 #             vec4 v;
56 #
57 #             // Iterated ten times.
58 #             while(_GLF_global_loop_count < _GLF_global_loop_bound)
59 #             {
60 #                 _GLF_global_loop_count++;
61 #                 v = _GLF_color;
62 #             }
63 #
64 #             _GLF_color = vec4(_int_0);
65 #
66 #             // Always true.
67 #             if(_int_1 > _int_0)
68 #             {
69 #                 _GLF_color = v;
70 #             }
71 #             else
72 #             {
73 #                 _GLF_color = vec4(_int_0);
74 #             }
75 #         }
76 #     }
77 # }
78 SHADER 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: 101
83 ; Schema: 0
84                OpCapability Shader
85           %1 = OpExtInstImport "GLSL.std.450"
86                OpMemoryModel Logical GLSL450
87                OpEntryPoint Fragment %4 "main" %13
88                OpExecutionMode %4 OriginUpperLeft
89                OpSource ESSL 320
90                OpName %4 "main"
91                OpName %8 "_GLF_global_loop_count"
92                OpName %13 "_GLF_color"
93                OpName %17 "buf0"
94                OpMemberName %17 0 "_GLF_uniform_int_values"
95                OpName %19 ""
96                OpName %36 "i"
97                OpName %53 "i"
98                OpName %78 "v"
99                OpDecorate %13 Location 0
100                OpDecorate %16 ArrayStride 16
101                OpMemberDecorate %17 0 Offset 0
102                OpDecorate %17 Block
103                OpDecorate %19 DescriptorSet 0
104                OpDecorate %19 Binding 0
105           %2 = OpTypeVoid
106           %3 = OpTypeFunction %2
107           %6 = OpTypeInt 32 1
108           %7 = OpTypePointer Private %6
109           %8 = OpVariable %7 Private
110           %9 = OpConstant %6 0
111          %10 = OpTypeFloat 32
112          %11 = OpTypeVector %10 4
113          %12 = OpTypePointer Output %11
114          %13 = OpVariable %12 Output
115          %14 = OpTypeInt 32 0
116          %15 = OpConstant %14 2
117          %16 = OpTypeArray %6 %15
118          %17 = OpTypeStruct %16
119          %18 = OpTypePointer Uniform %17
120          %19 = OpVariable %18 Uniform
121          %20 = OpTypePointer Uniform %6
122          %24 = OpConstant %6 1
123          %35 = OpTypePointer Function %6
124          %47 = OpTypeBool
125          %50 = OpConstant %6 10
126          %77 = OpTypePointer Function %11
127           %4 = OpFunction %2 None %3
128           %5 = OpLabel
129          %36 = OpVariable %35 Function
130          %53 = OpVariable %35 Function
131          %78 = OpVariable %77 Function
132                OpStore %8 %9
133          %21 = OpAccessChain %20 %19 %9 %9
134          %22 = OpLoad %6 %21
135          %23 = OpConvertSToF %10 %22
136          %25 = OpAccessChain %20 %19 %9 %24
137          %26 = OpLoad %6 %25
138          %27 = OpConvertSToF %10 %26
139          %28 = OpAccessChain %20 %19 %9 %24
140          %29 = OpLoad %6 %28
141          %30 = OpConvertSToF %10 %29
142          %31 = OpAccessChain %20 %19 %9 %9
143          %32 = OpLoad %6 %31
144          %33 = OpConvertSToF %10 %32
145          %34 = OpCompositeConstruct %11 %23 %27 %30 %33
146                OpStore %13 %34
147          %37 = OpAccessChain %20 %19 %9 %9
148          %38 = OpLoad %6 %37
149                OpStore %36 %38
150                OpBranch %39
151          %39 = OpLabel
152                OpLoopMerge %41 %42 None
153                OpBranch %43
154          %43 = OpLabel
155          %44 = OpLoad %6 %36
156          %45 = OpAccessChain %20 %19 %9 %24
157          %46 = OpLoad %6 %45
158          %48 = OpSGreaterThan %47 %44 %46
159          %49 = OpLoad %6 %8
160          %51 = OpSLessThan %47 %49 %50
161          %52 = OpLogicalAnd %47 %48 %51
162                OpBranchConditional %52 %40 %41
163          %40 = OpLabel
164          %54 = OpAccessChain %20 %19 %9 %9
165          %55 = OpLoad %6 %54
166                OpStore %53 %55
167                OpBranch %56
168          %56 = OpLabel
169                OpLoopMerge %58 %59 None
170                OpBranch %60
171          %60 = OpLabel
172          %61 = OpLoad %6 %53
173          %62 = OpAccessChain %20 %19 %9 %24
174          %63 = OpLoad %6 %62
175          %64 = OpINotEqual %47 %61 %63
176          %65 = OpLoad %6 %8
177          %66 = OpSLessThan %47 %65 %50
178          %67 = OpLogicalAnd %47 %64 %66
179                OpBranchConditional %67 %57 %58
180          %57 = OpLabel
181                OpBranch %68
182          %68 = OpLabel
183                OpLoopMerge %70 %71 None
184                OpBranch %72
185          %72 = OpLabel
186          %73 = OpLoad %6 %8
187          %74 = OpSLessThan %47 %73 %50
188                OpBranchConditional %74 %69 %70
189          %69 = OpLabel
190          %75 = OpLoad %6 %8
191          %76 = OpIAdd %6 %75 %24
192                OpStore %8 %76
193          %79 = OpLoad %11 %13
194                OpStore %78 %79
195                OpBranch %71
196          %71 = OpLabel
197                OpBranch %68
198          %70 = OpLabel
199          %80 = OpAccessChain %20 %19 %9 %24
200          %81 = OpLoad %6 %80
201          %82 = OpConvertSToF %10 %81
202          %83 = OpCompositeConstruct %11 %82 %82 %82 %82
203                OpStore %13 %83
204          %84 = OpAccessChain %20 %19 %9 %9
205          %85 = OpLoad %6 %84
206          %86 = OpAccessChain %20 %19 %9 %24
207          %87 = OpLoad %6 %86
208          %88 = OpSGreaterThan %47 %85 %87
209                OpSelectionMerge %90 None
210                OpBranchConditional %88 %89 %92
211          %89 = OpLabel
212          %91 = OpLoad %11 %78
213                OpStore %13 %91
214                OpBranch %90
215          %92 = OpLabel
216          %93 = OpAccessChain %20 %19 %9 %24
217          %94 = OpLoad %6 %93
218          %95 = OpConvertSToF %10 %94
219          %96 = OpCompositeConstruct %11 %95 %95 %95 %95
220                OpStore %13 %96
221                OpBranch %90
222          %90 = OpLabel
223                OpBranch %59
224          %59 = OpLabel
225          %97 = OpLoad %6 %53
226          %98 = OpISub %6 %97 %24
227                OpStore %53 %98
228                OpBranch %56
229          %58 = OpLabel
230                OpBranch %42
231          %42 = OpLabel
232          %99 = OpLoad %6 %36
233         %100 = OpISub %6 %99 %24
234                OpStore %36 %100
235                OpBranch %39
236          %41 = OpLabel
237                OpReturn
238                OpFunctionEnd
239 END
240
241 # uniforms for variant
242
243 # _GLF_uniform_int_values
244 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
245  1 0
246 END
247
248 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
249
250 PIPELINE graphics variant_pipeline
251   ATTACH variant_vertex_shader
252   ATTACH variant_fragment_shader
253   FRAMEBUFFER_SIZE 32 32
254   BIND BUFFER variant_framebuffer AS color LOCATION 0
255   BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
256 END
257 CLEAR_COLOR variant_pipeline 0 0 0 255
258
259 CLEAR variant_pipeline
260 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
261
262 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255