spec_constant_specid_autogen.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. OpMemoryModel Logical GLSL450
  25. OpEntryPoint GLCompute %main "main"
  26. OpExecutionMode %main LocalSize 1 1 1
  27. OpDecorate %sc SpecId 0
  28. %void = OpTypeVoid
  29. %3 = OpTypeFunction %void
  30. %uint = OpTypeInt 32 0
  31. %v3uint = OpTypeVector %uint 3
  32. %sc = OpSpecConstant %uint 10
  33. %main = OpFunction %void None %3
  34. %5 = OpLabel
  35. OpReturn
  36. OpFunctionEnd)";
  37. constexpr char kDst[] = R"( OpCapability Shader
  38. OpMemoryModel Logical GLSL450
  39. OpEntryPoint GLCompute %main "main"
  40. OpExecutionMode %main LocalSize 1 1 1
  41. %void = OpTypeVoid
  42. %3 = OpTypeFunction %void
  43. %uint = OpTypeInt 32 0
  44. %v3uint = OpTypeVector %uint 3
  45. %ss = OpSpecConstant %uint 10
  46. %main = OpFunction %void None %3
  47. %5 = OpLabel
  48. OpReturn
  49. OpFunctionEnd
  50. )";
  51. TEST(DiffTest, SpecConstantSpecid) {
  52. constexpr char kDiff[] = R"( ; SPIR-V
  53. ; Version: 1.6
  54. ; Generator: Khronos SPIR-V Tools Assembler; 0
  55. -; Bound: 8
  56. +; Bound: 9
  57. ; Schema: 0
  58. OpCapability Shader
  59. OpMemoryModel Logical GLSL450
  60. OpEntryPoint GLCompute %1 "main"
  61. OpExecutionMode %1 LocalSize 1 1 1
  62. -OpDecorate %2 SpecId 0
  63. %4 = OpTypeVoid
  64. %3 = OpTypeFunction %4
  65. %6 = OpTypeInt 32 0
  66. %7 = OpTypeVector %6 3
  67. -%2 = OpSpecConstant %6 10
  68. +%8 = OpSpecConstant %6 10
  69. %1 = OpFunction %4 None %3
  70. %5 = OpLabel
  71. OpReturn
  72. OpFunctionEnd
  73. )";
  74. Options options;
  75. DoStringDiffTest(kSrc, kDst, kDiff, options);
  76. }
  77. TEST(DiffTest, SpecConstantSpecidNoDebug) {
  78. constexpr char kSrcNoDebug[] = R"( OpCapability Shader
  79. OpMemoryModel Logical GLSL450
  80. OpEntryPoint GLCompute %main "main"
  81. OpExecutionMode %main LocalSize 1 1 1
  82. OpDecorate %sc SpecId 0
  83. %void = OpTypeVoid
  84. %3 = OpTypeFunction %void
  85. %uint = OpTypeInt 32 0
  86. %v3uint = OpTypeVector %uint 3
  87. %sc = OpSpecConstant %uint 10
  88. %main = OpFunction %void None %3
  89. %5 = OpLabel
  90. OpReturn
  91. OpFunctionEnd
  92. )";
  93. constexpr char kDstNoDebug[] = R"( OpCapability Shader
  94. OpMemoryModel Logical GLSL450
  95. OpEntryPoint GLCompute %main "main"
  96. OpExecutionMode %main LocalSize 1 1 1
  97. %void = OpTypeVoid
  98. %3 = OpTypeFunction %void
  99. %uint = OpTypeInt 32 0
  100. %v3uint = OpTypeVector %uint 3
  101. %ss = OpSpecConstant %uint 10
  102. %main = OpFunction %void None %3
  103. %5 = OpLabel
  104. OpReturn
  105. OpFunctionEnd
  106. )";
  107. constexpr char kDiff[] = R"( ; SPIR-V
  108. ; Version: 1.6
  109. ; Generator: Khronos SPIR-V Tools Assembler; 0
  110. -; Bound: 8
  111. +; Bound: 9
  112. ; Schema: 0
  113. OpCapability Shader
  114. OpMemoryModel Logical GLSL450
  115. OpEntryPoint GLCompute %1 "main"
  116. OpExecutionMode %1 LocalSize 1 1 1
  117. -OpDecorate %2 SpecId 0
  118. %4 = OpTypeVoid
  119. %3 = OpTypeFunction %4
  120. %6 = OpTypeInt 32 0
  121. %7 = OpTypeVector %6 3
  122. -%2 = OpSpecConstant %6 10
  123. +%8 = OpSpecConstant %6 10
  124. %1 = OpFunction %4 None %3
  125. %5 = OpLabel
  126. OpReturn
  127. OpFunctionEnd
  128. )";
  129. Options options;
  130. DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options);
  131. }
  132. } // namespace
  133. } // namespace diff
  134. } // namespace spvtools