1 // GENERATED FILE - DO NOT EDIT.
2 // Generated by generate_tests.py
3 //
4 // Copyright (c) 2022 Google LLC.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 // You may obtain a copy of the License at
9 //
10 // http://www.apache.org/licenses/LICENSE-2.0
11 //
12 // Unless required by applicable law or agreed to in writing, software
13 // distributed under the License is distributed on an "AS IS" BASIS,
14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 // See the License for the specific language governing permissions and
16 // limitations under the License.
17
18 #include "../diff_test_utils.h"
19
20 #include "gtest/gtest.h"
21
22 namespace spvtools {
23 namespace diff {
24 namespace {
25
26 // Test where variable set/binding/location decorations are different between
27 // src and dst vertex shaders.
28 constexpr char kSrc[] = R"(OpCapability Shader
29 OpMemoryModel Logical GLSL450
30 OpEntryPoint Vertex %40 "main" %4 %5 %6 %8 %20 %25
31 OpSource GLSL 450
32 OpName %4 "_ub"
33 OpName %5 "_uc"
34 OpName %6 "_ud"
35 OpName %8 "_ue"
36 OpName %9 "defaultUniformsVS"
37 OpMemberName %9 0 "_ua"
38 OpName %11 ""
39 OpName %16 "ANGLEDepthRangeParams"
40 OpMemberName %16 0 "near"
41 OpMemberName %16 1 "far"
42 OpMemberName %16 2 "diff"
43 OpMemberName %16 3 "reserved"
44 OpName %17 "ANGLEUniformBlock"
45 OpMemberName %17 0 "viewport"
46 OpMemberName %17 1 "clipDistancesEnabled"
47 OpMemberName %17 2 "xfbActiveUnpaused"
48 OpMemberName %17 3 "xfbVerticesPerInstance"
49 OpMemberName %17 4 "numSamples"
50 OpMemberName %17 5 "xfbBufferOffsets"
51 OpMemberName %17 6 "acbBufferOffsets"
52 OpMemberName %17 7 "depthRange"
53 OpName %19 "ANGLEUniforms"
54 OpName %20 "ANGLEXfbPosition"
55 OpName %23 "gl_PerVertex"
56 OpMemberName %23 0 "gl_Position"
57 OpMemberName %23 1 "gl_PointSize"
58 OpMemberName %23 2 "gl_ClipDistance"
59 OpMemberName %23 3 "gl_CullDistance"
60 OpName %25 ""
61 OpName %29 "_ua"
62 OpName %28 "_uf"
63 OpName %33 "_uf"
64 OpName %32 "_ug"
65 OpName %40 "main"
66 OpName %42 "param"
67 OpName %50 "param"
68 OpName %53 "param"
69 OpDecorate %4 Location 0
70 OpDecorate %5 Location 1
71 OpDecorate %6 Location 2
72 OpDecorate %8 Location 0
73 OpMemberDecorate %9 0 Offset 0
74 OpDecorate %9 Block
75 OpDecorate %11 DescriptorSet 0
76 OpDecorate %11 Binding 0
77 OpMemberDecorate %16 0 Offset 0
78 OpMemberDecorate %16 1 Offset 4
79 OpMemberDecorate %16 2 Offset 8
80 OpMemberDecorate %16 3 Offset 12
81 OpMemberDecorate %17 0 Offset 0
82 OpMemberDecorate %17 1 Offset 16
83 OpMemberDecorate %17 2 Offset 20
84 OpMemberDecorate %17 3 Offset 24
85 OpMemberDecorate %17 4 Offset 28
86 OpMemberDecorate %17 5 Offset 32
87 OpMemberDecorate %17 6 Offset 48
88 OpMemberDecorate %17 7 Offset 64
89 OpMemberDecorate %17 2 RelaxedPrecision
90 OpMemberDecorate %17 4 RelaxedPrecision
91 OpDecorate %17 Block
92 OpDecorate %19 DescriptorSet 0
93 OpDecorate %19 Binding 1
94 OpDecorate %20 Location 1
95 OpMemberDecorate %23 0 BuiltIn Position
96 OpMemberDecorate %23 1 BuiltIn PointSize
97 OpMemberDecorate %23 2 BuiltIn ClipDistance
98 OpMemberDecorate %23 3 BuiltIn CullDistance
99 OpDecorate %23 Block
100 OpDecorate %28 RelaxedPrecision
101 OpDecorate %29 RelaxedPrecision
102 OpDecorate %31 RelaxedPrecision
103 OpDecorate %32 RelaxedPrecision
104 OpDecorate %33 RelaxedPrecision
105 OpDecorate %35 RelaxedPrecision
106 OpDecorate %36 RelaxedPrecision
107 OpDecorate %37 RelaxedPrecision
108 OpDecorate %44 RelaxedPrecision
109 OpDecorate %52 RelaxedPrecision
110 OpDecorate %55 RelaxedPrecision
111 OpDecorate %56 RelaxedPrecision
112 %1 = OpTypeFloat 32
113 %2 = OpTypeVector %1 4
114 %9 = OpTypeStruct %2
115 %12 = OpTypeInt 32 0
116 %13 = OpTypeInt 32 1
117 %14 = OpTypeVector %13 4
118 %15 = OpTypeVector %12 4
119 %16 = OpTypeStruct %1 %1 %1 %1
120 %17 = OpTypeStruct %2 %12 %12 %13 %13 %14 %15 %16
121 %21 = OpConstant %12 8
122 %22 = OpTypeArray %1 %21
123 %23 = OpTypeStruct %2 %1 %22 %22
124 %38 = OpTypeVoid
125 %45 = OpConstant %12 0
126 %3 = OpTypePointer Input %2
127 %7 = OpTypePointer Output %2
128 %10 = OpTypePointer Uniform %9
129 %18 = OpTypePointer Uniform %17
130 %24 = OpTypePointer Output %23
131 %26 = OpTypePointer Function %2
132 %46 = OpTypePointer Uniform %2
133 %27 = OpTypeFunction %2 %26
134 %39 = OpTypeFunction %38
135 %4 = OpVariable %3 Input
136 %5 = OpVariable %3 Input
137 %6 = OpVariable %3 Input
138 %8 = OpVariable %7 Output
139 %11 = OpVariable %10 Uniform
140 %19 = OpVariable %18 Uniform
141 %20 = OpVariable %7 Output
142 %25 = OpVariable %24 Output
143 %28 = OpFunction %2 None %27
144 %29 = OpFunctionParameter %26
145 %30 = OpLabel
146 %31 = OpLoad %2 %29
147 OpReturnValue %31
148 OpFunctionEnd
149 %32 = OpFunction %2 None %27
150 %33 = OpFunctionParameter %26
151 %34 = OpLabel
152 %35 = OpLoad %2 %33
153 %36 = OpLoad %2 %33
154 %37 = OpFAdd %2 %35 %36
155 OpReturnValue %37
156 OpFunctionEnd
157 %40 = OpFunction %38 None %39
158 %41 = OpLabel
159 %42 = OpVariable %26 Function
160 %50 = OpVariable %26 Function
161 %53 = OpVariable %26 Function
162 %43 = OpLoad %2 %4
163 OpStore %42 %43
164 %44 = OpFunctionCall %2 %28 %42
165 %47 = OpAccessChain %46 %11 %45
166 %48 = OpLoad %2 %47
167 %49 = OpFAdd %2 %44 %48
168 OpStore %8 %49
169 %51 = OpLoad %2 %5
170 OpStore %50 %51
171 %52 = OpFunctionCall %2 %32 %50
172 %54 = OpLoad %2 %6
173 OpStore %53 %54
174 %55 = OpFunctionCall %2 %28 %53
175 %56 = OpFAdd %2 %52 %55
176 %57 = OpAccessChain %7 %25 %45
177 OpStore %57 %56
178 OpReturn
179 OpFunctionEnd
180 )";
181 constexpr char kDst[] = R"(OpCapability Shader
182 OpMemoryModel Logical GLSL450
183 OpEntryPoint Vertex %40 "main" %4 %5 %6 %8 %25
184 OpSource GLSL 450
185 OpName %4 "_ub"
186 OpName %5 "_uc"
187 OpName %6 "_ud"
188 OpName %8 "_ue"
189 OpName %9 "defaultUniformsVS"
190 OpMemberName %9 0 "_ua"
191 OpName %11 ""
192 OpName %16 "ANGLEDepthRangeParams"
193 OpMemberName %16 0 "near"
194 OpMemberName %16 1 "far"
195 OpMemberName %16 2 "diff"
196 OpMemberName %16 3 "reserved"
197 OpName %17 "ANGLEUniformBlock"
198 OpMemberName %17 0 "viewport"
199 OpMemberName %17 1 "clipDistancesEnabled"
200 OpMemberName %17 2 "xfbActiveUnpaused"
201 OpMemberName %17 3 "xfbVerticesPerInstance"
202 OpMemberName %17 4 "numSamples"
203 OpMemberName %17 5 "xfbBufferOffsets"
204 OpMemberName %17 6 "acbBufferOffsets"
205 OpMemberName %17 7 "depthRange"
206 OpName %19 "ANGLEUniforms"
207 OpName %23 "gl_PerVertex"
208 OpMemberName %23 0 "gl_Position"
209 OpName %25 ""
210 OpName %29 "_ua"
211 OpName %28 "_uf"
212 OpName %33 "_uf"
213 OpName %32 "_ug"
214 OpName %40 "main"
215 OpName %42 "param"
216 OpName %50 "param"
217 OpName %53 "param"
218 OpDecorate %4 Location 1
219 OpDecorate %5 Location 2
220 OpDecorate %6 Location 0
221 OpDecorate %8 Location 1
222 OpMemberDecorate %9 0 Offset 0
223 OpDecorate %9 Block
224 OpDecorate %11 DescriptorSet 0
225 OpDecorate %11 Binding 1
226 OpMemberDecorate %16 0 Offset 0
227 OpMemberDecorate %16 1 Offset 4
228 OpMemberDecorate %16 2 Offset 8
229 OpMemberDecorate %16 3 Offset 12
230 OpMemberDecorate %17 0 Offset 0
231 OpMemberDecorate %17 1 Offset 16
232 OpMemberDecorate %17 2 Offset 20
233 OpMemberDecorate %17 3 Offset 24
234 OpMemberDecorate %17 4 Offset 28
235 OpMemberDecorate %17 5 Offset 32
236 OpMemberDecorate %17 6 Offset 48
237 OpMemberDecorate %17 7 Offset 64
238 OpMemberDecorate %17 2 RelaxedPrecision
239 OpMemberDecorate %17 4 RelaxedPrecision
240 OpDecorate %17 Block
241 OpDecorate %19 DescriptorSet 2
242 OpDecorate %19 Binding 0
243 OpMemberDecorate %23 0 BuiltIn Position
244 OpDecorate %23 Block
245 OpDecorate %28 RelaxedPrecision
246 OpDecorate %29 RelaxedPrecision
247 OpDecorate %31 RelaxedPrecision
248 OpDecorate %32 RelaxedPrecision
249 OpDecorate %33 RelaxedPrecision
250 OpDecorate %35 RelaxedPrecision
251 OpDecorate %36 RelaxedPrecision
252 OpDecorate %37 RelaxedPrecision
253 OpDecorate %44 RelaxedPrecision
254 OpDecorate %52 RelaxedPrecision
255 OpDecorate %55 RelaxedPrecision
256 OpDecorate %56 RelaxedPrecision
257 %1 = OpTypeFloat 32
258 %2 = OpTypeVector %1 4
259 %9 = OpTypeStruct %2
260 %12 = OpTypeInt 32 0
261 %13 = OpTypeInt 32 1
262 %14 = OpTypeVector %13 4
263 %15 = OpTypeVector %12 4
264 %16 = OpTypeStruct %1 %1 %1 %1
265 %17 = OpTypeStruct %2 %12 %12 %13 %13 %14 %15 %16
266 %21 = OpConstant %12 8
267 %22 = OpTypeArray %1 %21
268 %23 = OpTypeStruct %2
269 %38 = OpTypeVoid
270 %45 = OpConstant %12 0
271 %58 = OpTypePointer Private %2
272 %3 = OpTypePointer Input %2
273 %59 = OpTypePointer Private %2
274 %7 = OpTypePointer Output %2
275 %10 = OpTypePointer Uniform %9
276 %18 = OpTypePointer Uniform %17
277 %24 = OpTypePointer Output %23
278 %26 = OpTypePointer Function %2
279 %46 = OpTypePointer Uniform %2
280 %27 = OpTypeFunction %2 %26
281 %39 = OpTypeFunction %38
282 %4 = OpVariable %3 Input
283 %5 = OpVariable %3 Input
284 %6 = OpVariable %3 Input
285 %8 = OpVariable %7 Output
286 %11 = OpVariable %10 Uniform
287 %19 = OpVariable %18 Uniform
288 %20 = OpVariable %59 Private
289 %25 = OpVariable %24 Output
290 %60 = OpConstant %13 0
291 %61 = OpConstant %1 0.5
292 %28 = OpFunction %2 None %27
293 %29 = OpFunctionParameter %26
294 %30 = OpLabel
295 %31 = OpLoad %2 %29
296 OpReturnValue %31
297 OpFunctionEnd
298 %32 = OpFunction %2 None %27
299 %33 = OpFunctionParameter %26
300 %34 = OpLabel
301 %35 = OpLoad %2 %33
302 %36 = OpLoad %2 %33
303 %37 = OpFAdd %2 %35 %36
304 OpReturnValue %37
305 OpFunctionEnd
306 %40 = OpFunction %38 None %39
307 %41 = OpLabel
308 %42 = OpVariable %26 Function
309 %50 = OpVariable %26 Function
310 %53 = OpVariable %26 Function
311 %43 = OpLoad %2 %4
312 OpStore %42 %43
313 %44 = OpFunctionCall %2 %28 %42
314 %47 = OpAccessChain %46 %11 %45
315 %48 = OpLoad %2 %47
316 %49 = OpFAdd %2 %44 %48
317 OpStore %8 %49
318 %51 = OpLoad %2 %5
319 OpStore %50 %51
320 %52 = OpFunctionCall %2 %32 %50
321 %54 = OpLoad %2 %6
322 OpStore %53 %54
323 %55 = OpFunctionCall %2 %28 %53
324 %56 = OpFAdd %2 %52 %55
325 %57 = OpAccessChain %7 %25 %45
326 OpStore %57 %56
327 %62 = OpAccessChain %7 %25 %60
328 %63 = OpLoad %2 %62
329 %64 = OpCompositeExtract %1 %63 0
330 %65 = OpCompositeExtract %1 %63 1
331 %66 = OpCompositeExtract %1 %63 2
332 %67 = OpCompositeExtract %1 %63 3
333 %69 = OpFNegate %1 %64
334 %70 = OpFAdd %1 %66 %67
335 %71 = OpFMul %1 %70 %61
336 %68 = OpCompositeConstruct %2 %65 %69 %71 %67
337 OpStore %62 %68
338 OpReturn
339 OpFunctionEnd
340 )";
341
TEST(DiffTest,DifferentDecorationsVertex)342 TEST(DiffTest, DifferentDecorationsVertex) {
343 constexpr char kDiff[] = R"( ; SPIR-V
344 ; Version: 1.6
345 ; Generator: Khronos SPIR-V Tools Assembler; 0
346 -; Bound: 58
347 +; Bound: 73
348 ; Schema: 0
349 OpCapability Shader
350 OpMemoryModel Logical GLSL450
351 -OpEntryPoint Vertex %40 "main" %4 %5 %6 %8 %20 %25
352 +OpEntryPoint Vertex %40 "main" %4 %5 %6 %8 %25
353 OpSource GLSL 450
354 OpName %4 "_ub"
355 OpName %5 "_uc"
356 OpName %6 "_ud"
357 OpName %8 "_ue"
358 OpName %9 "defaultUniformsVS"
359 OpMemberName %9 0 "_ua"
360 OpName %11 ""
361 OpName %16 "ANGLEDepthRangeParams"
362 OpMemberName %16 0 "near"
363 OpMemberName %16 1 "far"
364 OpMemberName %16 2 "diff"
365 OpMemberName %16 3 "reserved"
366 OpName %17 "ANGLEUniformBlock"
367 OpMemberName %17 0 "viewport"
368 OpMemberName %17 1 "clipDistancesEnabled"
369 OpMemberName %17 2 "xfbActiveUnpaused"
370 OpMemberName %17 3 "xfbVerticesPerInstance"
371 OpMemberName %17 4 "numSamples"
372 OpMemberName %17 5 "xfbBufferOffsets"
373 OpMemberName %17 6 "acbBufferOffsets"
374 OpMemberName %17 7 "depthRange"
375 OpName %19 "ANGLEUniforms"
376 -OpName %20 "ANGLEXfbPosition"
377 OpName %23 "gl_PerVertex"
378 OpMemberName %23 0 "gl_Position"
379 -OpMemberName %23 1 "gl_PointSize"
380 -OpMemberName %23 2 "gl_ClipDistance"
381 -OpMemberName %23 3 "gl_CullDistance"
382 OpName %25 ""
383 OpName %29 "_ua"
384 OpName %28 "_uf"
385 OpName %33 "_uf"
386 OpName %32 "_ug"
387 OpName %40 "main"
388 OpName %42 "param"
389 OpName %50 "param"
390 OpName %53 "param"
391 -OpDecorate %4 Location 0
392 +OpDecorate %4 Location 1
393 -OpDecorate %5 Location 1
394 +OpDecorate %5 Location 2
395 -OpDecorate %6 Location 2
396 +OpDecorate %6 Location 0
397 -OpDecorate %8 Location 0
398 +OpDecorate %8 Location 1
399 OpMemberDecorate %9 0 Offset 0
400 OpDecorate %9 Block
401 OpDecorate %11 DescriptorSet 0
402 -OpDecorate %11 Binding 0
403 +OpDecorate %11 Binding 1
404 OpMemberDecorate %16 0 Offset 0
405 OpMemberDecorate %16 1 Offset 4
406 OpMemberDecorate %16 2 Offset 8
407 OpMemberDecorate %16 3 Offset 12
408 OpMemberDecorate %17 0 Offset 0
409 OpMemberDecorate %17 1 Offset 16
410 OpMemberDecorate %17 2 Offset 20
411 OpMemberDecorate %17 3 Offset 24
412 OpMemberDecorate %17 4 Offset 28
413 OpMemberDecorate %17 5 Offset 32
414 OpMemberDecorate %17 6 Offset 48
415 OpMemberDecorate %17 7 Offset 64
416 OpMemberDecorate %17 2 RelaxedPrecision
417 OpMemberDecorate %17 4 RelaxedPrecision
418 OpDecorate %17 Block
419 -OpDecorate %19 DescriptorSet 0
420 +OpDecorate %19 DescriptorSet 2
421 -OpDecorate %19 Binding 1
422 +OpDecorate %19 Binding 0
423 -OpDecorate %20 Location 1
424 OpMemberDecorate %23 0 BuiltIn Position
425 -OpMemberDecorate %23 1 BuiltIn PointSize
426 -OpMemberDecorate %23 2 BuiltIn ClipDistance
427 -OpMemberDecorate %23 3 BuiltIn CullDistance
428 OpDecorate %23 Block
429 OpDecorate %28 RelaxedPrecision
430 OpDecorate %29 RelaxedPrecision
431 OpDecorate %31 RelaxedPrecision
432 OpDecorate %32 RelaxedPrecision
433 OpDecorate %33 RelaxedPrecision
434 OpDecorate %35 RelaxedPrecision
435 OpDecorate %36 RelaxedPrecision
436 OpDecorate %37 RelaxedPrecision
437 OpDecorate %44 RelaxedPrecision
438 OpDecorate %52 RelaxedPrecision
439 OpDecorate %55 RelaxedPrecision
440 OpDecorate %56 RelaxedPrecision
441 %1 = OpTypeFloat 32
442 %2 = OpTypeVector %1 4
443 %9 = OpTypeStruct %2
444 %12 = OpTypeInt 32 0
445 %13 = OpTypeInt 32 1
446 %14 = OpTypeVector %13 4
447 %15 = OpTypeVector %12 4
448 %16 = OpTypeStruct %1 %1 %1 %1
449 %17 = OpTypeStruct %2 %12 %12 %13 %13 %14 %15 %16
450 %21 = OpConstant %12 8
451 %22 = OpTypeArray %1 %21
452 -%23 = OpTypeStruct %2 %1 %22 %22
453 +%23 = OpTypeStruct %2
454 %38 = OpTypeVoid
455 %45 = OpConstant %12 0
456 +%59 = OpTypePointer Private %2
457 %3 = OpTypePointer Input %2
458 +%60 = OpTypePointer Private %2
459 %7 = OpTypePointer Output %2
460 %10 = OpTypePointer Uniform %9
461 %18 = OpTypePointer Uniform %17
462 %24 = OpTypePointer Output %23
463 %26 = OpTypePointer Function %2
464 %46 = OpTypePointer Uniform %2
465 %27 = OpTypeFunction %2 %26
466 %39 = OpTypeFunction %38
467 %4 = OpVariable %3 Input
468 %5 = OpVariable %3 Input
469 %6 = OpVariable %3 Input
470 %8 = OpVariable %7 Output
471 %11 = OpVariable %10 Uniform
472 %19 = OpVariable %18 Uniform
473 -%20 = OpVariable %7 Output
474 +%58 = OpVariable %60 Private
475 %25 = OpVariable %24 Output
476 +%61 = OpConstant %13 0
477 +%62 = OpConstant %1 0.5
478 %28 = OpFunction %2 None %27
479 %29 = OpFunctionParameter %26
480 %30 = OpLabel
481 %31 = OpLoad %2 %29
482 OpReturnValue %31
483 OpFunctionEnd
484 %32 = OpFunction %2 None %27
485 %33 = OpFunctionParameter %26
486 %34 = OpLabel
487 %35 = OpLoad %2 %33
488 %36 = OpLoad %2 %33
489 %37 = OpFAdd %2 %35 %36
490 OpReturnValue %37
491 OpFunctionEnd
492 %40 = OpFunction %38 None %39
493 %41 = OpLabel
494 %42 = OpVariable %26 Function
495 %50 = OpVariable %26 Function
496 %53 = OpVariable %26 Function
497 %43 = OpLoad %2 %4
498 OpStore %42 %43
499 %44 = OpFunctionCall %2 %28 %42
500 %47 = OpAccessChain %46 %11 %45
501 %48 = OpLoad %2 %47
502 %49 = OpFAdd %2 %44 %48
503 OpStore %8 %49
504 %51 = OpLoad %2 %5
505 OpStore %50 %51
506 %52 = OpFunctionCall %2 %32 %50
507 %54 = OpLoad %2 %6
508 OpStore %53 %54
509 %55 = OpFunctionCall %2 %28 %53
510 %56 = OpFAdd %2 %52 %55
511 %57 = OpAccessChain %7 %25 %45
512 OpStore %57 %56
513 +%63 = OpAccessChain %7 %25 %61
514 +%64 = OpLoad %2 %63
515 +%65 = OpCompositeExtract %1 %64 0
516 +%66 = OpCompositeExtract %1 %64 1
517 +%67 = OpCompositeExtract %1 %64 2
518 +%68 = OpCompositeExtract %1 %64 3
519 +%70 = OpFNegate %1 %65
520 +%71 = OpFAdd %1 %67 %68
521 +%72 = OpFMul %1 %71 %62
522 +%69 = OpCompositeConstruct %2 %66 %70 %72 %68
523 +OpStore %63 %69
524 OpReturn
525 OpFunctionEnd
526 )";
527 Options options;
528 DoStringDiffTest(kSrc, kDst, kDiff, options);
529 }
530
TEST(DiffTest,DifferentDecorationsVertexNoDebug)531 TEST(DiffTest, DifferentDecorationsVertexNoDebug) {
532 constexpr char kSrcNoDebug[] = R"(OpCapability Shader
533 OpMemoryModel Logical GLSL450
534 OpEntryPoint Vertex %40 "main" %4 %5 %6 %8 %20 %25
535 OpSource GLSL 450
536 OpDecorate %4 Location 0
537 OpDecorate %5 Location 1
538 OpDecorate %6 Location 2
539 OpDecorate %8 Location 0
540 OpMemberDecorate %9 0 Offset 0
541 OpDecorate %9 Block
542 OpDecorate %11 DescriptorSet 0
543 OpDecorate %11 Binding 0
544 OpMemberDecorate %16 0 Offset 0
545 OpMemberDecorate %16 1 Offset 4
546 OpMemberDecorate %16 2 Offset 8
547 OpMemberDecorate %16 3 Offset 12
548 OpMemberDecorate %17 0 Offset 0
549 OpMemberDecorate %17 1 Offset 16
550 OpMemberDecorate %17 2 Offset 20
551 OpMemberDecorate %17 3 Offset 24
552 OpMemberDecorate %17 4 Offset 28
553 OpMemberDecorate %17 5 Offset 32
554 OpMemberDecorate %17 6 Offset 48
555 OpMemberDecorate %17 7 Offset 64
556 OpMemberDecorate %17 2 RelaxedPrecision
557 OpMemberDecorate %17 4 RelaxedPrecision
558 OpDecorate %17 Block
559 OpDecorate %19 DescriptorSet 0
560 OpDecorate %19 Binding 1
561 OpDecorate %20 Location 1
562 OpMemberDecorate %23 0 BuiltIn Position
563 OpMemberDecorate %23 1 BuiltIn PointSize
564 OpMemberDecorate %23 2 BuiltIn ClipDistance
565 OpMemberDecorate %23 3 BuiltIn CullDistance
566 OpDecorate %23 Block
567 OpDecorate %28 RelaxedPrecision
568 OpDecorate %29 RelaxedPrecision
569 OpDecorate %31 RelaxedPrecision
570 OpDecorate %32 RelaxedPrecision
571 OpDecorate %33 RelaxedPrecision
572 OpDecorate %35 RelaxedPrecision
573 OpDecorate %36 RelaxedPrecision
574 OpDecorate %37 RelaxedPrecision
575 OpDecorate %44 RelaxedPrecision
576 OpDecorate %52 RelaxedPrecision
577 OpDecorate %55 RelaxedPrecision
578 OpDecorate %56 RelaxedPrecision
579 %1 = OpTypeFloat 32
580 %2 = OpTypeVector %1 4
581 %9 = OpTypeStruct %2
582 %12 = OpTypeInt 32 0
583 %13 = OpTypeInt 32 1
584 %14 = OpTypeVector %13 4
585 %15 = OpTypeVector %12 4
586 %16 = OpTypeStruct %1 %1 %1 %1
587 %17 = OpTypeStruct %2 %12 %12 %13 %13 %14 %15 %16
588 %21 = OpConstant %12 8
589 %22 = OpTypeArray %1 %21
590 %23 = OpTypeStruct %2 %1 %22 %22
591 %38 = OpTypeVoid
592 %45 = OpConstant %12 0
593 %3 = OpTypePointer Input %2
594 %7 = OpTypePointer Output %2
595 %10 = OpTypePointer Uniform %9
596 %18 = OpTypePointer Uniform %17
597 %24 = OpTypePointer Output %23
598 %26 = OpTypePointer Function %2
599 %46 = OpTypePointer Uniform %2
600 %27 = OpTypeFunction %2 %26
601 %39 = OpTypeFunction %38
602 %4 = OpVariable %3 Input
603 %5 = OpVariable %3 Input
604 %6 = OpVariable %3 Input
605 %8 = OpVariable %7 Output
606 %11 = OpVariable %10 Uniform
607 %19 = OpVariable %18 Uniform
608 %20 = OpVariable %7 Output
609 %25 = OpVariable %24 Output
610 %28 = OpFunction %2 None %27
611 %29 = OpFunctionParameter %26
612 %30 = OpLabel
613 %31 = OpLoad %2 %29
614 OpReturnValue %31
615 OpFunctionEnd
616 %32 = OpFunction %2 None %27
617 %33 = OpFunctionParameter %26
618 %34 = OpLabel
619 %35 = OpLoad %2 %33
620 %36 = OpLoad %2 %33
621 %37 = OpFAdd %2 %35 %36
622 OpReturnValue %37
623 OpFunctionEnd
624 %40 = OpFunction %38 None %39
625 %41 = OpLabel
626 %42 = OpVariable %26 Function
627 %50 = OpVariable %26 Function
628 %53 = OpVariable %26 Function
629 %43 = OpLoad %2 %4
630 OpStore %42 %43
631 %44 = OpFunctionCall %2 %28 %42
632 %47 = OpAccessChain %46 %11 %45
633 %48 = OpLoad %2 %47
634 %49 = OpFAdd %2 %44 %48
635 OpStore %8 %49
636 %51 = OpLoad %2 %5
637 OpStore %50 %51
638 %52 = OpFunctionCall %2 %32 %50
639 %54 = OpLoad %2 %6
640 OpStore %53 %54
641 %55 = OpFunctionCall %2 %28 %53
642 %56 = OpFAdd %2 %52 %55
643 %57 = OpAccessChain %7 %25 %45
644 OpStore %57 %56
645 OpReturn
646 OpFunctionEnd
647
648 )";
649 constexpr char kDstNoDebug[] = R"(OpCapability Shader
650 OpMemoryModel Logical GLSL450
651 OpEntryPoint Vertex %40 "main" %4 %5 %6 %8 %25
652 OpSource GLSL 450
653 OpDecorate %4 Location 1
654 OpDecorate %5 Location 2
655 OpDecorate %6 Location 0
656 OpDecorate %8 Location 1
657 OpMemberDecorate %9 0 Offset 0
658 OpDecorate %9 Block
659 OpDecorate %11 DescriptorSet 0
660 OpDecorate %11 Binding 1
661 OpMemberDecorate %16 0 Offset 0
662 OpMemberDecorate %16 1 Offset 4
663 OpMemberDecorate %16 2 Offset 8
664 OpMemberDecorate %16 3 Offset 12
665 OpMemberDecorate %17 0 Offset 0
666 OpMemberDecorate %17 1 Offset 16
667 OpMemberDecorate %17 2 Offset 20
668 OpMemberDecorate %17 3 Offset 24
669 OpMemberDecorate %17 4 Offset 28
670 OpMemberDecorate %17 5 Offset 32
671 OpMemberDecorate %17 6 Offset 48
672 OpMemberDecorate %17 7 Offset 64
673 OpMemberDecorate %17 2 RelaxedPrecision
674 OpMemberDecorate %17 4 RelaxedPrecision
675 OpDecorate %17 Block
676 OpDecorate %19 DescriptorSet 2
677 OpDecorate %19 Binding 0
678 OpMemberDecorate %23 0 BuiltIn Position
679 OpDecorate %23 Block
680 OpDecorate %28 RelaxedPrecision
681 OpDecorate %29 RelaxedPrecision
682 OpDecorate %31 RelaxedPrecision
683 OpDecorate %32 RelaxedPrecision
684 OpDecorate %33 RelaxedPrecision
685 OpDecorate %35 RelaxedPrecision
686 OpDecorate %36 RelaxedPrecision
687 OpDecorate %37 RelaxedPrecision
688 OpDecorate %44 RelaxedPrecision
689 OpDecorate %52 RelaxedPrecision
690 OpDecorate %55 RelaxedPrecision
691 OpDecorate %56 RelaxedPrecision
692 %1 = OpTypeFloat 32
693 %2 = OpTypeVector %1 4
694 %9 = OpTypeStruct %2
695 %12 = OpTypeInt 32 0
696 %13 = OpTypeInt 32 1
697 %14 = OpTypeVector %13 4
698 %15 = OpTypeVector %12 4
699 %16 = OpTypeStruct %1 %1 %1 %1
700 %17 = OpTypeStruct %2 %12 %12 %13 %13 %14 %15 %16
701 %21 = OpConstant %12 8
702 %22 = OpTypeArray %1 %21
703 %23 = OpTypeStruct %2
704 %38 = OpTypeVoid
705 %45 = OpConstant %12 0
706 %58 = OpTypePointer Private %2
707 %3 = OpTypePointer Input %2
708 %59 = OpTypePointer Private %2
709 %7 = OpTypePointer Output %2
710 %10 = OpTypePointer Uniform %9
711 %18 = OpTypePointer Uniform %17
712 %24 = OpTypePointer Output %23
713 %26 = OpTypePointer Function %2
714 %46 = OpTypePointer Uniform %2
715 %27 = OpTypeFunction %2 %26
716 %39 = OpTypeFunction %38
717 %4 = OpVariable %3 Input
718 %5 = OpVariable %3 Input
719 %6 = OpVariable %3 Input
720 %8 = OpVariable %7 Output
721 %11 = OpVariable %10 Uniform
722 %19 = OpVariable %18 Uniform
723 %20 = OpVariable %59 Private
724 %25 = OpVariable %24 Output
725 %60 = OpConstant %13 0
726 %61 = OpConstant %1 0.5
727 %28 = OpFunction %2 None %27
728 %29 = OpFunctionParameter %26
729 %30 = OpLabel
730 %31 = OpLoad %2 %29
731 OpReturnValue %31
732 OpFunctionEnd
733 %32 = OpFunction %2 None %27
734 %33 = OpFunctionParameter %26
735 %34 = OpLabel
736 %35 = OpLoad %2 %33
737 %36 = OpLoad %2 %33
738 %37 = OpFAdd %2 %35 %36
739 OpReturnValue %37
740 OpFunctionEnd
741 %40 = OpFunction %38 None %39
742 %41 = OpLabel
743 %42 = OpVariable %26 Function
744 %50 = OpVariable %26 Function
745 %53 = OpVariable %26 Function
746 %43 = OpLoad %2 %4
747 OpStore %42 %43
748 %44 = OpFunctionCall %2 %28 %42
749 %47 = OpAccessChain %46 %11 %45
750 %48 = OpLoad %2 %47
751 %49 = OpFAdd %2 %44 %48
752 OpStore %8 %49
753 %51 = OpLoad %2 %5
754 OpStore %50 %51
755 %52 = OpFunctionCall %2 %32 %50
756 %54 = OpLoad %2 %6
757 OpStore %53 %54
758 %55 = OpFunctionCall %2 %28 %53
759 %56 = OpFAdd %2 %52 %55
760 %57 = OpAccessChain %7 %25 %45
761 OpStore %57 %56
762 %62 = OpAccessChain %7 %25 %60
763 %63 = OpLoad %2 %62
764 %64 = OpCompositeExtract %1 %63 0
765 %65 = OpCompositeExtract %1 %63 1
766 %66 = OpCompositeExtract %1 %63 2
767 %67 = OpCompositeExtract %1 %63 3
768 %69 = OpFNegate %1 %64
769 %70 = OpFAdd %1 %66 %67
770 %71 = OpFMul %1 %70 %61
771 %68 = OpCompositeConstruct %2 %65 %69 %71 %67
772 OpStore %62 %68
773 OpReturn
774 OpFunctionEnd
775 )";
776 constexpr char kDiff[] = R"( ; SPIR-V
777 ; Version: 1.6
778 ; Generator: Khronos SPIR-V Tools Assembler; 0
779 -; Bound: 58
780 +; Bound: 77
781 ; Schema: 0
782 OpCapability Shader
783 OpMemoryModel Logical GLSL450
784 -OpEntryPoint Vertex %40 "main" %4 %5 %6 %8 %20 %25
785 +OpEntryPoint Vertex %40 "main" %5 %6 %4 %20 %25
786 OpSource GLSL 450
787 OpDecorate %4 Location 0
788 OpDecorate %5 Location 1
789 OpDecorate %6 Location 2
790 -OpDecorate %8 Location 0
791 OpMemberDecorate %9 0 Offset 0
792 OpDecorate %9 Block
793 -OpDecorate %11 DescriptorSet 0
794 +OpDecorate %11 DescriptorSet 2
795 OpDecorate %11 Binding 0
796 OpMemberDecorate %16 0 Offset 0
797 OpMemberDecorate %16 1 Offset 4
798 OpMemberDecorate %16 2 Offset 8
799 OpMemberDecorate %16 3 Offset 12
800 OpMemberDecorate %17 0 Offset 0
801 OpMemberDecorate %17 1 Offset 16
802 OpMemberDecorate %17 2 Offset 20
803 OpMemberDecorate %17 3 Offset 24
804 OpMemberDecorate %17 4 Offset 28
805 OpMemberDecorate %17 5 Offset 32
806 OpMemberDecorate %17 6 Offset 48
807 OpMemberDecorate %17 7 Offset 64
808 OpMemberDecorate %17 2 RelaxedPrecision
809 OpMemberDecorate %17 4 RelaxedPrecision
810 OpDecorate %17 Block
811 OpDecorate %19 DescriptorSet 0
812 OpDecorate %19 Binding 1
813 OpDecorate %20 Location 1
814 OpMemberDecorate %23 0 BuiltIn Position
815 -OpMemberDecorate %23 1 BuiltIn PointSize
816 -OpMemberDecorate %23 2 BuiltIn ClipDistance
817 -OpMemberDecorate %23 3 BuiltIn CullDistance
818 OpDecorate %23 Block
819 OpDecorate %28 RelaxedPrecision
820 OpDecorate %29 RelaxedPrecision
821 OpDecorate %31 RelaxedPrecision
822 OpDecorate %32 RelaxedPrecision
823 OpDecorate %33 RelaxedPrecision
824 OpDecorate %35 RelaxedPrecision
825 OpDecorate %36 RelaxedPrecision
826 OpDecorate %37 RelaxedPrecision
827 OpDecorate %44 RelaxedPrecision
828 OpDecorate %52 RelaxedPrecision
829 OpDecorate %55 RelaxedPrecision
830 OpDecorate %56 RelaxedPrecision
831 %1 = OpTypeFloat 32
832 %2 = OpTypeVector %1 4
833 %9 = OpTypeStruct %2
834 %12 = OpTypeInt 32 0
835 %13 = OpTypeInt 32 1
836 %14 = OpTypeVector %13 4
837 %15 = OpTypeVector %12 4
838 %16 = OpTypeStruct %1 %1 %1 %1
839 %17 = OpTypeStruct %2 %12 %12 %13 %13 %14 %15 %16
840 %21 = OpConstant %12 8
841 %22 = OpTypeArray %1 %21
842 -%23 = OpTypeStruct %2 %1 %22 %22
843 +%23 = OpTypeStruct %2
844 %38 = OpTypeVoid
845 %45 = OpConstant %12 0
846 +%63 = OpTypePointer Private %2
847 %3 = OpTypePointer Input %2
848 +%64 = OpTypePointer Private %2
849 %7 = OpTypePointer Output %2
850 %10 = OpTypePointer Uniform %9
851 %18 = OpTypePointer Uniform %17
852 %24 = OpTypePointer Output %23
853 %26 = OpTypePointer Function %2
854 %46 = OpTypePointer Uniform %2
855 %27 = OpTypeFunction %2 %26
856 %39 = OpTypeFunction %38
857 %4 = OpVariable %3 Input
858 %5 = OpVariable %3 Input
859 %6 = OpVariable %3 Input
860 -%8 = OpVariable %7 Output
861 -%11 = OpVariable %10 Uniform
862 +%11 = OpVariable %18 Uniform
863 -%19 = OpVariable %18 Uniform
864 +%19 = OpVariable %10 Uniform
865 %20 = OpVariable %7 Output
866 +%58 = OpVariable %64 Private
867 %25 = OpVariable %24 Output
868 +%65 = OpConstant %13 0
869 +%66 = OpConstant %1 0.5
870 %28 = OpFunction %2 None %27
871 %29 = OpFunctionParameter %26
872 %30 = OpLabel
873 %31 = OpLoad %2 %29
874 OpReturnValue %31
875 OpFunctionEnd
876 %32 = OpFunction %2 None %27
877 %33 = OpFunctionParameter %26
878 %34 = OpLabel
879 %35 = OpLoad %2 %33
880 %36 = OpLoad %2 %33
881 %37 = OpFAdd %2 %35 %36
882 OpReturnValue %37
883 OpFunctionEnd
884 %40 = OpFunction %38 None %39
885 %41 = OpLabel
886 %42 = OpVariable %26 Function
887 %50 = OpVariable %26 Function
888 %53 = OpVariable %26 Function
889 -%43 = OpLoad %2 %4
890 +%59 = OpLoad %2 %5
891 -OpStore %42 %43
892 +OpStore %42 %59
893 %44 = OpFunctionCall %2 %28 %42
894 -%47 = OpAccessChain %46 %11 %45
895 +%60 = OpAccessChain %46 %19 %45
896 -%48 = OpLoad %2 %47
897 +%48 = OpLoad %2 %60
898 %49 = OpFAdd %2 %44 %48
899 -OpStore %8 %49
900 +OpStore %20 %49
901 -%51 = OpLoad %2 %5
902 +%61 = OpLoad %2 %6
903 -OpStore %50 %51
904 +OpStore %50 %61
905 %52 = OpFunctionCall %2 %32 %50
906 -%54 = OpLoad %2 %6
907 +%62 = OpLoad %2 %4
908 -OpStore %53 %54
909 +OpStore %53 %62
910 %55 = OpFunctionCall %2 %28 %53
911 %56 = OpFAdd %2 %52 %55
912 %57 = OpAccessChain %7 %25 %45
913 OpStore %57 %56
914 +%67 = OpAccessChain %7 %25 %65
915 +%68 = OpLoad %2 %67
916 +%69 = OpCompositeExtract %1 %68 0
917 +%70 = OpCompositeExtract %1 %68 1
918 +%71 = OpCompositeExtract %1 %68 2
919 +%72 = OpCompositeExtract %1 %68 3
920 +%74 = OpFNegate %1 %69
921 +%75 = OpFAdd %1 %71 %72
922 +%76 = OpFMul %1 %75 %66
923 +%73 = OpCompositeConstruct %2 %70 %74 %76 %72
924 +OpStore %67 %73
925 OpReturn
926 OpFunctionEnd
927 )";
928 Options options;
929 DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options);
930 }
931
TEST(DiffTest,DifferentDecorationsVertexIgnoreSetBinding)932 TEST(DiffTest, DifferentDecorationsVertexIgnoreSetBinding) {
933 constexpr char kDiff[] = R"( ; SPIR-V
934 ; Version: 1.6
935 ; Generator: Khronos SPIR-V Tools Assembler; 0
936 -; Bound: 58
937 +; Bound: 73
938 ; Schema: 0
939 OpCapability Shader
940 OpMemoryModel Logical GLSL450
941 -OpEntryPoint Vertex %40 "main" %4 %5 %6 %8 %20 %25
942 +OpEntryPoint Vertex %40 "main" %4 %5 %6 %8 %25
943 OpSource GLSL 450
944 OpName %4 "_ub"
945 OpName %5 "_uc"
946 OpName %6 "_ud"
947 OpName %8 "_ue"
948 OpName %9 "defaultUniformsVS"
949 OpMemberName %9 0 "_ua"
950 OpName %11 ""
951 OpName %16 "ANGLEDepthRangeParams"
952 OpMemberName %16 0 "near"
953 OpMemberName %16 1 "far"
954 OpMemberName %16 2 "diff"
955 OpMemberName %16 3 "reserved"
956 OpName %17 "ANGLEUniformBlock"
957 OpMemberName %17 0 "viewport"
958 OpMemberName %17 1 "clipDistancesEnabled"
959 OpMemberName %17 2 "xfbActiveUnpaused"
960 OpMemberName %17 3 "xfbVerticesPerInstance"
961 OpMemberName %17 4 "numSamples"
962 OpMemberName %17 5 "xfbBufferOffsets"
963 OpMemberName %17 6 "acbBufferOffsets"
964 OpMemberName %17 7 "depthRange"
965 OpName %19 "ANGLEUniforms"
966 -OpName %20 "ANGLEXfbPosition"
967 OpName %23 "gl_PerVertex"
968 OpMemberName %23 0 "gl_Position"
969 -OpMemberName %23 1 "gl_PointSize"
970 -OpMemberName %23 2 "gl_ClipDistance"
971 -OpMemberName %23 3 "gl_CullDistance"
972 OpName %25 ""
973 OpName %29 "_ua"
974 OpName %28 "_uf"
975 OpName %33 "_uf"
976 OpName %32 "_ug"
977 OpName %40 "main"
978 OpName %42 "param"
979 OpName %50 "param"
980 OpName %53 "param"
981 -OpDecorate %4 Location 0
982 +OpDecorate %4 Location 1
983 -OpDecorate %5 Location 1
984 +OpDecorate %5 Location 2
985 -OpDecorate %6 Location 2
986 +OpDecorate %6 Location 0
987 -OpDecorate %8 Location 0
988 +OpDecorate %8 Location 1
989 OpMemberDecorate %9 0 Offset 0
990 OpDecorate %9 Block
991 OpDecorate %11 DescriptorSet 0
992 -OpDecorate %11 Binding 0
993 +OpDecorate %11 Binding 1
994 OpMemberDecorate %16 0 Offset 0
995 OpMemberDecorate %16 1 Offset 4
996 OpMemberDecorate %16 2 Offset 8
997 OpMemberDecorate %16 3 Offset 12
998 OpMemberDecorate %17 0 Offset 0
999 OpMemberDecorate %17 1 Offset 16
1000 OpMemberDecorate %17 2 Offset 20
1001 OpMemberDecorate %17 3 Offset 24
1002 OpMemberDecorate %17 4 Offset 28
1003 OpMemberDecorate %17 5 Offset 32
1004 OpMemberDecorate %17 6 Offset 48
1005 OpMemberDecorate %17 7 Offset 64
1006 OpMemberDecorate %17 2 RelaxedPrecision
1007 OpMemberDecorate %17 4 RelaxedPrecision
1008 OpDecorate %17 Block
1009 -OpDecorate %19 DescriptorSet 0
1010 +OpDecorate %19 DescriptorSet 2
1011 -OpDecorate %19 Binding 1
1012 +OpDecorate %19 Binding 0
1013 -OpDecorate %20 Location 1
1014 OpMemberDecorate %23 0 BuiltIn Position
1015 -OpMemberDecorate %23 1 BuiltIn PointSize
1016 -OpMemberDecorate %23 2 BuiltIn ClipDistance
1017 -OpMemberDecorate %23 3 BuiltIn CullDistance
1018 OpDecorate %23 Block
1019 OpDecorate %28 RelaxedPrecision
1020 OpDecorate %29 RelaxedPrecision
1021 OpDecorate %31 RelaxedPrecision
1022 OpDecorate %32 RelaxedPrecision
1023 OpDecorate %33 RelaxedPrecision
1024 OpDecorate %35 RelaxedPrecision
1025 OpDecorate %36 RelaxedPrecision
1026 OpDecorate %37 RelaxedPrecision
1027 OpDecorate %44 RelaxedPrecision
1028 OpDecorate %52 RelaxedPrecision
1029 OpDecorate %55 RelaxedPrecision
1030 OpDecorate %56 RelaxedPrecision
1031 %1 = OpTypeFloat 32
1032 %2 = OpTypeVector %1 4
1033 %9 = OpTypeStruct %2
1034 %12 = OpTypeInt 32 0
1035 %13 = OpTypeInt 32 1
1036 %14 = OpTypeVector %13 4
1037 %15 = OpTypeVector %12 4
1038 %16 = OpTypeStruct %1 %1 %1 %1
1039 %17 = OpTypeStruct %2 %12 %12 %13 %13 %14 %15 %16
1040 %21 = OpConstant %12 8
1041 %22 = OpTypeArray %1 %21
1042 -%23 = OpTypeStruct %2 %1 %22 %22
1043 +%23 = OpTypeStruct %2
1044 %38 = OpTypeVoid
1045 %45 = OpConstant %12 0
1046 +%59 = OpTypePointer Private %2
1047 %3 = OpTypePointer Input %2
1048 +%60 = OpTypePointer Private %2
1049 %7 = OpTypePointer Output %2
1050 %10 = OpTypePointer Uniform %9
1051 %18 = OpTypePointer Uniform %17
1052 %24 = OpTypePointer Output %23
1053 %26 = OpTypePointer Function %2
1054 %46 = OpTypePointer Uniform %2
1055 %27 = OpTypeFunction %2 %26
1056 %39 = OpTypeFunction %38
1057 %4 = OpVariable %3 Input
1058 %5 = OpVariable %3 Input
1059 %6 = OpVariable %3 Input
1060 %8 = OpVariable %7 Output
1061 %11 = OpVariable %10 Uniform
1062 %19 = OpVariable %18 Uniform
1063 -%20 = OpVariable %7 Output
1064 +%58 = OpVariable %60 Private
1065 %25 = OpVariable %24 Output
1066 +%61 = OpConstant %13 0
1067 +%62 = OpConstant %1 0.5
1068 %28 = OpFunction %2 None %27
1069 %29 = OpFunctionParameter %26
1070 %30 = OpLabel
1071 %31 = OpLoad %2 %29
1072 OpReturnValue %31
1073 OpFunctionEnd
1074 %32 = OpFunction %2 None %27
1075 %33 = OpFunctionParameter %26
1076 %34 = OpLabel
1077 %35 = OpLoad %2 %33
1078 %36 = OpLoad %2 %33
1079 %37 = OpFAdd %2 %35 %36
1080 OpReturnValue %37
1081 OpFunctionEnd
1082 %40 = OpFunction %38 None %39
1083 %41 = OpLabel
1084 %42 = OpVariable %26 Function
1085 %50 = OpVariable %26 Function
1086 %53 = OpVariable %26 Function
1087 %43 = OpLoad %2 %4
1088 OpStore %42 %43
1089 %44 = OpFunctionCall %2 %28 %42
1090 %47 = OpAccessChain %46 %11 %45
1091 %48 = OpLoad %2 %47
1092 %49 = OpFAdd %2 %44 %48
1093 OpStore %8 %49
1094 %51 = OpLoad %2 %5
1095 OpStore %50 %51
1096 %52 = OpFunctionCall %2 %32 %50
1097 %54 = OpLoad %2 %6
1098 OpStore %53 %54
1099 %55 = OpFunctionCall %2 %28 %53
1100 %56 = OpFAdd %2 %52 %55
1101 %57 = OpAccessChain %7 %25 %45
1102 OpStore %57 %56
1103 +%63 = OpAccessChain %7 %25 %61
1104 +%64 = OpLoad %2 %63
1105 +%65 = OpCompositeExtract %1 %64 0
1106 +%66 = OpCompositeExtract %1 %64 1
1107 +%67 = OpCompositeExtract %1 %64 2
1108 +%68 = OpCompositeExtract %1 %64 3
1109 +%70 = OpFNegate %1 %65
1110 +%71 = OpFAdd %1 %67 %68
1111 +%72 = OpFMul %1 %71 %62
1112 +%69 = OpCompositeConstruct %2 %66 %70 %72 %68
1113 +OpStore %63 %69
1114 OpReturn
1115 OpFunctionEnd
1116 )";
1117 Options options;
1118 options.ignore_set_binding = true;
1119 DoStringDiffTest(kSrc, kDst, kDiff, options);
1120 }
1121
TEST(DiffTest,DifferentDecorationsVertexIgnoreSetBindingLocation)1122 TEST(DiffTest, DifferentDecorationsVertexIgnoreSetBindingLocation) {
1123 constexpr char kDiff[] = R"( ; SPIR-V
1124 ; Version: 1.6
1125 ; Generator: Khronos SPIR-V Tools Assembler; 0
1126 -; Bound: 58
1127 +; Bound: 73
1128 ; Schema: 0
1129 OpCapability Shader
1130 OpMemoryModel Logical GLSL450
1131 -OpEntryPoint Vertex %40 "main" %4 %5 %6 %8 %20 %25
1132 +OpEntryPoint Vertex %40 "main" %4 %5 %6 %8 %25
1133 OpSource GLSL 450
1134 OpName %4 "_ub"
1135 OpName %5 "_uc"
1136 OpName %6 "_ud"
1137 OpName %8 "_ue"
1138 OpName %9 "defaultUniformsVS"
1139 OpMemberName %9 0 "_ua"
1140 OpName %11 ""
1141 OpName %16 "ANGLEDepthRangeParams"
1142 OpMemberName %16 0 "near"
1143 OpMemberName %16 1 "far"
1144 OpMemberName %16 2 "diff"
1145 OpMemberName %16 3 "reserved"
1146 OpName %17 "ANGLEUniformBlock"
1147 OpMemberName %17 0 "viewport"
1148 OpMemberName %17 1 "clipDistancesEnabled"
1149 OpMemberName %17 2 "xfbActiveUnpaused"
1150 OpMemberName %17 3 "xfbVerticesPerInstance"
1151 OpMemberName %17 4 "numSamples"
1152 OpMemberName %17 5 "xfbBufferOffsets"
1153 OpMemberName %17 6 "acbBufferOffsets"
1154 OpMemberName %17 7 "depthRange"
1155 OpName %19 "ANGLEUniforms"
1156 -OpName %20 "ANGLEXfbPosition"
1157 OpName %23 "gl_PerVertex"
1158 OpMemberName %23 0 "gl_Position"
1159 -OpMemberName %23 1 "gl_PointSize"
1160 -OpMemberName %23 2 "gl_ClipDistance"
1161 -OpMemberName %23 3 "gl_CullDistance"
1162 OpName %25 ""
1163 OpName %29 "_ua"
1164 OpName %28 "_uf"
1165 OpName %33 "_uf"
1166 OpName %32 "_ug"
1167 OpName %40 "main"
1168 OpName %42 "param"
1169 OpName %50 "param"
1170 OpName %53 "param"
1171 -OpDecorate %4 Location 0
1172 +OpDecorate %4 Location 1
1173 -OpDecorate %5 Location 1
1174 +OpDecorate %5 Location 2
1175 -OpDecorate %6 Location 2
1176 +OpDecorate %6 Location 0
1177 -OpDecorate %8 Location 0
1178 +OpDecorate %8 Location 1
1179 OpMemberDecorate %9 0 Offset 0
1180 OpDecorate %9 Block
1181 OpDecorate %11 DescriptorSet 0
1182 -OpDecorate %11 Binding 0
1183 +OpDecorate %11 Binding 1
1184 OpMemberDecorate %16 0 Offset 0
1185 OpMemberDecorate %16 1 Offset 4
1186 OpMemberDecorate %16 2 Offset 8
1187 OpMemberDecorate %16 3 Offset 12
1188 OpMemberDecorate %17 0 Offset 0
1189 OpMemberDecorate %17 1 Offset 16
1190 OpMemberDecorate %17 2 Offset 20
1191 OpMemberDecorate %17 3 Offset 24
1192 OpMemberDecorate %17 4 Offset 28
1193 OpMemberDecorate %17 5 Offset 32
1194 OpMemberDecorate %17 6 Offset 48
1195 OpMemberDecorate %17 7 Offset 64
1196 OpMemberDecorate %17 2 RelaxedPrecision
1197 OpMemberDecorate %17 4 RelaxedPrecision
1198 OpDecorate %17 Block
1199 -OpDecorate %19 DescriptorSet 0
1200 +OpDecorate %19 DescriptorSet 2
1201 -OpDecorate %19 Binding 1
1202 +OpDecorate %19 Binding 0
1203 -OpDecorate %20 Location 1
1204 OpMemberDecorate %23 0 BuiltIn Position
1205 -OpMemberDecorate %23 1 BuiltIn PointSize
1206 -OpMemberDecorate %23 2 BuiltIn ClipDistance
1207 -OpMemberDecorate %23 3 BuiltIn CullDistance
1208 OpDecorate %23 Block
1209 OpDecorate %28 RelaxedPrecision
1210 OpDecorate %29 RelaxedPrecision
1211 OpDecorate %31 RelaxedPrecision
1212 OpDecorate %32 RelaxedPrecision
1213 OpDecorate %33 RelaxedPrecision
1214 OpDecorate %35 RelaxedPrecision
1215 OpDecorate %36 RelaxedPrecision
1216 OpDecorate %37 RelaxedPrecision
1217 OpDecorate %44 RelaxedPrecision
1218 OpDecorate %52 RelaxedPrecision
1219 OpDecorate %55 RelaxedPrecision
1220 OpDecorate %56 RelaxedPrecision
1221 %1 = OpTypeFloat 32
1222 %2 = OpTypeVector %1 4
1223 %9 = OpTypeStruct %2
1224 %12 = OpTypeInt 32 0
1225 %13 = OpTypeInt 32 1
1226 %14 = OpTypeVector %13 4
1227 %15 = OpTypeVector %12 4
1228 %16 = OpTypeStruct %1 %1 %1 %1
1229 %17 = OpTypeStruct %2 %12 %12 %13 %13 %14 %15 %16
1230 %21 = OpConstant %12 8
1231 %22 = OpTypeArray %1 %21
1232 -%23 = OpTypeStruct %2 %1 %22 %22
1233 +%23 = OpTypeStruct %2
1234 %38 = OpTypeVoid
1235 %45 = OpConstant %12 0
1236 +%59 = OpTypePointer Private %2
1237 %3 = OpTypePointer Input %2
1238 +%60 = OpTypePointer Private %2
1239 %7 = OpTypePointer Output %2
1240 %10 = OpTypePointer Uniform %9
1241 %18 = OpTypePointer Uniform %17
1242 %24 = OpTypePointer Output %23
1243 %26 = OpTypePointer Function %2
1244 %46 = OpTypePointer Uniform %2
1245 %27 = OpTypeFunction %2 %26
1246 %39 = OpTypeFunction %38
1247 %4 = OpVariable %3 Input
1248 %5 = OpVariable %3 Input
1249 %6 = OpVariable %3 Input
1250 %8 = OpVariable %7 Output
1251 %11 = OpVariable %10 Uniform
1252 %19 = OpVariable %18 Uniform
1253 -%20 = OpVariable %7 Output
1254 +%58 = OpVariable %60 Private
1255 %25 = OpVariable %24 Output
1256 +%61 = OpConstant %13 0
1257 +%62 = OpConstant %1 0.5
1258 %28 = OpFunction %2 None %27
1259 %29 = OpFunctionParameter %26
1260 %30 = OpLabel
1261 %31 = OpLoad %2 %29
1262 OpReturnValue %31
1263 OpFunctionEnd
1264 %32 = OpFunction %2 None %27
1265 %33 = OpFunctionParameter %26
1266 %34 = OpLabel
1267 %35 = OpLoad %2 %33
1268 %36 = OpLoad %2 %33
1269 %37 = OpFAdd %2 %35 %36
1270 OpReturnValue %37
1271 OpFunctionEnd
1272 %40 = OpFunction %38 None %39
1273 %41 = OpLabel
1274 %42 = OpVariable %26 Function
1275 %50 = OpVariable %26 Function
1276 %53 = OpVariable %26 Function
1277 %43 = OpLoad %2 %4
1278 OpStore %42 %43
1279 %44 = OpFunctionCall %2 %28 %42
1280 %47 = OpAccessChain %46 %11 %45
1281 %48 = OpLoad %2 %47
1282 %49 = OpFAdd %2 %44 %48
1283 OpStore %8 %49
1284 %51 = OpLoad %2 %5
1285 OpStore %50 %51
1286 %52 = OpFunctionCall %2 %32 %50
1287 %54 = OpLoad %2 %6
1288 OpStore %53 %54
1289 %55 = OpFunctionCall %2 %28 %53
1290 %56 = OpFAdd %2 %52 %55
1291 %57 = OpAccessChain %7 %25 %45
1292 OpStore %57 %56
1293 +%63 = OpAccessChain %7 %25 %61
1294 +%64 = OpLoad %2 %63
1295 +%65 = OpCompositeExtract %1 %64 0
1296 +%66 = OpCompositeExtract %1 %64 1
1297 +%67 = OpCompositeExtract %1 %64 2
1298 +%68 = OpCompositeExtract %1 %64 3
1299 +%70 = OpFNegate %1 %65
1300 +%71 = OpFAdd %1 %67 %68
1301 +%72 = OpFMul %1 %71 %62
1302 +%69 = OpCompositeConstruct %2 %66 %70 %72 %68
1303 +OpStore %63 %69
1304 OpReturn
1305 OpFunctionEnd
1306 )";
1307 Options options;
1308 options.ignore_set_binding = true;
1309 options.ignore_location = true;
1310 DoStringDiffTest(kSrc, kDst, kDiff, options);
1311 }
1312
1313 } // namespace
1314 } // namespace diff
1315 } // namespace spvtools
1316