3 # Copyright 2020 Google LLC
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 # A test for a bug found by the GraphicsFuzz project.
20 # Short description: Equivalent shaders, one with irrelevant extra instructions
22 # The test passes because both shaders render the same image.
24 SHADER vertex texgen_vert PASSTHROUGH
26 SHADER fragment texgen_frag GLSL
28 precision highp float;
30 layout(location = 0) out vec4 _GLF_color;
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),
41 BUFFER default_texture FORMAT B8G8R8A8_UNORM
43 PIPELINE graphics texgen_pipeline
46 FRAMEBUFFER_SIZE 256 256
47 BIND BUFFER default_texture AS color LOCATION 0
50 CLEAR_COLOR texgen_pipeline 0 0 0 255
52 RUN texgen_pipeline DRAW_RECT POS 0 0 SIZE 256 256
54 SHADER vertex reference_vertex_shader PASSTHROUGH
56 SHADER fragment reference_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
59 ; Generator: Khronos Glslang Reference Front End; 10
63 %1 = OpExtInstImport "GLSL.std.450"
64 OpMemoryModel Logical GLSL450
65 OpEntryPoint Fragment %4 "main" %16 %73
66 OpExecutionMode %4 OriginUpperLeft
71 OpName %16 "gl_FragCoord"
74 OpName %73 "_GLF_color"
75 OpDecorate %8 RelaxedPrecision
76 OpDecorate %16 BuiltIn FragCoord
77 OpDecorate %26 RelaxedPrecision
78 OpDecorate %26 DescriptorSet 0
79 OpDecorate %26 Binding 0
80 OpDecorate %27 RelaxedPrecision
81 OpDecorate %29 RelaxedPrecision
82 OpDecorate %51 RelaxedPrecision
83 OpDecorate %66 RelaxedPrecision
84 OpDecorate %68 RelaxedPrecision
85 OpDecorate %69 RelaxedPrecision
86 OpDecorate %71 RelaxedPrecision
87 OpDecorate %73 Location 0
89 %3 = OpTypeFunction %2
91 %7 = OpTypePointer Function %6
94 %11 = OpTypeVector %10 2
95 %12 = OpTypePointer Function %11
96 %14 = OpTypeVector %10 4
97 %15 = OpTypePointer Input %14
98 %16 = OpVariable %15 Input
99 %19 = OpConstant %10 0.00390625
100 %21 = OpTypePointer Function %14
101 %23 = OpTypeImage %10 2D 0 0 0 1 Unknown
102 %24 = OpTypeSampledImage %23
103 %25 = OpTypePointer UniformConstant %24
104 %26 = OpVariable %25 UniformConstant
106 %36 = OpConstant %35 0
107 %37 = OpTypePointer Function %10
108 %40 = OpConstant %35 1
109 %44 = OpConstant %35 2
110 %48 = OpConstant %10 1
112 %52 = OpConstant %6 16
113 %61 = OpConstant %10 256
114 %70 = OpConstant %6 1
115 %72 = OpTypePointer Output %14
116 %73 = OpVariable %72 Output
117 %4 = OpFunction %2 None %3
119 %8 = OpVariable %7 Function
120 %13 = OpVariable %12 Function
121 %22 = OpVariable %21 Function
124 %18 = OpVectorShuffle %11 %17 %17 0 1
125 %20 = OpVectorTimesScalar %11 %18 %19
129 %29 = OpImageSampleImplicitLod %14 %27 %28
133 OpLoopMerge %32 %33 None
136 %38 = OpAccessChain %37 %22 %36
138 %41 = OpAccessChain %37 %22 %40
140 %43 = OpFAdd %10 %39 %42
141 %45 = OpAccessChain %37 %22 %44
143 %47 = OpFAdd %10 %43 %46
144 %50 = OpFOrdGreaterThan %49 %47 %48
146 %53 = OpSLessThan %49 %51 %52
147 %54 = OpLogicalAnd %49 %50 %53
148 OpBranchConditional %54 %31 %32
151 %56 = OpVectorShuffle %11 %55 %55 0 2
153 %58 = OpVectorShuffle %11 %57 %57 1 1
154 %59 = OpFAdd %11 %56 %58
157 %62 = OpVectorTimesScalar %11 %60 %61
158 %63 = OpExtInst %11 %1 Floor %62
159 %64 = OpCompositeConstruct %11 %61 %61
160 %65 = OpFDiv %11 %63 %64
164 %68 = OpImageSampleImplicitLod %14 %66 %67
167 %71 = OpIAdd %6 %69 %70
179 # uniforms for reference
182 SAMPLER reference_tex
185 BUFFER reference_framebuffer FORMAT B8G8R8A8_UNORM
187 PIPELINE graphics reference_pipeline
188 ATTACH reference_vertex_shader
189 ATTACH reference_fragment_shader
190 FRAMEBUFFER_SIZE 256 256
191 BIND BUFFER reference_framebuffer AS color LOCATION 0
192 BIND BUFFER default_texture AS combined_image_sampler SAMPLER reference_tex DESCRIPTOR_SET 0 BINDING 0
194 CLEAR_COLOR reference_pipeline 0 0 0 255
196 CLEAR reference_pipeline
197 RUN reference_pipeline DRAW_RECT POS 0 0 SIZE 256 256
200 SHADER vertex variant_vertex_shader PASSTHROUGH
202 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
205 ; Generator: Khronos Glslang Reference Front End; 10
209 %1 = OpExtInstImport "GLSL.std.450"
210 OpMemoryModel Logical GLSL450
211 OpEntryPoint Fragment %4 "main" %16 %73
212 OpExecutionMode %4 OriginUpperLeft
217 OpName %16 "gl_FragCoord"
220 OpName %73 "_GLF_color"
221 OpDecorate %8 RelaxedPrecision
222 OpDecorate %16 BuiltIn FragCoord
223 OpDecorate %26 RelaxedPrecision
224 OpDecorate %26 DescriptorSet 0
225 OpDecorate %26 Binding 0
226 OpDecorate %27 RelaxedPrecision
227 OpDecorate %29 RelaxedPrecision
228 OpDecorate %51 RelaxedPrecision
229 OpDecorate %66 RelaxedPrecision
230 OpDecorate %68 RelaxedPrecision
231 OpDecorate %69 RelaxedPrecision
232 OpDecorate %71 RelaxedPrecision
233 OpDecorate %73 Location 0
235 %3 = OpTypeFunction %2
237 %7 = OpTypePointer Function %6
240 %11 = OpTypeVector %10 2
241 %12 = OpTypePointer Function %11
242 %14 = OpTypeVector %10 4
243 %15 = OpTypePointer Input %14
244 %16 = OpVariable %15 Input
245 %19 = OpConstant %10 0.00390625
246 %21 = OpTypePointer Function %14
247 %23 = OpTypeImage %10 2D 0 0 0 1 Unknown
248 %24 = OpTypeSampledImage %23
249 %25 = OpTypePointer UniformConstant %24
250 %26 = OpVariable %25 UniformConstant
252 %36 = OpConstant %35 0
253 %37 = OpTypePointer Function %10
254 %40 = OpConstant %35 1
255 %44 = OpConstant %35 2
256 %48 = OpConstant %10 1
258 %52 = OpConstant %6 16
259 %61 = OpConstant %10 256
260 %70 = OpConstant %6 1
261 %72 = OpTypePointer Output %14
262 %73 = OpVariable %72 Output
263 %178 = OpTypeVector %6 3
264 %179 = OpTypeVector %6 4
265 %180 = OpTypeVector %35 2
266 %181 = OpTypeVector %35 3
267 %182 = OpTypeVector %10 3
268 %183 = OpTypeMatrix %182 2
269 %187 = OpTypeMatrix %14 4
270 %222 = OpConstantComposite %180 %36 %36
271 %225 = OpConstant %10 0
272 %226 = OpConstantComposite %11 %225 %225
273 %231 = OpConstantComposite %14 %225 %225 %225 %225
274 %265 = OpTypeStruct %180 %180
275 %267 = OpTypeStruct %35 %35
276 %279 = OpTypePointer Function %265
277 %280 = OpConstantComposite %265 %222 %222
278 %294 = OpConstant %35 3
279 %323 = OpTypePointer Function %35
280 %4 = OpFunction %2 None %3
282 %293 = OpVariable %12 Function %226
283 %288 = OpVariable %21 Function %231
284 %281 = OpVariable %279 Function %280
285 %8 = OpVariable %7 Function
286 %13 = OpVariable %12 Function
287 %22 = OpVariable %21 Function
288 %188 = OpCompositeConstruct %180 %44 %40
290 %266 = OpIAddCarry %265 %188 %222
291 %299 = OpULessThanEqual %49 %9 %70
292 %344 = OpULessThanEqual %49 %294 %294
293 %345 = OpSelect %35 %344 %294 %294
295 %346 = OpAccessChain %37 %288 %345
296 %300 = OpSelect %6 %299 %9 %70
297 %301 = OpAccessChain %37 %293 %300
299 %360 = OpULessThanEqual %49 %36 %294
300 %361 = OpSelect %35 %360 %36 %294
301 %362 = OpAccessChain %37 %22 %361
302 %223 = OpCompositeExtract %180 %266 0
303 %189 = OpCompositeConstruct %14 %19 %19 %61 %61
304 %18 = OpVectorShuffle %11 %17 %17 0 1
305 %20 = OpVectorTimesScalar %11 %18 %19
306 %227 = OpFSub %11 %20 %226
307 %190 = OpCompositeConstruct %182 %61 %48 %48
308 %228 = OpFSub %10 %48 %225
310 %191 = OpCompositeConstruct %180 %36 %40
313 %29 = OpImageSampleImplicitLod %14 %27 %28
317 OpLoopMerge %32 %33 None
320 %38 = OpAccessChain %37 %22 %36
322 %41 = OpAccessChain %37 %22 %40
324 %232 = OpFSub %14 %189 %231
325 %43 = OpFAdd %10 %39 %42
326 %45 = OpAccessChain %37 %22 %44
328 %47 = OpFAdd %10 %43 %46
329 %234 = OpCopyObject %10 %61
330 %50 = OpFOrdGreaterThan %49 %47 %48
331 %235 = OpISub %35 %40 %36
333 %53 = OpSLessThan %49 %51 %52
334 %54 = OpLogicalAnd %49 %50 %53
335 OpBranchConditional %54 %31 %32
338 %56 = OpVectorShuffle %11 %55 %55 0 2
340 %58 = OpVectorShuffle %11 %57 %57 1 1
341 %59 = OpFAdd %11 %56 %58
344 %268 = OpUMulExtended %267 %36 %40
345 %321 = OpULessThanEqual %49 %9 %70
346 %322 = OpSelect %6 %321 %9 %70
347 %324 = OpAccessChain %323 %281 %40 %322
348 %243 = OpCompositeExtract %35 %268 0
349 %62 = OpVectorTimesScalar %11 %60 %61
350 %63 = OpExtInst %11 %1 Floor %62
351 %64 = OpCompositeConstruct %11 %61 %61
352 %65 = OpFDiv %11 %63 %64
353 %205 = OpCompositeConstruct %181 %188 %40
357 %68 = OpImageSampleImplicitLod %14 %66 %67
360 %71 = OpIAdd %6 %69 %70
361 %376 = OpAccessChain %323 %324
362 %207 = OpCompositeConstruct %183 %190 %190
364 %244 = OpFMul %10 %234 %48
368 %208 = OpCompositeConstruct %14 %39 %42 %58
371 %209 = OpCompositeConstruct %183 %190 %190
378 # uniforms for variant
384 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
386 PIPELINE graphics variant_pipeline
387 ATTACH variant_vertex_shader
388 ATTACH variant_fragment_shader
389 FRAMEBUFFER_SIZE 256 256
390 BIND BUFFER variant_framebuffer AS color LOCATION 0
391 BIND BUFFER default_texture AS combined_image_sampler SAMPLER variant_tex DESCRIPTOR_SET 0 BINDING 0
393 CLEAR_COLOR variant_pipeline 0 0 0 255
395 CLEAR variant_pipeline
396 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
398 EXPECT reference_framebuffer EQ_HISTOGRAM_EMD_BUFFER variant_framebuffer TOLERANCE 0.005