Debian Codegraph @

test/text_to_binary.extension_test.cpp

raw
1 // Copyright (c) 2015-2016 The Khronos Group Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 // Assembler tests for instructions in the "Extension Instruction" section
16 // of the SPIR-V spec.
17
18 #include <string>
19 #include <tuple>
20 #include <vector>
21
22 #include "gmock/gmock.h"
23 #include "source/latest_version_glsl_std_450_header.h"
24 #include "source/latest_version_opencl_std_header.h"
25 #include "source/util/string_utils.h"
26 #include "test/test_fixture.h"
27 #include "test/unit_spirv.h"
28
29 namespace spvtools {
30 namespace {
31
32 using spvtest::Concatenate;
33 using spvtest::MakeInstruction;
34 using utils::MakeVector;
35 using spvtest::TextToBinaryTest;
36 using ::testing::Combine;
37 using ::testing::Eq;
38 using ::testing::Values;
39 using ::testing::ValuesIn;
40
41 // Returns a generator of common Vulkan environment values to be tested.
42 std::vector<spv_target_env> CommonVulkanEnvs() {
43 return {SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1, SPV_ENV_UNIVERSAL_1_2,
44 SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1};
45 }
46
47 TEST_F(TextToBinaryTest, InvalidExtInstImportName) {
48 EXPECT_THAT(CompileFailure("%1 = OpExtInstImport \"Haskell.std\""),
49 Eq("Invalid extended instruction import 'Haskell.std'"));
50 }
51
52 TEST_F(TextToBinaryTest, InvalidImportId) {
53 EXPECT_THAT(CompileFailure("%1 = OpTypeVoid\n"
54 "%2 = OpExtInst %1 %1"),
55 Eq("Invalid extended instruction import Id 2"));
56 }
57
58 TEST_F(TextToBinaryTest, InvalidImportInstruction) {
59 const std::string input = R"(%1 = OpTypeVoid
60 %2 = OpExtInstImport "OpenCL.std"
61 %3 = OpExtInst %1 %2 not_in_the_opencl)";
62 EXPECT_THAT(CompileFailure(input),
63 Eq("Invalid extended instruction name 'not_in_the_opencl'."));
64 }
65
66 TEST_F(TextToBinaryTest, MultiImport) {
67 const std::string input = R"(%2 = OpExtInstImport "OpenCL.std"
68 %2 = OpExtInstImport "OpenCL.std")";
69 EXPECT_THAT(CompileFailure(input),
70 Eq("Import Id is being defined a second time"));
71 }
72
73 TEST_F(TextToBinaryTest, TooManyArgumentsIdEqualQuote) {
74 const std::string input = R"(%opencl = OpExtInstImport "OpenCL.std"
75 %2 = OpExtInst %float %opencl cos %x %oops=")";
76 EXPECT_THAT(CompileFailure(input), Eq("Expected '=', found end of stream."));
77 }
78
79 TEST_F(TextToBinaryTest, TooManyArgumentsIdEqual) {
80 const std::string input = R"(%opencl = OpExtInstImport "OpenCL.std"
81 %2 = OpExtInst %float %opencl cos %x %oops=)";
82 EXPECT_THAT(CompileFailure(input), Eq("Expected '=', found end of stream."));
83 }
84
85 TEST_F(TextToBinaryTest, ExtInstFromTwoDifferentImports) {
86 const std::string input = R"(%1 = OpExtInstImport "OpenCL.std"
87 %2 = OpExtInstImport "GLSL.std.450"
88 %4 = OpExtInst %3 %1 native_sqrt %5
89 %7 = OpExtInst %6 %2 MatrixInverse %8
90 )";
91
92 // Make sure it assembles correctly.
93 EXPECT_THAT(
94 CompiledInstructions(input),
95 Eq(Concatenate({
96 MakeInstruction(spv::Op::OpExtInstImport, {1},
97 MakeVector("OpenCL.std")),
98 MakeInstruction(spv::Op::OpExtInstImport, {2},
99 MakeVector("GLSL.std.450")),
100 MakeInstruction(
101 spv::Op::OpExtInst,
102 {3, 4, 1, uint32_t(OpenCLLIB::Entrypoints::Native_sqrt), 5}),
103 MakeInstruction(spv::Op::OpExtInst,
104 {6, 7, 2, uint32_t(GLSLstd450MatrixInverse), 8}),
105 })));
106
107 // Make sure it disassembles correctly.
108 EXPECT_THAT(EncodeAndDecodeSuccessfully(input), Eq(input));
109 }
110
111 // A test case for assembling into words in an instruction.
112 struct AssemblyCase {
113 std::string input;
114 std::vector<uint32_t> expected;
115 };
116
117 using ExtensionAssemblyTest = spvtest::TextToBinaryTestBase<
118 ::testing::TestWithParam<std::tuple<spv_target_env, AssemblyCase>>>;
119
120 TEST_P(ExtensionAssemblyTest, Samples) {
121 const spv_target_env& env = std::get<0>(GetParam());
122 const AssemblyCase& ac = std::get<1>(GetParam());
123
124 // Check that it assembles correctly.
125 EXPECT_THAT(CompiledInstructions(ac.input, env), Eq(ac.expected));
126 }
127
128 using ExtensionRoundTripTest = spvtest::TextToBinaryTestBase<
129 ::testing::TestWithParam<std::tuple<spv_target_env, AssemblyCase>>>;
130
131 TEST_P(ExtensionRoundTripTest, Samples) {
132 const spv_target_env& env = std::get<0>(GetParam());
133 const AssemblyCase& ac = std::get<1>(GetParam());
134
135 // Check that it assembles correctly.
136 EXPECT_THAT(CompiledInstructions(ac.input, env), Eq(ac.expected));
137
138 // Check round trip through the disassembler.
139 EXPECT_THAT(
140 EncodeAndDecodeSuccessfully(ac.input, SPV_BINARY_TO_TEXT_OPTION_NONE,
141 SPV_TEXT_TO_BINARY_OPTION_NONE, env),
142 Eq(ac.input))
143 << "target env: " << spvTargetEnvDescription(env) << "\n";
144 }
145
146 // SPV_KHR_shader_ballot
147
148 INSTANTIATE_TEST_SUITE_P(
149 SPV_KHR_shader_ballot, ExtensionRoundTripTest,
150 // We'll get coverage over operand tables by trying the universal
151 // environments, and at least one specific environment.
152 Combine(
153 Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
154 SPV_ENV_VULKAN_1_0),
155 ValuesIn(std::vector<AssemblyCase>{
156 {"OpCapability SubgroupBallotKHR\n",
157 MakeInstruction(spv::Op::OpCapability,
158 {uint32_t(spv::Capability::SubgroupBallotKHR)})},
159 {"%2 = OpSubgroupBallotKHR %1 %3\n",
160 MakeInstruction(spv::Op::OpSubgroupBallotKHR, {1, 2, 3})},
161 {"%2 = OpSubgroupFirstInvocationKHR %1 %3\n",
162 MakeInstruction(spv::Op::OpSubgroupFirstInvocationKHR, {1, 2, 3})},
163 {"OpDecorate %1 BuiltIn SubgroupEqMask\n",
164 MakeInstruction(spv::Op::OpDecorate,
165 {1, uint32_t(spv::Decoration::BuiltIn),
166 uint32_t(spv::BuiltIn::SubgroupEqMaskKHR)})},
167 {"OpDecorate %1 BuiltIn SubgroupGeMask\n",
168 MakeInstruction(spv::Op::OpDecorate,
169 {1, uint32_t(spv::Decoration::BuiltIn),
170 uint32_t(spv::BuiltIn::SubgroupGeMaskKHR)})},
171 {"OpDecorate %1 BuiltIn SubgroupGtMask\n",
172 MakeInstruction(spv::Op::OpDecorate,
173 {1, uint32_t(spv::Decoration::BuiltIn),
174 uint32_t(spv::BuiltIn::SubgroupGtMaskKHR)})},
175 {"OpDecorate %1 BuiltIn SubgroupLeMask\n",
176 MakeInstruction(spv::Op::OpDecorate,
177 {1, uint32_t(spv::Decoration::BuiltIn),
178 uint32_t(spv::BuiltIn::SubgroupLeMaskKHR)})},
179 {"OpDecorate %1 BuiltIn SubgroupLtMask\n",
180 MakeInstruction(spv::Op::OpDecorate,
181 {1, uint32_t(spv::Decoration::BuiltIn),
182 uint32_t(spv::BuiltIn::SubgroupLtMaskKHR)})},
183 })));
184
185 INSTANTIATE_TEST_SUITE_P(
186 SPV_KHR_shader_ballot_vulkan_1_1, ExtensionRoundTripTest,
187 // In SPIR-V 1.3 and Vulkan 1.1 we can drop the KHR suffix on the
188 // builtin enums.
189 Combine(
190 Values(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_1),
191 ValuesIn(std::vector<AssemblyCase>{
192 {"OpCapability SubgroupBallotKHR\n",
193 MakeInstruction(spv::Op::OpCapability,
194 {(uint32_t)spv::Capability::SubgroupBallotKHR})},
195 {"%2 = OpSubgroupBallotKHR %1 %3\n",
196 MakeInstruction(spv::Op::OpSubgroupBallotKHR, {1, 2, 3})},
197 {"%2 = OpSubgroupFirstInvocationKHR %1 %3\n",
198 MakeInstruction(spv::Op::OpSubgroupFirstInvocationKHR, {1, 2, 3})},
199 {"OpDecorate %1 BuiltIn SubgroupEqMask\n",
200 MakeInstruction(spv::Op::OpDecorate,
201 {1, uint32_t(spv::Decoration::BuiltIn),
202 uint32_t(spv::BuiltIn::SubgroupEqMask)})},
203 {"OpDecorate %1 BuiltIn SubgroupGeMask\n",
204 MakeInstruction(spv::Op::OpDecorate,
205 {1, uint32_t(spv::Decoration::BuiltIn),
206 uint32_t(spv::BuiltIn::SubgroupGeMask)})},
207 {"OpDecorate %1 BuiltIn SubgroupGtMask\n",
208 MakeInstruction(spv::Op::OpDecorate,
209 {1, uint32_t(spv::Decoration::BuiltIn),
210 uint32_t(spv::BuiltIn::SubgroupGtMask)})},
211 {"OpDecorate %1 BuiltIn SubgroupLeMask\n",
212 MakeInstruction(spv::Op::OpDecorate,
213 {1, uint32_t(spv::Decoration::BuiltIn),
214 uint32_t(spv::BuiltIn::SubgroupLeMask)})},
215 {"OpDecorate %1 BuiltIn SubgroupLtMask\n",
216 MakeInstruction(spv::Op::OpDecorate,
217 {1, uint32_t(spv::Decoration::BuiltIn),
218 uint32_t(spv::BuiltIn::SubgroupLtMask)})},
219 })));
220
221 // The old builtin names (with KHR suffix) still work in the assembler, and
222 // map to the enums without the KHR.
223 INSTANTIATE_TEST_SUITE_P(
224 SPV_KHR_shader_ballot_vulkan_1_1_alias_check, ExtensionAssemblyTest,
225 // In SPIR-V 1.3 and Vulkan 1.1 we can drop the KHR suffix on the
226 // builtin enums.
227 Combine(Values(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_1),
228 ValuesIn(std::vector<AssemblyCase>{
229 {"OpDecorate %1 BuiltIn SubgroupEqMaskKHR\n",
230 MakeInstruction(spv::Op::OpDecorate,
231 {1, (uint32_t)spv::Decoration::BuiltIn,
232 (uint32_t)spv::BuiltIn::SubgroupEqMask})},
233 {"OpDecorate %1 BuiltIn SubgroupGeMaskKHR\n",
234 MakeInstruction(spv::Op::OpDecorate,
235 {1, (uint32_t)spv::Decoration::BuiltIn,
236 (uint32_t)spv::BuiltIn::SubgroupGeMask})},
237 {"OpDecorate %1 BuiltIn SubgroupGtMaskKHR\n",
238 MakeInstruction(spv::Op::OpDecorate,
239 {1, (uint32_t)spv::Decoration::BuiltIn,
240 (uint32_t)spv::BuiltIn::SubgroupGtMask})},
241 {"OpDecorate %1 BuiltIn SubgroupLeMaskKHR\n",
242 MakeInstruction(spv::Op::OpDecorate,
243 {1, (uint32_t)spv::Decoration::BuiltIn,
244 (uint32_t)spv::BuiltIn::SubgroupLeMask})},
245 {"OpDecorate %1 BuiltIn SubgroupLtMaskKHR\n",
246 MakeInstruction(spv::Op::OpDecorate,
247 {1, (uint32_t)spv::Decoration::BuiltIn,
248 (uint32_t)spv::BuiltIn::SubgroupLtMask})},
249 })));
250
251 // SPV_KHR_shader_draw_parameters
252
253 INSTANTIATE_TEST_SUITE_P(
254 SPV_KHR_shader_draw_parameters, ExtensionRoundTripTest,
255 // We'll get coverage over operand tables by trying the universal
256 // environments, and at least one specific environment.
257 Combine(ValuesIn(CommonVulkanEnvs()),
258 ValuesIn(std::vector<AssemblyCase>{
259 {"OpCapability DrawParameters\n",
260 MakeInstruction(spv::Op::OpCapability,
261 {(uint32_t)spv::Capability::DrawParameters})},
262 {"OpDecorate %1 BuiltIn BaseVertex\n",
263 MakeInstruction(spv::Op::OpDecorate,
264 {1, (uint32_t)spv::Decoration::BuiltIn,
265 (uint32_t)spv::BuiltIn::BaseVertex})},
266 {"OpDecorate %1 BuiltIn BaseInstance\n",
267 MakeInstruction(spv::Op::OpDecorate,
268 {1, (uint32_t)spv::Decoration::BuiltIn,
269 (uint32_t)spv::BuiltIn::BaseInstance})},
270 {"OpDecorate %1 BuiltIn DrawIndex\n",
271 MakeInstruction(spv::Op::OpDecorate,
272 {1, (uint32_t)spv::Decoration::BuiltIn,
273 (uint32_t)spv::BuiltIn::DrawIndex})},
274 })));
275
276 // SPV_KHR_subgroup_vote
277
278 INSTANTIATE_TEST_SUITE_P(
279 SPV_KHR_subgroup_vote, ExtensionRoundTripTest,
280 // We'll get coverage over operand tables by trying the universal
281 // environments, and at least one specific environment.
282 Combine(ValuesIn(CommonVulkanEnvs()),
283 ValuesIn(std::vector<AssemblyCase>{
284 {"OpCapability SubgroupVoteKHR\n",
285 MakeInstruction(spv::Op::OpCapability,
286 {(uint32_t)spv::Capability::SubgroupVoteKHR})},
287 {"%2 = OpSubgroupAnyKHR %1 %3\n",
288 MakeInstruction(spv::Op::OpSubgroupAnyKHR, {1, 2, 3})},
289 {"%2 = OpSubgroupAllKHR %1 %3\n",
290 MakeInstruction(spv::Op::OpSubgroupAllKHR, {1, 2, 3})},
291 {"%2 = OpSubgroupAllEqualKHR %1 %3\n",
292 MakeInstruction(spv::Op::OpSubgroupAllEqualKHR, {1, 2, 3})},
293 })));
294
295 // SPV_KHR_16bit_storage
296
297 INSTANTIATE_TEST_SUITE_P(
298 SPV_KHR_16bit_storage, ExtensionRoundTripTest,
299 // We'll get coverage over operand tables by trying the universal
300 // environments, and at least one specific environment.
301 Combine(
302 ValuesIn(CommonVulkanEnvs()),
303 ValuesIn(std::vector<AssemblyCase>{
304 {"OpCapability StorageBuffer16BitAccess\n",
305 MakeInstruction(
306 spv::Op::OpCapability,
307 {(uint32_t)spv::Capability::StorageUniformBufferBlock16})},
308 {"OpCapability StorageBuffer16BitAccess\n",
309 MakeInstruction(
310 spv::Op::OpCapability,
311 {(uint32_t)spv::Capability::StorageBuffer16BitAccess})},
312 {"OpCapability UniformAndStorageBuffer16BitAccess\n",
313 MakeInstruction(
314 spv::Op::OpCapability,
315 {(uint32_t)
316 spv::Capability::UniformAndStorageBuffer16BitAccess})},
317 {"OpCapability UniformAndStorageBuffer16BitAccess\n",
318 MakeInstruction(spv::Op::OpCapability,
319 {(uint32_t)spv::Capability::StorageUniform16})},
320 {"OpCapability StoragePushConstant16\n",
321 MakeInstruction(
322 spv::Op::OpCapability,
323 {(uint32_t)spv::Capability::StoragePushConstant16})},
324 {"OpCapability StorageInputOutput16\n",
325 MakeInstruction(
326 spv::Op::OpCapability,
327 {(uint32_t)spv::Capability::StorageInputOutput16})},
328 })));
329
330 INSTANTIATE_TEST_SUITE_P(
331 SPV_KHR_16bit_storage_alias_check, ExtensionAssemblyTest,
332 Combine(
333 ValuesIn(CommonVulkanEnvs()),
334 ValuesIn(std::vector<AssemblyCase>{
335 // The old name maps to the new enum.
336 {"OpCapability StorageUniformBufferBlock16\n",
337 MakeInstruction(
338 spv::Op::OpCapability,
339 {(uint32_t)spv::Capability::StorageBuffer16BitAccess})},
340 // The new name maps to the old enum.
341 {"OpCapability UniformAndStorageBuffer16BitAccess\n",
342 MakeInstruction(spv::Op::OpCapability,
343 {(uint32_t)spv::Capability::StorageUniform16})},
344 })));
345
346 // SPV_KHR_device_group
347
348 INSTANTIATE_TEST_SUITE_P(
349 SPV_KHR_device_group, ExtensionRoundTripTest,
350 // We'll get coverage over operand tables by trying the universal
351 // environments, and at least one specific environment.
352 Combine(ValuesIn(CommonVulkanEnvs()),
353 ValuesIn(std::vector<AssemblyCase>{
354 {"OpCapability DeviceGroup\n",
355 MakeInstruction(spv::Op::OpCapability,
356 {(uint32_t)spv::Capability::DeviceGroup})},
357 {"OpDecorate %1 BuiltIn DeviceIndex\n",
358 MakeInstruction(spv::Op::OpDecorate,
359 {1, (uint32_t)spv::Decoration::BuiltIn,
360 (uint32_t)spv::BuiltIn::DeviceIndex})},
361 })));
362
363 // SPV_KHR_8bit_storage
364
365 INSTANTIATE_TEST_SUITE_P(
366 SPV_KHR_8bit_storage, ExtensionRoundTripTest,
367 // We'll get coverage over operand tables by trying the universal
368 // environments, and at least one specific environment.
369 Combine(ValuesIn(CommonVulkanEnvs()),
370 ValuesIn(std::vector<AssemblyCase>{
371 {"OpCapability StorageBuffer8BitAccess\n",
372 MakeInstruction(
373 spv::Op::OpCapability,
374 {(uint32_t)spv::Capability::StorageBuffer8BitAccess})},
375 {"OpCapability UniformAndStorageBuffer8BitAccess\n",
376 MakeInstruction(
377 spv::Op::OpCapability,
378 {(uint32_t)
379 spv::Capability::UniformAndStorageBuffer8BitAccess})},
380 {"OpCapability StoragePushConstant8\n",
381 MakeInstruction(
382 spv::Op::OpCapability,
383 {(uint32_t)spv::Capability::StoragePushConstant8})},
384 })));
385
386 // SPV_KHR_multiview
387
388 INSTANTIATE_TEST_SUITE_P(
389 SPV_KHR_multiview, ExtensionRoundTripTest,
390 // We'll get coverage over operand tables by trying the universal
391 // environments, and at least one specific environment.
392 Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
393 SPV_ENV_VULKAN_1_0),
394 ValuesIn(std::vector<AssemblyCase>{
395 {"OpCapability MultiView\n",
396 MakeInstruction(spv::Op::OpCapability,
397 {(uint32_t)spv::Capability::MultiView})},
398 {"OpDecorate %1 BuiltIn ViewIndex\n",
399 MakeInstruction(spv::Op::OpDecorate,
400 {1, (uint32_t)spv::Decoration::BuiltIn,
401 (uint32_t)spv::BuiltIn::ViewIndex})},
402 })));
403
404 // SPV_AMD_shader_explicit_vertex_parameter
405
406 #define PREAMBLE \
407 "%1 = OpExtInstImport \"SPV_AMD_shader_explicit_vertex_parameter\"\n"
408 INSTANTIATE_TEST_SUITE_P(
409 SPV_AMD_shader_explicit_vertex_parameter, ExtensionRoundTripTest,
410 // We'll get coverage over operand tables by trying the universal
411 // environments, and at least one specific environment.
412 Combine(
413 Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
414 SPV_ENV_VULKAN_1_0),
415 ValuesIn(std::vector<AssemblyCase>{
416 {PREAMBLE "%3 = OpExtInst %2 %1 InterpolateAtVertexAMD %4 %5\n",
417 Concatenate(
418 {MakeInstruction(
419 spv::Op::OpExtInstImport, {1},
420 MakeVector("SPV_AMD_shader_explicit_vertex_parameter")),
421 MakeInstruction(spv::Op::OpExtInst, {2, 3, 1, 1, 4, 5})})},
422 })));
423 #undef PREAMBLE
424
425 // SPV_AMD_shader_trinary_minmax
426
427 #define PREAMBLE "%1 = OpExtInstImport \"SPV_AMD_shader_trinary_minmax\"\n"
428 INSTANTIATE_TEST_SUITE_P(
429 SPV_AMD_shader_trinary_minmax, ExtensionRoundTripTest,
430 // We'll get coverage over operand tables by trying the universal
431 // environments, and at least one specific environment.
432 Combine(
433 Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
434 SPV_ENV_VULKAN_1_0),
435 ValuesIn(std::vector<AssemblyCase>{
436 {PREAMBLE "%3 = OpExtInst %2 %1 FMin3AMD %4 %5 %6\n",
437 Concatenate(
438 {MakeInstruction(spv::Op::OpExtInstImport, {1},
439 MakeVector("SPV_AMD_shader_trinary_minmax")),
440 MakeInstruction(spv::Op::OpExtInst, {2, 3, 1, 1, 4, 5, 6})})},
441 {PREAMBLE "%3 = OpExtInst %2 %1 UMin3AMD %4 %5 %6\n",
442 Concatenate(
443 {MakeInstruction(spv::Op::OpExtInstImport, {1},
444 MakeVector("SPV_AMD_shader_trinary_minmax")),
445 MakeInstruction(spv::Op::OpExtInst, {2, 3, 1, 2, 4, 5, 6})})},
446 {PREAMBLE "%3 = OpExtInst %2 %1 SMin3AMD %4 %5 %6\n",
447 Concatenate(
448 {MakeInstruction(spv::Op::OpExtInstImport, {1},
449 MakeVector("SPV_AMD_shader_trinary_minmax")),
450 MakeInstruction(spv::Op::OpExtInst, {2, 3, 1, 3, 4, 5, 6})})},
451 {PREAMBLE "%3 = OpExtInst %2 %1 FMax3AMD %4 %5 %6\n",
452 Concatenate(
453 {MakeInstruction(spv::Op::OpExtInstImport, {1},
454 MakeVector("SPV_AMD_shader_trinary_minmax")),
455 MakeInstruction(spv::Op::OpExtInst, {2, 3, 1, 4, 4, 5, 6})})},
456 {PREAMBLE "%3 = OpExtInst %2 %1 UMax3AMD %4 %5 %6\n",
457 Concatenate(
458 {MakeInstruction(spv::Op::OpExtInstImport, {1},
459 MakeVector("SPV_AMD_shader_trinary_minmax")),
460 MakeInstruction(spv::Op::OpExtInst, {2, 3, 1, 5, 4, 5, 6})})},
461 {PREAMBLE "%3 = OpExtInst %2 %1 SMax3AMD %4 %5 %6\n",
462 Concatenate(
463 {MakeInstruction(spv::Op::OpExtInstImport, {1},
464 MakeVector("SPV_AMD_shader_trinary_minmax")),
465 MakeInstruction(spv::Op::OpExtInst, {2, 3, 1, 6, 4, 5, 6})})},
466 {PREAMBLE "%3 = OpExtInst %2 %1 FMid3AMD %4 %5 %6\n",
467 Concatenate(
468 {MakeInstruction(spv::Op::OpExtInstImport, {1},
469 MakeVector("SPV_AMD_shader_trinary_minmax")),
470 MakeInstruction(spv::Op::OpExtInst, {2, 3, 1, 7, 4, 5, 6})})},
471 {PREAMBLE "%3 = OpExtInst %2 %1 UMid3AMD %4 %5 %6\n",
472 Concatenate(
473 {MakeInstruction(spv::Op::OpExtInstImport, {1},
474 MakeVector("SPV_AMD_shader_trinary_minmax")),
475 MakeInstruction(spv::Op::OpExtInst, {2, 3, 1, 8, 4, 5, 6})})},
476 {PREAMBLE "%3 = OpExtInst %2 %1 SMid3AMD %4 %5 %6\n",
477 Concatenate(
478 {MakeInstruction(spv::Op::OpExtInstImport, {1},
479 MakeVector("SPV_AMD_shader_trinary_minmax")),
480 MakeInstruction(spv::Op::OpExtInst, {2, 3, 1, 9, 4, 5, 6})})},
481 })));
482 #undef PREAMBLE
483
484 // SPV_AMD_gcn_shader
485
486 #define PREAMBLE "%1 = OpExtInstImport \"SPV_AMD_gcn_shader\"\n"
487 INSTANTIATE_TEST_SUITE_P(
488 SPV_AMD_gcn_shader, ExtensionRoundTripTest,
489 // We'll get coverage over operand tables by trying the universal
490 // environments, and at least one specific environment.
491 Combine(
492 Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
493 SPV_ENV_VULKAN_1_0),
494 ValuesIn(std::vector<AssemblyCase>{
495 {PREAMBLE "%3 = OpExtInst %2 %1 CubeFaceIndexAMD %4\n",
496 Concatenate({MakeInstruction(spv::Op::OpExtInstImport, {1},
497 MakeVector("SPV_AMD_gcn_shader")),
498 MakeInstruction(spv::Op::OpExtInst,
499 {2, 3, 1, 1, 4})})},
500 {PREAMBLE "%3 = OpExtInst %2 %1 CubeFaceCoordAMD %4\n",
501 Concatenate({MakeInstruction(spv::Op::OpExtInstImport, {1},
502 MakeVector("SPV_AMD_gcn_shader")),
503 MakeInstruction(spv::Op::OpExtInst,
504 {2, 3, 1, 2, 4})})},
505 {PREAMBLE "%3 = OpExtInst %2 %1 TimeAMD\n",
506 Concatenate({MakeInstruction(spv::Op::OpExtInstImport, {1},
507 MakeVector("SPV_AMD_gcn_shader")),
508 MakeInstruction(spv::Op::OpExtInst, {2, 3, 1, 3})})},
509 })));
510 #undef PREAMBLE
511
512 // SPV_AMD_shader_ballot
513
514 #define PREAMBLE "%1 = OpExtInstImport \"SPV_AMD_shader_ballot\"\n"
515 INSTANTIATE_TEST_SUITE_P(
516 SPV_AMD_shader_ballot, ExtensionRoundTripTest,
517 // We'll get coverage over operand tables by trying the universal
518 // environments, and at least one specific environment.
519 Combine(
520 Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
521 SPV_ENV_VULKAN_1_0),
522 ValuesIn(std::vector<AssemblyCase>{
523 {PREAMBLE "%3 = OpExtInst %2 %1 SwizzleInvocationsAMD %4 %5\n",
524 Concatenate({MakeInstruction(spv::Op::OpExtInstImport, {1},
525 MakeVector("SPV_AMD_shader_ballot")),
526 MakeInstruction(spv::Op::OpExtInst,
527 {2, 3, 1, 1, 4, 5})})},
528 {PREAMBLE
529 "%3 = OpExtInst %2 %1 SwizzleInvocationsMaskedAMD %4 %5\n",
530 Concatenate({MakeInstruction(spv::Op::OpExtInstImport, {1},
531 MakeVector("SPV_AMD_shader_ballot")),
532 MakeInstruction(spv::Op::OpExtInst,
533 {2, 3, 1, 2, 4, 5})})},
534 {PREAMBLE "%3 = OpExtInst %2 %1 WriteInvocationAMD %4 %5 %6\n",
535 Concatenate({MakeInstruction(spv::Op::OpExtInstImport, {1},
536 MakeVector("SPV_AMD_shader_ballot")),
537 MakeInstruction(spv::Op::OpExtInst,
538 {2, 3, 1, 3, 4, 5, 6})})},
539 {PREAMBLE "%3 = OpExtInst %2 %1 MbcntAMD %4\n",
540 Concatenate({MakeInstruction(spv::Op::OpExtInstImport, {1},
541 MakeVector("SPV_AMD_shader_ballot")),
542 MakeInstruction(spv::Op::OpExtInst,
543 {2, 3, 1, 4, 4})})},
544 })));
545 #undef PREAMBLE
546
547 // SPV_KHR_variable_pointers
548
549 INSTANTIATE_TEST_SUITE_P(
550 SPV_KHR_variable_pointers, ExtensionRoundTripTest,
551 // We'll get coverage over operand tables by trying the universal
552 // environments, and at least one specific environment.
553 Combine(
554 Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
555 SPV_ENV_VULKAN_1_0),
556 ValuesIn(std::vector<AssemblyCase>{
557 {"OpCapability VariablePointers\n",
558 MakeInstruction(spv::Op::OpCapability,
559 {(uint32_t)spv::Capability::VariablePointers})},
560 {"OpCapability VariablePointersStorageBuffer\n",
561 MakeInstruction(
562 spv::Op::OpCapability,
563 {(uint32_t)spv::Capability::VariablePointersStorageBuffer})},
564 })));
565
566 // SPV_KHR_vulkan_memory_model
567
568 INSTANTIATE_TEST_SUITE_P(
569 SPV_KHR_vulkan_memory_model, ExtensionRoundTripTest,
570 // We'll get coverage over operand tables by trying the universal
571 // environments, and at least one specific environment.
572 //
573 // Note: SPV_KHR_vulkan_memory_model adds scope enum value QueueFamilyKHR.
574 // Scope enums are used in ID definitions elsewhere, that don't know they
575 // are using particular enums. So the assembler doesn't support assembling
576 // those enums names into the corresponding values. So there is no asm/dis
577 // tests for those enums.
578 Combine(
579 Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
580 SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1),
581 ValuesIn(std::vector<AssemblyCase>{
582 {"OpCapability VulkanMemoryModel\n",
583 MakeInstruction(
584 spv::Op::OpCapability,
585 {(uint32_t)spv::Capability::VulkanMemoryModelKHR})},
586 {"OpCapability VulkanMemoryModelDeviceScope\n",
587 MakeInstruction(
588 spv::Op::OpCapability,
589 {(uint32_t)spv::Capability::VulkanMemoryModelDeviceScopeKHR})},
590 {"OpMemoryModel Logical Vulkan\n",
591 MakeInstruction(spv::Op::OpMemoryModel,
592 {(uint32_t)spv::AddressingModel::Logical,
593 (uint32_t)spv::MemoryModel::VulkanKHR})},
594 {"OpStore %1 %2 MakePointerAvailable %3\n",
595 MakeInstruction(
596 spv::Op::OpStore,
597 {1, 2,
598 (uint32_t)spv::MemoryAccessMask::MakePointerAvailableKHR,
599 3})},
600 {"OpStore %1 %2 Volatile|MakePointerAvailable %3\n",
601 MakeInstruction(
602 spv::Op::OpStore,
603 {1, 2,
604 int(spv::MemoryAccessMask::MakePointerAvailableKHR) |
605 int(spv::MemoryAccessMask::Volatile),
606 3})},
607 {"OpStore %1 %2 Aligned|MakePointerAvailable 4 %3\n",
608 MakeInstruction(
609 spv::Op::OpStore,
610 {1, 2,
611 int(spv::MemoryAccessMask::MakePointerAvailableKHR) |
612 int(spv::MemoryAccessMask::Aligned),
613 4, 3})},
614 {"OpStore %1 %2 MakePointerAvailable|NonPrivatePointer %3\n",
615 MakeInstruction(
616 spv::Op::OpStore,
617 {1, 2,
618 int(spv::MemoryAccessMask::MakePointerAvailableKHR) |
619 int(spv::MemoryAccessMask::NonPrivatePointerKHR),
620 3})},
621 {"%2 = OpLoad %1 %3 MakePointerVisible %4\n",
622 MakeInstruction(
623 spv::Op::OpLoad,
624 {1, 2, 3,
625 (uint32_t)spv::MemoryAccessMask::MakePointerVisibleKHR, 4})},
626 {"%2 = OpLoad %1 %3 Volatile|MakePointerVisible %4\n",
627 MakeInstruction(
628 spv::Op::OpLoad,
629 {1, 2, 3,
630 int(spv::MemoryAccessMask::MakePointerVisibleKHR) |
631 int(spv::MemoryAccessMask::Volatile),
632 4})},
633 {"%2 = OpLoad %1 %3 Aligned|MakePointerVisible 8 %4\n",
634 MakeInstruction(
635 spv::Op::OpLoad,
636 {1, 2, 3,
637 int(spv::MemoryAccessMask::MakePointerVisibleKHR) |
638 int(spv::MemoryAccessMask::Aligned),
639 8, 4})},
640 {"%2 = OpLoad %1 %3 MakePointerVisible|NonPrivatePointer "
641 "%4\n",
642 MakeInstruction(
643 spv::Op::OpLoad,
644 {1, 2, 3,
645 int(spv::MemoryAccessMask::MakePointerVisibleKHR) |
646 int(spv::MemoryAccessMask::NonPrivatePointerKHR),
647 4})},
648 {"OpCopyMemory %1 %2 "
649 "MakePointerAvailable|"
650 "MakePointerVisible|"
651 "NonPrivatePointer "
652 "%3 %4\n",
653 MakeInstruction(
654 spv::Op::OpCopyMemory,
655 {1, 2,
656 (int(spv::MemoryAccessMask::MakePointerVisibleKHR) |
657 int(spv::MemoryAccessMask::MakePointerAvailableKHR) |
658 int(spv::MemoryAccessMask::NonPrivatePointerKHR)),
659 3, 4})},
660 {"OpCopyMemorySized %1 %2 %3 "
661 "MakePointerAvailable|"
662 "MakePointerVisible|"
663 "NonPrivatePointer "
664 "%4 %5\n",
665 MakeInstruction(
666 spv::Op::OpCopyMemorySized,
667 {1, 2, 3,
668 (int(spv::MemoryAccessMask::MakePointerVisibleKHR) |
669 int(spv::MemoryAccessMask::MakePointerAvailableKHR) |
670 int(spv::MemoryAccessMask::NonPrivatePointerKHR)),
671 4, 5})},
672 // Image operands
673 {"OpImageWrite %1 %2 %3 MakeTexelAvailable "
674 "%4\n",
675 MakeInstruction(
676 spv::Op::OpImageWrite,
677 {1, 2, 3, int(spv::ImageOperandsMask::MakeTexelAvailableKHR),
678 4})},
679 {"OpImageWrite %1 %2 %3 MakeTexelAvailable|NonPrivateTexel "
680 "%4\n",
681 MakeInstruction(
682 spv::Op::OpImageWrite,
683 {1, 2, 3,
684 int(spv::ImageOperandsMask::MakeTexelAvailableKHR) |
685 int(spv::ImageOperandsMask::NonPrivateTexelKHR),
686 4})},
687 {"OpImageWrite %1 %2 %3 "
688 "MakeTexelAvailable|NonPrivateTexel|VolatileTexel "
689 "%4\n",
690 MakeInstruction(
691 spv::Op::OpImageWrite,
692 {1, 2, 3,
693 int(spv::ImageOperandsMask::MakeTexelAvailableKHR) |
694 int(spv::ImageOperandsMask::NonPrivateTexelKHR) |
695 int(spv::ImageOperandsMask::VolatileTexelKHR),
696 4})},
697 {"%2 = OpImageRead %1 %3 %4 MakeTexelVisible "
698 "%5\n",
699 MakeInstruction(spv::Op::OpImageRead,
700 {1, 2, 3, 4,
701 int(spv::ImageOperandsMask::MakeTexelVisibleKHR),
702 5})},
703 {"%2 = OpImageRead %1 %3 %4 "
704 "MakeTexelVisible|NonPrivateTexel "
705 "%5\n",
706 MakeInstruction(
707 spv::Op::OpImageRead,
708 {1, 2, 3, 4,
709 int(spv::ImageOperandsMask::MakeTexelVisibleKHR) |
710 int(spv::ImageOperandsMask::NonPrivateTexelKHR),
711 5})},
712 {"%2 = OpImageRead %1 %3 %4 "
713 "MakeTexelVisible|NonPrivateTexel|VolatileTexel "
714 "%5\n",
715 MakeInstruction(
716 spv::Op::OpImageRead,
717 {1, 2, 3, 4,
718 int(spv::ImageOperandsMask::MakeTexelVisibleKHR) |
719 int(spv::ImageOperandsMask::NonPrivateTexelKHR) |
720 int(spv::ImageOperandsMask::VolatileTexelKHR),
721 5})},
722
723 // Memory semantics ID values are numbers put into a SPIR-V
724 // constant integer referenced by Id. There is no token for
725 // them, and so no assembler or disassembler support required.
726 // Similar for Scope ID.
727 })));
728
729 // SPV_GOOGLE_decorate_string
730
731 // Now that OpDecorateString is the preferred spelling for
732 // OpDecorateStringGOOGLE use that name in round trip tests, and the GOOGLE
733 // name in an assembly-only test.
734
735 INSTANTIATE_TEST_SUITE_P(
736 SPV_GOOGLE_decorate_string, ExtensionRoundTripTest,
737 Combine(
738 // We'll get coverage over operand tables by trying the universal
739 // environments, and at least one specific environment.
740 Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
741 SPV_ENV_UNIVERSAL_1_2, SPV_ENV_VULKAN_1_0),
742 ValuesIn(std::vector<AssemblyCase>{
743 {"OpDecorateString %1 UserSemantic \"ABC\"\n",
744 MakeInstruction(spv::Op::OpDecorateStringGOOGLE,
745 {1, (uint32_t)spv::Decoration::HlslSemanticGOOGLE},
746 MakeVector("ABC"))},
747 {"OpDecorateString %1 UserSemantic \"ABC\"\n",
748 MakeInstruction(spv::Op::OpDecorateString,
749 {1, (uint32_t)spv::Decoration::UserSemantic},
750 MakeVector("ABC"))},
751 {"OpMemberDecorateString %1 3 UserSemantic \"DEF\"\n",
752 MakeInstruction(spv::Op::OpMemberDecorateStringGOOGLE,
753 {1, 3, (uint32_t)spv::Decoration::UserSemantic},
754 MakeVector("DEF"))},
755 {"OpMemberDecorateString %1 3 UserSemantic \"DEF\"\n",
756 MakeInstruction(spv::Op::OpMemberDecorateString,
757 {1, 3, (uint32_t)spv::Decoration::UserSemantic},
758 MakeVector("DEF"))},
759 })));
760
761 INSTANTIATE_TEST_SUITE_P(
762 SPV_GOOGLE_decorate_string, ExtensionAssemblyTest,
763 Combine(
764 // We'll get coverage over operand tables by trying the universal
765 // environments, and at least one specific environment.
766 Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
767 SPV_ENV_UNIVERSAL_1_2, SPV_ENV_VULKAN_1_0),
768 ValuesIn(std::vector<AssemblyCase>{
769 {"OpDecorateStringGOOGLE %1 HlslSemanticGOOGLE \"ABC\"\n",
770 MakeInstruction(spv::Op::OpDecorateStringGOOGLE,
771 {1, (uint32_t)spv::Decoration::HlslSemanticGOOGLE},
772 MakeVector("ABC"))},
773 {"OpMemberDecorateStringGOOGLE %1 3 HlslSemanticGOOGLE \"DEF\"\n",
774 MakeInstruction(spv::Op::OpMemberDecorateStringGOOGLE,
775 {1, 3,
776 (uint32_t)spv::Decoration::HlslSemanticGOOGLE},
777 MakeVector("DEF"))},
778 })));
779
780 // SPV_GOOGLE_hlsl_functionality1
781
782 // Now that CounterBuffer is the preferred spelling for HlslCounterBufferGOOGLE,
783 // use that name in round trip tests, and the GOOGLE name in an assembly-only
784 // test.
785 INSTANTIATE_TEST_SUITE_P(
786 SPV_GOOGLE_hlsl_functionality1, ExtensionRoundTripTest,
787 Combine(
788 // We'll get coverage over operand tables by trying the universal
789 // environments, and at least one specific environment.
790 Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
791 SPV_ENV_UNIVERSAL_1_2, SPV_ENV_VULKAN_1_0),
792 // HlslSemanticGOOGLE is tested in SPV_GOOGLE_decorate_string, since
793 // they are coupled together.
794 ValuesIn(std::vector<AssemblyCase>{
795 {"OpDecorateId %1 CounterBuffer %2\n",
796 MakeInstruction(
797 spv::Op::OpDecorateId,
798 {1, (uint32_t)spv::Decoration::HlslCounterBufferGOOGLE, 2})},
799 {"OpDecorateId %1 CounterBuffer %2\n",
800 MakeInstruction(spv::Op::OpDecorateId,
801 {1, (uint32_t)spv::Decoration::CounterBuffer, 2})},
802 })));
803
804 INSTANTIATE_TEST_SUITE_P(
805 SPV_GOOGLE_hlsl_functionality1, ExtensionAssemblyTest,
806 Combine(
807 // We'll get coverage over operand tables by trying the universal
808 // environments, and at least one specific environment.
809 Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
810 SPV_ENV_UNIVERSAL_1_2, SPV_ENV_VULKAN_1_0),
811 // HlslSemanticGOOGLE is tested in SPV_GOOGLE_decorate_string, since
812 // they are coupled together.
813 ValuesIn(std::vector<AssemblyCase>{
814 {"OpDecorateId %1 HlslCounterBufferGOOGLE %2\n",
815 MakeInstruction(
816 spv::Op::OpDecorateId,
817 {1, (uint32_t)spv::Decoration::HlslCounterBufferGOOGLE, 2})},
818 })));
819
820 // SPV_NV_viewport_array2
821
822 INSTANTIATE_TEST_SUITE_P(
823 SPV_NV_viewport_array2, ExtensionRoundTripTest,
824 Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
825 SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_3,
826 SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1),
827 ValuesIn(std::vector<AssemblyCase>{
828 {"OpExtension \"SPV_NV_viewport_array2\"\n",
829 MakeInstruction(spv::Op::OpExtension,
830 MakeVector("SPV_NV_viewport_array2"))},
831 // The EXT and NV extensions have the same token number for this
832 // capability.
833 {"OpCapability ShaderViewportIndexLayerEXT\n",
834 MakeInstruction(
835 spv::Op::OpCapability,
836 {(uint32_t)spv::Capability::ShaderViewportIndexLayerNV})},
837 // Check the new capability's token number
838 {"OpCapability ShaderViewportIndexLayerEXT\n",
839 MakeInstruction(spv::Op::OpCapability, {5254})},
840 // Decorations
841 {"OpDecorate %1 ViewportRelativeNV\n",
842 MakeInstruction(
843 spv::Op::OpDecorate,
844 {1, (uint32_t)spv::Decoration::ViewportRelativeNV})},
845 {"OpDecorate %1 BuiltIn ViewportMaskNV\n",
846 MakeInstruction(spv::Op::OpDecorate,
847 {1, (uint32_t)spv::Decoration::BuiltIn,
848 (uint32_t)spv::BuiltIn::ViewportMaskNV})},
849 })));
850
851 // SPV_NV_shader_subgroup_partitioned
852
853 INSTANTIATE_TEST_SUITE_P(
854 SPV_NV_shader_subgroup_partitioned, ExtensionRoundTripTest,
855 Combine(
856 Values(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_1),
857 ValuesIn(std::vector<AssemblyCase>{
858 {"OpExtension \"SPV_NV_shader_subgroup_partitioned\"\n",
859 MakeInstruction(spv::Op::OpExtension,
860 MakeVector("SPV_NV_shader_subgroup_partitioned"))},
861 {"OpCapability GroupNonUniformPartitionedEXT\n",
862 MakeInstruction(
863 spv::Op::OpCapability,
864 {(uint32_t)spv::Capability::GroupNonUniformPartitionedEXT})},
865 // Check the new capability's token number
866 {"OpCapability GroupNonUniformPartitionedEXT\n",
867 MakeInstruction(spv::Op::OpCapability, {5297})},
868 {"%2 = OpGroupNonUniformPartitionEXT %1 %3\n",
869 MakeInstruction(spv::Op::OpGroupNonUniformPartitionEXT,
870 {1, 2, 3})},
871 // Check the new instruction's token number
872 {"%2 = OpGroupNonUniformPartitionEXT %1 %3\n",
873 MakeInstruction(static_cast<spv::Op>(5296), {1, 2, 3})},
874 // Check the new group operations
875 {"%2 = OpGroupIAdd %1 %3 PartitionedReduceEXT %4\n",
876 MakeInstruction(
877 spv::Op::OpGroupIAdd,
878 {1, 2, 3, (uint32_t)spv::GroupOperation::PartitionedReduceEXT,
879 4})},
880 {"%2 = OpGroupIAdd %1 %3 PartitionedReduceEXT %4\n",
881 MakeInstruction(spv::Op::OpGroupIAdd, {1, 2, 3, 6, 4})},
882 {"%2 = OpGroupIAdd %1 %3 PartitionedInclusiveScanEXT %4\n",
883 MakeInstruction(
884 spv::Op::OpGroupIAdd,
885 {1, 2, 3,
886 (uint32_t)spv::GroupOperation::PartitionedInclusiveScanNV,
887 4})},
888 {"%2 = OpGroupIAdd %1 %3 PartitionedInclusiveScanEXT %4\n",
889 MakeInstruction(spv::Op::OpGroupIAdd, {1, 2, 3, 7, 4})},
890 {"%2 = OpGroupIAdd %1 %3 PartitionedExclusiveScanEXT %4\n",
891 MakeInstruction(
892 spv::Op::OpGroupIAdd,
893 {1, 2, 3,
894 (uint32_t)spv::GroupOperation::PartitionedExclusiveScanEXT,
895 4})},
896 {"%2 = OpGroupIAdd %1 %3 PartitionedExclusiveScanEXT %4\n",
897 MakeInstruction(spv::Op::OpGroupIAdd, {1, 2, 3, 8, 4})},
898 })));
899
900 // SPV_EXT_descriptor_indexing
901
902 INSTANTIATE_TEST_SUITE_P(
903 SPV_EXT_descriptor_indexing, ExtensionRoundTripTest,
904 Combine(
905 Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1,
906 SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_0,
907 SPV_ENV_VULKAN_1_1),
908 ValuesIn(std::vector<AssemblyCase>{
909 {"OpExtension \"SPV_EXT_descriptor_indexing\"\n",
910 MakeInstruction(spv::Op::OpExtension,
911 MakeVector("SPV_EXT_descriptor_indexing"))},
912 // Check capabilities, by name
913 {"OpCapability ShaderNonUniform\n",
914 MakeInstruction(spv::Op::OpCapability,
915 {(uint32_t)spv::Capability::ShaderNonUniformEXT})},
916 {"OpCapability RuntimeDescriptorArray\n",
917 MakeInstruction(
918 spv::Op::OpCapability,
919 {(uint32_t)spv::Capability::RuntimeDescriptorArrayEXT})},
920 {"OpCapability InputAttachmentArrayDynamicIndexing\n",
921 MakeInstruction(spv::Op::OpCapability,
922 {(uint32_t)spv::Capability::
923 InputAttachmentArrayDynamicIndexingEXT})},
924 {"OpCapability UniformTexelBufferArrayDynamicIndexing\n",
925 MakeInstruction(spv::Op::OpCapability,
926 {(uint32_t)spv::Capability::
927 UniformTexelBufferArrayDynamicIndexingEXT})},
928 {"OpCapability StorageTexelBufferArrayDynamicIndexing\n",
929 MakeInstruction(spv::Op::OpCapability,
930 {(uint32_t)spv::Capability::
931 StorageTexelBufferArrayDynamicIndexingEXT})},
932 {"OpCapability UniformBufferArrayNonUniformIndexing\n",
933 MakeInstruction(spv::Op::OpCapability,
934 {(uint32_t)spv::Capability::
935 UniformBufferArrayNonUniformIndexingEXT})},
936 {"OpCapability SampledImageArrayNonUniformIndexing\n",
937 MakeInstruction(spv::Op::OpCapability,
938 {(uint32_t)spv::Capability::
939 SampledImageArrayNonUniformIndexingEXT})},
940 {"OpCapability StorageBufferArrayNonUniformIndexing\n",
941 MakeInstruction(spv::Op::OpCapability,
942 {(uint32_t)spv::Capability::
943 StorageBufferArrayNonUniformIndexingEXT})},
944 {"OpCapability StorageImageArrayNonUniformIndexing\n",
945 MakeInstruction(spv::Op::OpCapability,
946 {(uint32_t)spv::Capability::
947 StorageImageArrayNonUniformIndexingEXT})},
948 {"OpCapability InputAttachmentArrayNonUniformIndexing\n",
949 MakeInstruction(spv::Op::OpCapability,
950 {(uint32_t)spv::Capability::
951 InputAttachmentArrayNonUniformIndexingEXT})},
952 {"OpCapability UniformTexelBufferArrayNonUniformIndexing\n",
953 MakeInstruction(
954 spv::Op::OpCapability,
955 {(uint32_t)spv::Capability::
956 UniformTexelBufferArrayNonUniformIndexingEXT})},
957 {"OpCapability StorageTexelBufferArrayNonUniformIndexing\n",
958 MakeInstruction(
959 spv::Op::OpCapability,
960 {(uint32_t)spv::Capability::
961 StorageTexelBufferArrayNonUniformIndexingEXT})},
962 // Check capabilities, by number
963 {"OpCapability ShaderNonUniform\n",
964 MakeInstruction(spv::Op::OpCapability, {5301})},
965 {"OpCapability RuntimeDescriptorArray\n",
966 MakeInstruction(spv::Op::OpCapability, {5302})},
967 {"OpCapability InputAttachmentArrayDynamicIndexing\n",
968 MakeInstruction(spv::Op::OpCapability, {5303})},
969 {"OpCapability UniformTexelBufferArrayDynamicIndexing\n",
970 MakeInstruction(spv::Op::OpCapability, {5304})},
971 {"OpCapability StorageTexelBufferArrayDynamicIndexing\n",
972 MakeInstruction(spv::Op::OpCapability, {5305})},
973 {"OpCapability UniformBufferArrayNonUniformIndexing\n",
974 MakeInstruction(spv::Op::OpCapability, {5306})},
975 {"OpCapability SampledImageArrayNonUniformIndexing\n",
976 MakeInstruction(spv::Op::OpCapability, {5307})},
977 {"OpCapability StorageBufferArrayNonUniformIndexing\n",
978 MakeInstruction(spv::Op::OpCapability, {5308})},
979 {"OpCapability StorageImageArrayNonUniformIndexing\n",
980 MakeInstruction(spv::Op::OpCapability, {5309})},
981 {"OpCapability InputAttachmentArrayNonUniformIndexing\n",
982 MakeInstruction(spv::Op::OpCapability, {5310})},
983 {"OpCapability UniformTexelBufferArrayNonUniformIndexing\n",
984 MakeInstruction(spv::Op::OpCapability, {5311})},
985 {"OpCapability StorageTexelBufferArrayNonUniformIndexing\n",
986 MakeInstruction(spv::Op::OpCapability, {5312})},
987
988 // Check the decoration token
989 {"OpDecorate %1 NonUniform\n",
990 MakeInstruction(spv::Op::OpDecorate,
991 {1, (uint32_t)spv::Decoration::NonUniformEXT})},
992 {"OpDecorate %1 NonUniform\n",
993 MakeInstruction(spv::Op::OpDecorate, {1, 5300})},
994 })));
995
996 // SPV_KHR_linkonce_odr
997
998 INSTANTIATE_TEST_SUITE_P(
999 SPV_KHR_linkonce_odr, ExtensionRoundTripTest,
1000 Combine(
1001 Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_0,
1002 SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_2),
1003 ValuesIn(std::vector<AssemblyCase>{
1004 {"OpExtension \"SPV_KHR_linkonce_odr\"\n",
1005 MakeInstruction(spv::Op::OpExtension,
1006 MakeVector("SPV_KHR_linkonce_odr"))},
1007 {"OpDecorate %1 LinkageAttributes \"foobar\" LinkOnceODR\n",
1008 MakeInstruction(
1009 spv::Op::OpDecorate,
1010 Concatenate({{1, (uint32_t)spv::Decoration::LinkageAttributes},
1011 MakeVector("foobar"),
1012 {(uint32_t)spv::LinkageType::LinkOnceODR}}))},
1013 })));
1014
1015 // SPV_KHR_expect_assume
1016
1017 INSTANTIATE_TEST_SUITE_P(
1018 SPV_KHR_expect_assume, ExtensionRoundTripTest,
1019 Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_3,
1020 SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_2),
1021 ValuesIn(std::vector<AssemblyCase>{
1022 {"OpExtension \"SPV_KHR_expect_assume\"\n",
1023 MakeInstruction(spv::Op::OpExtension,
1024 MakeVector("SPV_KHR_expect_assume"))},
1025 {"OpAssumeTrueKHR %1\n",
1026 MakeInstruction(spv::Op::OpAssumeTrueKHR, {1})}})));
1027 // SPV_KHR_subgroup_uniform_control_flow
1028
1029 INSTANTIATE_TEST_SUITE_P(
1030 SPV_KHR_subgroup_uniform_control_flow, ExtensionRoundTripTest,
1031 Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_3,
1032 SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_2),
1033 ValuesIn(std::vector<AssemblyCase>{
1034 {"OpExtension \"SPV_KHR_subgroup_uniform_control_flow\"\n",
1035 MakeInstruction(
1036 spv::Op::OpExtension,
1037 MakeVector("SPV_KHR_subgroup_uniform_control_flow"))},
1038 {"OpExecutionMode %1 SubgroupUniformControlFlowKHR\n",
1039 MakeInstruction(spv::Op::OpExecutionMode,
1040 {1, (uint32_t)spv::ExecutionMode::
1041 SubgroupUniformControlFlowKHR})},
1042 })));
1043
1044 // SPV_KHR_integer_dot_product
1045
1046 INSTANTIATE_TEST_SUITE_P(
1047 SPV_KHR_integer_dot_product, ExtensionRoundTripTest,
1048 Combine(
1049 Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_5,
1050 SPV_ENV_UNIVERSAL_1_6, SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1,
1051 SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_3),
1052 ValuesIn(std::vector<AssemblyCase>{
1053 {"OpExtension \"SPV_KHR_integer_dot_product\"\n",
1054 MakeInstruction(spv::Op::OpExtension,
1055 MakeVector("SPV_KHR_integer_dot_product"))},
1056 {"OpCapability DotProductInputAll\n",
1057 MakeInstruction(
1058 spv::Op::OpCapability,
1059 {(uint32_t)spv::Capability::DotProductInputAllKHR})},
1060 {"OpCapability DotProductInput4x8Bit\n",
1061 MakeInstruction(
1062 spv::Op::OpCapability,
1063 {(uint32_t)spv::Capability::DotProductInput4x8BitKHR})},
1064 {"OpCapability DotProductInput4x8BitPacked\n",
1065 MakeInstruction(
1066 spv::Op::OpCapability,
1067 {(uint32_t)spv::Capability::DotProductInput4x8BitPackedKHR})},
1068 {"OpCapability DotProduct\n",
1069 MakeInstruction(spv::Op::OpCapability,
1070 {(uint32_t)spv::Capability::DotProductKHR})},
1071 {"%2 = OpSDot %1 %3 %4\n",
1072 MakeInstruction(spv::Op::OpSDotKHR, {1, 2, 3, 4})},
1073 {"%2 = OpSDot %1 %3 %4 PackedVectorFormat4x8Bit\n",
1074 MakeInstruction(
1075 spv::Op::OpSDotKHR,
1076 {1, 2, 3, 4,
1077 (uint32_t)
1078 spv::PackedVectorFormat::PackedVectorFormat4x8BitKHR})},
1079 {"%2 = OpUDot %1 %3 %4\n",
1080 MakeInstruction(spv::Op::OpUDotKHR, {1, 2, 3, 4})},
1081 {"%2 = OpUDot %1 %3 %4 PackedVectorFormat4x8Bit\n",
1082 MakeInstruction(
1083 spv::Op::OpUDotKHR,
1084 {1, 2, 3, 4,
1085 (uint32_t)
1086 spv::PackedVectorFormat::PackedVectorFormat4x8BitKHR})},
1087 {"%2 = OpSUDot %1 %3 %4\n",
1088 MakeInstruction(spv::Op::OpSUDotKHR, {1, 2, 3, 4})},
1089 {"%2 = OpSUDot %1 %3 %4 PackedVectorFormat4x8Bit\n",
1090 MakeInstruction(
1091 spv::Op::OpSUDotKHR,
1092 {1, 2, 3, 4,
1093 (uint32_t)
1094 spv::PackedVectorFormat::PackedVectorFormat4x8BitKHR})},
1095 {"%2 = OpSDotAccSat %1 %3 %4 %5\n",
1096 MakeInstruction(spv::Op::OpSDotAccSatKHR, {1, 2, 3, 4, 5})},
1097 {"%2 = OpSDotAccSat %1 %3 %4 %5 PackedVectorFormat4x8Bit\n",
1098 MakeInstruction(
1099 spv::Op::OpSDotAccSatKHR,
1100 {1, 2, 3, 4, 5,
1101 (uint32_t)
1102 spv::PackedVectorFormat::PackedVectorFormat4x8BitKHR})},
1103 {"%2 = OpUDotAccSat %1 %3 %4 %5\n",
1104 MakeInstruction(spv::Op::OpUDotAccSatKHR, {1, 2, 3, 4, 5})},
1105 {"%2 = OpUDotAccSat %1 %3 %4 %5 PackedVectorFormat4x8Bit\n",
1106 MakeInstruction(
1107 spv::Op::OpUDotAccSatKHR,
1108 {1, 2, 3, 4, 5,
1109 (uint32_t)
1110 spv::PackedVectorFormat::PackedVectorFormat4x8BitKHR})},
1111 {"%2 = OpSUDotAccSat %1 %3 %4 %5\n",
1112 MakeInstruction(spv::Op::OpSUDotAccSatKHR, {1, 2, 3, 4, 5})},
1113 {"%2 = OpSUDotAccSat %1 %3 %4 %5 PackedVectorFormat4x8Bit\n",
1114 MakeInstruction(
1115 spv::Op::OpSUDotAccSatKHR,
1116 {1, 2, 3, 4, 5,
1117 (uint32_t)
1118 spv::PackedVectorFormat::PackedVectorFormat4x8BitKHR})},
1119 })));
1120
1121 // SPV_KHR_bit_instructions
1122
1123 INSTANTIATE_TEST_SUITE_P(
1124 SPV_KHR_bit_instructions, ExtensionRoundTripTest,
1125 Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_5,
1126 SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_2),
1127 ValuesIn(std::vector<AssemblyCase>{
1128 {"OpExtension \"SPV_KHR_bit_instructions\"\n",
1129 MakeInstruction(spv::Op::OpExtension,
1130 MakeVector("SPV_KHR_bit_instructions"))},
1131 {"OpCapability BitInstructions\n",
1132 MakeInstruction(spv::Op::OpCapability,
1133 {(uint32_t)spv::Capability::BitInstructions})},
1134 })));
1135
1136 // SPV_KHR_uniform_group_instructions
1137
1138 INSTANTIATE_TEST_SUITE_P(
1139 SPV_KHR_uniform_group_instructions, ExtensionRoundTripTest,
1140 Combine(
1141 Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_5,
1142 SPV_ENV_UNIVERSAL_1_6, SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1,
1143 SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_3),
1144 ValuesIn(std::vector<AssemblyCase>{
1145 {"OpExtension \"SPV_KHR_uniform_group_instructions\"\n",
1146 MakeInstruction(spv::Op::OpExtension,
1147 MakeVector("SPV_KHR_uniform_group_instructions"))},
1148 {"OpCapability GroupUniformArithmeticKHR\n",
1149 MakeInstruction(
1150 spv::Op::OpCapability,
1151 {(uint32_t)spv::Capability::GroupUniformArithmeticKHR})},
1152 {"%2 = OpGroupIMulKHR %1 %3 Reduce %4\n",
1153 MakeInstruction(spv::Op::OpGroupIMulKHR,
1154 {1, 2, 3, (uint32_t)spv::GroupOperation::Reduce,
1155 4})},
1156 {"%2 = OpGroupFMulKHR %1 %3 Reduce %4\n",
1157 MakeInstruction(spv::Op::OpGroupFMulKHR,
1158 {1, 2, 3, (uint32_t)spv::GroupOperation::Reduce,
1159 4})},
1160 {"%2 = OpGroupBitwiseAndKHR %1 %3 Reduce %4\n",
1161 MakeInstruction(spv::Op::OpGroupBitwiseAndKHR,
1162 {1, 2, 3, (uint32_t)spv::GroupOperation::Reduce,
1163 4})},
1164 {"%2 = OpGroupBitwiseOrKHR %1 %3 Reduce %4\n",
1165 MakeInstruction(spv::Op::OpGroupBitwiseOrKHR,
1166 {1, 2, 3, (uint32_t)spv::GroupOperation::Reduce,
1167 4})},
1168 {"%2 = OpGroupBitwiseXorKHR %1 %3 Reduce %4\n",
1169 MakeInstruction(spv::Op::OpGroupBitwiseXorKHR,
1170 {1, 2, 3, (uint32_t)spv::GroupOperation::Reduce,
1171 4})},
1172 {"%2 = OpGroupLogicalAndKHR %1 %3 Reduce %4\n",
1173 MakeInstruction(spv::Op::OpGroupLogicalAndKHR,
1174 {1, 2, 3, (uint32_t)spv::GroupOperation::Reduce,
1175 4})},
1176 {"%2 = OpGroupLogicalOrKHR %1 %3 Reduce %4\n",
1177 MakeInstruction(spv::Op::OpGroupLogicalOrKHR,
1178 {1, 2, 3, (uint32_t)spv::GroupOperation::Reduce,
1179 4})},
1180 {"%2 = OpGroupLogicalXorKHR %1 %3 Reduce %4\n",
1181 MakeInstruction(spv::Op::OpGroupLogicalXorKHR,
1182 {1, 2, 3, (uint32_t)spv::GroupOperation::Reduce,
1183 4})},
1184 })));
1185
1186 // SPV_KHR_subgroup_rotate
1187
1188 INSTANTIATE_TEST_SUITE_P(
1189 SPV_KHR_subgroup_rotate, ExtensionRoundTripTest,
1190 Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_6,
1191 SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_2,
1192 SPV_ENV_VULKAN_1_3, SPV_ENV_OPENCL_2_1),
1193 ValuesIn(std::vector<AssemblyCase>{
1194 {"OpExtension \"SPV_KHR_subgroup_rotate\"\n",
1195 MakeInstruction(spv::Op::OpExtension,
1196 MakeVector("SPV_KHR_subgroup_rotate"))},
1197 {"OpCapability GroupNonUniformRotateKHR\n",
1198 MakeInstruction(
1199 spv::Op::OpCapability,
1200 {(uint32_t)spv::Capability::GroupNonUniformRotateKHR})},
1201 {"%2 = OpGroupNonUniformRotateKHR %1 %3 %4 %5\n",
1202 MakeInstruction(spv::Op::OpGroupNonUniformRotateKHR,
1203 {1, 2, 3, 4, 5})},
1204 {"%2 = OpGroupNonUniformRotateKHR %1 %3 %4 %5 %6\n",
1205 MakeInstruction(spv::Op::OpGroupNonUniformRotateKHR,
1206 {1, 2, 3, 4, 5, 6})},
1207 })));
1208
1209 // SPV_EXT_shader_tile_image
1210
1211 INSTANTIATE_TEST_SUITE_P(
1212 SPV_EXT_shader_tile_image, ExtensionRoundTripTest,
1213 Combine(
1214 Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_5, SPV_ENV_VULKAN_1_0,
1215 SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_3),
1216 ValuesIn(std::vector<AssemblyCase>{
1217 {"OpExtension \"SPV_EXT_shader_tile_image\"\n",
1218 MakeInstruction(spv::Op::OpExtension,
1219 MakeVector("SPV_EXT_shader_tile_image"))},
1220 {"OpCapability TileImageColorReadAccessEXT\n",
1221 MakeInstruction(
1222 spv::Op::OpCapability,
1223 {(uint32_t)spv::Capability::TileImageColorReadAccessEXT})},
1224 {"OpCapability TileImageDepthReadAccessEXT\n",
1225 MakeInstruction(
1226 spv::Op::OpCapability,
1227 {(uint32_t)spv::Capability::TileImageDepthReadAccessEXT})},
1228 {"OpCapability TileImageStencilReadAccessEXT\n",
1229 MakeInstruction(
1230 spv::Op::OpCapability,
1231 {(uint32_t)spv::Capability::TileImageStencilReadAccessEXT})},
1232 {"OpExecutionMode %1 NonCoherentColorAttachmentReadEXT\n",
1233 MakeInstruction(spv::Op::OpExecutionMode,
1234 {1, (uint32_t)spv::ExecutionMode::
1235 NonCoherentColorAttachmentReadEXT})},
1236 {"OpExecutionMode %1 NonCoherentDepthAttachmentReadEXT\n",
1237 MakeInstruction(spv::Op::OpExecutionMode,
1238 {1, (uint32_t)spv::ExecutionMode::
1239 NonCoherentDepthAttachmentReadEXT})},
1240 {"OpExecutionMode %1 NonCoherentStencilAttachmentReadEXT\n",
1241 MakeInstruction(spv::Op::OpExecutionMode,
1242 {1, (uint32_t)spv::ExecutionMode::
1243 NonCoherentStencilAttachmentReadEXT})},
1244 {"%2 = OpColorAttachmentReadEXT %1 %3\n",
1245 MakeInstruction(spv::Op::OpColorAttachmentReadEXT, {1, 2, 3})},
1246 {"%2 = OpColorAttachmentReadEXT %1 %3 %4\n",
1247 MakeInstruction(spv::Op::OpColorAttachmentReadEXT, {1, 2, 3, 4})},
1248 {"%2 = OpDepthAttachmentReadEXT %1\n",
1249 MakeInstruction(spv::Op::OpDepthAttachmentReadEXT, {1, 2})},
1250 {"%2 = OpDepthAttachmentReadEXT %1 %3\n",
1251 MakeInstruction(spv::Op::OpDepthAttachmentReadEXT, {1, 2, 3})},
1252 {"%2 = OpStencilAttachmentReadEXT %1\n",
1253 MakeInstruction(spv::Op::OpStencilAttachmentReadEXT, {1, 2})},
1254 {"%2 = OpStencilAttachmentReadEXT %1 %3\n",
1255 MakeInstruction(spv::Op::OpStencilAttachmentReadEXT, {1, 2, 3})},
1256 })));
1257
1258 // SPV_KHR_maximal_reconvergence
1259
1260 INSTANTIATE_TEST_SUITE_P(
1261 SPV_KHR_maximal_reconvergence, ExtensionRoundTripTest,
1262 Combine(
1263 Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_5, SPV_ENV_VULKAN_1_0,
1264 SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_3),
1265 ValuesIn(std::vector<AssemblyCase>{
1266 {"OpExtension \"SPV_KHR_maximal_reconvergence\"\n",
1267 MakeInstruction(spv::Op::OpExtension,
1268 MakeVector("SPV_KHR_maximal_reconvergence"))},
1269 {"OpExecutionMode %1 MaximallyReconvergesKHR\n",
1270 MakeInstruction(
1271 spv::Op::OpExecutionMode,
1272 {1, (uint32_t)spv::ExecutionMode::MaximallyReconvergesKHR})},
1273 })));
1274
1275 // SPV_KHR_float_controls2
1276
1277 INSTANTIATE_TEST_SUITE_P(
1278 SPV_KHR_float_controls2, ExtensionRoundTripTest,
1279 Combine(
1280 Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_5, SPV_ENV_VULKAN_1_0,
1281 SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_3),
1282 ValuesIn(std::vector<AssemblyCase>{
1283 {"OpExtension \"SPV_KHR_float_controls2\"\n",
1284 MakeInstruction(spv::Op::OpExtension,
1285 MakeVector("SPV_KHR_float_controls2"))},
1286 {"OpCapability FloatControls2\n",
1287 MakeInstruction(spv::Op::OpCapability,
1288 {(uint32_t)spv::Capability::FloatControls2})},
1289 {"OpExecutionMode %1 FPFastMathDefault %2 %3\n",
1290 // The operands are: target type, flags constant
1291 MakeInstruction(
1292 spv::Op::OpExecutionMode,
1293 {1, (uint32_t)spv::ExecutionMode::FPFastMathDefault, 2, 3})},
1294 {"OpDecorate %1 FPFastMathMode AllowContract\n",
1295 MakeInstruction(
1296 spv::Op::OpDecorate,
1297 {1, (uint32_t)spv::Decoration::FPFastMathMode,
1298 (uint32_t)spv::FPFastMathModeMask::AllowContract})},
1299 {"OpDecorate %1 FPFastMathMode AllowReassoc\n",
1300 MakeInstruction(
1301 spv::Op::OpDecorate,
1302 {1, (uint32_t)spv::Decoration::FPFastMathMode,
1303 (uint32_t)spv::FPFastMathModeMask::AllowReassoc})},
1304 {"OpDecorate %1 FPFastMathMode AllowTransform\n",
1305 MakeInstruction(
1306 spv::Op::OpDecorate,
1307 {1, (uint32_t)spv::Decoration::FPFastMathMode,
1308 (uint32_t)spv::FPFastMathModeMask::AllowTransform})},
1309 })));
1310
1311 // SPV_EXT_replicated_composites
1312
1313 INSTANTIATE_TEST_SUITE_P(
1314 SPV_EXT_replicated_composites, ExtensionRoundTripTest,
1315 Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_6,
1316 SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_2,
1317 SPV_ENV_VULKAN_1_3, SPV_ENV_OPENCL_2_1),
1318 ValuesIn(std::vector<AssemblyCase>{
1319 {"OpExtension \"SPV_EXT_replicated_composites\"\n",
1320 MakeInstruction(spv::Op::OpExtension,
1321 MakeVector("SPV_EXT_replicated_composites"))},
1322 {"OpCapability ReplicatedCompositesEXT\n",
1323 MakeInstruction(
1324 spv::Op::OpCapability,
1325 {(uint32_t)spv::Capability::ReplicatedCompositesEXT})},
1326 {"%2 = OpConstantCompositeReplicateEXT %1 %3\n",
1327 MakeInstruction(spv::Op::OpConstantCompositeReplicateEXT,
1328 {1, 2, 3})},
1329 {"%2 = OpSpecConstantCompositeReplicateEXT %1 %3\n",
1330 MakeInstruction(spv::Op::OpSpecConstantCompositeReplicateEXT,
1331 {1, 2, 3})},
1332 {"%2 = OpCompositeConstructReplicateEXT %1 %3\n",
1333 MakeInstruction(spv::Op::OpCompositeConstructReplicateEXT,
1334 {1, 2, 3})},
1335 })));
1336
1337 // SPV_KHR_untyped_pointers
1338 INSTANTIATE_TEST_SUITE_P(
1339 SPV_KHR_untyped_pointers, ExtensionRoundTripTest,
1340 Combine(
1341 Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_0,
1342 SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_2),
1343 ValuesIn(std::vector<AssemblyCase>{
1344 {"OpExtension \"SPV_KHR_untyped_pointers\"\n",
1345 MakeInstruction(spv::Op::OpExtension,
1346 MakeVector("SPV_KHR_untyped_pointers"))},
1347 {"OpCapability UntypedPointersKHR\n",
1348 MakeInstruction(spv::Op::OpCapability,
1349 {(int)spv::Capability::UntypedPointersKHR})},
1350 {"OpCapability UntypedPointersKHR\n",
1351 MakeInstruction(spv::Op::OpCapability, {4473})},
1352 {"%1 = OpTypeUntypedPointerKHR Workgroup\n",
1353 MakeInstruction(spv::Op::OpTypeUntypedPointerKHR,
1354 {1, int(spv::StorageClass::Workgroup)})},
1355 {"%2 = OpUntypedVariableKHR %1 Workgroup %3\n",
1356 MakeInstruction(spv::Op::OpUntypedVariableKHR,
1357 {1, 2, int(spv::StorageClass::Workgroup), 3})},
1358 {"%2 = OpUntypedVariableKHR %1 Workgroup %3 %4\n",
1359 MakeInstruction(spv::Op::OpUntypedVariableKHR,
1360 {1, 2, int(spv::StorageClass::Workgroup), 3, 4})},
1361 {"%2 = OpUntypedAccessChainKHR %1 %3 %4\n",
1362 MakeInstruction(spv::Op::OpUntypedAccessChainKHR, {1, 2, 3, 4})},
1363 {"%2 = OpUntypedAccessChainKHR %1 %3 %4 %5 %6 %7\n",
1364 MakeInstruction(spv::Op::OpUntypedAccessChainKHR,
1365 {1, 2, 3, 4, 5, 6, 7})},
1366 {"%2 = OpUntypedInBoundsAccessChainKHR %1 %3 %4\n",
1367 MakeInstruction(spv::Op::OpUntypedInBoundsAccessChainKHR,
1368 {1, 2, 3, 4})},
1369 {"%2 = OpUntypedInBoundsAccessChainKHR %1 %3 %4 %5 %6 %7\n",
1370 MakeInstruction(spv::Op::OpUntypedInBoundsAccessChainKHR,
1371 {1, 2, 3, 4, 5, 6, 7})},
1372 {"%2 = OpUntypedPtrAccessChainKHR %1 %3 %4 %5\n",
1373 MakeInstruction(spv::Op::OpUntypedPtrAccessChainKHR,
1374 {1, 2, 3, 4, 5})},
1375 {"%2 = OpUntypedPtrAccessChainKHR %1 %3 %4 %5 %6 %7\n",
1376 MakeInstruction(spv::Op::OpUntypedPtrAccessChainKHR,
1377 {1, 2, 3, 4, 5, 6, 7})},
1378 {"%2 = OpUntypedInBoundsPtrAccessChainKHR %1 %3 %4 %5\n",
1379 MakeInstruction(spv::Op::OpUntypedInBoundsPtrAccessChainKHR,
1380 {1, 2, 3, 4, 5})},
1381 {"%2 = OpUntypedInBoundsPtrAccessChainKHR %1 %3 %4 %5 %6 %7\n",
1382 MakeInstruction(spv::Op::OpUntypedInBoundsPtrAccessChainKHR,
1383 {1, 2, 3, 4, 5, 6, 7})},
1384 })));
1385
1386 // SPV_ARM_tensors
1387 INSTANTIATE_TEST_SUITE_P(
1388 SPV_ARM_tensors, ExtensionRoundTripTest,
1389 Combine(
1390 Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_6, SPV_ENV_VULKAN_1_0,
1391 SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_3,
1392 SPV_ENV_OPENCL_2_1),
1393 ValuesIn(std::vector<AssemblyCase>{
1394 {"OpExtension \"SPV_ARM_tensors\"\n",
1395 MakeInstruction(spv::Op::OpExtension,
1396 MakeVector("SPV_ARM_tensors"))},
1397 {"OpCapability TensorsARM\n",
1398 MakeInstruction(spv::Op::OpCapability,
1399 {(uint32_t)spv::Capability::TensorsARM})},
1400 {"OpCapability StorageTensorArrayDynamicIndexingARM\n",
1401 MakeInstruction(
1402 spv::Op::OpCapability,
1403 {(uint32_t)
1404 spv::Capability::StorageTensorArrayDynamicIndexingARM})},
1405 {"OpCapability StorageTensorArrayNonUniformIndexingARM\n",
1406 MakeInstruction(spv::Op::OpCapability,
1407 {(uint32_t)spv::Capability::
1408 StorageTensorArrayNonUniformIndexingARM})},
1409 {"%1 = OpTypeTensorARM %2\n",
1410 MakeInstruction(spv::Op::OpTypeTensorARM, {1, 2})},
1411 {"%1 = OpTypeTensorARM %2 %3\n",
1412 MakeInstruction(spv::Op::OpTypeTensorARM, {1, 2, 3})},
1413 {"%1 = OpTypeTensorARM %2 %3 %4\n",
1414 MakeInstruction(spv::Op::OpTypeTensorARM, {1, 2, 3, 4})},
1415 {"%2 = OpTensorReadARM %1 %3 %4\n",
1416 MakeInstruction(spv::Op::OpTensorReadARM, {1, 2, 3, 4})},
1417 {"%2 = OpTensorReadARM %1 %3 %4 NoneARM\n",
1418 MakeInstruction(spv::Op::OpTensorReadARM,
1419 {1, 2, 3, 4,
1420 (uint32_t)spv::TensorOperandsMask::MaskNone})},
1421 {"%2 = OpTensorReadARM %1 %3 %4 NontemporalARM\n",
1422 MakeInstruction(
1423 spv::Op::OpTensorReadARM,
1424 {1, 2, 3, 4,
1425 (uint32_t)spv::TensorOperandsMask::NontemporalARM})},
1426 {"%2 = OpTensorReadARM %1 %3 %4 OutOfBoundsValueARM %5\n",
1427 MakeInstruction(
1428 spv::Op::OpTensorReadARM,
1429 {1, 2, 3, 4,
1430 (uint32_t)spv::TensorOperandsMask::OutOfBoundsValueARM, 5})},
1431 {"%2 = OpTensorReadARM %1 %3 %4 MakeElementVisibleARM %5\n",
1432 MakeInstruction(
1433 spv::Op::OpTensorReadARM,
1434 {1, 2, 3, 4,
1435 (uint32_t)spv::TensorOperandsMask::MakeElementVisibleARM,
1436 5})},
1437 {"%2 = OpTensorReadARM %1 %3 %4 NonPrivateElementARM\n",
1438 MakeInstruction(
1439 spv::Op::OpTensorReadARM,
1440 {1, 2, 3, 4,
1441 (uint32_t)spv::TensorOperandsMask::NonPrivateElementARM})},
1442 {"OpTensorWriteARM %1 %2 %3\n",
1443 MakeInstruction(spv::Op::OpTensorWriteARM, {1, 2, 3})},
1444 {"OpTensorWriteARM %1 %2 %3 NoneARM\n",
1445 MakeInstruction(spv::Op::OpTensorWriteARM,
1446 {1, 2, 3,
1447 (uint32_t)spv::TensorOperandsMask::MaskNone})},
1448 {"OpTensorWriteARM %1 %2 %3 NontemporalARM\n",
1449 MakeInstruction(
1450 spv::Op::OpTensorWriteARM,
1451 {1, 2, 3, (uint32_t)spv::TensorOperandsMask::NontemporalARM})},
1452 {"OpTensorWriteARM %1 %2 %3 MakeElementAvailableARM %4\n",
1453 MakeInstruction(
1454 spv::Op::OpTensorWriteARM,
1455 {1, 2, 3,
1456 (uint32_t)spv::TensorOperandsMask::MakeElementAvailableARM,
1457 4})},
1458 {"OpTensorWriteARM %1 %2 %3 NonPrivateElementARM\n",
1459 MakeInstruction(
1460 spv::Op::OpTensorWriteARM,
1461 {1, 2, 3,
1462 (uint32_t)spv::TensorOperandsMask::NonPrivateElementARM})},
1463 {"%2 = OpTensorQuerySizeARM %1 %3 %4\n",
1464 MakeInstruction(spv::Op::OpTensorQuerySizeARM, {1, 2, 3, 4})},
1465 })));
1466
1467 // SPV_EXT_float8
1468 INSTANTIATE_TEST_SUITE_P(
1469 SPV_EXT_float8, ExtensionRoundTripTest,
1470 Combine(
1471 Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_6, SPV_ENV_VULKAN_1_0,
1472 SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_3,
1473 SPV_ENV_OPENCL_2_1),
1474 ValuesIn(std::vector<AssemblyCase>{
1475 {"OpExtension \"SPV_EXT_float8\"\n",
1476 MakeInstruction(spv::Op::OpExtension,
1477 MakeVector("SPV_EXT_float8"))},
1478 {"OpCapability Float8EXT\n",
1479 MakeInstruction(spv::Op::OpCapability,
1480 {(uint32_t)spv::Capability::Float8EXT})},
1481 {"OpCapability Float8CooperativeMatrixEXT\n",
1482 MakeInstruction(
1483 spv::Op::OpCapability,
1484 {(uint32_t)spv::Capability::Float8CooperativeMatrixEXT})},
1485 {"%1 = OpTypeFloat 8 Float8E4M3EXT\n",
1486 MakeInstruction(spv::Op::OpTypeFloat,
1487 {1, 8, (uint32_t)spv::FPEncoding::Float8E4M3EXT})},
1488 {"%1 = OpTypeFloat 8 Float8E5M2EXT\n",
1489 MakeInstruction(spv::Op::OpTypeFloat,
1490 {1, 8, (uint32_t)spv::FPEncoding::Float8E5M2EXT})},
1491 {"OpDecorate %1 SaturatedToLargestFloat8NormalConversionEXT\n",
1492 MakeInstruction(
1493 spv::Op::OpDecorate,
1494 {1,
1495 uint32_t(spv::Decoration::
1496 SaturatedToLargestFloat8NormalConversionEXT)})},
1497 })));
1498
1499 // SPV_INTEL_function_variants
1500 // https://github.com/intel/llvm/blob/sycl/sycl/doc/design/spirv-extensions/SPV_INTEL_function_variants.asciidoc
1501 INSTANTIATE_TEST_SUITE_P(
1502 SPV_INTEL_function_variants, ExtensionRoundTripTest,
1503 Combine(
1504 Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_6),
1505 ValuesIn(std::vector<AssemblyCase>{
1506 {"OpExtension \"SPV_INTEL_function_variants\"\n",
1507 MakeInstruction(spv::Op::OpExtension,
1508 MakeVector("SPV_INTEL_function_variants"))},
1509 {"OpCapability SpecConditionalINTEL\n",
1510 MakeInstruction(
1511 spv::Op::OpCapability,
1512 {(uint32_t)spv::Capability::SpecConditionalINTEL})},
1513 {"OpCapability FunctionVariantsINTEL\n",
1514 MakeInstruction(
1515 spv::Op::OpCapability,
1516 {(uint32_t)spv::Capability::FunctionVariantsINTEL})},
1517 {"OpDecorate %1 ConditionalINTEL %2\n",
1518 MakeInstruction(spv::Op::OpDecorate,
1519 {1, (uint32_t)spv::Decoration::ConditionalINTEL,
1520 2})},
1521
1522 {"OpConditionalExtensionINTEL %1 \"foo\"\n",
1523 MakeInstruction(spv::Op::OpConditionalExtensionINTEL, {1},
1524 MakeVector("foo"))},
1525
1526 {"OpConditionalEntryPointINTEL %1 Kernel %2 \"foo\"\n",
1527 MakeInstruction(spv::Op::OpConditionalEntryPointINTEL,
1528 {1, (uint32_t)spv::ExecutionModel::Kernel, 2},
1529 MakeVector("foo"))},
1530
1531 {"OpConditionalCapabilityINTEL %1 Kernel\n",
1532 MakeInstruction(spv::Op::OpConditionalCapabilityINTEL,
1533 {1, (uint32_t)spv::ExecutionModel::Kernel})},
1534
1535 {"%2 = OpSpecConstantTargetINTEL %1 42\n",
1536 MakeInstruction(spv::Op::OpSpecConstantTargetINTEL, {1, 2, 42})},
1537
1538 {"%2 = OpSpecConstantTargetINTEL %1 42 99\n",
1539 MakeInstruction(spv::Op::OpSpecConstantTargetINTEL,
1540 {1, 2, 42, 99})},
1541
1542 {"%2 = OpSpecConstantTargetINTEL %1 42 99 108\n",
1543 MakeInstruction(spv::Op::OpSpecConstantTargetINTEL,
1544 {1, 2, 42, 99, 108})},
1545
1546 {"%2 = OpSpecConstantArchitectureINTEL %1 42 99 108 72\n",
1547 MakeInstruction(spv::Op::OpSpecConstantArchitectureINTEL,
1548 {1, 2, 42, 99, 108, 72})},
1549
1550 {"%2 = OpSpecConstantCapabilitiesINTEL %1\n",
1551 MakeInstruction(spv::Op::OpSpecConstantCapabilitiesINTEL, {1, 2})},
1552
1553 {"%2 = OpSpecConstantCapabilitiesINTEL %1 Kernel\n",
1554 MakeInstruction(spv::Op::OpSpecConstantCapabilitiesINTEL,
1555 {1, 2, (uint32_t)spv::Capability::Kernel})},
1556
1557 {"%2 = OpSpecConstantCapabilitiesINTEL %1 Kernel Shader\n",
1558 MakeInstruction(spv::Op::OpSpecConstantCapabilitiesINTEL,
1559 {1, 2, (uint32_t)spv::Capability::Kernel,
1560 (uint32_t)spv::Capability::Shader})},
1561
1562 {"%2 = OpConditionalCopyObjectINTEL %1 %3 %4\n",
1563 MakeInstruction(spv::Op::OpConditionalCopyObjectINTEL,
1564 {1, 2, 3, 4})},
1565
1566 {"%2 = OpConditionalCopyObjectINTEL %1 %3 %4 %5 %6\n",
1567 MakeInstruction(spv::Op::OpConditionalCopyObjectINTEL,
1568 {1, 2, 3, 4, 5, 6})},
1569
1570 })));
1571
1572 // SPV_ARM_graph
1573 INSTANTIATE_TEST_SUITE_P(
1574 SPV_ARM_graph, ExtensionRoundTripTest,
1575 Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_6,
1576 SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_2,
1577 SPV_ENV_VULKAN_1_3, SPV_ENV_OPENCL_2_1),
1578 ValuesIn(std::vector<AssemblyCase>{
1579 {"OpExtension \"SPV_ARM_graph\"\n",
1580 MakeInstruction(spv::Op::OpExtension,
1581 MakeVector("SPV_ARM_graph"))},
1582 {"OpCapability GraphARM\n",
1583 MakeInstruction(spv::Op::OpCapability,
1584 {(uint32_t)spv::Capability::GraphARM})},
1585 {"%1 = OpTypeGraphARM 1 %2 %3\n",
1586 MakeInstruction(spv::Op::OpTypeGraphARM, {1, 1, 2, 3})},
1587 {"%2 = OpGraphConstantARM %1 42\n",
1588 MakeInstruction(spv::Op::OpGraphConstantARM, {1, 2, 42})},
1589 {"%2 = OpGraphARM %1\n",
1590 MakeInstruction(spv::Op::OpGraphARM, {1, 2})},
1591 {"OpGraphEndARM\n",
1592 MakeInstruction(spv::Op::OpGraphEndARM, {})},
1593 {"%2 = OpGraphInputARM %1 %3\n",
1594 MakeInstruction(spv::Op::OpGraphInputARM, {1, 2, 3})},
1595 {"%2 = OpGraphInputARM %1 %3 %4\n",
1596 MakeInstruction(spv::Op::OpGraphInputARM, {1, 2, 3, 4})},
1597 {"OpGraphSetOutputARM %1 %2\n",
1598 MakeInstruction(spv::Op::OpGraphSetOutputARM, {1, 2})},
1599 {"OpGraphSetOutputARM %1 %2 %3\n",
1600 MakeInstruction(spv::Op::OpGraphSetOutputARM, {1, 2, 3})},
1601 })));
1602
1603 } // namespace
1604 } // namespace spvtools