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