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