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