Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cosh-return-inf-unused.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 bug found by GraphicsFuzz.
19
20 # Short description: Cosh returns inf for one component which is never used
21
22 # The test passes because 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 # precision highp float;
29 # precision highp int;
30 #
31 # layout(location = 0) out vec4 _GLF_color;
32 #
33 # layout(set = 0, binding = 0) uniform buf0
34 # {
35 #     float zero;
36 # };
37 #
38 # // Returns 3.0 if b > 1, otherwise returns 5.0.
39 # float func(int b)
40 # {
41 #     for (int ndx = 0; ndx < 2; ndx++)
42 #     {
43 #         // Always false.
44 #         if (gl_FragCoord.x < 0.0)
45 #         {
46 #             for (int i = 0; i < 2; i++)
47 #             {
48 #                 // Always false.
49 #                 if (int(cosh(vec2(1, 800)).x) <= 1)
50 #                     discard;
51 #             }
52 #         }
53 #     }
54 #
55 #     if (b > 1)
56 #         return 3.0;
57 #
58 #     // Always false.
59 #     if (gl_FragCoord.x < 0.0)
60 #         _GLF_color = vec4(0);
61 #
62 #     return 5.0;
63 # }
64 #
65 # void main()
66 # {
67 #     _GLF_color = vec4(1);
68 #     float f = 0.0;
69 #
70 #     do
71 #     {
72 #         // Always false.
73 #         if (int(_GLF_color.y) < 0)
74 #             discard;
75 #         else
76 #             f = func(int(zero)); // f == 5.0
77 #
78 #         // Always false.
79 #         if (int(_GLF_color.y) > 65)
80 #             discard;
81 #
82 #         for (int x = 0; x < int(zero) + 1; x++)
83 #         {
84 #             f = func(x + 10); // f == 3.0
85 #         }
86 #
87 #     } while (int(zero) > 1); // Always false.
88 #
89 #     if (f == 3.0)
90 #         _GLF_color = vec4(1, 0, 0, 1);
91 #     else
92 #         _GLF_color = vec4(0);
93 # }
94 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
95 ; SPIR-V
96 ; Version: 1.0
97 ; Generator: Khronos Glslang Reference Front End; 8
98 ; Bound: 140
99 ; Schema: 0
100                OpCapability Shader
101           %1 = OpExtInstImport "GLSL.std.450"
102                OpMemoryModel Logical GLSL450
103                OpEntryPoint Fragment %4 "main" %26 %72
104                OpExecutionMode %4 OriginUpperLeft
105                OpSource ESSL 310
106                OpName %4 "main"
107                OpName %11 "func(i1;"
108                OpName %10 "b"
109                OpName %13 "ndx"
110                OpName %26 "gl_FragCoord"
111                OpName %36 "i"
112                OpName %72 "_GLF_color"
113                OpName %79 "f"
114                OpName %94 "buf0"
115                OpMemberName %94 0 "zero"
116                OpName %96 ""
117                OpName %101 "param"
118                OpName %111 "x"
119                OpName %126 "param"
120                OpDecorate %26 BuiltIn FragCoord
121                OpDecorate %72 Location 0
122                OpMemberDecorate %94 0 Offset 0
123                OpDecorate %94 Block
124                OpDecorate %96 DescriptorSet 0
125                OpDecorate %96 Binding 0
126           %2 = OpTypeVoid
127           %3 = OpTypeFunction %2
128           %6 = OpTypeInt 32 1
129           %7 = OpTypePointer Function %6
130           %8 = OpTypeFloat 32
131           %9 = OpTypeFunction %8 %7
132          %14 = OpConstant %6 0
133          %21 = OpConstant %6 2
134          %22 = OpTypeBool
135          %24 = OpTypeVector %8 4
136          %25 = OpTypePointer Input %24
137          %26 = OpVariable %25 Input
138          %27 = OpTypeInt 32 0
139          %28 = OpConstant %27 0
140          %29 = OpTypePointer Input %8
141          %32 = OpConstant %8 0
142          %44 = OpTypeVector %8 2
143          %45 = OpConstant %8 1
144          %46 = OpConstant %8 800
145          %47 = OpConstantComposite %44 %45 %46
146          %51 = OpConstant %6 1
147          %64 = OpConstant %8 3
148          %71 = OpTypePointer Output %24
149          %72 = OpVariable %71 Output
150          %73 = OpConstantComposite %24 %32 %32 %32 %32
151          %74 = OpConstant %8 5
152          %77 = OpConstantComposite %24 %45 %45 %45 %45
153          %78 = OpTypePointer Function %8
154          %84 = OpConstant %27 1
155          %85 = OpTypePointer Output %8
156          %94 = OpTypeStruct %8
157          %95 = OpTypePointer Uniform %94
158          %96 = OpVariable %95 Uniform
159          %97 = OpTypePointer Uniform %8
160         %106 = OpConstant %6 65
161         %124 = OpConstant %6 10
162         %138 = OpConstantComposite %24 %45 %32 %32 %45
163           %4 = OpFunction %2 None %3
164           %5 = OpLabel
165          %79 = OpVariable %78 Function
166         %101 = OpVariable %7 Function
167         %111 = OpVariable %7 Function
168         %126 = OpVariable %7 Function
169                OpStore %72 %77
170                OpStore %79 %32
171                OpBranch %80
172          %80 = OpLabel
173                OpLoopMerge %82 %83 None
174                OpBranch %81
175          %81 = OpLabel
176          %86 = OpAccessChain %85 %72 %84
177          %87 = OpLoad %8 %86
178          %88 = OpConvertFToS %6 %87
179          %89 = OpSLessThan %22 %88 %14
180                OpSelectionMerge %91 None
181                OpBranchConditional %89 %90 %93
182          %90 = OpLabel
183                OpKill
184          %93 = OpLabel
185          %98 = OpAccessChain %97 %96 %14
186          %99 = OpLoad %8 %98
187         %100 = OpConvertFToS %6 %99
188                OpStore %101 %100
189         %102 = OpFunctionCall %8 %11 %101
190                OpStore %79 %102
191                OpBranch %91
192          %91 = OpLabel
193         %103 = OpAccessChain %85 %72 %84
194         %104 = OpLoad %8 %103
195         %105 = OpConvertFToS %6 %104
196         %107 = OpSGreaterThan %22 %105 %106
197                OpSelectionMerge %109 None
198                OpBranchConditional %107 %108 %109
199         %108 = OpLabel
200                OpKill
201         %109 = OpLabel
202                OpStore %111 %14
203                OpBranch %112
204         %112 = OpLabel
205                OpLoopMerge %114 %115 None
206                OpBranch %116
207         %116 = OpLabel
208         %117 = OpLoad %6 %111
209         %118 = OpAccessChain %97 %96 %14
210         %119 = OpLoad %8 %118
211         %120 = OpConvertFToS %6 %119
212         %121 = OpIAdd %6 %120 %51
213         %122 = OpSLessThan %22 %117 %121
214                OpBranchConditional %122 %113 %114
215         %113 = OpLabel
216         %123 = OpLoad %6 %111
217         %125 = OpIAdd %6 %123 %124
218                OpStore %126 %125
219         %127 = OpFunctionCall %8 %11 %126
220                OpStore %79 %127
221                OpBranch %115
222         %115 = OpLabel
223         %128 = OpLoad %6 %111
224         %129 = OpIAdd %6 %128 %51
225                OpStore %111 %129
226                OpBranch %112
227         %114 = OpLabel
228                OpBranch %83
229          %83 = OpLabel
230         %130 = OpAccessChain %97 %96 %14
231         %131 = OpLoad %8 %130
232         %132 = OpConvertFToS %6 %131
233         %133 = OpSGreaterThan %22 %132 %51
234                OpBranchConditional %133 %80 %82
235          %82 = OpLabel
236         %134 = OpLoad %8 %79
237         %135 = OpFOrdEqual %22 %134 %64
238                OpSelectionMerge %137 None
239                OpBranchConditional %135 %136 %139
240         %136 = OpLabel
241                OpStore %72 %138
242                OpBranch %137
243         %139 = OpLabel
244                OpStore %72 %73
245                OpBranch %137
246         %137 = OpLabel
247                OpReturn
248                OpFunctionEnd
249          %11 = OpFunction %8 None %9
250          %10 = OpFunctionParameter %7
251          %12 = OpLabel
252          %13 = OpVariable %7 Function
253          %36 = OpVariable %7 Function
254                OpStore %13 %14
255                OpBranch %15
256          %15 = OpLabel
257                OpLoopMerge %17 %18 None
258                OpBranch %19
259          %19 = OpLabel
260          %20 = OpLoad %6 %13
261          %23 = OpSLessThan %22 %20 %21
262                OpBranchConditional %23 %16 %17
263          %16 = OpLabel
264          %30 = OpAccessChain %29 %26 %28
265          %31 = OpLoad %8 %30
266          %33 = OpFOrdLessThan %22 %31 %32
267                OpSelectionMerge %35 None
268                OpBranchConditional %33 %34 %35
269          %34 = OpLabel
270                OpStore %36 %14
271                OpBranch %37
272          %37 = OpLabel
273                OpLoopMerge %39 %40 None
274                OpBranch %41
275          %41 = OpLabel
276          %42 = OpLoad %6 %36
277          %43 = OpSLessThan %22 %42 %21
278                OpBranchConditional %43 %38 %39
279          %38 = OpLabel
280          %48 = OpExtInst %44 %1 Cosh %47
281          %49 = OpCompositeExtract %8 %48 0
282          %50 = OpConvertFToS %6 %49
283          %52 = OpSLessThanEqual %22 %50 %51
284                OpSelectionMerge %54 None
285                OpBranchConditional %52 %53 %54
286          %53 = OpLabel
287                OpKill
288          %54 = OpLabel
289                OpBranch %40
290          %40 = OpLabel
291          %56 = OpLoad %6 %36
292          %57 = OpIAdd %6 %56 %51
293                OpStore %36 %57
294                OpBranch %37
295          %39 = OpLabel
296                OpBranch %35
297          %35 = OpLabel
298                OpBranch %18
299          %18 = OpLabel
300          %58 = OpLoad %6 %13
301          %59 = OpIAdd %6 %58 %51
302                OpStore %13 %59
303                OpBranch %15
304          %17 = OpLabel
305          %60 = OpLoad %6 %10
306          %61 = OpSGreaterThan %22 %60 %51
307                OpSelectionMerge %63 None
308                OpBranchConditional %61 %62 %63
309          %62 = OpLabel
310                OpReturnValue %64
311          %63 = OpLabel
312          %66 = OpAccessChain %29 %26 %28
313          %67 = OpLoad %8 %66
314          %68 = OpFOrdLessThan %22 %67 %32
315                OpSelectionMerge %70 None
316                OpBranchConditional %68 %69 %70
317          %69 = OpLabel
318                OpStore %72 %73
319                OpBranch %70
320          %70 = OpLabel
321                OpReturnValue %74
322                OpFunctionEnd
323 END
324
325 # uniforms for variant
326
327 # zero
328 BUFFER variant_zero DATA_TYPE float DATA
329  0.0
330 END
331
332 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
333
334 PIPELINE graphics variant_pipeline
335   ATTACH variant_vertex_shader
336   ATTACH variant_fragment_shader
337   FRAMEBUFFER_SIZE 256 256
338   BIND BUFFER variant_framebuffer AS color LOCATION 0
339   BIND BUFFER variant_zero AS uniform DESCRIPTOR_SET 0 BINDING 0
340 END
341 CLEAR_COLOR variant_pipeline 0 0 0 255
342
343 CLEAR variant_pipeline
344 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
345
346 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255