basic_autogen.cpp 11 KB

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