| 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 |
|
| 18 |
#include "../diff_test_utils.h" |
| 19 |
#include "gtest/gtest.h" |
| 20 |
|
| 21 |
namespace spvtools { |
| 22 |
namespace diff { |
| 23 |
namespace { |
| 24 |
|
| 25 |
// Tests a diff where the shader has OpExtInst in the debug, decorations and |
| 26 |
// types/variables sections. |
| 27 |
constexpr char kSrc[] = R"( OpCapability Shader |
| 28 |
OpExtension "SPV_KHR_non_semantic_info" |
| 29 |
%1 = OpExtInstImport "GLSL.std.450" |
| 30 |
%20 = OpExtInstImport "NonSemantic.MadeUp" |
| 31 |
OpMemoryModel Logical GLSL450 |
| 32 |
OpEntryPoint Fragment %4 "main" %9 %11 |
| 33 |
OpExecutionMode %4 OriginUpperLeft |
| 34 |
OpSource ESSL 310 |
| 35 |
OpName %4 "main" |
| 36 |
%21 = OpExtInst %2 %20 123 |
| 37 |
%22 = OpExtInst %2 %20 234 |
| 38 |
OpName %9 "color" |
| 39 |
OpName %11 "v" |
| 40 |
OpDecorate %9 RelaxedPrecision |
| 41 |
OpDecorate %9 Location 0 |
| 42 |
OpDecorate %11 RelaxedPrecision |
| 43 |
OpDecorate %11 Location 0 |
| 44 |
%23 = OpExtInst %2 %20 345 |
| 45 |
%24 = OpExtInst %2 %20 456 |
| 46 |
OpDecorate %12 RelaxedPrecision |
| 47 |
OpDecorate %13 RelaxedPrecision |
| 48 |
OpDecorate %14 RelaxedPrecision |
| 49 |
%2 = OpTypeVoid |
| 50 |
%3 = OpTypeFunction %2 |
| 51 |
%6 = OpTypeFloat 32 |
| 52 |
%7 = OpTypeVector %6 4 |
| 53 |
%8 = OpTypePointer Output %7 |
| 54 |
%9 = OpVariable %8 Output |
| 55 |
%10 = OpTypePointer Input %6 |
| 56 |
%11 = OpVariable %10 Input |
| 57 |
%25 = OpExtInst %2 %20 567 |
| 58 |
%26 = OpExtInst %2 %20 678 |
| 59 |
%4 = OpFunction %2 None %3 |
| 60 |
%5 = OpLabel |
| 61 |
%12 = OpLoad %6 %11 |
| 62 |
%13 = OpExtInst %6 %1 Log2 %12 |
| 63 |
%14 = OpCompositeConstruct %7 %13 %13 %13 %13 |
| 64 |
OpStore %9 %14 |
| 65 |
OpReturn |
| 66 |
OpFunctionEnd)"; |
| 67 |
constexpr char kDst[] = R"( OpCapability Shader |
| 68 |
OpExtension "SPV_KHR_non_semantic_info" |
| 69 |
%1 = OpExtInstImport "GLSL.std.450" |
| 70 |
%30 = OpExtInstImport "NonSemantic.MadeUp" |
| 71 |
OpMemoryModel Logical GLSL450 |
| 72 |
OpEntryPoint Fragment %4 "main" %9 %11 |
| 73 |
OpExecutionMode %4 OriginUpperLeft |
| 74 |
OpSource ESSL 310 |
| 75 |
OpName %4 "main" |
| 76 |
%31 = OpExtInst %2 %30 123 |
| 77 |
%32 = OpExtInst %2 %30 2340 |
| 78 |
OpName %9 "color" |
| 79 |
OpName %11 "v" |
| 80 |
OpDecorate %9 RelaxedPrecision |
| 81 |
OpDecorate %9 Location 0 |
| 82 |
OpDecorate %11 RelaxedPrecision |
| 83 |
OpDecorate %11 Location 0 |
| 84 |
%33 = OpExtInst %2 %30 3450 |
| 85 |
%34 = OpExtInst %2 %30 456 |
| 86 |
OpDecorate %12 RelaxedPrecision |
| 87 |
OpDecorate %13 RelaxedPrecision |
| 88 |
OpDecorate %14 RelaxedPrecision |
| 89 |
%2 = OpTypeVoid |
| 90 |
%3 = OpTypeFunction %2 |
| 91 |
%6 = OpTypeFloat 32 |
| 92 |
%7 = OpTypeVector %6 4 |
| 93 |
%8 = OpTypePointer Output %7 |
| 94 |
%9 = OpVariable %8 Output |
| 95 |
%10 = OpTypePointer Input %6 |
| 96 |
%11 = OpVariable %10 Input |
| 97 |
%35 = OpExtInst %2 %30 567 |
| 98 |
%36 = OpExtInst %2 %30 678 |
| 99 |
%4 = OpFunction %2 None %3 |
| 100 |
%5 = OpLabel |
| 101 |
%12 = OpLoad %6 %11 |
| 102 |
%13 = OpExtInst %6 %1 Log2 %12 |
| 103 |
%14 = OpCompositeConstruct %7 %13 %13 %13 %13 |
| 104 |
OpStore %9 %14 |
| 105 |
OpReturn |
| 106 |
OpFunctionEnd |
| 107 |
)"; |
| 108 |
|
| 109 |
TEST(DiffTest, OpextinstInVariables) { |
| 110 |
constexpr char kDiff[] = R"( ; SPIR-V |
| 111 |
; Version: 1.6 |
| 112 |
; Generator: Khronos SPIR-V Tools Assembler; 0 |
| 113 |
-; Bound: 27 |
| 114 |
+; Bound: 29 |
| 115 |
; Schema: 0 |
| 116 |
OpCapability Shader |
| 117 |
OpExtension "SPV_KHR_non_semantic_info" |
| 118 |
%1 = OpExtInstImport "GLSL.std.450" |
| 119 |
%20 = OpExtInstImport "NonSemantic.MadeUp" |
| 120 |
OpMemoryModel Logical GLSL450 |
| 121 |
OpEntryPoint Fragment %4 "main" %9 %11 |
| 122 |
OpExecutionMode %4 OriginUpperLeft |
| 123 |
OpSource ESSL 310 |
| 124 |
OpName %4 "main" |
| 125 |
OpName %9 "color" |
| 126 |
OpName %11 "v" |
| 127 |
OpDecorate %9 RelaxedPrecision |
| 128 |
OpDecorate %9 Location 0 |
| 129 |
OpDecorate %11 RelaxedPrecision |
| 130 |
OpDecorate %11 Location 0 |
| 131 |
OpDecorate %12 RelaxedPrecision |
| 132 |
OpDecorate %13 RelaxedPrecision |
| 133 |
OpDecorate %14 RelaxedPrecision |
| 134 |
%21 = OpExtInst %2 %20 123 |
| 135 |
-%22 = OpExtInst %2 %20 234 |
| 136 |
-%23 = OpExtInst %2 %20 345 |
| 137 |
+%27 = OpExtInst %2 %20 2340 |
| 138 |
+%28 = OpExtInst %2 %20 3450 |
| 139 |
%24 = OpExtInst %2 %20 456 |
| 140 |
%2 = OpTypeVoid |
| 141 |
%3 = OpTypeFunction %2 |
| 142 |
%6 = OpTypeFloat 32 |
| 143 |
%7 = OpTypeVector %6 4 |
| 144 |
%8 = OpTypePointer Output %7 |
| 145 |
%9 = OpVariable %8 Output |
| 146 |
%10 = OpTypePointer Input %6 |
| 147 |
%11 = OpVariable %10 Input |
| 148 |
%25 = OpExtInst %2 %20 567 |
| 149 |
%26 = OpExtInst %2 %20 678 |
| 150 |
%4 = OpFunction %2 None %3 |
| 151 |
%5 = OpLabel |
| 152 |
%12 = OpLoad %6 %11 |
| 153 |
%13 = OpExtInst %6 %1 Log2 %12 |
| 154 |
%14 = OpCompositeConstruct %7 %13 %13 %13 %13 |
| 155 |
OpStore %9 %14 |
| 156 |
OpReturn |
| 157 |
OpFunctionEnd |
| 158 |
)"; |
| 159 |
Options options; |
| 160 |
DoStringDiffTest(kSrc, kDst, kDiff, options); |
| 161 |
} |
| 162 |
|
| 163 |
TEST(DiffTest, OpextinstInVariablesNoDebug) { |
| 164 |
constexpr char kSrcNoDebug[] = R"( OpCapability Shader |
| 165 |
OpExtension "SPV_KHR_non_semantic_info" |
| 166 |
%1 = OpExtInstImport "GLSL.std.450" |
| 167 |
%20 = OpExtInstImport "NonSemantic.MadeUp" |
| 168 |
OpMemoryModel Logical GLSL450 |
| 169 |
OpEntryPoint Fragment %4 "main" %9 %11 |
| 170 |
OpExecutionMode %4 OriginUpperLeft |
| 171 |
OpSource ESSL 310 |
| 172 |
%21 = OpExtInst %2 %20 123 |
| 173 |
%22 = OpExtInst %2 %20 234 |
| 174 |
OpDecorate %9 RelaxedPrecision |
| 175 |
OpDecorate %9 Location 0 |
| 176 |
OpDecorate %11 RelaxedPrecision |
| 177 |
OpDecorate %11 Location 0 |
| 178 |
%23 = OpExtInst %2 %20 345 |
| 179 |
%24 = OpExtInst %2 %20 456 |
| 180 |
OpDecorate %12 RelaxedPrecision |
| 181 |
OpDecorate %13 RelaxedPrecision |
| 182 |
OpDecorate %14 RelaxedPrecision |
| 183 |
%2 = OpTypeVoid |
| 184 |
%3 = OpTypeFunction %2 |
| 185 |
%6 = OpTypeFloat 32 |
| 186 |
%7 = OpTypeVector %6 4 |
| 187 |
%8 = OpTypePointer Output %7 |
| 188 |
%9 = OpVariable %8 Output |
| 189 |
%10 = OpTypePointer Input %6 |
| 190 |
%11 = OpVariable %10 Input |
| 191 |
%25 = OpExtInst %2 %20 567 |
| 192 |
%26 = OpExtInst %2 %20 678 |
| 193 |
%4 = OpFunction %2 None %3 |
| 194 |
%5 = OpLabel |
| 195 |
%12 = OpLoad %6 %11 |
| 196 |
%13 = OpExtInst %6 %1 Log2 %12 |
| 197 |
%14 = OpCompositeConstruct %7 %13 %13 %13 %13 |
| 198 |
OpStore %9 %14 |
| 199 |
OpReturn |
| 200 |
OpFunctionEnd |
| 201 |
)"; |
| 202 |
constexpr char kDstNoDebug[] = R"( OpCapability Shader |
| 203 |
OpExtension "SPV_KHR_non_semantic_info" |
| 204 |
%1 = OpExtInstImport "GLSL.std.450" |
| 205 |
%30 = OpExtInstImport "NonSemantic.MadeUp" |
| 206 |
OpMemoryModel Logical GLSL450 |
| 207 |
OpEntryPoint Fragment %4 "main" %9 %11 |
| 208 |
OpExecutionMode %4 OriginUpperLeft |
| 209 |
OpSource ESSL 310 |
| 210 |
%31 = OpExtInst %2 %30 123 |
| 211 |
%32 = OpExtInst %2 %30 2340 |
| 212 |
OpDecorate %9 RelaxedPrecision |
| 213 |
OpDecorate %9 Location 0 |
| 214 |
OpDecorate %11 RelaxedPrecision |
| 215 |
OpDecorate %11 Location 0 |
| 216 |
%33 = OpExtInst %2 %30 3450 |
| 217 |
%34 = OpExtInst %2 %30 456 |
| 218 |
OpDecorate %12 RelaxedPrecision |
| 219 |
OpDecorate %13 RelaxedPrecision |
| 220 |
OpDecorate %14 RelaxedPrecision |
| 221 |
%2 = OpTypeVoid |
| 222 |
%3 = OpTypeFunction %2 |
| 223 |
%6 = OpTypeFloat 32 |
| 224 |
%7 = OpTypeVector %6 4 |
| 225 |
%8 = OpTypePointer Output %7 |
| 226 |
%9 = OpVariable %8 Output |
| 227 |
%10 = OpTypePointer Input %6 |
| 228 |
%11 = OpVariable %10 Input |
| 229 |
%35 = OpExtInst %2 %30 567 |
| 230 |
%36 = OpExtInst %2 %30 678 |
| 231 |
%4 = OpFunction %2 None %3 |
| 232 |
%5 = OpLabel |
| 233 |
%12 = OpLoad %6 %11 |
| 234 |
%13 = OpExtInst %6 %1 Log2 %12 |
| 235 |
%14 = OpCompositeConstruct %7 %13 %13 %13 %13 |
| 236 |
OpStore %9 %14 |
| 237 |
OpReturn |
| 238 |
OpFunctionEnd |
| 239 |
)"; |
| 240 |
constexpr char kDiff[] = R"( ; SPIR-V |
| 241 |
; Version: 1.6 |
| 242 |
; Generator: Khronos SPIR-V Tools Assembler; 0 |
| 243 |
-; Bound: 27 |
| 244 |
+; Bound: 29 |
| 245 |
; Schema: 0 |
| 246 |
OpCapability Shader |
| 247 |
OpExtension "SPV_KHR_non_semantic_info" |
| 248 |
%1 = OpExtInstImport "GLSL.std.450" |
| 249 |
%20 = OpExtInstImport "NonSemantic.MadeUp" |
| 250 |
OpMemoryModel Logical GLSL450 |
| 251 |
OpEntryPoint Fragment %4 "main" %9 %11 |
| 252 |
OpExecutionMode %4 OriginUpperLeft |
| 253 |
OpSource ESSL 310 |
| 254 |
OpDecorate %9 RelaxedPrecision |
| 255 |
OpDecorate %9 Location 0 |
| 256 |
OpDecorate %11 RelaxedPrecision |
| 257 |
OpDecorate %11 Location 0 |
| 258 |
OpDecorate %12 RelaxedPrecision |
| 259 |
OpDecorate %13 RelaxedPrecision |
| 260 |
OpDecorate %14 RelaxedPrecision |
| 261 |
%21 = OpExtInst %2 %20 123 |
| 262 |
-%22 = OpExtInst %2 %20 234 |
| 263 |
-%23 = OpExtInst %2 %20 345 |
| 264 |
+%27 = OpExtInst %2 %20 2340 |
| 265 |
+%28 = OpExtInst %2 %20 3450 |
| 266 |
%24 = OpExtInst %2 %20 456 |
| 267 |
%2 = OpTypeVoid |
| 268 |
%3 = OpTypeFunction %2 |
| 269 |
%6 = OpTypeFloat 32 |
| 270 |
%7 = OpTypeVector %6 4 |
| 271 |
%8 = OpTypePointer Output %7 |
| 272 |
%9 = OpVariable %8 Output |
| 273 |
%10 = OpTypePointer Input %6 |
| 274 |
%11 = OpVariable %10 Input |
| 275 |
%25 = OpExtInst %2 %20 567 |
| 276 |
%26 = OpExtInst %2 %20 678 |
| 277 |
%4 = OpFunction %2 None %3 |
| 278 |
%5 = OpLabel |
| 279 |
%12 = OpLoad %6 %11 |
| 280 |
%13 = OpExtInst %6 %1 Log2 %12 |
| 281 |
%14 = OpCompositeConstruct %7 %13 %13 %13 %13 |
| 282 |
OpStore %9 %14 |
| 283 |
OpReturn |
| 284 |
OpFunctionEnd |
| 285 |
)"; |
| 286 |
Options options; |
| 287 |
DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); |
| 288 |
} |
| 289 |
|
| 290 |
} // namespace |
| 291 |
} // namespace diff |
| 292 |
} // namespace spvtools |