Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-machine-scheduler-for-if-pow.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 a specific machine scheduler path
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 310 es
28 # #define _int_10 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
30 # #define _float_0_0 _GLF_uniform_float_values[0]
31 # #define _float_4_0 _GLF_uniform_float_values[1]
32 # #define _float_1_0 _GLF_uniform_float_values[2]
33 # #define _float_2_0 _GLF_uniform_float_values[3]
34 #
35 # precision highp float;
36 #
37 # // Contents of _GLF_uniform_int_values: [10, 0]
38 # layout(set = 0, binding = 0) uniform buf0
39 # {
40 #     int _GLF_uniform_int_values[2];
41 # };
42 #
43 # // Contents of _GLF_uniform_float_values: [0.0, 4.0, 1.0, 2.0]
44 # layout(set = 0, binding = 1) uniform buf1
45 # {
46 #     float _GLF_uniform_float_values[4];
47 # };
48 #
49 # layout(location = 0) out vec4 _GLF_v1;
50 #
51 # void main()
52 # {
53 #     vec2 uv = gl_FragCoord.xy;
54 #     vec4 v1 = vec4(_float_0_0);
55 #     if (uv.y >= _float_0_0)
56 #     {
57 #         v1.x = _float_1_0;
58 #         v1.y = _float_0_0;
59 #         v1.z = _float_0_0;
60 #         v1.w = _float_1_0;
61 #     }
62 #
63 #     float a = _float_1_0;
64 #     for (int i = _int_0; i < _int_10; i++)
65 #     {
66 #         // Always false.
67 #         if (_float_1_0 < _float_0_0)
68 #         {
69 #             discard;
70 #         }
71 #         // a becomes 4.
72 #         a = pow(v1.x + v1.y + v1.z + v1.w, _float_2_0);
73 #     }
74 #
75 #     if (a == _float_4_0)
76 #     {
77 #         _GLF_v1 = v1;
78 #     }
79 #     else
80 #     {
81 #         _GLF_v1 = vec4(_int_0);
82 #     }
83 # }
84 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
85 ; SPIR-V
86 ; Version: 1.0
87 ; Generator: Khronos Glslang Reference Front End; 8
88 ; Bound: 116
89 ; Schema: 0
90                OpCapability Shader
91           %1 = OpExtInstImport "GLSL.std.450"
92                OpMemoryModel Logical GLSL450
93                OpEntryPoint Fragment %4 "main" %12 %109
94                OpExecutionMode %4 OriginUpperLeft
95                OpSource ESSL 310
96                OpName %4 "main"
97                OpName %9 "uv"
98                OpName %12 "gl_FragCoord"
99                OpName %16 "v1"
100                OpName %20 "buf1"
101                OpMemberName %20 0 "_GLF_uniform_float_values"
102                OpName %22 ""
103                OpName %55 "a"
104                OpName %59 "i"
105                OpName %61 "buf0"
106                OpMemberName %61 0 "_GLF_uniform_int_values"
107                OpName %63 ""
108                OpName %109 "_GLF_v1"
109                OpDecorate %12 BuiltIn FragCoord
110                OpDecorate %19 ArrayStride 16
111                OpMemberDecorate %20 0 Offset 0
112                OpDecorate %20 Block
113                OpDecorate %22 DescriptorSet 0
114                OpDecorate %22 Binding 1
115                OpDecorate %59 RelaxedPrecision
116                OpDecorate %60 ArrayStride 16
117                OpMemberDecorate %61 0 RelaxedPrecision
118                OpMemberDecorate %61 0 Offset 0
119                OpDecorate %61 Block
120                OpDecorate %63 DescriptorSet 0
121                OpDecorate %63 Binding 0
122                OpDecorate %67 RelaxedPrecision
123                OpDecorate %73 RelaxedPrecision
124                OpDecorate %75 RelaxedPrecision
125                OpDecorate %100 RelaxedPrecision
126                OpDecorate %101 RelaxedPrecision
127                OpDecorate %109 Location 0
128                OpDecorate %113 RelaxedPrecision
129           %2 = OpTypeVoid
130           %3 = OpTypeFunction %2
131           %6 = OpTypeFloat 32
132           %7 = OpTypeVector %6 2
133           %8 = OpTypePointer Function %7
134          %10 = OpTypeVector %6 4
135          %11 = OpTypePointer Input %10
136          %12 = OpVariable %11 Input
137          %15 = OpTypePointer Function %10
138          %17 = OpTypeInt 32 0
139          %18 = OpConstant %17 4
140          %19 = OpTypeArray %6 %18
141          %20 = OpTypeStruct %19
142          %21 = OpTypePointer Uniform %20
143          %22 = OpVariable %21 Uniform
144          %23 = OpTypeInt 32 1
145          %24 = OpConstant %23 0
146          %25 = OpTypePointer Uniform %6
147          %29 = OpConstant %17 1
148          %30 = OpTypePointer Function %6
149          %35 = OpTypeBool
150          %39 = OpConstant %23 2
151          %42 = OpConstant %17 0
152          %49 = OpConstant %17 2
153          %53 = OpConstant %17 3
154          %58 = OpTypePointer Function %23
155          %60 = OpTypeArray %23 %49
156          %61 = OpTypeStruct %60
157          %62 = OpTypePointer Uniform %61
158          %63 = OpVariable %62 Uniform
159          %64 = OpConstant %23 1
160          %65 = OpTypePointer Uniform %23
161          %96 = OpConstant %23 3
162         %108 = OpTypePointer Output %10
163         %109 = OpVariable %108 Output
164           %4 = OpFunction %2 None %3
165           %5 = OpLabel
166           %9 = OpVariable %8 Function
167          %16 = OpVariable %15 Function
168          %55 = OpVariable %30 Function
169          %59 = OpVariable %58 Function
170          %13 = OpLoad %10 %12
171          %14 = OpVectorShuffle %7 %13 %13 0 1
172                OpStore %9 %14
173          %26 = OpAccessChain %25 %22 %24 %24
174          %27 = OpLoad %6 %26
175          %28 = OpCompositeConstruct %10 %27 %27 %27 %27
176                OpStore %16 %28
177          %31 = OpAccessChain %30 %9 %29
178          %32 = OpLoad %6 %31
179          %33 = OpAccessChain %25 %22 %24 %24
180          %34 = OpLoad %6 %33
181          %36 = OpFOrdGreaterThanEqual %35 %32 %34
182                OpSelectionMerge %38 None
183                OpBranchConditional %36 %37 %38
184          %37 = OpLabel
185          %40 = OpAccessChain %25 %22 %24 %39
186          %41 = OpLoad %6 %40
187          %43 = OpAccessChain %30 %16 %42
188                OpStore %43 %41
189          %44 = OpAccessChain %25 %22 %24 %24
190          %45 = OpLoad %6 %44
191          %46 = OpAccessChain %30 %16 %29
192                OpStore %46 %45
193          %47 = OpAccessChain %25 %22 %24 %24
194          %48 = OpLoad %6 %47
195          %50 = OpAccessChain %30 %16 %49
196                OpStore %50 %48
197          %51 = OpAccessChain %25 %22 %24 %39
198          %52 = OpLoad %6 %51
199          %54 = OpAccessChain %30 %16 %53
200                OpStore %54 %52
201                OpBranch %38
202          %38 = OpLabel
203          %56 = OpAccessChain %25 %22 %24 %39
204          %57 = OpLoad %6 %56
205                OpStore %55 %57
206          %66 = OpAccessChain %65 %63 %24 %64
207          %67 = OpLoad %23 %66
208                OpStore %59 %67
209                OpBranch %68
210          %68 = OpLabel
211                OpLoopMerge %70 %71 None
212                OpBranch %72
213          %72 = OpLabel
214          %73 = OpLoad %23 %59
215          %74 = OpAccessChain %65 %63 %24 %24
216          %75 = OpLoad %23 %74
217          %76 = OpSLessThan %35 %73 %75
218                OpBranchConditional %76 %69 %70
219          %69 = OpLabel
220          %77 = OpAccessChain %25 %22 %24 %39
221          %78 = OpLoad %6 %77
222          %79 = OpAccessChain %25 %22 %24 %24
223          %80 = OpLoad %6 %79
224          %81 = OpFOrdLessThan %35 %78 %80
225                OpSelectionMerge %83 None
226                OpBranchConditional %81 %82 %83
227          %82 = OpLabel
228                OpKill
229          %83 = OpLabel
230          %85 = OpAccessChain %30 %16 %42
231          %86 = OpLoad %6 %85
232          %87 = OpAccessChain %30 %16 %29
233          %88 = OpLoad %6 %87
234          %89 = OpFAdd %6 %86 %88
235          %90 = OpAccessChain %30 %16 %49
236          %91 = OpLoad %6 %90
237          %92 = OpFAdd %6 %89 %91
238          %93 = OpAccessChain %30 %16 %53
239          %94 = OpLoad %6 %93
240          %95 = OpFAdd %6 %92 %94
241          %97 = OpAccessChain %25 %22 %24 %96
242          %98 = OpLoad %6 %97
243          %99 = OpExtInst %6 %1 Pow %95 %98
244                OpStore %55 %99
245                OpBranch %71
246          %71 = OpLabel
247         %100 = OpLoad %23 %59
248         %101 = OpIAdd %23 %100 %64
249                OpStore %59 %101
250                OpBranch %68
251          %70 = OpLabel
252         %102 = OpLoad %6 %55
253         %103 = OpAccessChain %25 %22 %24 %64
254         %104 = OpLoad %6 %103
255         %105 = OpFOrdEqual %35 %102 %104
256                OpSelectionMerge %107 None
257                OpBranchConditional %105 %106 %111
258         %106 = OpLabel
259         %110 = OpLoad %10 %16
260                OpStore %109 %110
261                OpBranch %107
262         %111 = OpLabel
263         %112 = OpAccessChain %65 %63 %24 %64
264         %113 = OpLoad %23 %112
265         %114 = OpConvertSToF %6 %113
266         %115 = OpCompositeConstruct %10 %114 %114 %114 %114
267                OpStore %109 %115
268                OpBranch %107
269         %107 = OpLabel
270                OpReturn
271                OpFunctionEnd
272 END
273
274 # uniforms for variant
275
276 # _GLF_uniform_float_values
277 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
278  0.0 4.0 1.0 2.0
279 END
280 # _GLF_uniform_int_values
281 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
282  10 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__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
293   BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
294 END
295 CLEAR_COLOR variant_pipeline 0 0 0 255
296
297 CLEAR variant_pipeline
298 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
299
300 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255