text_to_binary.extension_test.cpp 66 KB

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