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