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