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