Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-loop-condition-clamp-vec-of-ones.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 # Optimized using spirv-opt with the following arguments:
25 # '--scalar-replacement=100'
26 # '--eliminate-dead-inserts'
27 # '--eliminate-local-multi-store'
28 # '--convert-local-access-chains'
29 # '--eliminate-dead-branches'
30 # '--merge-blocks'
31 # '--eliminate-dead-branches'
32 # '--eliminate-dead-branches'
33 # '--merge-blocks'
34 # '--scalar-replacement=100'
35 # '--eliminate-dead-branches'
36 # '--merge-blocks'
37 # '--ccp'
38 # '--eliminate-local-single-store'
39 # '--scalar-replacement=100'
40 # '--convert-local-access-chains'
41 # '--ccp'
42 # '--reduce-load-size'
43 # '--eliminate-dead-branches'
44 # '--eliminate-local-single-block'
45 # '--redundancy-elimination'
46 # '--combine-access-chains'
47 # '--ccp'
48 # '--inline-entry-points-exhaustive'
49 # '--scalar-replacement=100'
50 # '--ccp'
51 # spirv-opt commit hash: a0370efd589be33d5d9a85cfde2f85841b3755af
52
53
54
55 SHADER vertex variant_vertex_shader PASSTHROUGH
56
57 # variant_fragment_shader is derived from the following GLSL:
58 # #version 320 es
59 # #define _int_1 _GLF_uniform_int_values[0]
60 # #define _int_0 _GLF_uniform_int_values[1]
61 # #define _float_1_0 _GLF_uniform_float_values[0]
62 # #define _float_0_5 _GLF_uniform_float_values[1]
63 #
64 # precision highp float;
65 # precision highp int;
66 #
67 # // Contents of _GLF_uniform_int_values: [1, 0]
68 # layout(set = 0, binding = 0) uniform buf0
69 # {
70 #     int _GLF_uniform_int_values[2];
71 # };
72 #
73 # // Contents of _GLF_uniform_float_values: [1.0, 0.5]
74 # layout(set = 0, binding = 1) uniform buf1
75 # {
76 #     float _GLF_uniform_float_values[2];
77 # };
78 #
79 # // Contents of one: [1.0, 1.0]
80 # layout(set = 0, binding = 2) uniform buf2
81 # {
82 #     vec2 one;
83 # };
84 #
85 # layout(location = 0) out vec4 _GLF_color;
86 #
87 # void main()
88 # {
89 #     float f = _float_1_0;
90 #
91 #     // Iterated once.
92 #     do
93 #     {
94 #         // Iterated once.
95 #         for (int i = 0; i != clamp(_int_0, int(one.x), 2); i++)
96 #         {
97 #             // Always chooses 2.0, thus f becomes 0.5.
98 #             f /= one.y > _float_1_0 ? 256.0 : 2.0;
99 #         }
100 #     }
101 #     while(_float_1_0 > one.y);
102 #
103 #     // Always true.
104 #     if (f > _float_0_5 - 0.01 && f < _float_0_5 + 0.01)
105 #     {
106 #         _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
107 #     }
108 #     else
109 #     {
110 #         _GLF_color = vec4(_int_0);
111 #     }
112 # }
113 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
114 ; SPIR-V
115 ; Version: 1.0
116 ; Generator: Khronos Glslang Reference Front End; 10
117 ; Bound: 110
118 ; Schema: 0
119                OpCapability Shader
120           %1 = OpExtInstImport "GLSL.std.450"
121                OpMemoryModel Logical GLSL450
122                OpEntryPoint Fragment %4 "main" %88
123                OpExecutionMode %4 OriginUpperLeft
124                OpSource ESSL 320
125                OpName %4 "main"
126                OpName %8 "f"
127                OpName %12 "buf1"
128                OpMemberName %12 0 "_GLF_uniform_float_values"
129                OpName %14 ""
130                OpName %25 "i"
131                OpName %33 "buf0"
132                OpMemberName %33 0 "_GLF_uniform_int_values"
133                OpName %35 ""
134                OpName %41 "buf2"
135                OpMemberName %41 0 "one"
136                OpName %43 ""
137                OpName %88 "_GLF_color"
138                OpDecorate %11 ArrayStride 16
139                OpMemberDecorate %12 0 Offset 0
140                OpDecorate %12 Block
141                OpDecorate %14 DescriptorSet 0
142                OpDecorate %14 Binding 1
143                OpDecorate %32 ArrayStride 16
144                OpMemberDecorate %33 0 Offset 0
145                OpDecorate %33 Block
146                OpDecorate %35 DescriptorSet 0
147                OpDecorate %35 Binding 0
148                OpMemberDecorate %41 0 Offset 0
149                OpDecorate %41 Block
150                OpDecorate %43 DescriptorSet 0
151                OpDecorate %43 Binding 2
152                OpDecorate %88 Location 0
153           %2 = OpTypeVoid
154           %3 = OpTypeFunction %2
155           %6 = OpTypeFloat 32
156           %7 = OpTypePointer Function %6
157           %9 = OpTypeInt 32 0
158          %10 = OpConstant %9 2
159          %11 = OpTypeArray %6 %10
160          %12 = OpTypeStruct %11
161          %13 = OpTypePointer Uniform %12
162          %14 = OpVariable %13 Uniform
163          %15 = OpTypeInt 32 1
164          %16 = OpConstant %15 0
165          %17 = OpTypePointer Uniform %6
166          %24 = OpTypePointer Function %15
167          %32 = OpTypeArray %15 %10
168          %33 = OpTypeStruct %32
169          %34 = OpTypePointer Uniform %33
170          %35 = OpVariable %34 Uniform
171          %36 = OpConstant %15 1
172          %37 = OpTypePointer Uniform %15
173          %40 = OpTypeVector %6 2
174          %41 = OpTypeStruct %40
175          %42 = OpTypePointer Uniform %41
176          %43 = OpVariable %42 Uniform
177          %44 = OpConstant %9 0
178          %48 = OpConstant %15 2
179          %50 = OpTypeBool
180          %52 = OpConstant %9 1
181          %58 = OpConstant %6 256
182          %59 = OpConstant %6 2
183          %73 = OpConstant %6 0.00999999978
184          %86 = OpTypeVector %6 4
185          %87 = OpTypePointer Output %86
186          %88 = OpVariable %87 Output
187           %4 = OpFunction %2 None %3
188           %5 = OpLabel
189           %8 = OpVariable %7 Function
190          %25 = OpVariable %24 Function
191          %18 = OpAccessChain %17 %14 %16 %16
192          %19 = OpLoad %6 %18
193                OpStore %8 %19
194                OpBranch %20
195          %20 = OpLabel
196         %109 = OpPhi %6 %19 %5 %108 %23
197                OpStore %25 %16
198                OpLoopMerge %22 %23 None
199                OpBranch %26
200          %26 = OpLabel
201         %108 = OpPhi %6 %109 %20 %62 %27
202         %107 = OpPhi %15 %16 %20 %64 %27
203          %38 = OpAccessChain %37 %35 %16 %36
204          %39 = OpLoad %15 %38
205          %45 = OpAccessChain %17 %43 %16 %44
206          %46 = OpLoad %6 %45
207          %47 = OpConvertFToS %15 %46
208          %49 = OpExtInst %15 %1 SClamp %39 %47 %48
209          %51 = OpINotEqual %50 %107 %49
210                OpLoopMerge %28 %27 None
211                OpBranchConditional %51 %27 %28
212          %27 = OpLabel
213          %53 = OpAccessChain %17 %43 %16 %52
214          %54 = OpLoad %6 %53
215          %57 = OpFOrdGreaterThan %50 %54 %19
216          %60 = OpSelect %6 %57 %58 %59
217          %62 = OpFDiv %6 %108 %60
218                OpStore %8 %62
219          %64 = OpIAdd %15 %107 %36
220                OpStore %25 %64
221                OpBranch %26
222          %28 = OpLabel
223                OpBranch %23
224          %23 = OpLabel
225          %67 = OpAccessChain %17 %43 %16 %52
226          %68 = OpLoad %6 %67
227          %69 = OpFOrdGreaterThan %50 %19 %68
228                OpBranchConditional %69 %20 %22
229          %22 = OpLabel
230          %71 = OpAccessChain %17 %14 %16 %36
231          %72 = OpLoad %6 %71
232          %74 = OpFSub %6 %72 %73
233          %75 = OpFOrdGreaterThan %50 %108 %74
234                OpSelectionMerge %77 None
235                OpBranchConditional %75 %76 %77
236          %76 = OpLabel
237          %81 = OpFAdd %6 %72 %73
238          %82 = OpFOrdLessThan %50 %108 %81
239                OpBranch %77
240          %77 = OpLabel
241          %83 = OpPhi %50 %75 %22 %82 %76
242                OpSelectionMerge %85 None
243                OpBranchConditional %83 %84 %102
244          %84 = OpLabel
245          %89 = OpAccessChain %37 %35 %16 %16
246          %90 = OpLoad %15 %89
247          %91 = OpConvertSToF %6 %90
248          %94 = OpConvertSToF %6 %39
249         %101 = OpCompositeConstruct %86 %91 %94 %94 %91
250                OpStore %88 %101
251                OpBranch %85
252         %102 = OpLabel
253         %105 = OpConvertSToF %6 %39
254         %106 = OpCompositeConstruct %86 %105 %105 %105 %105
255                OpStore %88 %106
256                OpBranch %85
257          %85 = OpLabel
258                OpReturn
259                OpFunctionEnd
260 END
261
262 # uniforms for variant
263
264 # one
265 BUFFER variant_one DATA_TYPE vec2<float> STD140 DATA
266  1.0 1.0
267 END
268 # _GLF_uniform_float_values
269 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
270  1.0 0.5
271 END
272 # _GLF_uniform_int_values
273 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
274  1 0
275 END
276
277 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
278
279 PIPELINE graphics variant_pipeline
280   ATTACH variant_vertex_shader
281   ATTACH variant_fragment_shader
282   FRAMEBUFFER_SIZE 256 256
283   BIND BUFFER variant_framebuffer AS color LOCATION 0
284   BIND BUFFER variant_one AS uniform DESCRIPTOR_SET 0 BINDING 2
285   BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
286   BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
287 END
288 CLEAR_COLOR variant_pipeline 0 0 0 255
289
290 CLEAR variant_pipeline
291 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
292
293 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255