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