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