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