Fix missing dependency on sparse binds
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / spv-stable-sampler-polar-simple-O-access-chain.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 bug found by the GraphicsFuzz project.
19
20 # Short description: Equivalent shaders, one with an additional access chain
21
22 # The test passes because both shaders render the same image.
23
24 SHADER vertex texgen_vert PASSTHROUGH
25
26 SHADER fragment texgen_frag GLSL
27 #version 430
28 precision highp float;
29
30 layout(location = 0) out vec4 _GLF_color;
31
32 void main()
33 {
34  _GLF_color = vec4(
35  floor(gl_FragCoord.x) * (1.0 / 255.0),
36  (int(gl_FragCoord.x) ^ int(gl_FragCoord.y)) * (1.0 / 255.0),
37  floor(gl_FragCoord.y) * (1.0 / 255.0),
38  1.0);
39 }
40 END
41 BUFFER default_texture FORMAT B8G8R8A8_UNORM
42
43 PIPELINE graphics texgen_pipeline
44   ATTACH texgen_vert
45   ATTACH texgen_frag
46   FRAMEBUFFER_SIZE 256 256
47   BIND BUFFER default_texture AS color LOCATION 0
48 END
49
50 CLEAR_COLOR texgen_pipeline 0 0 0 255
51 CLEAR texgen_pipeline
52 RUN texgen_pipeline DRAW_RECT POS 0 0  SIZE 256 256
53
54 SHADER vertex reference_vertex_shader PASSTHROUGH
55
56 SHADER fragment reference_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
57 ; SPIR-V
58 ; Version: 1.0
59 ; Generator: Khronos Glslang Reference Front End; 10
60 ; Bound: 254
61 ; Schema: 0
62                OpCapability Shader
63           %1 = OpExtInstImport "GLSL.std.450"
64                OpMemoryModel Logical GLSL450
65                OpEntryPoint Fragment %4 "main" %115 %130
66                OpExecutionMode %4 OriginUpperLeft
67                OpSource ESSL 320
68                OpName %4 "main"
69                OpName %115 "gl_FragCoord"
70                OpName %130 "_GLF_color"
71                OpName %134 "tex"
72                OpDecorate %115 BuiltIn FragCoord
73                OpDecorate %130 Location 0
74                OpDecorate %134 RelaxedPrecision
75                OpDecorate %134 DescriptorSet 0
76                OpDecorate %134 Binding 0
77                OpDecorate %135 RelaxedPrecision
78                OpDecorate %137 RelaxedPrecision
79           %2 = OpTypeVoid
80           %3 = OpTypeFunction %2
81           %6 = OpTypeFloat 32
82           %7 = OpTypeVector %6 2
83          %19 = OpConstant %6 0.318309873
84          %22 = OpConstant %6 0.00100000005
85          %23 = OpTypeBool
86          %27 = OpConstant %6 0
87          %32 = OpTypeInt 32 0
88          %36 = OpConstant %32 0
89          %55 = OpConstant %6 0.970000029
90          %56 = OpConstant %6 0.189999998
91          %73 = OpConstant %6 0.5
92          %81 = OpConstant %6 1
93          %98 = OpConstantComposite %7 %73 %73
94         %113 = OpTypeVector %6 4
95         %114 = OpTypePointer Input %113
96         %115 = OpVariable %114 Input
97         %118 = OpConstant %6 0.00390625
98         %124 = OpConstant %6 256
99         %129 = OpTypePointer Output %113
100         %130 = OpVariable %129 Output
101         %131 = OpTypeImage %6 2D 0 0 0 1 Unknown
102         %132 = OpTypeSampledImage %131
103         %133 = OpTypePointer UniformConstant %132
104         %134 = OpVariable %133 UniformConstant
105         %253 = OpConstantComposite %7 %118 %118
106           %4 = OpFunction %2 None %3
107           %5 = OpLabel
108         %116 = OpLoad %113 %115
109         %117 = OpVectorShuffle %7 %116 %116 0 1
110         %119 = OpVectorTimesScalar %7 %117 %118
111         %160 = OpFSub %7 %119 %98
112         %162 = OpExtInst %6 %1 Length %160
113                OpSelectionMerge %235 None
114                OpSwitch %36 %176
115         %176 = OpLabel
116         %179 = OpFOrdLessThan %23 %162 %22
117                OpSelectionMerge %181 None
118                OpBranchConditional %179 %180 %181
119         %180 = OpLabel
120                OpBranch %235
121         %181 = OpLabel
122         %183 = OpExtInst %7 %1 FAbs %160
123         %185 = OpCompositeExtract %6 %183 1
124         %187 = OpCompositeExtract %6 %183 0
125         %188 = OpFOrdGreaterThan %23 %185 %187
126                OpSelectionMerge %201 None
127                OpBranchConditional %188 %189 %195
128         %189 = OpLabel
129         %194 = OpFDiv %6 %187 %185
130                OpBranch %201
131         %195 = OpLabel
132         %200 = OpFDiv %6 %185 %187
133                OpBranch %201
134         %201 = OpLabel
135         %247 = OpPhi %6 %194 %189 %200 %195
136         %203 = OpFMul %6 %56 %247
137         %205 = OpFMul %6 %203 %247
138         %206 = OpFSub %6 %55 %205
139         %208 = OpFMul %6 %206 %247
140         %210 = OpFMul %6 %208 %19
141         %215 = OpFOrdLessThan %23 %185 %187
142                OpSelectionMerge %219 None
143                OpBranchConditional %215 %216 %219
144         %216 = OpLabel
145         %218 = OpFSub %6 %73 %210
146                OpBranch %219
147         %219 = OpLabel
148         %248 = OpPhi %6 %210 %201 %218 %216
149         %221 = OpCompositeExtract %6 %160 0
150         %222 = OpFOrdLessThan %23 %221 %27
151                OpSelectionMerge %226 None
152                OpBranchConditional %222 %223 %226
153         %223 = OpLabel
154         %225 = OpFSub %6 %81 %248
155                OpBranch %226
156         %226 = OpLabel
157         %249 = OpPhi %6 %248 %219 %225 %223
158         %228 = OpCompositeExtract %6 %160 1
159         %229 = OpFOrdLessThan %23 %228 %27
160                OpSelectionMerge %233 None
161                OpBranchConditional %229 %230 %233
162         %230 = OpLabel
163         %232 = OpFNegate %6 %249
164                OpBranch %233
165         %233 = OpLabel
166         %250 = OpPhi %6 %249 %226 %232 %230
167                OpBranch %235
168         %235 = OpLabel
169         %251 = OpPhi %6 %27 %180 %250 %233
170         %167 = OpCompositeConstruct %7 %162 %251
171         %125 = OpVectorTimesScalar %7 %167 %124
172         %126 = OpExtInst %7 %1 Floor %125
173         %128 = OpFMul %7 %126 %253
174         %135 = OpLoad %132 %134
175         %137 = OpImageSampleImplicitLod %113 %135 %128
176         %140 = OpCompositeExtract %6 %137 0
177         %141 = OpCompositeExtract %6 %137 1
178         %142 = OpCompositeExtract %6 %137 2
179         %143 = OpCompositeConstruct %113 %140 %141 %142 %81
180                OpStore %130 %143
181                OpReturn
182                OpFunctionEnd
183 END
184
185 # uniforms for reference
186
187 # tex
188 SAMPLER reference_tex
189
190
191 BUFFER reference_framebuffer FORMAT B8G8R8A8_UNORM
192
193 PIPELINE graphics reference_pipeline
194   ATTACH reference_vertex_shader
195   ATTACH reference_fragment_shader
196   FRAMEBUFFER_SIZE 256 256
197   BIND BUFFER reference_framebuffer AS color LOCATION 0
198   BIND BUFFER default_texture AS combined_image_sampler SAMPLER reference_tex DESCRIPTOR_SET 0 BINDING 0
199 END
200 CLEAR_COLOR reference_pipeline 0 0 0 255
201
202 CLEAR reference_pipeline
203 RUN reference_pipeline DRAW_RECT POS 0 0 SIZE 256 256
204
205
206 SHADER vertex variant_vertex_shader PASSTHROUGH
207
208 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
209 ; SPIR-V
210 ; Version: 1.0
211 ; Generator: Khronos Glslang Reference Front End; 10
212 ; Bound: 529
213 ; Schema: 0
214                OpCapability Shader
215           %1 = OpExtInstImport "GLSL.std.450"
216                OpMemoryModel Logical GLSL450
217                OpEntryPoint Fragment %4 "main" %115 %130
218                OpExecutionMode %4 OriginUpperLeft
219                OpSource ESSL 320
220                OpName %4 "main"
221                OpName %115 "gl_FragCoord"
222                OpName %130 "_GLF_color"
223                OpName %134 "tex"
224                OpDecorate %115 BuiltIn FragCoord
225                OpDecorate %130 Location 0
226                OpDecorate %134 RelaxedPrecision
227                OpDecorate %134 DescriptorSet 0
228                OpDecorate %134 Binding 0
229                OpDecorate %135 RelaxedPrecision
230                OpDecorate %137 RelaxedPrecision
231           %2 = OpTypeVoid
232           %3 = OpTypeFunction %2
233           %6 = OpTypeFloat 32
234           %7 = OpTypeVector %6 2
235          %19 = OpConstant %6 0.318309873
236          %22 = OpConstant %6 0.00100000005
237          %23 = OpTypeBool
238          %27 = OpConstant %6 0
239          %32 = OpTypeInt 32 0
240          %36 = OpConstant %32 0
241          %55 = OpConstant %6 0.970000029
242          %56 = OpConstant %6 0.189999998
243          %73 = OpConstant %6 0.5
244          %81 = OpConstant %6 1
245          %98 = OpConstantComposite %7 %73 %73
246         %113 = OpTypeVector %6 4
247         %114 = OpTypePointer Input %113
248         %115 = OpVariable %114 Input
249         %118 = OpConstant %6 0.00390625
250         %124 = OpConstant %6 256
251         %129 = OpTypePointer Output %113
252         %130 = OpVariable %129 Output
253         %131 = OpTypeImage %6 2D 0 0 0 1 Unknown
254         %132 = OpTypeSampledImage %131
255         %133 = OpTypePointer UniformConstant %132
256         %134 = OpVariable %133 UniformConstant
257         %253 = OpConstantComposite %7 %118 %118
258         %379 = OpTypeInt 32 1
259         %380 = OpConstant %379 3
260         %383 = OpConstant %379 0
261         %384 = OpTypePointer Input %6
262         %475 = OpConstantFalse %23
263         %526 = OpTypePointer Function %23
264           %4 = OpFunction %2 None %3
265           %5 = OpLabel
266         %527 = OpVariable %526 Function %475
267         %116 = OpLoad %113 %115
268         %117 = OpVectorShuffle %7 %116 %116 0 1
269         %119 = OpVectorTimesScalar %7 %117 %118
270         %160 = OpFSub %7 %119 %98
271         %162 = OpExtInst %6 %1 Length %160
272                OpSelectionMerge %235 None
273                OpSwitch %36 %176
274         %176 = OpLabel
275         %179 = OpFOrdLessThan %23 %162 %22
276                OpSelectionMerge %181 None
277                OpBranchConditional %179 %180 %181
278         %180 = OpLabel
279                OpBranch %235
280         %181 = OpLabel
281         %183 = OpExtInst %7 %1 FAbs %160
282         %185 = OpCompositeExtract %6 %183 1
283         %187 = OpCompositeExtract %6 %183 0
284         %188 = OpFOrdGreaterThan %23 %185 %187
285                OpSelectionMerge %201 None
286                OpBranchConditional %188 %189 %195
287         %189 = OpLabel
288         %194 = OpFDiv %6 %187 %185
289                OpBranch %201
290         %195 = OpLabel
291         %200 = OpFDiv %6 %185 %187
292                OpBranch %201
293         %201 = OpLabel
294         %247 = OpPhi %6 %194 %189 %200 %195
295         %203 = OpFMul %6 %56 %247
296         %205 = OpFMul %6 %203 %247
297         %206 = OpFSub %6 %55 %205
298         %208 = OpFMul %6 %206 %247
299         %210 = OpFMul %6 %208 %19
300         %215 = OpFOrdLessThan %23 %185 %187
301                OpSelectionMerge %219 None
302                OpBranchConditional %215 %216 %219
303         %216 = OpLabel
304         %218 = OpFSub %6 %73 %210
305                OpBranch %219
306         %219 = OpLabel
307         %248 = OpPhi %6 %210 %201 %218 %216
308         %221 = OpCompositeExtract %6 %160 0
309         %222 = OpFOrdLessThan %23 %221 %27
310                OpSelectionMerge %226 None
311                OpBranchConditional %222 %223 %226
312         %223 = OpLabel
313         %225 = OpFSub %6 %81 %248
314                OpBranch %226
315         %226 = OpLabel
316         %249 = OpPhi %6 %248 %219 %225 %223
317         %228 = OpCompositeExtract %6 %160 1
318         %229 = OpFOrdLessThan %23 %228 %27
319                OpSelectionMerge %233 None
320                OpBranchConditional %229 %230 %233
321         %230 = OpLabel
322         %232 = OpFNegate %6 %249
323                OpBranch %233
324         %233 = OpLabel
325         %250 = OpPhi %6 %249 %226 %232 %230
326                OpBranch %235
327         %235 = OpLabel
328         %251 = OpPhi %6 %27 %180 %250 %233
329         %167 = OpCompositeConstruct %7 %162 %251
330         %125 = OpVectorTimesScalar %7 %167 %124
331         %126 = OpExtInst %7 %1 Floor %125
332         %128 = OpFMul %7 %126 %253
333         %135 = OpLoad %132 %134
334         %137 = OpImageSampleImplicitLod %113 %135 %128
335         %140 = OpCompositeExtract %6 %137 0
336         %141 = OpCompositeExtract %6 %137 1
337         %142 = OpCompositeExtract %6 %137 2
338                OpStore %527 %179
339         %528 = OpLoad %23 %527
340         %381 = OpULessThanEqual %23 %383 %380
341         %382 = OpSelect %379 %381 %383 %380
342         %385 = OpAccessChain %384 %115 %382
343         %143 = OpCompositeConstruct %113 %140 %141 %142 %81
344                OpStore %130 %143
345                OpReturn
346                OpFunctionEnd
347 END
348
349 # uniforms for variant
350
351 # tex
352 SAMPLER variant_tex
353
354
355 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
356
357 PIPELINE graphics variant_pipeline
358   ATTACH variant_vertex_shader
359   ATTACH variant_fragment_shader
360   FRAMEBUFFER_SIZE 256 256
361   BIND BUFFER variant_framebuffer AS color LOCATION 0
362   BIND BUFFER default_texture AS combined_image_sampler SAMPLER variant_tex DESCRIPTOR_SET 0 BINDING 0
363 END
364 CLEAR_COLOR variant_pipeline 0 0 0 255
365
366 CLEAR variant_pipeline
367 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
368
369 EXPECT reference_framebuffer EQ_HISTOGRAM_EMD_BUFFER variant_framebuffer TOLERANCE 0.005