Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-copy-prop-arrays-func-argument.amber
1 #!amber
2
3 # Copyright 2019 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 GraphicsFuzz.
19
20 # Short description: A fragment shader that covers a specific propagate array copy path.
21
22 # The test passes because shader always writes red.
23
24 # Optimized using spirv-opt with the following arguments:
25 # '--eliminate-dead-branches'
26 # '--merge-return'
27 # '--reduce-load-size'
28 # '--if-conversion'
29 # '--private-to-local'
30 # '--if-conversion'
31 # '--eliminate-dead-branches'
32 # '--eliminate-local-multi-store'
33 # '--scalar-replacement=100'
34 # '--vector-dce'
35 # '--inline-entry-points-exhaustive'
36 # '--eliminate-local-single-store'
37 # '--convert-local-access-chains'
38 # '--eliminate-dead-branches'
39 # '--merge-return'
40 # '--reduce-load-size'
41 # '--eliminate-dead-branches'
42 # '--merge-blocks'
43 # '--redundancy-elimination'
44 # '--eliminate-dead-branches'
45 # spirv-opt commit hash: 9215c1b7df0029f27807e8c8d7ec80532ce90a87
46
47
48
49 SHADER vertex variant_vertex_shader PASSTHROUGH
50
51 # variant_fragment_shader is derived from the following GLSL:
52 # #version 310 es
53 # precision highp float;
54 #
55 # layout(location = 0) out vec4 _GLF_color;
56 #
57 # layout(set = 0, binding = 0) uniform buf0
58 # {
59 #     int zero;
60 # };
61 #
62 # struct Array
63 # {
64 #     int values[2];
65 # };
66 #
67 # // Function always returns 1 regardless of array contents
68 # int func(Array a)
69 # {
70 #     while(true)
71 #     {
72 #         if(a.values[zero] == 1)
73 #             return 1;
74 #
75 #         break;
76 #     }
77 #     return 1;
78 # }
79 # void main()
80 # {
81 #     Array a;
82 #     // If condition is always true
83 #     if (func(a) == 1)
84 #         _GLF_color = vec4(1, 0, 0, 1);
85 #     else
86 #         _GLF_color = vec4(0);
87 # }
88 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
89 ; SPIR-V
90 ; Version: 1.0
91 ; Generator: Khronos Glslang Reference Front End; 8
92 ; Bound: 104
93 ; Schema: 0
94                OpCapability Shader
95           %1 = OpExtInstImport "GLSL.std.450"
96                OpMemoryModel Logical GLSL450
97                OpEntryPoint Fragment %4 "main" %51
98                OpExecutionMode %4 OriginUpperLeft
99                OpSource ESSL 310
100                OpName %4 "main"
101                OpName %10 "Array"
102                OpMemberName %10 0 "values"
103                OpName %14 "func(struct-Array-i1[2]1;"
104                OpName %13 "a"
105                OpName %24 "buf0"
106                OpMemberName %24 0 "zero"
107                OpName %26 ""
108                OpName %42 "param"
109                OpName %51 "_GLF_color"
110                OpMemberDecorate %10 0 RelaxedPrecision
111                OpDecorate %14 RelaxedPrecision
112                OpMemberDecorate %24 0 RelaxedPrecision
113                OpMemberDecorate %24 0 Offset 0
114                OpDecorate %24 Block
115                OpDecorate %26 DescriptorSet 0
116                OpDecorate %26 Binding 0
117                OpDecorate %29 RelaxedPrecision
118                OpDecorate %32 RelaxedPrecision
119                OpDecorate %51 Location 0
120                OpDecorate %58 RelaxedPrecision
121                OpDecorate %73 RelaxedPrecision
122                OpDecorate %72 RelaxedPrecision
123                OpDecorate %80 RelaxedPrecision
124                OpDecorate %81 RelaxedPrecision
125                OpDecorate %94 RelaxedPrecision
126                OpDecorate %96 RelaxedPrecision
127                OpDecorate %100 RelaxedPrecision
128                OpDecorate %103 RelaxedPrecision
129           %2 = OpTypeVoid
130           %3 = OpTypeFunction %2
131           %6 = OpTypeInt 32 1
132           %7 = OpTypeInt 32 0
133           %8 = OpConstant %7 2
134           %9 = OpTypeArray %6 %8
135          %10 = OpTypeStruct %9
136          %11 = OpTypePointer Function %10
137          %12 = OpTypeFunction %6 %11
138          %21 = OpTypeBool
139          %22 = OpConstantTrue %21
140          %23 = OpConstant %6 0
141          %24 = OpTypeStruct %6
142          %25 = OpTypePointer Uniform %24
143          %26 = OpVariable %25 Uniform
144          %27 = OpTypePointer Uniform %6
145          %30 = OpTypePointer Function %6
146          %33 = OpConstant %6 1
147          %48 = OpTypeFloat 32
148          %49 = OpTypeVector %48 4
149          %50 = OpTypePointer Output %49
150          %51 = OpVariable %50 Output
151          %52 = OpConstant %48 1
152          %53 = OpConstant %48 0
153          %54 = OpConstantComposite %49 %52 %53 %53 %52
154          %56 = OpConstantComposite %49 %53 %53 %53 %53
155          %63 = OpConstantFalse %21
156          %64 = OpTypePointer Function %21
157          %68 = OpUndef %10
158          %76 = OpUndef %6
159          %77 = OpUndef %21
160          %78 = OpConstantNull %9
161           %4 = OpFunction %2 None %3
162           %5 = OpLabel
163          %79 = OpVariable %64 Function %63
164          %80 = OpVariable %30 Function
165          %81 = OpVariable %30 Function
166          %42 = OpVariable %11 Function
167                OpStore %42 %68
168                OpStore %79 %63
169                OpBranch %82
170          %82 = OpLabel
171                OpLoopMerge %85 %83 None
172                OpBranch %87
173          %87 = OpLabel
174                OpLoopMerge %90 %88 None
175                OpBranch %92
176          %92 = OpLabel
177          %93 = OpAccessChain %27 %26 %23
178          %94 = OpLoad %6 %93
179          %95 = OpAccessChain %30 %42 %23 %94
180          %96 = OpLoad %6 %95
181          %97 = OpIEqual %21 %96 %33
182                OpSelectionMerge %98 None
183                OpBranchConditional %97 %99 %98
184          %99 = OpLabel
185                OpStore %79 %22
186                OpStore %80 %33
187                OpBranch %90
188          %98 = OpLabel
189                OpBranch %90
190          %88 = OpLabel
191                OpBranch %87
192          %90 = OpLabel
193         %100 = OpPhi %6 %33 %99 %76 %98
194         %101 = OpPhi %21 %22 %99 %63 %98
195                OpSelectionMerge %102 None
196                OpBranchConditional %101 %85 %102
197         %102 = OpLabel
198                OpStore %79 %22
199                OpStore %80 %33
200                OpBranch %85
201          %83 = OpLabel
202                OpBranch %82
203          %85 = OpLabel
204         %103 = OpPhi %6 %100 %90 %33 %102
205                OpStore %81 %103
206          %45 = OpIEqual %21 %103 %33
207                OpSelectionMerge %47 None
208                OpBranchConditional %45 %46 %55
209          %55 = OpLabel
210                OpStore %51 %56
211                OpBranch %47
212          %46 = OpLabel
213                OpStore %51 %54
214                OpBranch %47
215          %47 = OpLabel
216                OpReturn
217                OpFunctionEnd
218          %14 = OpFunction %6 None %12
219          %13 = OpFunctionParameter %11
220          %15 = OpLabel
221          %65 = OpVariable %64 Function %63
222          %58 = OpVariable %30 Function
223                OpBranch %60
224          %60 = OpLabel
225          %71 = OpPhi %21 %63 %15 %77 %62
226                OpLoopMerge %57 %62 None
227                OpBranch %61
228          %61 = OpLabel
229                OpBranch %16
230          %16 = OpLabel
231          %70 = OpPhi %21 %71 %61 %77 %19
232                OpLoopMerge %18 %19 None
233                OpBranch %20
234          %20 = OpLabel
235                OpBranch %17
236          %17 = OpLabel
237          %28 = OpAccessChain %27 %26 %23
238          %29 = OpLoad %6 %28
239          %31 = OpAccessChain %30 %13 %23 %29
240          %32 = OpLoad %6 %31
241          %34 = OpIEqual %21 %32 %33
242                OpSelectionMerge %36 None
243                OpBranchConditional %34 %35 %36
244          %35 = OpLabel
245                OpStore %65 %22
246                OpStore %58 %33
247                OpBranch %18
248          %36 = OpLabel
249                OpBranch %18
250          %19 = OpLabel
251                OpBranch %16
252          %18 = OpLabel
253          %73 = OpPhi %6 %33 %35 %76 %36
254          %69 = OpPhi %21 %22 %35 %70 %36
255                OpSelectionMerge %66 None
256                OpBranchConditional %69 %57 %66
257          %66 = OpLabel
258                OpStore %65 %22
259                OpStore %58 %33
260                OpBranch %57
261          %62 = OpLabel
262                OpBranch %60
263          %57 = OpLabel
264          %72 = OpPhi %6 %73 %18 %33 %66
265                OpReturnValue %72
266                OpFunctionEnd
267 END
268
269 # uniforms for variant
270
271 # zero
272 BUFFER variant_zero DATA_TYPE int32 DATA
273  0
274 END
275
276 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
277
278 PIPELINE graphics variant_pipeline
279   ATTACH variant_vertex_shader
280   ATTACH variant_fragment_shader
281   FRAMEBUFFER_SIZE 256 256
282   BIND BUFFER variant_framebuffer AS color LOCATION 0
283   BIND BUFFER variant_zero AS uniform DESCRIPTOR_SET 0 BINDING 0
284 END
285 CLEAR_COLOR variant_pipeline 0 0 0 255
286
287 CLEAR variant_pipeline
288 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
289
290 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255