• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 specialization constants are not matched with constants
27 // when used as array size.
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 OpDecorate %15 SpecId 4
93 OpMemberDecorate %17 1 RelaxedPrecision
94 OpMemberDecorate %17 0 BuiltIn Position
95 OpMemberDecorate %17 1 BuiltIn PointSize
96 OpMemberDecorate %17 2 BuiltIn ClipDistance
97 OpMemberDecorate %17 3 BuiltIn CullDistance
98 OpDecorate %17 Block
99 %1 = OpTypeFloat 32
100 %2 = OpTypeVector %1 4
101 %5 = OpTypeInt 32 0
102 %8 = OpTypeVector %5 4
103 %15 = OpSpecConstant %5 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,SpecConstantArraySize)123 TEST(DiffTest, SpecConstantArraySize) {
124   constexpr char kDiff[] = R"( ; SPIR-V
125  ; Version: 1.6
126  ; Generator: Khronos SPIR-V Tools Assembler; 0
127 -; Bound: 27
128 +; Bound: 29
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 +OpDecorate %27 SpecId 4
144  OpMemberDecorate %17 1 RelaxedPrecision
145  OpMemberDecorate %17 0 BuiltIn Position
146  OpMemberDecorate %17 1 BuiltIn PointSize
147  OpMemberDecorate %17 2 BuiltIn ClipDistance
148  OpMemberDecorate %17 3 BuiltIn CullDistance
149  OpDecorate %17 Block
150  %1 = OpTypeFloat 32
151  %2 = OpTypeVector %1 4
152  %5 = OpTypeInt 32 0
153  %8 = OpTypeVector %5 4
154 -%15 = OpConstant %5 8
155 -%16 = OpTypeArray %1 %15
156 +%27 = OpSpecConstant %5 8
157 +%28 = OpTypeArray %1 %27
158 -%17 = OpTypeStruct %2 %1 %16 %16
159 +%17 = OpTypeStruct %2 %1 %28 %28
160  %20 = OpTypeVoid
161  %25 = OpConstant %5 0
162  %3 = OpTypePointer Input %2
163  %13 = OpTypePointer Output %2
164  %18 = OpTypePointer Output %17
165  %21 = OpTypeFunction %20
166  %4 = OpVariable %3 Input
167  %19 = OpVariable %18 Output
168  %22 = OpFunction %20 None %21
169  %23 = OpLabel
170  %24 = OpLoad %2 %4
171  %26 = OpAccessChain %13 %19 %25
172  OpStore %26 %24
173  OpReturn
174  OpFunctionEnd
175 )";
176   Options options;
177   DoStringDiffTest(kSrc, kDst, kDiff, options);
178 }
179 
TEST(DiffTest,SpecConstantArraySizeNoDebug)180 TEST(DiffTest, SpecConstantArraySizeNoDebug) {
181   constexpr char kSrcNoDebug[] = R"(; SPIR-V
182 ; Version: 1.0
183 ; Generator: Google ANGLE Shader Compiler; 0
184 ; Bound: 27
185 ; Schema: 0
186 OpCapability Shader
187 OpMemoryModel Logical GLSL450
188 OpEntryPoint Vertex %22 "main" %4 %19
189 OpSource GLSL 450
190 OpDecorate %4 Location 0
191 OpMemberDecorate %17 1 RelaxedPrecision
192 OpMemberDecorate %17 0 BuiltIn Position
193 OpMemberDecorate %17 1 BuiltIn PointSize
194 OpMemberDecorate %17 2 BuiltIn ClipDistance
195 OpMemberDecorate %17 3 BuiltIn CullDistance
196 OpDecorate %17 Block
197 %1 = OpTypeFloat 32
198 %2 = OpTypeVector %1 4
199 %5 = OpTypeInt 32 0
200 %8 = OpTypeVector %5 4
201 %15 = OpConstant %5 8
202 %16 = OpTypeArray %1 %15
203 %17 = OpTypeStruct %2 %1 %16 %16
204 %20 = OpTypeVoid
205 %25 = OpConstant %5 0
206 %3 = OpTypePointer Input %2
207 %13 = OpTypePointer Output %2
208 %18 = OpTypePointer Output %17
209 %21 = OpTypeFunction %20
210 %4 = OpVariable %3 Input
211 %19 = OpVariable %18 Output
212 %22 = OpFunction %20 None %21
213 %23 = OpLabel
214 %24 = OpLoad %2 %4
215 %26 = OpAccessChain %13 %19 %25
216 OpStore %26 %24
217 OpReturn
218 OpFunctionEnd
219 )";
220   constexpr char kDstNoDebug[] = R"(; SPIR-V
221 ; Version: 1.0
222 ; Generator: Google ANGLE Shader Compiler; 0
223 ; Bound: 27
224 ; Schema: 0
225 OpCapability Shader
226 OpMemoryModel Logical GLSL450
227 OpEntryPoint Vertex %22 "main" %4 %19
228 OpSource GLSL 450
229 OpDecorate %4 Location 0
230 OpDecorate %15 SpecId 4
231 OpMemberDecorate %17 1 RelaxedPrecision
232 OpMemberDecorate %17 0 BuiltIn Position
233 OpMemberDecorate %17 1 BuiltIn PointSize
234 OpMemberDecorate %17 2 BuiltIn ClipDistance
235 OpMemberDecorate %17 3 BuiltIn CullDistance
236 OpDecorate %17 Block
237 %1 = OpTypeFloat 32
238 %2 = OpTypeVector %1 4
239 %5 = OpTypeInt 32 0
240 %8 = OpTypeVector %5 4
241 %15 = OpSpecConstant %5 8
242 %16 = OpTypeArray %1 %15
243 %17 = OpTypeStruct %2 %1 %16 %16
244 %20 = OpTypeVoid
245 %25 = OpConstant %5 0
246 %3 = OpTypePointer Input %2
247 %13 = OpTypePointer Output %2
248 %18 = OpTypePointer Output %17
249 %21 = OpTypeFunction %20
250 %4 = OpVariable %3 Input
251 %19 = OpVariable %18 Output
252 %22 = OpFunction %20 None %21
253 %23 = OpLabel
254 %24 = OpLoad %2 %4
255 %26 = OpAccessChain %13 %19 %25
256 OpStore %26 %24
257 OpReturn
258 OpFunctionEnd
259 )";
260   constexpr char kDiff[] = R"( ; SPIR-V
261  ; Version: 1.6
262  ; Generator: Khronos SPIR-V Tools Assembler; 0
263 -; Bound: 27
264 +; Bound: 29
265  ; Schema: 0
266  OpCapability Shader
267  OpMemoryModel Logical GLSL450
268  OpEntryPoint Vertex %22 "main" %4 %19
269  OpSource GLSL 450
270  OpDecorate %4 Location 0
271 +OpDecorate %27 SpecId 4
272  OpMemberDecorate %17 1 RelaxedPrecision
273  OpMemberDecorate %17 0 BuiltIn Position
274  OpMemberDecorate %17 1 BuiltIn PointSize
275  OpMemberDecorate %17 2 BuiltIn ClipDistance
276  OpMemberDecorate %17 3 BuiltIn CullDistance
277  OpDecorate %17 Block
278  %1 = OpTypeFloat 32
279  %2 = OpTypeVector %1 4
280  %5 = OpTypeInt 32 0
281  %8 = OpTypeVector %5 4
282 -%15 = OpConstant %5 8
283 -%16 = OpTypeArray %1 %15
284 +%27 = OpSpecConstant %5 8
285 +%28 = OpTypeArray %1 %27
286 -%17 = OpTypeStruct %2 %1 %16 %16
287 +%17 = OpTypeStruct %2 %1 %28 %28
288  %20 = OpTypeVoid
289  %25 = OpConstant %5 0
290  %3 = OpTypePointer Input %2
291  %13 = OpTypePointer Output %2
292  %18 = OpTypePointer Output %17
293  %21 = OpTypeFunction %20
294  %4 = OpVariable %3 Input
295  %19 = OpVariable %18 Output
296  %22 = OpFunction %20 None %21
297  %23 = OpLabel
298  %24 = OpLoad %2 %4
299  %26 = OpAccessChain %13 %19 %25
300  OpStore %26 %24
301  OpReturn
302  OpFunctionEnd
303 )";
304   Options options;
305   DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options);
306 }
307 
308 }  // namespace
309 }  // namespace diff
310 }  // namespace spvtools
311