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 // Tests that identical integer constants are matched when used as array size,
27 // regardless of int or uint.
28 constexpr char kSrc[] = R"(; SPIR-V
29 ; Version: 1.0
30 ; Generator: Google ANGLE Shader Compiler; 0
31 ; Bound: 27
32 ; Schema: 0
33 OpCapability Shader
34 OpMemoryModel Logical GLSL450
35 OpEntryPoint Vertex %22 "main" %4 %19
36 OpSource GLSL 450
37 OpName %4 "_ua_position"
38 OpName %17 "gl_PerVertex"
39 OpMemberName %17 0 "gl_Position"
40 OpMemberName %17 1 "gl_PointSize"
41 OpMemberName %17 2 "gl_ClipDistance"
42 OpMemberName %17 3 "gl_CullDistance"
43 OpName %19 ""
44 OpName %22 "main"
45 OpDecorate %4 Location 0
46 OpMemberDecorate %17 1 RelaxedPrecision
47 OpMemberDecorate %17 0 BuiltIn Position
48 OpMemberDecorate %17 1 BuiltIn PointSize
49 OpMemberDecorate %17 2 BuiltIn ClipDistance
50 OpMemberDecorate %17 3 BuiltIn CullDistance
51 OpDecorate %17 Block
52 %1 = OpTypeFloat 32
53 %2 = OpTypeVector %1 4
54 %5 = OpTypeInt 32 0
55 %8 = OpTypeVector %5 4
56 %15 = OpConstant %5 8
57 %16 = OpTypeArray %1 %15
58 %17 = OpTypeStruct %2 %1 %16 %16
59 %20 = OpTypeVoid
60 %25 = OpConstant %5 0
61 %3 = OpTypePointer Input %2
62 %13 = OpTypePointer Output %2
63 %18 = OpTypePointer Output %17
64 %21 = OpTypeFunction %20
65 %4 = OpVariable %3 Input
66 %19 = OpVariable %18 Output
67 %22 = OpFunction %20 None %21
68 %23 = OpLabel
69 %24 = OpLoad %2 %4
70 %26 = OpAccessChain %13 %19 %25
71 OpStore %26 %24
72 OpReturn
73 OpFunctionEnd)";
74 constexpr char kDst[] = R"(; SPIR-V
75 ; Version: 1.0
76 ; Generator: Google ANGLE Shader Compiler; 0
77 ; Bound: 27
78 ; Schema: 0
79 OpCapability Shader
80 OpMemoryModel Logical GLSL450
81 OpEntryPoint Vertex %22 "main" %4 %19
82 OpSource GLSL 450
83 OpName %4 "_ua_position"
84 OpName %17 "gl_PerVertex"
85 OpMemberName %17 0 "gl_Position"
86 OpMemberName %17 1 "gl_PointSize"
87 OpMemberName %17 2 "gl_ClipDistance"
88 OpMemberName %17 3 "gl_CullDistance"
89 OpName %19 ""
90 OpName %22 "main"
91 OpDecorate %4 Location 0
92 OpMemberDecorate %17 1 RelaxedPrecision
93 OpMemberDecorate %17 0 BuiltIn Position
94 OpMemberDecorate %17 1 BuiltIn PointSize
95 OpMemberDecorate %17 2 BuiltIn ClipDistance
96 OpMemberDecorate %17 3 BuiltIn CullDistance
97 OpDecorate %17 Block
98 %1 = OpTypeFloat 32
99 %2 = OpTypeVector %1 4
100 %5 = OpTypeInt 32 0
101 %6 = OpTypeInt 32 1
102 %8 = OpTypeVector %5 4
103 %15 = OpConstant %6 8
104 %16 = OpTypeArray %1 %15
105 %17 = OpTypeStruct %2 %1 %16 %16
106 %20 = OpTypeVoid
107 %25 = OpConstant %5 0
108 %3 = OpTypePointer Input %2
109 %13 = OpTypePointer Output %2
110 %18 = OpTypePointer Output %17
111 %21 = OpTypeFunction %20
112 %4 = OpVariable %3 Input
113 %19 = OpVariable %18 Output
114 %22 = OpFunction %20 None %21
115 %23 = OpLabel
116 %24 = OpLoad %2 %4
117 %26 = OpAccessChain %13 %19 %25
118 OpStore %26 %24
119 OpReturn
120 OpFunctionEnd
121 )";
122
TEST(DiffTest,ConstantArraySize)123 TEST(DiffTest, ConstantArraySize) {
124 constexpr char kDiff[] = R"( ; SPIR-V
125 ; Version: 1.6
126 ; Generator: Khronos SPIR-V Tools Assembler; 0
127 -; Bound: 27
128 +; Bound: 28
129 ; Schema: 0
130 OpCapability Shader
131 OpMemoryModel Logical GLSL450
132 OpEntryPoint Vertex %22 "main" %4 %19
133 OpSource GLSL 450
134 OpName %4 "_ua_position"
135 OpName %17 "gl_PerVertex"
136 OpMemberName %17 0 "gl_Position"
137 OpMemberName %17 1 "gl_PointSize"
138 OpMemberName %17 2 "gl_ClipDistance"
139 OpMemberName %17 3 "gl_CullDistance"
140 OpName %19 ""
141 OpName %22 "main"
142 OpDecorate %4 Location 0
143 OpMemberDecorate %17 1 RelaxedPrecision
144 OpMemberDecorate %17 0 BuiltIn Position
145 OpMemberDecorate %17 1 BuiltIn PointSize
146 OpMemberDecorate %17 2 BuiltIn ClipDistance
147 OpMemberDecorate %17 3 BuiltIn CullDistance
148 OpDecorate %17 Block
149 %1 = OpTypeFloat 32
150 %2 = OpTypeVector %1 4
151 %5 = OpTypeInt 32 0
152 +%27 = OpTypeInt 32 1
153 %8 = OpTypeVector %5 4
154 -%15 = OpConstant %5 8
155 +%15 = OpConstant %27 8
156 %16 = OpTypeArray %1 %15
157 %17 = OpTypeStruct %2 %1 %16 %16
158 %20 = OpTypeVoid
159 %25 = OpConstant %5 0
160 %3 = OpTypePointer Input %2
161 %13 = OpTypePointer Output %2
162 %18 = OpTypePointer Output %17
163 %21 = OpTypeFunction %20
164 %4 = OpVariable %3 Input
165 %19 = OpVariable %18 Output
166 %22 = OpFunction %20 None %21
167 %23 = OpLabel
168 %24 = OpLoad %2 %4
169 %26 = OpAccessChain %13 %19 %25
170 OpStore %26 %24
171 OpReturn
172 OpFunctionEnd
173 )";
174 Options options;
175 DoStringDiffTest(kSrc, kDst, kDiff, options);
176 }
177
TEST(DiffTest,ConstantArraySizeNoDebug)178 TEST(DiffTest, ConstantArraySizeNoDebug) {
179 constexpr char kSrcNoDebug[] = R"(; SPIR-V
180 ; Version: 1.0
181 ; Generator: Google ANGLE Shader Compiler; 0
182 ; Bound: 27
183 ; Schema: 0
184 OpCapability Shader
185 OpMemoryModel Logical GLSL450
186 OpEntryPoint Vertex %22 "main" %4 %19
187 OpSource GLSL 450
188 OpDecorate %4 Location 0
189 OpMemberDecorate %17 1 RelaxedPrecision
190 OpMemberDecorate %17 0 BuiltIn Position
191 OpMemberDecorate %17 1 BuiltIn PointSize
192 OpMemberDecorate %17 2 BuiltIn ClipDistance
193 OpMemberDecorate %17 3 BuiltIn CullDistance
194 OpDecorate %17 Block
195 %1 = OpTypeFloat 32
196 %2 = OpTypeVector %1 4
197 %5 = OpTypeInt 32 0
198 %8 = OpTypeVector %5 4
199 %15 = OpConstant %5 8
200 %16 = OpTypeArray %1 %15
201 %17 = OpTypeStruct %2 %1 %16 %16
202 %20 = OpTypeVoid
203 %25 = OpConstant %5 0
204 %3 = OpTypePointer Input %2
205 %13 = OpTypePointer Output %2
206 %18 = OpTypePointer Output %17
207 %21 = OpTypeFunction %20
208 %4 = OpVariable %3 Input
209 %19 = OpVariable %18 Output
210 %22 = OpFunction %20 None %21
211 %23 = OpLabel
212 %24 = OpLoad %2 %4
213 %26 = OpAccessChain %13 %19 %25
214 OpStore %26 %24
215 OpReturn
216 OpFunctionEnd
217 )";
218 constexpr char kDstNoDebug[] = R"(; SPIR-V
219 ; Version: 1.0
220 ; Generator: Google ANGLE Shader Compiler; 0
221 ; Bound: 27
222 ; Schema: 0
223 OpCapability Shader
224 OpMemoryModel Logical GLSL450
225 OpEntryPoint Vertex %22 "main" %4 %19
226 OpSource GLSL 450
227 OpDecorate %4 Location 0
228 OpMemberDecorate %17 1 RelaxedPrecision
229 OpMemberDecorate %17 0 BuiltIn Position
230 OpMemberDecorate %17 1 BuiltIn PointSize
231 OpMemberDecorate %17 2 BuiltIn ClipDistance
232 OpMemberDecorate %17 3 BuiltIn CullDistance
233 OpDecorate %17 Block
234 %1 = OpTypeFloat 32
235 %2 = OpTypeVector %1 4
236 %5 = OpTypeInt 32 0
237 %6 = OpTypeInt 32 1
238 %8 = OpTypeVector %5 4
239 %15 = OpConstant %6 8
240 %16 = OpTypeArray %1 %15
241 %17 = OpTypeStruct %2 %1 %16 %16
242 %20 = OpTypeVoid
243 %25 = OpConstant %5 0
244 %3 = OpTypePointer Input %2
245 %13 = OpTypePointer Output %2
246 %18 = OpTypePointer Output %17
247 %21 = OpTypeFunction %20
248 %4 = OpVariable %3 Input
249 %19 = OpVariable %18 Output
250 %22 = OpFunction %20 None %21
251 %23 = OpLabel
252 %24 = OpLoad %2 %4
253 %26 = OpAccessChain %13 %19 %25
254 OpStore %26 %24
255 OpReturn
256 OpFunctionEnd
257 )";
258 constexpr char kDiff[] = R"( ; SPIR-V
259 ; Version: 1.6
260 ; Generator: Khronos SPIR-V Tools Assembler; 0
261 -; Bound: 27
262 +; Bound: 28
263 ; Schema: 0
264 OpCapability Shader
265 OpMemoryModel Logical GLSL450
266 OpEntryPoint Vertex %22 "main" %4 %19
267 OpSource GLSL 450
268 OpDecorate %4 Location 0
269 OpMemberDecorate %17 1 RelaxedPrecision
270 OpMemberDecorate %17 0 BuiltIn Position
271 OpMemberDecorate %17 1 BuiltIn PointSize
272 OpMemberDecorate %17 2 BuiltIn ClipDistance
273 OpMemberDecorate %17 3 BuiltIn CullDistance
274 OpDecorate %17 Block
275 %1 = OpTypeFloat 32
276 %2 = OpTypeVector %1 4
277 %5 = OpTypeInt 32 0
278 +%27 = OpTypeInt 32 1
279 %8 = OpTypeVector %5 4
280 -%15 = OpConstant %5 8
281 +%15 = OpConstant %27 8
282 %16 = OpTypeArray %1 %15
283 %17 = OpTypeStruct %2 %1 %16 %16
284 %20 = OpTypeVoid
285 %25 = OpConstant %5 0
286 %3 = OpTypePointer Input %2
287 %13 = OpTypePointer Output %2
288 %18 = OpTypePointer Output %17
289 %21 = OpTypeFunction %20
290 %4 = OpVariable %3 Input
291 %19 = OpVariable %18 Output
292 %22 = OpFunction %20 None %21
293 %23 = OpLabel
294 %24 = OpLoad %2 %4
295 %26 = OpAccessChain %13 %19 %25
296 OpStore %26 %24
297 OpReturn
298 OpFunctionEnd
299 )";
300 Options options;
301 DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options);
302 }
303
304 } // namespace
305 } // namespace diff
306 } // namespace spvtools
307