extra_if_block_autogen.cpp 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867
  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. // Test where src has an extra if block in one function, and dst has an extra
  23. // if block in another function.
  24. constexpr char kSrc[] = R"( OpCapability Shader
  25. %1 = OpExtInstImport "GLSL.std.450"
  26. OpMemoryModel Logical GLSL450
  27. OpEntryPoint Fragment %4 "main" %63 %68
  28. OpExecutionMode %4 OriginUpperLeft
  29. OpSource ESSL 310
  30. OpName %4 "main"
  31. OpName %8 "f1("
  32. OpName %10 "f2("
  33. OpName %13 "v"
  34. OpName %16 "Buffer"
  35. OpMemberName %16 0 "flag1"
  36. OpMemberName %16 1 "flag2"
  37. OpName %18 ""
  38. OpName %45 "v"
  39. OpName %63 "color"
  40. OpName %68 "v"
  41. OpDecorate %8 RelaxedPrecision
  42. OpDecorate %10 RelaxedPrecision
  43. OpDecorate %13 RelaxedPrecision
  44. OpMemberDecorate %16 0 RelaxedPrecision
  45. OpMemberDecorate %16 0 Offset 0
  46. OpMemberDecorate %16 1 RelaxedPrecision
  47. OpMemberDecorate %16 1 Offset 4
  48. OpDecorate %16 Block
  49. OpDecorate %18 DescriptorSet 0
  50. OpDecorate %18 Binding 0
  51. OpDecorate %23 RelaxedPrecision
  52. OpDecorate %30 RelaxedPrecision
  53. OpDecorate %31 RelaxedPrecision
  54. OpDecorate %34 RelaxedPrecision
  55. OpDecorate %35 RelaxedPrecision
  56. OpDecorate %36 RelaxedPrecision
  57. OpDecorate %37 RelaxedPrecision
  58. OpDecorate %38 RelaxedPrecision
  59. OpDecorate %39 RelaxedPrecision
  60. OpDecorate %40 RelaxedPrecision
  61. OpDecorate %41 RelaxedPrecision
  62. OpDecorate %42 RelaxedPrecision
  63. OpDecorate %45 RelaxedPrecision
  64. OpDecorate %47 RelaxedPrecision
  65. OpDecorate %48 RelaxedPrecision
  66. OpDecorate %50 RelaxedPrecision
  67. OpDecorate %51 RelaxedPrecision
  68. OpDecorate %54 RelaxedPrecision
  69. OpDecorate %55 RelaxedPrecision
  70. OpDecorate %56 RelaxedPrecision
  71. OpDecorate %57 RelaxedPrecision
  72. OpDecorate %58 RelaxedPrecision
  73. OpDecorate %63 RelaxedPrecision
  74. OpDecorate %63 Location 0
  75. OpDecorate %64 RelaxedPrecision
  76. OpDecorate %65 RelaxedPrecision
  77. OpDecorate %66 RelaxedPrecision
  78. OpDecorate %68 RelaxedPrecision
  79. OpDecorate %68 Location 0
  80. %2 = OpTypeVoid
  81. %3 = OpTypeFunction %2
  82. %6 = OpTypeFloat 32
  83. %7 = OpTypeFunction %6
  84. %12 = OpTypePointer Function %6
  85. %14 = OpConstant %6 0
  86. %15 = OpTypeInt 32 0
  87. %16 = OpTypeStruct %15 %15
  88. %17 = OpTypePointer Uniform %16
  89. %18 = OpVariable %17 Uniform
  90. %19 = OpTypeInt 32 1
  91. %20 = OpConstant %19 0
  92. %21 = OpTypePointer Uniform %15
  93. %24 = OpConstant %15 0
  94. %25 = OpTypeBool
  95. %29 = OpConstant %6 1
  96. %32 = OpConstant %19 1
  97. %49 = OpConstant %6 10
  98. %52 = OpConstant %6 0.5
  99. %53 = OpConstant %6 0.699999988
  100. %61 = OpTypeVector %6 4
  101. %62 = OpTypePointer Output %61
  102. %63 = OpVariable %62 Output
  103. %67 = OpTypePointer Input %6
  104. %68 = OpVariable %67 Input
  105. %4 = OpFunction %2 None %3
  106. %5 = OpLabel
  107. %64 = OpFunctionCall %6 %8
  108. %65 = OpFunctionCall %6 %10
  109. %66 = OpCompositeConstruct %61 %64 %65 %14 %29
  110. OpStore %63 %66
  111. OpReturn
  112. OpFunctionEnd
  113. %8 = OpFunction %6 None %7
  114. %9 = OpLabel
  115. %13 = OpVariable %12 Function
  116. OpStore %13 %14
  117. %22 = OpAccessChain %21 %18 %20
  118. %23 = OpLoad %15 %22
  119. %26 = OpINotEqual %25 %23 %24
  120. OpSelectionMerge %28 None
  121. OpBranchConditional %26 %27 %28
  122. %27 = OpLabel
  123. %30 = OpLoad %6 %13
  124. %31 = OpFAdd %6 %30 %29
  125. OpStore %13 %31
  126. OpBranch %28
  127. %28 = OpLabel
  128. %33 = OpAccessChain %21 %18 %32
  129. %34 = OpLoad %15 %33
  130. %35 = OpConvertUToF %6 %34
  131. %36 = OpExtInst %6 %1 Log2 %35
  132. %37 = OpLoad %6 %13
  133. %38 = OpFAdd %6 %37 %36
  134. OpStore %13 %38
  135. %39 = OpLoad %6 %13
  136. %40 = OpLoad %6 %13
  137. %41 = OpExtInst %6 %1 Sqrt %40
  138. %42 = OpFSub %6 %39 %41
  139. OpReturnValue %42
  140. OpFunctionEnd
  141. %10 = OpFunction %6 None %7
  142. %11 = OpLabel
  143. %45 = OpVariable %12 Function
  144. %46 = OpAccessChain %21 %18 %20
  145. %47 = OpLoad %15 %46
  146. %48 = OpConvertUToF %6 %47
  147. %50 = OpFDiv %6 %48 %49
  148. OpStore %45 %50
  149. %51 = OpLoad %6 %45
  150. %54 = OpExtInst %6 %1 FClamp %51 %52 %53
  151. %55 = OpLoad %6 %45
  152. %56 = OpFMul %6 %55 %54
  153. OpStore %45 %56
  154. %57 = OpLoad %6 %45
  155. %58 = OpExtInst %6 %1 Exp %57
  156. OpReturnValue %58
  157. OpFunctionEnd
  158. )";
  159. constexpr char kDst[] = R"( OpCapability Shader
  160. %1 = OpExtInstImport "GLSL.std.450"
  161. OpMemoryModel Logical GLSL450
  162. OpEntryPoint Fragment %4 "main" %63 %69
  163. OpExecutionMode %4 OriginUpperLeft
  164. OpSource ESSL 310
  165. OpName %4 "main"
  166. OpName %8 "f1("
  167. OpName %10 "f2("
  168. OpName %13 "v"
  169. OpName %16 "Buffer"
  170. OpMemberName %16 0 "flag1"
  171. OpMemberName %16 1 "flag2"
  172. OpName %18 ""
  173. OpName %34 "v"
  174. OpName %63 "color"
  175. OpName %69 "v"
  176. OpDecorate %8 RelaxedPrecision
  177. OpDecorate %10 RelaxedPrecision
  178. OpDecorate %13 RelaxedPrecision
  179. OpMemberDecorate %16 0 RelaxedPrecision
  180. OpMemberDecorate %16 0 Offset 0
  181. OpMemberDecorate %16 1 RelaxedPrecision
  182. OpMemberDecorate %16 1 Offset 4
  183. OpDecorate %16 Block
  184. OpDecorate %18 DescriptorSet 0
  185. OpDecorate %18 Binding 0
  186. OpDecorate %23 RelaxedPrecision
  187. OpDecorate %24 RelaxedPrecision
  188. OpDecorate %25 RelaxedPrecision
  189. OpDecorate %26 RelaxedPrecision
  190. OpDecorate %27 RelaxedPrecision
  191. OpDecorate %28 RelaxedPrecision
  192. OpDecorate %29 RelaxedPrecision
  193. OpDecorate %30 RelaxedPrecision
  194. OpDecorate %31 RelaxedPrecision
  195. OpDecorate %34 RelaxedPrecision
  196. OpDecorate %37 RelaxedPrecision
  197. OpDecorate %38 RelaxedPrecision
  198. OpDecorate %40 RelaxedPrecision
  199. OpDecorate %41 RelaxedPrecision
  200. OpDecorate %44 RelaxedPrecision
  201. OpDecorate %45 RelaxedPrecision
  202. OpDecorate %46 RelaxedPrecision
  203. OpDecorate %48 RelaxedPrecision
  204. OpDecorate %55 RelaxedPrecision
  205. OpDecorate %56 RelaxedPrecision
  206. OpDecorate %57 RelaxedPrecision
  207. OpDecorate %58 RelaxedPrecision
  208. OpDecorate %63 RelaxedPrecision
  209. OpDecorate %63 Location 0
  210. OpDecorate %64 RelaxedPrecision
  211. OpDecorate %65 RelaxedPrecision
  212. OpDecorate %67 RelaxedPrecision
  213. OpDecorate %69 RelaxedPrecision
  214. OpDecorate %69 Location 0
  215. %2 = OpTypeVoid
  216. %3 = OpTypeFunction %2
  217. %6 = OpTypeFloat 32
  218. %7 = OpTypeFunction %6
  219. %12 = OpTypePointer Function %6
  220. %14 = OpConstant %6 0
  221. %15 = OpTypeInt 32 0
  222. %16 = OpTypeStruct %15 %15
  223. %17 = OpTypePointer Uniform %16
  224. %18 = OpVariable %17 Uniform
  225. %19 = OpTypeInt 32 1
  226. %20 = OpConstant %19 1
  227. %21 = OpTypePointer Uniform %15
  228. %35 = OpConstant %19 0
  229. %39 = OpConstant %6 10
  230. %42 = OpConstant %6 0.5
  231. %43 = OpConstant %6 0.699999988
  232. %49 = OpConstant %15 0
  233. %50 = OpTypeBool
  234. %54 = OpConstant %6 0.100000001
  235. %61 = OpTypeVector %6 4
  236. %62 = OpTypePointer Output %61
  237. %63 = OpVariable %62 Output
  238. %66 = OpConstant %6 1
  239. %68 = OpTypePointer Input %6
  240. %69 = OpVariable %68 Input
  241. %4 = OpFunction %2 None %3
  242. %5 = OpLabel
  243. %64 = OpFunctionCall %6 %8
  244. %65 = OpFunctionCall %6 %10
  245. %67 = OpCompositeConstruct %61 %64 %65 %14 %66
  246. OpStore %63 %67
  247. OpReturn
  248. OpFunctionEnd
  249. %8 = OpFunction %6 None %7
  250. %9 = OpLabel
  251. %13 = OpVariable %12 Function
  252. OpStore %13 %14
  253. %22 = OpAccessChain %21 %18 %20
  254. %23 = OpLoad %15 %22
  255. %24 = OpConvertUToF %6 %23
  256. %25 = OpExtInst %6 %1 Log2 %24
  257. %26 = OpLoad %6 %13
  258. %27 = OpFAdd %6 %26 %25
  259. OpStore %13 %27
  260. %28 = OpLoad %6 %13
  261. %29 = OpLoad %6 %13
  262. %30 = OpExtInst %6 %1 Sqrt %29
  263. %31 = OpFSub %6 %28 %30
  264. OpReturnValue %31
  265. OpFunctionEnd
  266. %10 = OpFunction %6 None %7
  267. %11 = OpLabel
  268. %34 = OpVariable %12 Function
  269. %36 = OpAccessChain %21 %18 %35
  270. %37 = OpLoad %15 %36
  271. %38 = OpConvertUToF %6 %37
  272. %40 = OpFDiv %6 %38 %39
  273. OpStore %34 %40
  274. %41 = OpLoad %6 %34
  275. %44 = OpExtInst %6 %1 FClamp %41 %42 %43
  276. %45 = OpLoad %6 %34
  277. %46 = OpFMul %6 %45 %44
  278. OpStore %34 %46
  279. %47 = OpAccessChain %21 %18 %20
  280. %48 = OpLoad %15 %47
  281. %51 = OpINotEqual %50 %48 %49
  282. OpSelectionMerge %53 None
  283. OpBranchConditional %51 %52 %53
  284. %52 = OpLabel
  285. %55 = OpLoad %6 %34
  286. %56 = OpFSub %6 %55 %54
  287. OpStore %34 %56
  288. OpBranch %53
  289. %53 = OpLabel
  290. %57 = OpLoad %6 %34
  291. %58 = OpExtInst %6 %1 Exp %57
  292. OpReturnValue %58
  293. OpFunctionEnd
  294. )";
  295. TEST(DiffTest, ExtraIfBlock) {
  296. constexpr char kDiff[] = R"( ; SPIR-V
  297. ; Version: 1.6
  298. ; Generator: Khronos SPIR-V Tools Assembler; 0
  299. -; Bound: 69
  300. +; Bound: 77
  301. ; Schema: 0
  302. OpCapability Shader
  303. %1 = OpExtInstImport "GLSL.std.450"
  304. OpMemoryModel Logical GLSL450
  305. OpEntryPoint Fragment %4 "main" %63 %68
  306. OpExecutionMode %4 OriginUpperLeft
  307. OpSource ESSL 310
  308. OpName %4 "main"
  309. OpName %8 "f1("
  310. OpName %10 "f2("
  311. OpName %13 "v"
  312. OpName %16 "Buffer"
  313. OpMemberName %16 0 "flag1"
  314. OpMemberName %16 1 "flag2"
  315. OpName %18 ""
  316. OpName %45 "v"
  317. OpName %63 "color"
  318. OpName %68 "v"
  319. OpDecorate %8 RelaxedPrecision
  320. OpDecorate %10 RelaxedPrecision
  321. OpDecorate %13 RelaxedPrecision
  322. OpMemberDecorate %16 0 RelaxedPrecision
  323. OpMemberDecorate %16 0 Offset 0
  324. OpMemberDecorate %16 1 RelaxedPrecision
  325. OpMemberDecorate %16 1 Offset 4
  326. OpDecorate %16 Block
  327. OpDecorate %18 DescriptorSet 0
  328. OpDecorate %18 Binding 0
  329. -OpDecorate %23 RelaxedPrecision
  330. -OpDecorate %30 RelaxedPrecision
  331. -OpDecorate %31 RelaxedPrecision
  332. OpDecorate %34 RelaxedPrecision
  333. OpDecorate %35 RelaxedPrecision
  334. OpDecorate %36 RelaxedPrecision
  335. OpDecorate %37 RelaxedPrecision
  336. OpDecorate %38 RelaxedPrecision
  337. OpDecorate %39 RelaxedPrecision
  338. OpDecorate %40 RelaxedPrecision
  339. OpDecorate %41 RelaxedPrecision
  340. OpDecorate %42 RelaxedPrecision
  341. OpDecorate %45 RelaxedPrecision
  342. OpDecorate %47 RelaxedPrecision
  343. OpDecorate %48 RelaxedPrecision
  344. OpDecorate %50 RelaxedPrecision
  345. OpDecorate %51 RelaxedPrecision
  346. OpDecorate %54 RelaxedPrecision
  347. OpDecorate %55 RelaxedPrecision
  348. OpDecorate %56 RelaxedPrecision
  349. +OpDecorate %70 RelaxedPrecision
  350. OpDecorate %57 RelaxedPrecision
  351. +OpDecorate %75 RelaxedPrecision
  352. +OpDecorate %76 RelaxedPrecision
  353. OpDecorate %58 RelaxedPrecision
  354. OpDecorate %63 RelaxedPrecision
  355. OpDecorate %63 Location 0
  356. OpDecorate %64 RelaxedPrecision
  357. OpDecorate %65 RelaxedPrecision
  358. OpDecorate %66 RelaxedPrecision
  359. OpDecorate %68 RelaxedPrecision
  360. OpDecorate %68 Location 0
  361. %2 = OpTypeVoid
  362. %3 = OpTypeFunction %2
  363. %6 = OpTypeFloat 32
  364. %7 = OpTypeFunction %6
  365. %12 = OpTypePointer Function %6
  366. %14 = OpConstant %6 0
  367. %15 = OpTypeInt 32 0
  368. %16 = OpTypeStruct %15 %15
  369. %17 = OpTypePointer Uniform %16
  370. %18 = OpVariable %17 Uniform
  371. %19 = OpTypeInt 32 1
  372. %20 = OpConstant %19 0
  373. %21 = OpTypePointer Uniform %15
  374. %24 = OpConstant %15 0
  375. %25 = OpTypeBool
  376. %29 = OpConstant %6 1
  377. %32 = OpConstant %19 1
  378. %49 = OpConstant %6 10
  379. %52 = OpConstant %6 0.5
  380. +%74 = OpConstant %6 0.100000001
  381. %53 = OpConstant %6 0.699999988
  382. %61 = OpTypeVector %6 4
  383. %62 = OpTypePointer Output %61
  384. %63 = OpVariable %62 Output
  385. %67 = OpTypePointer Input %6
  386. %68 = OpVariable %67 Input
  387. %4 = OpFunction %2 None %3
  388. %5 = OpLabel
  389. %64 = OpFunctionCall %6 %8
  390. %65 = OpFunctionCall %6 %10
  391. %66 = OpCompositeConstruct %61 %64 %65 %14 %29
  392. OpStore %63 %66
  393. OpReturn
  394. OpFunctionEnd
  395. %8 = OpFunction %6 None %7
  396. %9 = OpLabel
  397. %13 = OpVariable %12 Function
  398. OpStore %13 %14
  399. -%22 = OpAccessChain %21 %18 %20
  400. -%23 = OpLoad %15 %22
  401. -%26 = OpINotEqual %25 %23 %24
  402. -OpSelectionMerge %28 None
  403. -OpBranchConditional %26 %27 %28
  404. -%27 = OpLabel
  405. -%30 = OpLoad %6 %13
  406. -%31 = OpFAdd %6 %30 %29
  407. -OpStore %13 %31
  408. -OpBranch %28
  409. -%28 = OpLabel
  410. %33 = OpAccessChain %21 %18 %32
  411. %34 = OpLoad %15 %33
  412. %35 = OpConvertUToF %6 %34
  413. %36 = OpExtInst %6 %1 Log2 %35
  414. %37 = OpLoad %6 %13
  415. %38 = OpFAdd %6 %37 %36
  416. OpStore %13 %38
  417. %39 = OpLoad %6 %13
  418. %40 = OpLoad %6 %13
  419. %41 = OpExtInst %6 %1 Sqrt %40
  420. %42 = OpFSub %6 %39 %41
  421. OpReturnValue %42
  422. OpFunctionEnd
  423. %10 = OpFunction %6 None %7
  424. %11 = OpLabel
  425. %45 = OpVariable %12 Function
  426. %46 = OpAccessChain %21 %18 %20
  427. %47 = OpLoad %15 %46
  428. %48 = OpConvertUToF %6 %47
  429. %50 = OpFDiv %6 %48 %49
  430. OpStore %45 %50
  431. %51 = OpLoad %6 %45
  432. %54 = OpExtInst %6 %1 FClamp %51 %52 %53
  433. %55 = OpLoad %6 %45
  434. %56 = OpFMul %6 %55 %54
  435. OpStore %45 %56
  436. +%69 = OpAccessChain %21 %18 %32
  437. +%70 = OpLoad %15 %69
  438. +%71 = OpINotEqual %25 %70 %24
  439. +OpSelectionMerge %73 None
  440. +OpBranchConditional %71 %72 %73
  441. +%72 = OpLabel
  442. %57 = OpLoad %6 %45
  443. +%75 = OpFSub %6 %57 %74
  444. +OpStore %45 %75
  445. +OpBranch %73
  446. +%73 = OpLabel
  447. +%76 = OpLoad %6 %45
  448. -%58 = OpExtInst %6 %1 Exp %57
  449. +%58 = OpExtInst %6 %1 Exp %76
  450. OpReturnValue %58
  451. OpFunctionEnd
  452. )";
  453. Options options;
  454. DoStringDiffTest(kSrc, kDst, kDiff, options);
  455. }
  456. TEST(DiffTest, ExtraIfBlockNoDebug) {
  457. constexpr char kSrcNoDebug[] = R"( OpCapability Shader
  458. %1 = OpExtInstImport "GLSL.std.450"
  459. OpMemoryModel Logical GLSL450
  460. OpEntryPoint Fragment %4 "main" %63 %68
  461. OpExecutionMode %4 OriginUpperLeft
  462. OpSource ESSL 310
  463. OpDecorate %8 RelaxedPrecision
  464. OpDecorate %10 RelaxedPrecision
  465. OpDecorate %13 RelaxedPrecision
  466. OpMemberDecorate %16 0 RelaxedPrecision
  467. OpMemberDecorate %16 0 Offset 0
  468. OpMemberDecorate %16 1 RelaxedPrecision
  469. OpMemberDecorate %16 1 Offset 4
  470. OpDecorate %16 Block
  471. OpDecorate %18 DescriptorSet 0
  472. OpDecorate %18 Binding 0
  473. OpDecorate %23 RelaxedPrecision
  474. OpDecorate %30 RelaxedPrecision
  475. OpDecorate %31 RelaxedPrecision
  476. OpDecorate %34 RelaxedPrecision
  477. OpDecorate %35 RelaxedPrecision
  478. OpDecorate %36 RelaxedPrecision
  479. OpDecorate %37 RelaxedPrecision
  480. OpDecorate %38 RelaxedPrecision
  481. OpDecorate %39 RelaxedPrecision
  482. OpDecorate %40 RelaxedPrecision
  483. OpDecorate %41 RelaxedPrecision
  484. OpDecorate %42 RelaxedPrecision
  485. OpDecorate %45 RelaxedPrecision
  486. OpDecorate %47 RelaxedPrecision
  487. OpDecorate %48 RelaxedPrecision
  488. OpDecorate %50 RelaxedPrecision
  489. OpDecorate %51 RelaxedPrecision
  490. OpDecorate %54 RelaxedPrecision
  491. OpDecorate %55 RelaxedPrecision
  492. OpDecorate %56 RelaxedPrecision
  493. OpDecorate %57 RelaxedPrecision
  494. OpDecorate %58 RelaxedPrecision
  495. OpDecorate %63 RelaxedPrecision
  496. OpDecorate %63 Location 0
  497. OpDecorate %64 RelaxedPrecision
  498. OpDecorate %65 RelaxedPrecision
  499. OpDecorate %66 RelaxedPrecision
  500. OpDecorate %68 RelaxedPrecision
  501. OpDecorate %68 Location 0
  502. %2 = OpTypeVoid
  503. %3 = OpTypeFunction %2
  504. %6 = OpTypeFloat 32
  505. %7 = OpTypeFunction %6
  506. %12 = OpTypePointer Function %6
  507. %14 = OpConstant %6 0
  508. %15 = OpTypeInt 32 0
  509. %16 = OpTypeStruct %15 %15
  510. %17 = OpTypePointer Uniform %16
  511. %18 = OpVariable %17 Uniform
  512. %19 = OpTypeInt 32 1
  513. %20 = OpConstant %19 0
  514. %21 = OpTypePointer Uniform %15
  515. %24 = OpConstant %15 0
  516. %25 = OpTypeBool
  517. %29 = OpConstant %6 1
  518. %32 = OpConstant %19 1
  519. %49 = OpConstant %6 10
  520. %52 = OpConstant %6 0.5
  521. %53 = OpConstant %6 0.699999988
  522. %61 = OpTypeVector %6 4
  523. %62 = OpTypePointer Output %61
  524. %63 = OpVariable %62 Output
  525. %67 = OpTypePointer Input %6
  526. %68 = OpVariable %67 Input
  527. %4 = OpFunction %2 None %3
  528. %5 = OpLabel
  529. %64 = OpFunctionCall %6 %8
  530. %65 = OpFunctionCall %6 %10
  531. %66 = OpCompositeConstruct %61 %64 %65 %14 %29
  532. OpStore %63 %66
  533. OpReturn
  534. OpFunctionEnd
  535. %8 = OpFunction %6 None %7
  536. %9 = OpLabel
  537. %13 = OpVariable %12 Function
  538. OpStore %13 %14
  539. %22 = OpAccessChain %21 %18 %20
  540. %23 = OpLoad %15 %22
  541. %26 = OpINotEqual %25 %23 %24
  542. OpSelectionMerge %28 None
  543. OpBranchConditional %26 %27 %28
  544. %27 = OpLabel
  545. %30 = OpLoad %6 %13
  546. %31 = OpFAdd %6 %30 %29
  547. OpStore %13 %31
  548. OpBranch %28
  549. %28 = OpLabel
  550. %33 = OpAccessChain %21 %18 %32
  551. %34 = OpLoad %15 %33
  552. %35 = OpConvertUToF %6 %34
  553. %36 = OpExtInst %6 %1 Log2 %35
  554. %37 = OpLoad %6 %13
  555. %38 = OpFAdd %6 %37 %36
  556. OpStore %13 %38
  557. %39 = OpLoad %6 %13
  558. %40 = OpLoad %6 %13
  559. %41 = OpExtInst %6 %1 Sqrt %40
  560. %42 = OpFSub %6 %39 %41
  561. OpReturnValue %42
  562. OpFunctionEnd
  563. %10 = OpFunction %6 None %7
  564. %11 = OpLabel
  565. %45 = OpVariable %12 Function
  566. %46 = OpAccessChain %21 %18 %20
  567. %47 = OpLoad %15 %46
  568. %48 = OpConvertUToF %6 %47
  569. %50 = OpFDiv %6 %48 %49
  570. OpStore %45 %50
  571. %51 = OpLoad %6 %45
  572. %54 = OpExtInst %6 %1 FClamp %51 %52 %53
  573. %55 = OpLoad %6 %45
  574. %56 = OpFMul %6 %55 %54
  575. OpStore %45 %56
  576. %57 = OpLoad %6 %45
  577. %58 = OpExtInst %6 %1 Exp %57
  578. OpReturnValue %58
  579. OpFunctionEnd
  580. )";
  581. constexpr char kDstNoDebug[] = R"( OpCapability Shader
  582. %1 = OpExtInstImport "GLSL.std.450"
  583. OpMemoryModel Logical GLSL450
  584. OpEntryPoint Fragment %4 "main" %63 %69
  585. OpExecutionMode %4 OriginUpperLeft
  586. OpSource ESSL 310
  587. OpDecorate %8 RelaxedPrecision
  588. OpDecorate %10 RelaxedPrecision
  589. OpDecorate %13 RelaxedPrecision
  590. OpMemberDecorate %16 0 RelaxedPrecision
  591. OpMemberDecorate %16 0 Offset 0
  592. OpMemberDecorate %16 1 RelaxedPrecision
  593. OpMemberDecorate %16 1 Offset 4
  594. OpDecorate %16 Block
  595. OpDecorate %18 DescriptorSet 0
  596. OpDecorate %18 Binding 0
  597. OpDecorate %23 RelaxedPrecision
  598. OpDecorate %24 RelaxedPrecision
  599. OpDecorate %25 RelaxedPrecision
  600. OpDecorate %26 RelaxedPrecision
  601. OpDecorate %27 RelaxedPrecision
  602. OpDecorate %28 RelaxedPrecision
  603. OpDecorate %29 RelaxedPrecision
  604. OpDecorate %30 RelaxedPrecision
  605. OpDecorate %31 RelaxedPrecision
  606. OpDecorate %34 RelaxedPrecision
  607. OpDecorate %37 RelaxedPrecision
  608. OpDecorate %38 RelaxedPrecision
  609. OpDecorate %40 RelaxedPrecision
  610. OpDecorate %41 RelaxedPrecision
  611. OpDecorate %44 RelaxedPrecision
  612. OpDecorate %45 RelaxedPrecision
  613. OpDecorate %46 RelaxedPrecision
  614. OpDecorate %48 RelaxedPrecision
  615. OpDecorate %55 RelaxedPrecision
  616. OpDecorate %56 RelaxedPrecision
  617. OpDecorate %57 RelaxedPrecision
  618. OpDecorate %58 RelaxedPrecision
  619. OpDecorate %63 RelaxedPrecision
  620. OpDecorate %63 Location 0
  621. OpDecorate %64 RelaxedPrecision
  622. OpDecorate %65 RelaxedPrecision
  623. OpDecorate %67 RelaxedPrecision
  624. OpDecorate %69 RelaxedPrecision
  625. OpDecorate %69 Location 0
  626. %2 = OpTypeVoid
  627. %3 = OpTypeFunction %2
  628. %6 = OpTypeFloat 32
  629. %7 = OpTypeFunction %6
  630. %12 = OpTypePointer Function %6
  631. %14 = OpConstant %6 0
  632. %15 = OpTypeInt 32 0
  633. %16 = OpTypeStruct %15 %15
  634. %17 = OpTypePointer Uniform %16
  635. %18 = OpVariable %17 Uniform
  636. %19 = OpTypeInt 32 1
  637. %20 = OpConstant %19 1
  638. %21 = OpTypePointer Uniform %15
  639. %35 = OpConstant %19 0
  640. %39 = OpConstant %6 10
  641. %42 = OpConstant %6 0.5
  642. %43 = OpConstant %6 0.699999988
  643. %49 = OpConstant %15 0
  644. %50 = OpTypeBool
  645. %54 = OpConstant %6 0.100000001
  646. %61 = OpTypeVector %6 4
  647. %62 = OpTypePointer Output %61
  648. %63 = OpVariable %62 Output
  649. %66 = OpConstant %6 1
  650. %68 = OpTypePointer Input %6
  651. %69 = OpVariable %68 Input
  652. %4 = OpFunction %2 None %3
  653. %5 = OpLabel
  654. %64 = OpFunctionCall %6 %8
  655. %65 = OpFunctionCall %6 %10
  656. %67 = OpCompositeConstruct %61 %64 %65 %14 %66
  657. OpStore %63 %67
  658. OpReturn
  659. OpFunctionEnd
  660. %8 = OpFunction %6 None %7
  661. %9 = OpLabel
  662. %13 = OpVariable %12 Function
  663. OpStore %13 %14
  664. %22 = OpAccessChain %21 %18 %20
  665. %23 = OpLoad %15 %22
  666. %24 = OpConvertUToF %6 %23
  667. %25 = OpExtInst %6 %1 Log2 %24
  668. %26 = OpLoad %6 %13
  669. %27 = OpFAdd %6 %26 %25
  670. OpStore %13 %27
  671. %28 = OpLoad %6 %13
  672. %29 = OpLoad %6 %13
  673. %30 = OpExtInst %6 %1 Sqrt %29
  674. %31 = OpFSub %6 %28 %30
  675. OpReturnValue %31
  676. OpFunctionEnd
  677. %10 = OpFunction %6 None %7
  678. %11 = OpLabel
  679. %34 = OpVariable %12 Function
  680. %36 = OpAccessChain %21 %18 %35
  681. %37 = OpLoad %15 %36
  682. %38 = OpConvertUToF %6 %37
  683. %40 = OpFDiv %6 %38 %39
  684. OpStore %34 %40
  685. %41 = OpLoad %6 %34
  686. %44 = OpExtInst %6 %1 FClamp %41 %42 %43
  687. %45 = OpLoad %6 %34
  688. %46 = OpFMul %6 %45 %44
  689. OpStore %34 %46
  690. %47 = OpAccessChain %21 %18 %20
  691. %48 = OpLoad %15 %47
  692. %51 = OpINotEqual %50 %48 %49
  693. OpSelectionMerge %53 None
  694. OpBranchConditional %51 %52 %53
  695. %52 = OpLabel
  696. %55 = OpLoad %6 %34
  697. %56 = OpFSub %6 %55 %54
  698. OpStore %34 %56
  699. OpBranch %53
  700. %53 = OpLabel
  701. %57 = OpLoad %6 %34
  702. %58 = OpExtInst %6 %1 Exp %57
  703. OpReturnValue %58
  704. OpFunctionEnd
  705. )";
  706. constexpr char kDiff[] = R"( ; SPIR-V
  707. ; Version: 1.6
  708. ; Generator: Khronos SPIR-V Tools Assembler; 0
  709. -; Bound: 69
  710. +; Bound: 77
  711. ; Schema: 0
  712. OpCapability Shader
  713. %1 = OpExtInstImport "GLSL.std.450"
  714. OpMemoryModel Logical GLSL450
  715. OpEntryPoint Fragment %4 "main" %63 %68
  716. OpExecutionMode %4 OriginUpperLeft
  717. OpSource ESSL 310
  718. OpDecorate %8 RelaxedPrecision
  719. OpDecorate %10 RelaxedPrecision
  720. OpDecorate %13 RelaxedPrecision
  721. OpMemberDecorate %16 0 RelaxedPrecision
  722. OpMemberDecorate %16 0 Offset 0
  723. OpMemberDecorate %16 1 RelaxedPrecision
  724. OpMemberDecorate %16 1 Offset 4
  725. OpDecorate %16 Block
  726. OpDecorate %18 DescriptorSet 0
  727. OpDecorate %18 Binding 0
  728. -OpDecorate %23 RelaxedPrecision
  729. -OpDecorate %30 RelaxedPrecision
  730. -OpDecorate %31 RelaxedPrecision
  731. OpDecorate %34 RelaxedPrecision
  732. OpDecorate %35 RelaxedPrecision
  733. OpDecorate %36 RelaxedPrecision
  734. OpDecorate %37 RelaxedPrecision
  735. OpDecorate %38 RelaxedPrecision
  736. OpDecorate %39 RelaxedPrecision
  737. OpDecorate %40 RelaxedPrecision
  738. OpDecorate %41 RelaxedPrecision
  739. OpDecorate %42 RelaxedPrecision
  740. OpDecorate %45 RelaxedPrecision
  741. OpDecorate %47 RelaxedPrecision
  742. OpDecorate %48 RelaxedPrecision
  743. OpDecorate %50 RelaxedPrecision
  744. OpDecorate %51 RelaxedPrecision
  745. OpDecorate %54 RelaxedPrecision
  746. OpDecorate %55 RelaxedPrecision
  747. OpDecorate %56 RelaxedPrecision
  748. +OpDecorate %70 RelaxedPrecision
  749. OpDecorate %57 RelaxedPrecision
  750. +OpDecorate %75 RelaxedPrecision
  751. +OpDecorate %76 RelaxedPrecision
  752. OpDecorate %58 RelaxedPrecision
  753. OpDecorate %63 RelaxedPrecision
  754. OpDecorate %63 Location 0
  755. OpDecorate %64 RelaxedPrecision
  756. OpDecorate %65 RelaxedPrecision
  757. OpDecorate %66 RelaxedPrecision
  758. OpDecorate %68 RelaxedPrecision
  759. OpDecorate %68 Location 0
  760. %2 = OpTypeVoid
  761. %3 = OpTypeFunction %2
  762. %6 = OpTypeFloat 32
  763. %7 = OpTypeFunction %6
  764. %12 = OpTypePointer Function %6
  765. %14 = OpConstant %6 0
  766. %15 = OpTypeInt 32 0
  767. %16 = OpTypeStruct %15 %15
  768. %17 = OpTypePointer Uniform %16
  769. %18 = OpVariable %17 Uniform
  770. %19 = OpTypeInt 32 1
  771. %20 = OpConstant %19 0
  772. %21 = OpTypePointer Uniform %15
  773. %24 = OpConstant %15 0
  774. %25 = OpTypeBool
  775. %29 = OpConstant %6 1
  776. %32 = OpConstant %19 1
  777. %49 = OpConstant %6 10
  778. %52 = OpConstant %6 0.5
  779. +%74 = OpConstant %6 0.100000001
  780. %53 = OpConstant %6 0.699999988
  781. %61 = OpTypeVector %6 4
  782. %62 = OpTypePointer Output %61
  783. %63 = OpVariable %62 Output
  784. %67 = OpTypePointer Input %6
  785. %68 = OpVariable %67 Input
  786. %4 = OpFunction %2 None %3
  787. %5 = OpLabel
  788. %64 = OpFunctionCall %6 %8
  789. %65 = OpFunctionCall %6 %10
  790. %66 = OpCompositeConstruct %61 %64 %65 %14 %29
  791. OpStore %63 %66
  792. OpReturn
  793. OpFunctionEnd
  794. %8 = OpFunction %6 None %7
  795. %9 = OpLabel
  796. %13 = OpVariable %12 Function
  797. OpStore %13 %14
  798. -%22 = OpAccessChain %21 %18 %20
  799. -%23 = OpLoad %15 %22
  800. -%26 = OpINotEqual %25 %23 %24
  801. -OpSelectionMerge %28 None
  802. -OpBranchConditional %26 %27 %28
  803. -%27 = OpLabel
  804. -%30 = OpLoad %6 %13
  805. -%31 = OpFAdd %6 %30 %29
  806. -OpStore %13 %31
  807. -OpBranch %28
  808. -%28 = OpLabel
  809. %33 = OpAccessChain %21 %18 %32
  810. %34 = OpLoad %15 %33
  811. %35 = OpConvertUToF %6 %34
  812. %36 = OpExtInst %6 %1 Log2 %35
  813. %37 = OpLoad %6 %13
  814. %38 = OpFAdd %6 %37 %36
  815. OpStore %13 %38
  816. %39 = OpLoad %6 %13
  817. %40 = OpLoad %6 %13
  818. %41 = OpExtInst %6 %1 Sqrt %40
  819. %42 = OpFSub %6 %39 %41
  820. OpReturnValue %42
  821. OpFunctionEnd
  822. %10 = OpFunction %6 None %7
  823. %11 = OpLabel
  824. %45 = OpVariable %12 Function
  825. %46 = OpAccessChain %21 %18 %20
  826. %47 = OpLoad %15 %46
  827. %48 = OpConvertUToF %6 %47
  828. %50 = OpFDiv %6 %48 %49
  829. OpStore %45 %50
  830. %51 = OpLoad %6 %45
  831. %54 = OpExtInst %6 %1 FClamp %51 %52 %53
  832. %55 = OpLoad %6 %45
  833. %56 = OpFMul %6 %55 %54
  834. OpStore %45 %56
  835. +%69 = OpAccessChain %21 %18 %32
  836. +%70 = OpLoad %15 %69
  837. +%71 = OpINotEqual %25 %70 %24
  838. +OpSelectionMerge %73 None
  839. +OpBranchConditional %71 %72 %73
  840. +%72 = OpLabel
  841. %57 = OpLoad %6 %45
  842. +%75 = OpFSub %6 %57 %74
  843. +OpStore %45 %75
  844. +OpBranch %73
  845. +%73 = OpLabel
  846. +%76 = OpLoad %6 %45
  847. -%58 = OpExtInst %6 %1 Exp %57
  848. +%58 = OpExtInst %6 %1 Exp %76
  849. OpReturnValue %58
  850. OpFunctionEnd
  851. )";
  852. Options options;
  853. DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options);
  854. }
  855. } // namespace
  856. } // namespace diff
  857. } // namespace spvtools