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 an additional access chain
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" %115 %130
66 OpExecutionMode %4 OriginUpperLeft
69 OpName %115 "gl_FragCoord"
70 OpName %130 "_GLF_color"
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
80 %3 = OpTypeFunction %2
82 %7 = OpTypeVector %6 2
83 %19 = OpConstant %6 0.318309873
84 %22 = OpConstant %6 0.00100000005
88 %36 = OpConstant %32 0
89 %55 = OpConstant %6 0.970000029
90 %56 = OpConstant %6 0.189999998
91 %73 = OpConstant %6 0.5
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
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
116 %179 = OpFOrdLessThan %23 %162 %22
117 OpSelectionMerge %181 None
118 OpBranchConditional %179 %180 %181
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
129 %194 = OpFDiv %6 %187 %185
132 %200 = OpFDiv %6 %185 %187
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
145 %218 = OpFSub %6 %73 %210
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
154 %225 = OpFSub %6 %81 %248
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
163 %232 = OpFNegate %6 %249
166 %250 = OpPhi %6 %249 %226 %232 %230
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
185 # uniforms for reference
188 SAMPLER reference_tex
191 BUFFER reference_framebuffer FORMAT B8G8R8A8_UNORM
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
200 CLEAR_COLOR reference_pipeline 0 0 0 255
202 CLEAR reference_pipeline
203 RUN reference_pipeline DRAW_RECT POS 0 0 SIZE 256 256
206 SHADER vertex variant_vertex_shader PASSTHROUGH
208 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
211 ; Generator: Khronos Glslang Reference Front End; 10
215 %1 = OpExtInstImport "GLSL.std.450"
216 OpMemoryModel Logical GLSL450
217 OpEntryPoint Fragment %4 "main" %115 %130
218 OpExecutionMode %4 OriginUpperLeft
221 OpName %115 "gl_FragCoord"
222 OpName %130 "_GLF_color"
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
232 %3 = OpTypeFunction %2
234 %7 = OpTypeVector %6 2
235 %19 = OpConstant %6 0.318309873
236 %22 = OpConstant %6 0.00100000005
238 %27 = OpConstant %6 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
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
275 %179 = OpFOrdLessThan %23 %162 %22
276 OpSelectionMerge %181 None
277 OpBranchConditional %179 %180 %181
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
288 %194 = OpFDiv %6 %187 %185
291 %200 = OpFDiv %6 %185 %187
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
304 %218 = OpFSub %6 %73 %210
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
313 %225 = OpFSub %6 %81 %248
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
322 %232 = OpFNegate %6 %249
325 %250 = OpPhi %6 %249 %226 %232 %230
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
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
349 # uniforms for variant
355 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
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
364 CLEAR_COLOR variant_pipeline 0 0 0 255
366 CLEAR variant_pipeline
367 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
369 EXPECT reference_framebuffer EQ_HISTOGRAM_EMD_BUFFER variant_framebuffer TOLERANCE 0.005