unrelated_shaders_autogen.cpp 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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. // Tests diff of unrelated shaders (with different execution models).
  23. constexpr char kSrc[] = R"( OpCapability Shader
  24. %1 = OpExtInstImport "GLSL.std.450"
  25. OpMemoryModel Logical GLSL450
  26. OpEntryPoint Vertex %4 "main" %8 %10
  27. OpSource ESSL 310
  28. OpName %4 "main"
  29. OpName %8 "v"
  30. OpName %10 "a"
  31. OpDecorate %8 Location 0
  32. OpDecorate %10 Location 0
  33. %2 = OpTypeVoid
  34. %3 = OpTypeFunction %2
  35. %6 = OpTypeFloat 32
  36. %7 = OpTypePointer Output %6
  37. %8 = OpVariable %7 Output
  38. %9 = OpTypePointer Input %6
  39. %10 = OpVariable %9 Input
  40. %4 = OpFunction %2 None %3
  41. %5 = OpLabel
  42. %11 = OpLoad %6 %10
  43. OpStore %8 %11
  44. OpReturn
  45. OpFunctionEnd
  46. )";
  47. constexpr char kDst[] = R"( OpCapability Shader
  48. %1 = OpExtInstImport "GLSL.std.450"
  49. OpMemoryModel Logical GLSL450
  50. OpEntryPoint Fragment %4 "main" %9 %11
  51. OpExecutionMode %4 OriginUpperLeft
  52. OpSource ESSL 310
  53. OpName %4 "main"
  54. OpName %9 "color"
  55. OpName %11 "v"
  56. OpDecorate %9 RelaxedPrecision
  57. OpDecorate %9 Location 0
  58. OpDecorate %11 RelaxedPrecision
  59. OpDecorate %11 Location 0
  60. OpDecorate %12 RelaxedPrecision
  61. OpDecorate %13 RelaxedPrecision
  62. %2 = OpTypeVoid
  63. %3 = OpTypeFunction %2
  64. %6 = OpTypeFloat 32
  65. %7 = OpTypeVector %6 4
  66. %8 = OpTypePointer Output %7
  67. %9 = OpVariable %8 Output
  68. %10 = OpTypePointer Input %6
  69. %11 = OpVariable %10 Input
  70. %4 = OpFunction %2 None %3
  71. %5 = OpLabel
  72. %12 = OpLoad %6 %11
  73. %13 = OpCompositeConstruct %7 %12 %12 %12 %12
  74. OpStore %9 %13
  75. OpReturn
  76. OpFunctionEnd
  77. )";
  78. TEST(DiffTest, UnrelatedShaders) {
  79. constexpr char kDiff[] = R"( ; SPIR-V
  80. ; Version: 1.6
  81. ; Generator: Khronos SPIR-V Tools Assembler; 0
  82. -; Bound: 12
  83. +; Bound: 16
  84. ; Schema: 0
  85. OpCapability Shader
  86. %1 = OpExtInstImport "GLSL.std.450"
  87. OpMemoryModel Logical GLSL450
  88. -OpEntryPoint Vertex %4 "main" %8 %10
  89. +OpEntryPoint Fragment %4 "main" %14 %8
  90. +OpExecutionMode %4 OriginUpperLeft
  91. OpSource ESSL 310
  92. OpName %4 "main"
  93. +OpName %14 "color"
  94. OpName %8 "v"
  95. -OpName %10 "a"
  96. +OpDecorate %14 RelaxedPrecision
  97. +OpDecorate %14 Location 0
  98. +OpDecorate %8 RelaxedPrecision
  99. OpDecorate %8 Location 0
  100. -OpDecorate %10 Location 0
  101. +OpDecorate %11 RelaxedPrecision
  102. +OpDecorate %15 RelaxedPrecision
  103. %2 = OpTypeVoid
  104. %3 = OpTypeFunction %2
  105. %6 = OpTypeFloat 32
  106. -%7 = OpTypePointer Output %6
  107. +%12 = OpTypeVector %6 4
  108. +%13 = OpTypePointer Output %12
  109. +%14 = OpVariable %13 Output
  110. -%8 = OpVariable %7 Output
  111. +%8 = OpVariable %9 Input
  112. %9 = OpTypePointer Input %6
  113. -%10 = OpVariable %9 Input
  114. %4 = OpFunction %2 None %3
  115. %5 = OpLabel
  116. -%11 = OpLoad %6 %10
  117. +%11 = OpLoad %6 %8
  118. -OpStore %8 %11
  119. +%15 = OpCompositeConstruct %12 %11 %11 %11 %11
  120. +OpStore %14 %15
  121. OpReturn
  122. OpFunctionEnd
  123. )";
  124. Options options;
  125. DoStringDiffTest(kSrc, kDst, kDiff, options);
  126. }
  127. TEST(DiffTest, UnrelatedShadersNoDebug) {
  128. constexpr char kSrcNoDebug[] = R"( OpCapability Shader
  129. %1 = OpExtInstImport "GLSL.std.450"
  130. OpMemoryModel Logical GLSL450
  131. OpEntryPoint Vertex %4 "main" %8 %10
  132. OpSource ESSL 310
  133. OpDecorate %8 Location 0
  134. OpDecorate %10 Location 0
  135. %2 = OpTypeVoid
  136. %3 = OpTypeFunction %2
  137. %6 = OpTypeFloat 32
  138. %7 = OpTypePointer Output %6
  139. %8 = OpVariable %7 Output
  140. %9 = OpTypePointer Input %6
  141. %10 = OpVariable %9 Input
  142. %4 = OpFunction %2 None %3
  143. %5 = OpLabel
  144. %11 = OpLoad %6 %10
  145. OpStore %8 %11
  146. OpReturn
  147. OpFunctionEnd
  148. )";
  149. constexpr char kDstNoDebug[] = R"( OpCapability Shader
  150. %1 = OpExtInstImport "GLSL.std.450"
  151. OpMemoryModel Logical GLSL450
  152. OpEntryPoint Fragment %4 "main" %9 %11
  153. OpExecutionMode %4 OriginUpperLeft
  154. OpSource ESSL 310
  155. OpDecorate %9 RelaxedPrecision
  156. OpDecorate %9 Location 0
  157. OpDecorate %11 RelaxedPrecision
  158. OpDecorate %11 Location 0
  159. OpDecorate %12 RelaxedPrecision
  160. OpDecorate %13 RelaxedPrecision
  161. %2 = OpTypeVoid
  162. %3 = OpTypeFunction %2
  163. %6 = OpTypeFloat 32
  164. %7 = OpTypeVector %6 4
  165. %8 = OpTypePointer Output %7
  166. %9 = OpVariable %8 Output
  167. %10 = OpTypePointer Input %6
  168. %11 = OpVariable %10 Input
  169. %4 = OpFunction %2 None %3
  170. %5 = OpLabel
  171. %12 = OpLoad %6 %11
  172. %13 = OpCompositeConstruct %7 %12 %12 %12 %12
  173. OpStore %9 %13
  174. OpReturn
  175. OpFunctionEnd
  176. )";
  177. constexpr char kDiff[] = R"( ; SPIR-V
  178. ; Version: 1.6
  179. ; Generator: Khronos SPIR-V Tools Assembler; 0
  180. -; Bound: 12
  181. +; Bound: 15
  182. ; Schema: 0
  183. OpCapability Shader
  184. %1 = OpExtInstImport "GLSL.std.450"
  185. OpMemoryModel Logical GLSL450
  186. -OpEntryPoint Vertex %4 "main" %8 %10
  187. +OpEntryPoint Fragment %4 "main" %8 %10
  188. +OpExecutionMode %4 OriginUpperLeft
  189. OpSource ESSL 310
  190. +OpDecorate %8 RelaxedPrecision
  191. OpDecorate %8 Location 0
  192. +OpDecorate %10 RelaxedPrecision
  193. OpDecorate %10 Location 0
  194. +OpDecorate %11 RelaxedPrecision
  195. +OpDecorate %14 RelaxedPrecision
  196. %2 = OpTypeVoid
  197. %3 = OpTypeFunction %2
  198. %6 = OpTypeFloat 32
  199. -%7 = OpTypePointer Output %6
  200. +%12 = OpTypeVector %6 4
  201. +%13 = OpTypePointer Output %12
  202. -%8 = OpVariable %7 Output
  203. +%8 = OpVariable %13 Output
  204. %9 = OpTypePointer Input %6
  205. %10 = OpVariable %9 Input
  206. %4 = OpFunction %2 None %3
  207. %5 = OpLabel
  208. %11 = OpLoad %6 %10
  209. +%14 = OpCompositeConstruct %12 %11 %11 %11 %11
  210. -OpStore %8 %11
  211. +OpStore %8 %14
  212. OpReturn
  213. OpFunctionEnd
  214. )";
  215. Options options;
  216. DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options);
  217. }
  218. } // namespace
  219. } // namespace diff
  220. } // namespace spvtools