spec_constant_composite_autogen.cpp 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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 OpSpecConstantComposite matching.
  23. constexpr char kSrc[] = R"( OpCapability Shader
  24. %1 = OpExtInstImport "GLSL.std.450"
  25. OpMemoryModel Logical GLSL450
  26. OpEntryPoint GLCompute %main "main"
  27. OpExecutionMode %main LocalSize 1 1 1
  28. OpSource GLSL 450
  29. OpName %main "main"
  30. OpDecorate %7 SpecId 3
  31. OpDecorate %8 SpecId 4
  32. OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize
  33. %void = OpTypeVoid
  34. %3 = OpTypeFunction %void
  35. %uint = OpTypeInt 32 0
  36. %7 = OpSpecConstant %uint 1
  37. %8 = OpSpecConstant %uint 1
  38. %uint_1 = OpConstant %uint 1
  39. %v3uint = OpTypeVector %uint 3
  40. %gl_WorkGroupSize = OpSpecConstantComposite %v3uint %7 %8 %uint_1
  41. %main = OpFunction %void None %3
  42. %5 = OpLabel
  43. OpReturn
  44. OpFunctionEnd)";
  45. constexpr char kDst[] = R"( OpCapability Shader
  46. %1 = OpExtInstImport "GLSL.std.450"
  47. OpMemoryModel Logical GLSL450
  48. OpEntryPoint GLCompute %main "main"
  49. OpExecutionMode %main LocalSize 1 1 1
  50. OpSource GLSL 450
  51. OpName %main "main"
  52. OpDecorate %7 SpecId 3
  53. OpDecorate %8 SpecId 4
  54. OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize
  55. %void = OpTypeVoid
  56. %3 = OpTypeFunction %void
  57. %uint = OpTypeInt 32 0
  58. %7 = OpSpecConstant %uint 2048
  59. %8 = OpSpecConstant %uint 1
  60. %uint_1 = OpConstant %uint 1
  61. %v3uint = OpTypeVector %uint 3
  62. %gl_WorkGroupSize = OpSpecConstantComposite %v3uint %7 %8 %uint_1
  63. %main = OpFunction %void None %3
  64. %5 = OpLabel
  65. OpReturn
  66. OpFunctionEnd
  67. )";
  68. TEST(DiffTest, SpecConstantComposite) {
  69. constexpr char kDiff[] = R"( ; SPIR-V
  70. ; Version: 1.6
  71. ; Generator: Khronos SPIR-V Tools Assembler; 0
  72. ; Bound: 12
  73. ; Schema: 0
  74. OpCapability Shader
  75. %1 = OpExtInstImport "GLSL.std.450"
  76. OpMemoryModel Logical GLSL450
  77. OpEntryPoint GLCompute %2 "main"
  78. OpExecutionMode %2 LocalSize 1 1 1
  79. OpSource GLSL 450
  80. OpName %2 "main"
  81. OpDecorate %7 SpecId 3
  82. OpDecorate %8 SpecId 4
  83. OpDecorate %4 BuiltIn WorkgroupSize
  84. %6 = OpTypeVoid
  85. %3 = OpTypeFunction %6
  86. %9 = OpTypeInt 32 0
  87. -%7 = OpSpecConstant %9 1
  88. +%7 = OpSpecConstant %9 2048
  89. %8 = OpSpecConstant %9 1
  90. %10 = OpConstant %9 1
  91. %11 = OpTypeVector %9 3
  92. %4 = OpSpecConstantComposite %11 %7 %8 %10
  93. %2 = OpFunction %6 None %3
  94. %5 = OpLabel
  95. OpReturn
  96. OpFunctionEnd
  97. )";
  98. Options options;
  99. DoStringDiffTest(kSrc, kDst, kDiff, options);
  100. }
  101. TEST(DiffTest, SpecConstantCompositeNoDebug) {
  102. constexpr char kSrcNoDebug[] = R"( OpCapability Shader
  103. %1 = OpExtInstImport "GLSL.std.450"
  104. OpMemoryModel Logical GLSL450
  105. OpEntryPoint GLCompute %main "main"
  106. OpExecutionMode %main LocalSize 1 1 1
  107. OpSource GLSL 450
  108. OpDecorate %7 SpecId 3
  109. OpDecorate %8 SpecId 4
  110. OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize
  111. %void = OpTypeVoid
  112. %3 = OpTypeFunction %void
  113. %uint = OpTypeInt 32 0
  114. %7 = OpSpecConstant %uint 1
  115. %8 = OpSpecConstant %uint 1
  116. %uint_1 = OpConstant %uint 1
  117. %v3uint = OpTypeVector %uint 3
  118. %gl_WorkGroupSize = OpSpecConstantComposite %v3uint %7 %8 %uint_1
  119. %main = OpFunction %void None %3
  120. %5 = OpLabel
  121. OpReturn
  122. OpFunctionEnd
  123. )";
  124. constexpr char kDstNoDebug[] = R"( OpCapability Shader
  125. %1 = OpExtInstImport "GLSL.std.450"
  126. OpMemoryModel Logical GLSL450
  127. OpEntryPoint GLCompute %main "main"
  128. OpExecutionMode %main LocalSize 1 1 1
  129. OpSource GLSL 450
  130. OpDecorate %7 SpecId 3
  131. OpDecorate %8 SpecId 4
  132. OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize
  133. %void = OpTypeVoid
  134. %3 = OpTypeFunction %void
  135. %uint = OpTypeInt 32 0
  136. %7 = OpSpecConstant %uint 2048
  137. %8 = OpSpecConstant %uint 1
  138. %uint_1 = OpConstant %uint 1
  139. %v3uint = OpTypeVector %uint 3
  140. %gl_WorkGroupSize = OpSpecConstantComposite %v3uint %7 %8 %uint_1
  141. %main = OpFunction %void None %3
  142. %5 = OpLabel
  143. OpReturn
  144. OpFunctionEnd
  145. )";
  146. constexpr char kDiff[] = R"( ; SPIR-V
  147. ; Version: 1.6
  148. ; Generator: Khronos SPIR-V Tools Assembler; 0
  149. ; Bound: 12
  150. ; Schema: 0
  151. OpCapability Shader
  152. %1 = OpExtInstImport "GLSL.std.450"
  153. OpMemoryModel Logical GLSL450
  154. OpEntryPoint GLCompute %2 "main"
  155. OpExecutionMode %2 LocalSize 1 1 1
  156. OpSource GLSL 450
  157. OpDecorate %7 SpecId 3
  158. OpDecorate %8 SpecId 4
  159. OpDecorate %4 BuiltIn WorkgroupSize
  160. %6 = OpTypeVoid
  161. %3 = OpTypeFunction %6
  162. %9 = OpTypeInt 32 0
  163. -%7 = OpSpecConstant %9 1
  164. +%7 = OpSpecConstant %9 2048
  165. %8 = OpSpecConstant %9 1
  166. %10 = OpConstant %9 1
  167. %11 = OpTypeVector %9 3
  168. %4 = OpSpecConstantComposite %11 %7 %8 %10
  169. %2 = OpFunction %6 None %3
  170. %5 = OpLabel
  171. OpReturn
  172. OpFunctionEnd
  173. )";
  174. Options options;
  175. DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options);
  176. }
  177. } // namespace
  178. } // namespace diff
  179. } // namespace spvtools