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