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