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