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