| 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, regardless of int or |
| 27 |
// uint. This helps compare output from different generators that default to |
| 28 |
// int or uint for constants such as those passed to OpAccessChain. |
| 29 |
constexpr char kSrc[] = R"(; SPIR-V |
| 30 |
; Version: 1.0 |
| 31 |
; Generator: Google ANGLE Shader Compiler; 0 |
| 32 |
; Bound: 27 |
| 33 |
; Schema: 0 |
| 34 |
OpCapability Shader |
| 35 |
OpMemoryModel Logical GLSL450 |
| 36 |
OpEntryPoint Vertex %22 "main" %4 %19 |
| 37 |
OpSource GLSL 450 |
| 38 |
OpName %4 "_ua_position" |
| 39 |
OpName %17 "gl_PerVertex" |
| 40 |
OpMemberName %17 0 "gl_Position" |
| 41 |
OpMemberName %17 1 "gl_PointSize" |
| 42 |
OpMemberName %17 2 "gl_ClipDistance" |
| 43 |
OpMemberName %17 3 "gl_CullDistance" |
| 44 |
OpName %19 "" |
| 45 |
OpName %22 "main" |
| 46 |
OpDecorate %4 Location 0 |
| 47 |
OpMemberDecorate %17 1 RelaxedPrecision |
| 48 |
OpMemberDecorate %17 0 BuiltIn Position |
| 49 |
OpMemberDecorate %17 1 BuiltIn PointSize |
| 50 |
OpMemberDecorate %17 2 BuiltIn ClipDistance |
| 51 |
OpMemberDecorate %17 3 BuiltIn CullDistance |
| 52 |
OpDecorate %17 Block |
| 53 |
%1 = OpTypeFloat 32 |
| 54 |
%2 = OpTypeVector %1 4 |
| 55 |
%5 = OpTypeInt 32 0 |
| 56 |
%8 = OpTypeVector %5 4 |
| 57 |
%15 = OpConstant %5 8 |
| 58 |
%16 = OpTypeArray %1 %15 |
| 59 |
%17 = OpTypeStruct %2 %1 %16 %16 |
| 60 |
%20 = OpTypeVoid |
| 61 |
%25 = OpConstant %5 0 |
| 62 |
%3 = OpTypePointer Input %2 |
| 63 |
%13 = OpTypePointer Output %2 |
| 64 |
%18 = OpTypePointer Output %17 |
| 65 |
%21 = OpTypeFunction %20 |
| 66 |
%4 = OpVariable %3 Input |
| 67 |
%19 = OpVariable %18 Output |
| 68 |
%22 = OpFunction %20 None %21 |
| 69 |
%23 = OpLabel |
| 70 |
%24 = OpLoad %2 %4 |
| 71 |
%26 = OpAccessChain %13 %19 %25 |
| 72 |
OpStore %26 %24 |
| 73 |
OpReturn |
| 74 |
OpFunctionEnd)"; |
| 75 |
constexpr char kDst[] = R"(; SPIR-V |
| 76 |
; Version: 1.0 |
| 77 |
; Generator: Khronos Glslang Reference Front End; 10 |
| 78 |
; Bound: 28 |
| 79 |
; Schema: 0 |
| 80 |
OpCapability Shader |
| 81 |
%1 = OpExtInstImport "GLSL.std.450" |
| 82 |
OpMemoryModel Logical GLSL450 |
| 83 |
OpEntryPoint Vertex %4 "main" %13 %17 |
| 84 |
OpSource GLSL 450 |
| 85 |
OpName %4 "main" |
| 86 |
OpName %11 "gl_PerVertex" |
| 87 |
OpMemberName %11 0 "gl_Position" |
| 88 |
OpMemberName %11 1 "gl_PointSize" |
| 89 |
OpMemberName %11 2 "gl_ClipDistance" |
| 90 |
OpMemberName %11 3 "gl_CullDistance" |
| 91 |
OpName %13 "" |
| 92 |
OpName %17 "_ua_position" |
| 93 |
OpMemberDecorate %11 0 BuiltIn Position |
| 94 |
OpMemberDecorate %11 1 BuiltIn PointSize |
| 95 |
OpMemberDecorate %11 2 BuiltIn ClipDistance |
| 96 |
OpMemberDecorate %11 3 BuiltIn CullDistance |
| 97 |
OpDecorate %11 Block |
| 98 |
OpDecorate %17 Location 0 |
| 99 |
%2 = OpTypeVoid |
| 100 |
%3 = OpTypeFunction %2 |
| 101 |
%6 = OpTypeFloat 32 |
| 102 |
%7 = OpTypeVector %6 4 |
| 103 |
%8 = OpTypeInt 32 0 |
| 104 |
%9 = OpConstant %8 1 |
| 105 |
%10 = OpTypeArray %6 %9 |
| 106 |
%11 = OpTypeStruct %7 %6 %10 %10 |
| 107 |
%12 = OpTypePointer Output %11 |
| 108 |
%13 = OpVariable %12 Output |
| 109 |
%14 = OpTypeInt 32 1 |
| 110 |
%15 = OpConstant %14 0 |
| 111 |
%16 = OpTypePointer Input %7 |
| 112 |
%17 = OpVariable %16 Input |
| 113 |
%19 = OpTypePointer Output %7 |
| 114 |
%4 = OpFunction %2 None %3 |
| 115 |
%5 = OpLabel |
| 116 |
%18 = OpLoad %7 %17 |
| 117 |
%20 = OpAccessChain %19 %13 %15 |
| 118 |
OpStore %20 %18 |
| 119 |
OpReturn |
| 120 |
OpFunctionEnd |
| 121 |
)"; |
| 122 |
|
| 123 |
TEST(DiffTest, IntVsUintConstants) { |
| 124 |
constexpr char kDiff[] = R"( ; SPIR-V |
| 125 |
; Version: 1.6 |
| 126 |
; Generator: Khronos SPIR-V Tools Assembler; 0 |
| 127 |
-; Bound: 27 |
| 128 |
+; Bound: 31 |
| 129 |
; Schema: 0 |
| 130 |
OpCapability Shader |
| 131 |
+%27 = OpExtInstImport "GLSL.std.450" |
| 132 |
OpMemoryModel Logical GLSL450 |
| 133 |
-OpEntryPoint Vertex %22 "main" %4 %19 |
| 134 |
+OpEntryPoint Vertex %22 "main" %19 %4 |
| 135 |
OpSource GLSL 450 |
| 136 |
OpName %4 "_ua_position" |
| 137 |
OpName %17 "gl_PerVertex" |
| 138 |
OpMemberName %17 0 "gl_Position" |
| 139 |
OpMemberName %17 1 "gl_PointSize" |
| 140 |
OpMemberName %17 2 "gl_ClipDistance" |
| 141 |
OpMemberName %17 3 "gl_CullDistance" |
| 142 |
OpName %19 "" |
| 143 |
OpName %22 "main" |
| 144 |
OpDecorate %4 Location 0 |
| 145 |
-OpMemberDecorate %17 1 RelaxedPrecision |
| 146 |
OpMemberDecorate %17 0 BuiltIn Position |
| 147 |
OpMemberDecorate %17 1 BuiltIn PointSize |
| 148 |
OpMemberDecorate %17 2 BuiltIn ClipDistance |
| 149 |
OpMemberDecorate %17 3 BuiltIn CullDistance |
| 150 |
OpDecorate %17 Block |
| 151 |
%1 = OpTypeFloat 32 |
| 152 |
%2 = OpTypeVector %1 4 |
| 153 |
%5 = OpTypeInt 32 0 |
| 154 |
-%8 = OpTypeVector %5 4 |
| 155 |
-%15 = OpConstant %5 8 |
| 156 |
-%16 = OpTypeArray %1 %15 |
| 157 |
-%17 = OpTypeStruct %2 %1 %16 %16 |
| 158 |
+%17 = OpTypeStruct %2 %1 %29 %29 |
| 159 |
%20 = OpTypeVoid |
| 160 |
+%28 = OpConstant %5 1 |
| 161 |
+%29 = OpTypeArray %1 %28 |
| 162 |
-%25 = OpConstant %5 0 |
| 163 |
+%25 = OpConstant %30 0 |
| 164 |
%3 = OpTypePointer Input %2 |
| 165 |
%13 = OpTypePointer Output %2 |
| 166 |
+%30 = OpTypeInt 32 1 |
| 167 |
%18 = OpTypePointer Output %17 |
| 168 |
%21 = OpTypeFunction %20 |
| 169 |
%4 = OpVariable %3 Input |
| 170 |
%19 = OpVariable %18 Output |
| 171 |
%22 = OpFunction %20 None %21 |
| 172 |
%23 = OpLabel |
| 173 |
%24 = OpLoad %2 %4 |
| 174 |
%26 = OpAccessChain %13 %19 %25 |
| 175 |
OpStore %26 %24 |
| 176 |
OpReturn |
| 177 |
OpFunctionEnd |
| 178 |
)"; |
| 179 |
Options options; |
| 180 |
DoStringDiffTest(kSrc, kDst, kDiff, options); |
| 181 |
} |
| 182 |
|
| 183 |
TEST(DiffTest, IntVsUintConstantsNoDebug) { |
| 184 |
constexpr char kSrcNoDebug[] = R"(; SPIR-V |
| 185 |
; Version: 1.0 |
| 186 |
; Generator: Google ANGLE Shader Compiler; 0 |
| 187 |
; Bound: 27 |
| 188 |
; Schema: 0 |
| 189 |
OpCapability Shader |
| 190 |
OpMemoryModel Logical GLSL450 |
| 191 |
OpEntryPoint Vertex %22 "main" %4 %19 |
| 192 |
OpSource GLSL 450 |
| 193 |
OpDecorate %4 Location 0 |
| 194 |
OpMemberDecorate %17 1 RelaxedPrecision |
| 195 |
OpMemberDecorate %17 0 BuiltIn Position |
| 196 |
OpMemberDecorate %17 1 BuiltIn PointSize |
| 197 |
OpMemberDecorate %17 2 BuiltIn ClipDistance |
| 198 |
OpMemberDecorate %17 3 BuiltIn CullDistance |
| 199 |
OpDecorate %17 Block |
| 200 |
%1 = OpTypeFloat 32 |
| 201 |
%2 = OpTypeVector %1 4 |
| 202 |
%5 = OpTypeInt 32 0 |
| 203 |
%8 = OpTypeVector %5 4 |
| 204 |
%15 = OpConstant %5 8 |
| 205 |
%16 = OpTypeArray %1 %15 |
| 206 |
%17 = OpTypeStruct %2 %1 %16 %16 |
| 207 |
%20 = OpTypeVoid |
| 208 |
%25 = OpConstant %5 0 |
| 209 |
%3 = OpTypePointer Input %2 |
| 210 |
%13 = OpTypePointer Output %2 |
| 211 |
%18 = OpTypePointer Output %17 |
| 212 |
%21 = OpTypeFunction %20 |
| 213 |
%4 = OpVariable %3 Input |
| 214 |
%19 = OpVariable %18 Output |
| 215 |
%22 = OpFunction %20 None %21 |
| 216 |
%23 = OpLabel |
| 217 |
%24 = OpLoad %2 %4 |
| 218 |
%26 = OpAccessChain %13 %19 %25 |
| 219 |
OpStore %26 %24 |
| 220 |
OpReturn |
| 221 |
OpFunctionEnd |
| 222 |
)"; |
| 223 |
constexpr char kDstNoDebug[] = R"(; SPIR-V |
| 224 |
; Version: 1.0 |
| 225 |
; Generator: Khronos Glslang Reference Front End; 10 |
| 226 |
; Bound: 28 |
| 227 |
; Schema: 0 |
| 228 |
OpCapability Shader |
| 229 |
%1 = OpExtInstImport "GLSL.std.450" |
| 230 |
OpMemoryModel Logical GLSL450 |
| 231 |
OpEntryPoint Vertex %4 "main" %13 %17 |
| 232 |
OpSource GLSL 450 |
| 233 |
OpMemberDecorate %11 0 BuiltIn Position |
| 234 |
OpMemberDecorate %11 1 BuiltIn PointSize |
| 235 |
OpMemberDecorate %11 2 BuiltIn ClipDistance |
| 236 |
OpMemberDecorate %11 3 BuiltIn CullDistance |
| 237 |
OpDecorate %11 Block |
| 238 |
OpDecorate %17 Location 0 |
| 239 |
%2 = OpTypeVoid |
| 240 |
%3 = OpTypeFunction %2 |
| 241 |
%6 = OpTypeFloat 32 |
| 242 |
%7 = OpTypeVector %6 4 |
| 243 |
%8 = OpTypeInt 32 0 |
| 244 |
%9 = OpConstant %8 1 |
| 245 |
%10 = OpTypeArray %6 %9 |
| 246 |
%11 = OpTypeStruct %7 %6 %10 %10 |
| 247 |
%12 = OpTypePointer Output %11 |
| 248 |
%13 = OpVariable %12 Output |
| 249 |
%14 = OpTypeInt 32 1 |
| 250 |
%15 = OpConstant %14 0 |
| 251 |
%16 = OpTypePointer Input %7 |
| 252 |
%17 = OpVariable %16 Input |
| 253 |
%19 = OpTypePointer Output %7 |
| 254 |
%4 = OpFunction %2 None %3 |
| 255 |
%5 = OpLabel |
| 256 |
%18 = OpLoad %7 %17 |
| 257 |
%20 = OpAccessChain %19 %13 %15 |
| 258 |
OpStore %20 %18 |
| 259 |
OpReturn |
| 260 |
OpFunctionEnd |
| 261 |
)"; |
| 262 |
constexpr char kDiff[] = R"( ; SPIR-V |
| 263 |
; Version: 1.6 |
| 264 |
; Generator: Khronos SPIR-V Tools Assembler; 0 |
| 265 |
-; Bound: 27 |
| 266 |
+; Bound: 31 |
| 267 |
; Schema: 0 |
| 268 |
OpCapability Shader |
| 269 |
+%27 = OpExtInstImport "GLSL.std.450" |
| 270 |
OpMemoryModel Logical GLSL450 |
| 271 |
-OpEntryPoint Vertex %22 "main" %4 %19 |
| 272 |
+OpEntryPoint Vertex %22 "main" %19 %4 |
| 273 |
OpSource GLSL 450 |
| 274 |
OpDecorate %4 Location 0 |
| 275 |
-OpMemberDecorate %17 1 RelaxedPrecision |
| 276 |
OpMemberDecorate %17 0 BuiltIn Position |
| 277 |
OpMemberDecorate %17 1 BuiltIn PointSize |
| 278 |
OpMemberDecorate %17 2 BuiltIn ClipDistance |
| 279 |
OpMemberDecorate %17 3 BuiltIn CullDistance |
| 280 |
OpDecorate %17 Block |
| 281 |
%1 = OpTypeFloat 32 |
| 282 |
%2 = OpTypeVector %1 4 |
| 283 |
%5 = OpTypeInt 32 0 |
| 284 |
-%8 = OpTypeVector %5 4 |
| 285 |
-%15 = OpConstant %5 8 |
| 286 |
-%16 = OpTypeArray %1 %15 |
| 287 |
-%17 = OpTypeStruct %2 %1 %16 %16 |
| 288 |
+%17 = OpTypeStruct %2 %1 %29 %29 |
| 289 |
%20 = OpTypeVoid |
| 290 |
+%28 = OpConstant %5 1 |
| 291 |
+%29 = OpTypeArray %1 %28 |
| 292 |
-%25 = OpConstant %5 0 |
| 293 |
+%25 = OpConstant %30 0 |
| 294 |
%3 = OpTypePointer Input %2 |
| 295 |
%13 = OpTypePointer Output %2 |
| 296 |
+%30 = OpTypeInt 32 1 |
| 297 |
%18 = OpTypePointer Output %17 |
| 298 |
%21 = OpTypeFunction %20 |
| 299 |
%4 = OpVariable %3 Input |
| 300 |
%19 = OpVariable %18 Output |
| 301 |
%22 = OpFunction %20 None %21 |
| 302 |
%23 = OpLabel |
| 303 |
%24 = OpLoad %2 %4 |
| 304 |
%26 = OpAccessChain %13 %19 %25 |
| 305 |
OpStore %26 %24 |
| 306 |
OpReturn |
| 307 |
OpFunctionEnd |
| 308 |
)"; |
| 309 |
Options options; |
| 310 |
DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); |
| 311 |
} |
| 312 |
|
| 313 |
TEST(DiffTest, IntVsUintConstantsDumpIds) { |
| 314 |
constexpr char kDiff[] = R"( ; SPIR-V |
| 315 |
; Version: 1.6 |
| 316 |
; Generator: Khronos SPIR-V Tools Assembler; 0 |
| 317 |
-; Bound: 27 |
| 318 |
+; Bound: 31 |
| 319 |
; Schema: 0 |
| 320 |
OpCapability Shader |
| 321 |
+%27 = OpExtInstImport "GLSL.std.450" |
| 322 |
OpMemoryModel Logical GLSL450 |
| 323 |
-OpEntryPoint Vertex %22 "main" %4 %19 |
| 324 |
+OpEntryPoint Vertex %22 "main" %19 %4 |
| 325 |
OpSource GLSL 450 |
| 326 |
OpName %4 "_ua_position" |
| 327 |
OpName %17 "gl_PerVertex" |
| 328 |
OpMemberName %17 0 "gl_Position" |
| 329 |
OpMemberName %17 1 "gl_PointSize" |
| 330 |
OpMemberName %17 2 "gl_ClipDistance" |
| 331 |
OpMemberName %17 3 "gl_CullDistance" |
| 332 |
OpName %19 "" |
| 333 |
OpName %22 "main" |
| 334 |
OpDecorate %4 Location 0 |
| 335 |
-OpMemberDecorate %17 1 RelaxedPrecision |
| 336 |
OpMemberDecorate %17 0 BuiltIn Position |
| 337 |
OpMemberDecorate %17 1 BuiltIn PointSize |
| 338 |
OpMemberDecorate %17 2 BuiltIn ClipDistance |
| 339 |
OpMemberDecorate %17 3 BuiltIn CullDistance |
| 340 |
OpDecorate %17 Block |
| 341 |
%1 = OpTypeFloat 32 |
| 342 |
%2 = OpTypeVector %1 4 |
| 343 |
%5 = OpTypeInt 32 0 |
| 344 |
-%8 = OpTypeVector %5 4 |
| 345 |
-%15 = OpConstant %5 8 |
| 346 |
-%16 = OpTypeArray %1 %15 |
| 347 |
-%17 = OpTypeStruct %2 %1 %16 %16 |
| 348 |
+%17 = OpTypeStruct %2 %1 %29 %29 |
| 349 |
%20 = OpTypeVoid |
| 350 |
+%28 = OpConstant %5 1 |
| 351 |
+%29 = OpTypeArray %1 %28 |
| 352 |
-%25 = OpConstant %5 0 |
| 353 |
+%25 = OpConstant %30 0 |
| 354 |
%3 = OpTypePointer Input %2 |
| 355 |
%13 = OpTypePointer Output %2 |
| 356 |
+%30 = OpTypeInt 32 1 |
| 357 |
%18 = OpTypePointer Output %17 |
| 358 |
%21 = OpTypeFunction %20 |
| 359 |
%4 = OpVariable %3 Input |
| 360 |
%19 = OpVariable %18 Output |
| 361 |
%22 = OpFunction %20 None %21 |
| 362 |
%23 = OpLabel |
| 363 |
%24 = OpLoad %2 %4 |
| 364 |
%26 = OpAccessChain %13 %19 %25 |
| 365 |
OpStore %26 %24 |
| 366 |
OpReturn |
| 367 |
OpFunctionEnd |
| 368 |
Src -> Dst |
| 369 |
1 -> 6 [TypeFloat] |
| 370 |
2 -> 7 [TypeVector] |
| 371 |
3 -> 16 [TypePointer] |
| 372 |
4 -> 17 [Variable] |
| 373 |
5 -> 8 [TypeInt] |
| 374 |
8 -> 21 [TypeVector] |
| 375 |
13 -> 19 [TypePointer] |
| 376 |
15 -> 22 [Constant] |
| 377 |
16 -> 23 [TypeArray] |
| 378 |
17 -> 11 [TypeStruct] |
| 379 |
18 -> 12 [TypePointer] |
| 380 |
19 -> 13 [Variable] |
| 381 |
20 -> 2 [TypeVoid] |
| 382 |
21 -> 3 [TypeFunction] |
| 383 |
22 -> 4 [Function] |
| 384 |
23 -> 5 [Label] |
| 385 |
24 -> 18 [Load] |
| 386 |
25 -> 15 [Constant] |
| 387 |
26 -> 20 [AccessChain] |
| 388 |
)"; |
| 389 |
Options options; |
| 390 |
options.dump_id_map = true; |
| 391 |
DoStringDiffTest(kSrc, kDst, kDiff, options); |
| 392 |
} |
| 393 |
|
| 394 |
} // namespace |
| 395 |
} // namespace diff |
| 396 |
} // namespace spvtools |