From 7d768812e20296c877a44ce0633d71f952fbf83c Mon Sep 17 00:00:00 2001 From: alan-baker Date: Wed, 15 Dec 2021 14:38:28 -0500 Subject: [PATCH] Basic support for SPIR-V 1.6 (#4663) * Basic support for SPIR-V 1.6 * Update SPIRV-Headers deps * Add new environment enum for SPIR-V 1.6 * Make default environment 1.6 for most tools * Update tests * Disallow conditional branch with duplicate labels * Disallow Dim=Buffer with sampled images * Do not require the non-semantic extension after SPIR-V 1.5 --- DEPS | 2 +- include/spirv-tools/libspirv.h | 2 + source/ext_inst.cpp | 1 + source/spirv_target_env.cpp | 18 ++- source/table.cpp | 1 + source/val/validate_cfg.cpp | 7 + source/val/validate_extensions.cpp | 3 +- source/val/validate_image.cpp | 13 ++ source/val/validation_state.cpp | 14 +- test/binary_header_get_test.cpp | 4 +- test/target_env_test.cpp | 8 +- test/text_to_binary.extension_test.cpp | 37 ++--- test/tools/expect.py | 15 ++ test/tools/opt/flags.py | 10 +- test/val/val_cfg_test.cpp | 45 ++++++ test/val/val_ext_inst_test.cpp | 12 ++ ...extension_spv_khr_terminate_invocation.cpp | 29 +++- test/val/val_image_test.cpp | 18 +++ test/val/val_non_semantic_test.cpp | 22 ++- test/val/val_version_test.cpp | 136 +++++++++++++++++- tools/as/as.cpp | 2 +- tools/cfg/cfg.cpp | 2 +- tools/link/linker.cpp | 2 +- tools/lint/lint.cpp | 2 +- tools/opt/opt.cpp | 2 +- tools/reduce/reduce.cpp | 2 +- tools/val/val.cpp | 8 +- 27 files changed, 362 insertions(+), 55 deletions(-) diff --git a/DEPS b/DEPS index 2aaf11f9..88cb4cad 100644 --- a/DEPS +++ b/DEPS @@ -6,7 +6,7 @@ vars = { 'effcee_revision': 'ddf5e2bb92957dc8a12c5392f8495333d6844133', 'googletest_revision': 'bf0701daa9f5b30e5882e2f8f9a5280bcba87e77', 're2_revision': '4244cd1cb492fa1d10986ec67f862964c073f844', - 'spirv_headers_revision': '814e728b30ddd0f4509233099a3ad96fd4318c07', + 'spirv_headers_revision': 'eddd4dfc930f1374a70797460240a501c7d333f7', } deps = { diff --git a/include/spirv-tools/libspirv.h b/include/spirv-tools/libspirv.h index 8df14f5f..9d7de17e 100644 --- a/include/spirv-tools/libspirv.h +++ b/include/spirv-tools/libspirv.h @@ -516,6 +516,8 @@ typedef enum { SPV_ENV_UNIVERSAL_1_5, // SPIR-V 1.5 latest revision, no other restrictions. SPV_ENV_VULKAN_1_2, // Vulkan 1.2 latest revision. + + SPV_ENV_UNIVERSAL_1_6, // SPIR-V 1.6 latest revision, no other restrictions. SPV_ENV_MAX // Keep this as the last enum value. } spv_target_env; diff --git a/source/ext_inst.cpp b/source/ext_inst.cpp index 812053ec..37b423ee 100644 --- a/source/ext_inst.cpp +++ b/source/ext_inst.cpp @@ -96,6 +96,7 @@ spv_result_t spvExtInstTableGet(spv_ext_inst_table* pExtInstTable, case SPV_ENV_UNIVERSAL_1_4: case SPV_ENV_UNIVERSAL_1_5: case SPV_ENV_VULKAN_1_2: + case SPV_ENV_UNIVERSAL_1_6: *pExtInstTable = &kTable_1_0; return SPV_SUCCESS; default: diff --git a/source/spirv_target_env.cpp b/source/spirv_target_env.cpp index 187ab61e..43d1c3dd 100644 --- a/source/spirv_target_env.cpp +++ b/source/spirv_target_env.cpp @@ -72,6 +72,8 @@ const char* spvTargetEnvDescription(spv_target_env env) { return "SPIR-V 1.5"; case SPV_ENV_VULKAN_1_2: return "SPIR-V 1.5 (under Vulkan 1.2 semantics)"; + case SPV_ENV_UNIVERSAL_1_6: + return "SPIR-V 1.6"; case SPV_ENV_MAX: assert(false && "Invalid target environment value."); break; @@ -113,6 +115,8 @@ uint32_t spvVersionForTargetEnv(spv_target_env env) { case SPV_ENV_UNIVERSAL_1_5: case SPV_ENV_VULKAN_1_2: return SPV_SPIRV_VERSION_WORD(1, 5); + case SPV_ENV_UNIVERSAL_1_6: + return SPV_SPIRV_VERSION_WORD(1, 6); case SPV_ENV_MAX: assert(false && "Invalid target environment value."); break; @@ -131,6 +135,7 @@ static const std::pair spvTargetEnvNameMap[] = { {"spv1.3", SPV_ENV_UNIVERSAL_1_3}, {"spv1.4", SPV_ENV_UNIVERSAL_1_4}, {"spv1.5", SPV_ENV_UNIVERSAL_1_5}, + {"spv1.6", SPV_ENV_UNIVERSAL_1_6}, {"opencl1.2embedded", SPV_ENV_OPENCL_EMBEDDED_1_2}, {"opencl1.2", SPV_ENV_OPENCL_1_2}, {"opencl2.0embedded", SPV_ENV_OPENCL_EMBEDDED_2_0}, @@ -211,6 +216,7 @@ bool spvIsVulkanEnv(spv_target_env env) { case SPV_ENV_UNIVERSAL_1_3: case SPV_ENV_UNIVERSAL_1_4: case SPV_ENV_UNIVERSAL_1_5: + case SPV_ENV_UNIVERSAL_1_6: return false; case SPV_ENV_VULKAN_1_0: case SPV_ENV_VULKAN_1_1: @@ -244,6 +250,7 @@ bool spvIsOpenCLEnv(spv_target_env env) { case SPV_ENV_VULKAN_1_1_SPIRV_1_4: case SPV_ENV_UNIVERSAL_1_5: case SPV_ENV_VULKAN_1_2: + case SPV_ENV_UNIVERSAL_1_6: return false; case SPV_ENV_OPENCL_1_2: case SPV_ENV_OPENCL_EMBEDDED_1_2: @@ -284,6 +291,7 @@ bool spvIsOpenGLEnv(spv_target_env env) { case SPV_ENV_VULKAN_1_1_SPIRV_1_4: case SPV_ENV_UNIVERSAL_1_5: case SPV_ENV_VULKAN_1_2: + case SPV_ENV_UNIVERSAL_1_6: return false; case SPV_ENV_OPENGL_4_0: case SPV_ENV_OPENGL_4_1: @@ -321,6 +329,7 @@ bool spvIsValidEnv(spv_target_env env) { case SPV_ENV_VULKAN_1_1_SPIRV_1_4: case SPV_ENV_UNIVERSAL_1_5: case SPV_ENV_VULKAN_1_2: + case SPV_ENV_UNIVERSAL_1_6: case SPV_ENV_OPENGL_4_0: case SPV_ENV_OPENGL_4_1: case SPV_ENV_OPENGL_4_2: @@ -355,16 +364,17 @@ std::string spvLogStringForEnv(spv_target_env env) { } case SPV_ENV_VULKAN_1_0: case SPV_ENV_VULKAN_1_1: - case SPV_ENV_VULKAN_1_1_SPIRV_1_4: { - case SPV_ENV_VULKAN_1_2: - return "Vulkan"; + case SPV_ENV_VULKAN_1_1_SPIRV_1_4: + case SPV_ENV_VULKAN_1_2: { + return "Vulkan"; } case SPV_ENV_UNIVERSAL_1_0: case SPV_ENV_UNIVERSAL_1_1: case SPV_ENV_UNIVERSAL_1_2: case SPV_ENV_UNIVERSAL_1_3: case SPV_ENV_UNIVERSAL_1_4: - case SPV_ENV_UNIVERSAL_1_5: { + case SPV_ENV_UNIVERSAL_1_5: + case SPV_ENV_UNIVERSAL_1_6: { return "Universal"; } case SPV_ENV_WEBGPU_0: diff --git a/source/table.cpp b/source/table.cpp index d4a2d7e9..a87bbf28 100644 --- a/source/table.cpp +++ b/source/table.cpp @@ -41,6 +41,7 @@ spv_context spvContextCreate(spv_target_env env) { case SPV_ENV_UNIVERSAL_1_4: case SPV_ENV_UNIVERSAL_1_5: case SPV_ENV_VULKAN_1_2: + case SPV_ENV_UNIVERSAL_1_6: break; default: return nullptr; diff --git a/source/val/validate_cfg.cpp b/source/val/validate_cfg.cpp index 7842e56d..26b2e94a 100644 --- a/source/val/validate_cfg.cpp +++ b/source/val/validate_cfg.cpp @@ -27,6 +27,7 @@ #include "source/cfa.h" #include "source/opcode.h" +#include "source/spirv_constant.h" #include "source/spirv_target_env.h" #include "source/spirv_validator_options.h" #include "source/val/basic_block.h" @@ -191,6 +192,12 @@ spv_result_t ValidateBranchConditional(ValidationState_t& _, "ID of an OpLabel instruction"; } + if (_.version() >= SPV_SPIRV_VERSION_WORD(1, 6) && true_id == false_id) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "In SPIR-V 1.6 or later, True Label and False Label must be " + "different labels"; + } + return SPV_SUCCESS; } diff --git a/source/val/validate_extensions.cpp b/source/val/validate_extensions.cpp index 479e9e41..b9f8e3c5 100644 --- a/source/val/validate_extensions.cpp +++ b/source/val/validate_extensions.cpp @@ -739,7 +739,8 @@ spv_result_t ValidateExtension(ValidationState_t& _, const Instruction* inst) { spv_result_t ValidateExtInstImport(ValidationState_t& _, const Instruction* inst) { const auto name_id = 1; - if (!_.HasExtension(kSPV_KHR_non_semantic_info)) { + if (_.version() <= SPV_SPIRV_VERSION_WORD(1, 5) && + !_.HasExtension(kSPV_KHR_non_semantic_info)) { const std::string name = inst->GetOperandAs(name_id); if (name.find("NonSemantic.") == 0) { return _.diag(SPV_ERROR_INVALID_DATA, inst) diff --git a/source/val/validate_image.cpp b/source/val/validate_image.cpp index 59000a2d..037fab69 100644 --- a/source/val/validate_image.cpp +++ b/source/val/validate_image.cpp @@ -20,6 +20,7 @@ #include "source/diagnostic.h" #include "source/opcode.h" +#include "source/spirv_constant.h" #include "source/spirv_target_env.h" #include "source/util/bitutils.h" #include "source/val/instruction.h" @@ -71,6 +72,7 @@ bool CheckAllImageOperandsHandled() { // blocks other PRs. // https://github.com/KhronosGroup/SPIRV-Tools/issues/4565 case SpvImageOperandsOffsetsMask: + case SpvImageOperandsNontemporalMask: return true; } return false; @@ -630,6 +632,10 @@ spv_result_t ValidateImageOperands(ValidationState_t& _, // TODO: add validation } + if (mask & SpvImageOperandsNontemporalMask) { + // Checked elsewhere: SPIR-V 1.6 version or later. + } + return SPV_SUCCESS; } @@ -915,6 +921,13 @@ spv_result_t ValidateTypeSampledImage(ValidationState_t& _, "operand set to 0 or 1"; } + // This covers both OpTypeSampledImage and OpSampledImage. + if (_.version() >= SPV_SPIRV_VERSION_WORD(1, 6) && info.dim == SpvDimBuffer) { + return _.diag(SPV_ERROR_INVALID_ID, inst) + << "In SPIR-V 1.6 or later, sampled image dimension must not be " + "Buffer"; + } + return SPV_SUCCESS; } diff --git a/source/val/validation_state.cpp b/source/val/validation_state.cpp index 9d708be4..f127654e 100644 --- a/source/val/validation_state.cpp +++ b/source/val/validation_state.cpp @@ -175,8 +175,18 @@ ValidationState_t::ValidationState_t(const spv_const_context ctx, } } - // LocalSizeId is always allowed in non-Vulkan environments. - features_.env_allow_localsizeid = !spvIsVulkanEnv(env); + // LocalSizeId is only disallowed without maintainence4. + switch (env) { + case SPV_ENV_VULKAN_1_0: + case SPV_ENV_VULKAN_1_1: + case SPV_ENV_VULKAN_1_1_SPIRV_1_4: + case SPV_ENV_VULKAN_1_2: + features_.env_allow_localsizeid = false; + break; + default: + features_.env_allow_localsizeid = true; + break; + } // Only attempt to count if we have words, otherwise let the other validation // fail and generate an error. diff --git a/test/binary_header_get_test.cpp b/test/binary_header_get_test.cpp index 3ce0b63a..f94f0c1a 100644 --- a/test/binary_header_get_test.cpp +++ b/test/binary_header_get_test.cpp @@ -51,8 +51,8 @@ TEST_F(BinaryHeaderGet, Default) { ASSERT_EQ(SPV_SUCCESS, spvBinaryHeaderGet(&const_bin, endian, &header)); ASSERT_EQ(static_cast(SpvMagicNumber), header.magic); - // Expect SPIRV-Headers updated to SPIR-V 1.5. - ASSERT_EQ(0x00010500u, header.version); + // Expect SPIRV-Headers updated to SPIR-V 1.6. + ASSERT_EQ(0x00010600u, header.version); ASSERT_EQ(static_cast(SPV_GENERATOR_CODEPLAY), header.generator); ASSERT_EQ(1u, header.bound); ASSERT_EQ(0u, header.schema); diff --git a/test/target_env_test.cpp b/test/target_env_test.cpp index 4acb8ff2..c5646b8f 100644 --- a/test/target_env_test.cpp +++ b/test/target_env_test.cpp @@ -135,7 +135,7 @@ INSTANTIATE_TEST_SUITE_P( {VK(1, 0), SPV(1, 3), true, SPV_ENV_VULKAN_1_1}, {VK(1, 0), SPV(1, 4), true, SPV_ENV_VULKAN_1_1_SPIRV_1_4}, {VK(1, 0), SPV(1, 5), true, SPV_ENV_VULKAN_1_2}, - {VK(1, 0), SPV(1, 6), false, SPV_ENV_UNIVERSAL_1_0}, + {VK(1, 0), SPV(1, 7), false, SPV_ENV_UNIVERSAL_1_0}, // Vulkan 1.1 cases {VK(1, 1), SPV(1, 0), true, SPV_ENV_VULKAN_1_1}, {VK(1, 1), SPV(1, 1), true, SPV_ENV_VULKAN_1_1}, @@ -143,7 +143,7 @@ INSTANTIATE_TEST_SUITE_P( {VK(1, 1), SPV(1, 3), true, SPV_ENV_VULKAN_1_1}, {VK(1, 1), SPV(1, 4), true, SPV_ENV_VULKAN_1_1_SPIRV_1_4}, {VK(1, 1), SPV(1, 5), true, SPV_ENV_VULKAN_1_2}, - {VK(1, 1), SPV(1, 6), false, SPV_ENV_UNIVERSAL_1_0}, + {VK(1, 1), SPV(1, 7), false, SPV_ENV_UNIVERSAL_1_0}, // Vulkan 1.2 cases {VK(1, 2), SPV(1, 0), true, SPV_ENV_VULKAN_1_2}, {VK(1, 2), SPV(1, 1), true, SPV_ENV_VULKAN_1_2}, @@ -151,9 +151,7 @@ INSTANTIATE_TEST_SUITE_P( {VK(1, 2), SPV(1, 3), true, SPV_ENV_VULKAN_1_2}, {VK(1, 2), SPV(1, 4), true, SPV_ENV_VULKAN_1_2}, {VK(1, 2), SPV(1, 5), true, SPV_ENV_VULKAN_1_2}, - {VK(1, 2), SPV(1, 6), false, SPV_ENV_UNIVERSAL_1_0}, - // Vulkan 1.3 cases - {VK(1, 3), SPV(1, 0), false, SPV_ENV_UNIVERSAL_1_0}, + {VK(1, 2), SPV(1, 7), false, SPV_ENV_UNIVERSAL_1_0}, // Vulkan 2.0 cases {VK(2, 0), SPV(1, 0), false, SPV_ENV_UNIVERSAL_1_0}, // Vulkan 99.0 cases diff --git a/test/text_to_binary.extension_test.cpp b/test/text_to_binary.extension_test.cpp index 1324206c..1f3ff243 100644 --- a/test/text_to_binary.extension_test.cpp +++ b/test/text_to_binary.extension_test.cpp @@ -957,61 +957,62 @@ INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P( SPV_KHR_integer_dot_product, ExtensionRoundTripTest, Combine( - Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_5, SPV_ENV_VULKAN_1_0, - SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_2), + Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_5, + SPV_ENV_UNIVERSAL_1_6, SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1, + SPV_ENV_VULKAN_1_2), ValuesIn(std::vector{ {"OpExtension \"SPV_KHR_integer_dot_product\"\n", MakeInstruction(SpvOpExtension, MakeVector("SPV_KHR_integer_dot_product"))}, - {"OpCapability DotProductInputAllKHR\n", + {"OpCapability DotProductInputAll\n", MakeInstruction(SpvOpCapability, {SpvCapabilityDotProductInputAllKHR})}, - {"OpCapability DotProductInput4x8BitKHR\n", + {"OpCapability DotProductInput4x8Bit\n", MakeInstruction(SpvOpCapability, {SpvCapabilityDotProductInput4x8BitKHR})}, - {"OpCapability DotProductInput4x8BitPackedKHR\n", + {"OpCapability DotProductInput4x8BitPacked\n", MakeInstruction(SpvOpCapability, {SpvCapabilityDotProductInput4x8BitPackedKHR})}, - {"OpCapability DotProductKHR\n", + {"OpCapability DotProduct\n", MakeInstruction(SpvOpCapability, {SpvCapabilityDotProductKHR})}, - {"%2 = OpSDotKHR %1 %3 %4\n", + {"%2 = OpSDot %1 %3 %4\n", MakeInstruction(SpvOpSDotKHR, {1, 2, 3, 4})}, - {"%2 = OpSDotKHR %1 %3 %4 PackedVectorFormat4x8BitKHR\n", + {"%2 = OpSDot %1 %3 %4 PackedVectorFormat4x8Bit\n", MakeInstruction( SpvOpSDotKHR, {1, 2, 3, 4, SpvPackedVectorFormatPackedVectorFormat4x8BitKHR})}, - {"%2 = OpUDotKHR %1 %3 %4\n", + {"%2 = OpUDot %1 %3 %4\n", MakeInstruction(SpvOpUDotKHR, {1, 2, 3, 4})}, - {"%2 = OpUDotKHR %1 %3 %4 PackedVectorFormat4x8BitKHR\n", + {"%2 = OpUDot %1 %3 %4 PackedVectorFormat4x8Bit\n", MakeInstruction( SpvOpUDotKHR, {1, 2, 3, 4, SpvPackedVectorFormatPackedVectorFormat4x8BitKHR})}, - {"%2 = OpSUDotKHR %1 %3 %4\n", + {"%2 = OpSUDot %1 %3 %4\n", MakeInstruction(SpvOpSUDotKHR, {1, 2, 3, 4})}, - {"%2 = OpSUDotKHR %1 %3 %4 PackedVectorFormat4x8BitKHR\n", + {"%2 = OpSUDot %1 %3 %4 PackedVectorFormat4x8Bit\n", MakeInstruction( SpvOpSUDotKHR, {1, 2, 3, 4, SpvPackedVectorFormatPackedVectorFormat4x8BitKHR})}, - {"%2 = OpSDotAccSatKHR %1 %3 %4 %5\n", + {"%2 = OpSDotAccSat %1 %3 %4 %5\n", MakeInstruction(SpvOpSDotAccSatKHR, {1, 2, 3, 4, 5})}, - {"%2 = OpSDotAccSatKHR %1 %3 %4 %5 PackedVectorFormat4x8BitKHR\n", + {"%2 = OpSDotAccSat %1 %3 %4 %5 PackedVectorFormat4x8Bit\n", MakeInstruction( SpvOpSDotAccSatKHR, {1, 2, 3, 4, 5, SpvPackedVectorFormatPackedVectorFormat4x8BitKHR})}, - {"%2 = OpUDotAccSatKHR %1 %3 %4 %5\n", + {"%2 = OpUDotAccSat %1 %3 %4 %5\n", MakeInstruction(SpvOpUDotAccSatKHR, {1, 2, 3, 4, 5})}, - {"%2 = OpUDotAccSatKHR %1 %3 %4 %5 PackedVectorFormat4x8BitKHR\n", + {"%2 = OpUDotAccSat %1 %3 %4 %5 PackedVectorFormat4x8Bit\n", MakeInstruction( SpvOpUDotAccSatKHR, {1, 2, 3, 4, 5, SpvPackedVectorFormatPackedVectorFormat4x8BitKHR})}, - {"%2 = OpSUDotAccSatKHR %1 %3 %4 %5\n", + {"%2 = OpSUDotAccSat %1 %3 %4 %5\n", MakeInstruction(SpvOpSUDotAccSatKHR, {1, 2, 3, 4, 5})}, - {"%2 = OpSUDotAccSatKHR %1 %3 %4 %5 PackedVectorFormat4x8BitKHR\n", + {"%2 = OpSUDotAccSat %1 %3 %4 %5 PackedVectorFormat4x8Bit\n", MakeInstruction( SpvOpSUDotAccSatKHR, {1, 2, 3, 4, 5, diff --git a/test/tools/expect.py b/test/tools/expect.py index 0b51adc9..7351c029 100755 --- a/test/tools/expect.py +++ b/test/tools/expect.py @@ -285,6 +285,21 @@ class ValidObjectFile1_5(ReturnCodeIsZero, CorrectObjectFilePreamble): return True, '' +class ValidObjectFile1_6(ReturnCodeIsZero, CorrectObjectFilePreamble): + """Mixin class for checking that every input file generates a valid SPIR-V 1.6 + object file following the object file naming rule, and there is no output on + stdout/stderr.""" + + def check_object_file_preamble(self, status): + for input_filename in status.input_filenames: + object_filename = get_object_filename(input_filename) + success, message = self.verify_object_file_preamble( + os.path.join(status.directory, object_filename), 0x10600) + if not success: + return False, message + return True, '' + + class ValidObjectFileWithAssemblySubstr(SuccessfulReturn, CorrectObjectFilePreamble): """Mixin class for checking that every input file generates a valid object diff --git a/test/tools/opt/flags.py b/test/tools/opt/flags.py index 1486760d..52a43c51 100644 --- a/test/tools/opt/flags.py +++ b/test/tools/opt/flags.py @@ -34,7 +34,7 @@ def empty_main_assembly(): @inside_spirv_testsuite('SpirvOptBase') -class TestAssemblyFileAsOnlyParameter(expect.ValidObjectFile1_5): +class TestAssemblyFileAsOnlyParameter(expect.ValidObjectFile1_6): """Tests that spirv-opt accepts a SPIR-V object file.""" shader = placeholder.FileSPIRVShader(empty_main_assembly(), '.spvasm') @@ -52,7 +52,7 @@ class TestHelpFlag(expect.ReturnCodeIsZero, expect.StdoutMatch): @inside_spirv_testsuite('SpirvOptFlags') -class TestValidPassFlags(expect.ValidObjectFile1_5, +class TestValidPassFlags(expect.ValidObjectFile1_6, expect.ExecutedListOfPasses): """Tests that spirv-opt accepts all valid optimization flags.""" @@ -132,7 +132,7 @@ class TestValidPassFlags(expect.ValidObjectFile1_5, @inside_spirv_testsuite('SpirvOptFlags') -class TestPerformanceOptimizationPasses(expect.ValidObjectFile1_5, +class TestPerformanceOptimizationPasses(expect.ValidObjectFile1_6, expect.ExecutedListOfPasses): """Tests that spirv-opt schedules all the passes triggered by -O.""" @@ -190,7 +190,7 @@ class TestPerformanceOptimizationPasses(expect.ValidObjectFile1_5, @inside_spirv_testsuite('SpirvOptFlags') -class TestSizeOptimizationPasses(expect.ValidObjectFile1_5, +class TestSizeOptimizationPasses(expect.ValidObjectFile1_6, expect.ExecutedListOfPasses): """Tests that spirv-opt schedules all the passes triggered by -Os.""" @@ -237,7 +237,7 @@ class TestSizeOptimizationPasses(expect.ValidObjectFile1_5, @inside_spirv_testsuite('SpirvOptFlags') -class TestLegalizationPasses(expect.ValidObjectFile1_5, +class TestLegalizationPasses(expect.ValidObjectFile1_6, expect.ExecutedListOfPasses): """Tests that spirv-opt schedules all the passes triggered by --legalize-hlsl. """ diff --git a/test/val/val_cfg_test.cpp b/test/val/val_cfg_test.cpp index 311cfa77..634a842e 100644 --- a/test/val/val_cfg_test.cpp +++ b/test/val/val_cfg_test.cpp @@ -4579,6 +4579,51 @@ OpFunctionEnd EXPECT_EQ(SPV_ERROR_INVALID_CFG, ValidateInstructions()); } +TEST_F(ValidateCFG, BranchConditionalDifferentTargetsPre1p6) { + const std::string text = R"( +OpCapability Shader +OpCapability Linkage +OpMemoryModel Logical GLSL450 +%void = OpTypeVoid +%bool = OpTypeBool +%undef = OpUndef %bool +%void_fn = OpTypeFunction %void +%func = OpFunction %void None %void_fn +%entry = OpLabel +OpBranchConditional %undef %target %target +%target = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_5); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_5)); +} + +TEST_F(ValidateCFG, BranchConditionalDifferentTargetsPost1p6) { + const std::string text = R"( +OpCapability Shader +OpCapability Linkage +OpMemoryModel Logical GLSL450 +%void = OpTypeVoid +%bool = OpTypeBool +%undef = OpUndef %bool +%void_fn = OpTypeFunction %void +%func = OpFunction %void None %void_fn +%entry = OpLabel +OpBranchConditional %undef %target %target +%target = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_6); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_6)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("In SPIR-V 1.6 or later, True Label and False Label " + "must be different labels")); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/test/val/val_ext_inst_test.cpp b/test/val/val_ext_inst_test.cpp index 2b6df04d..a2109db0 100644 --- a/test/val/val_ext_inst_test.cpp +++ b/test/val/val_ext_inst_test.cpp @@ -6045,6 +6045,18 @@ OpMemoryModel Logical GLSL450 "declared without SPV_KHR_non_semantic_info")); } +TEST_F(ValidateClspvReflection, DoesNotRequiresNonSemanticExtensionPost1p6) { + const std::string text = R"( +OpCapability Shader +OpCapability Linkage +%1 = OpExtInstImport "NonSemantic.ClspvReflection.1" +OpMemoryModel Logical GLSL450 +)"; + + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_6); + ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_6)); +} + TEST_F(ValidateClspvReflection, MissingVersion) { const std::string text = R"( OpCapability Shader diff --git a/test/val/val_extension_spv_khr_terminate_invocation.cpp b/test/val/val_extension_spv_khr_terminate_invocation.cpp index 4cabf9e2..8d924149 100644 --- a/test/val/val_extension_spv_khr_terminate_invocation.cpp +++ b/test/val/val_extension_spv_khr_terminate_invocation.cpp @@ -55,7 +55,7 @@ TEST_F(ValidateSpvKHRTerminateInvocation, Valid) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } -TEST_F(ValidateSpvKHRTerminateInvocation, RequiresExtension) { +TEST_F(ValidateSpvKHRTerminateInvocation, RequiresExtensionPre1p6) { const std::string str = R"( OpCapability Shader OpMemoryModel Logical Simple @@ -72,9 +72,30 @@ TEST_F(ValidateSpvKHRTerminateInvocation, RequiresExtension) { )"; CompileSuccessfully(str.c_str()); EXPECT_NE(SPV_SUCCESS, ValidateInstructions()); - EXPECT_THAT(getDiagnosticString(), - HasSubstr("TerminateInvocation requires one of the following " - "extensions: SPV_KHR_terminate_invocation")); + EXPECT_THAT( + getDiagnosticString(), + HasSubstr( + "TerminateInvocation requires SPIR-V version 1.6 at minimum or one " + "of the following extensions: SPV_KHR_terminate_invocation")); +} + +TEST_F(ValidateSpvKHRTerminateInvocation, RequiresNoExtensionPost1p6) { + const std::string str = R"( + OpCapability Shader + OpMemoryModel Logical Simple + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + + %void = OpTypeVoid + %void_fn = OpTypeFunction %void + + %main = OpFunction %void None %void_fn + %entry = OpLabel + OpTerminateInvocation + OpFunctionEnd +)"; + CompileSuccessfully(str.c_str(), SPV_ENV_UNIVERSAL_1_6); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_6)); } TEST_F(ValidateSpvKHRTerminateInvocation, RequiresShaderCapability) { diff --git a/test/val/val_image_test.cpp b/test/val/val_image_test.cpp index 11b14fb0..cb2f4ef3 100644 --- a/test/val/val_image_test.cpp +++ b/test/val/val_image_test.cpp @@ -6099,6 +6099,24 @@ OpFunctionEnd "execution mode for GLCompute execution model")); } +TEST_F(ValidateImage, TypeSampledImageNotBufferPost1p6) { + const std::string text = R"( +OpCapability Shader +OpCapability Linkage +OpCapability SampledBuffer +OpMemoryModel Logical GLSL450 +%float = OpTypeFloat 32 +%image = OpTypeImage %float Buffer 0 0 0 1 Unknown +%sampled = OpTypeSampledImage %image +)"; + + CompileSuccessfully(text, SPV_ENV_UNIVERSAL_1_6); + EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions(SPV_ENV_UNIVERSAL_1_6)); + EXPECT_THAT(getDiagnosticString(), + HasSubstr("In SPIR-V 1.6 or later, sampled image dimension must " + "not be Buffer")); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/test/val/val_non_semantic_test.cpp b/test/val/val_non_semantic_test.cpp index b80bb1ac..210cd1ac 100644 --- a/test/val/val_non_semantic_test.cpp +++ b/test/val/val_non_semantic_test.cpp @@ -105,7 +105,7 @@ INSTANTIATE_TEST_SUITE_P(OnlyOpExtension, ValidateNonSemanticGenerated, Values(""), Values(TestResult()))); INSTANTIATE_TEST_SUITE_P( - MissingOpExtension, ValidateNonSemanticGenerated, + MissingOpExtensionPre1p6, ValidateNonSemanticGenerated, Combine(Values(false), Values(true), Values(""), Values(""), Values(TestResult( SPV_ERROR_INVALID_DATA, @@ -190,6 +190,26 @@ OpEntryPoint Vertex %main "main" HasSubstr("ID 2[%2] has not been defined")); } +TEST_F(ValidateNonSemanticString, MissingOpExtensionPost1p6) { + const std::string spirv = R"( +OpCapability Shader +%extinst = OpExtInstImport "NonSemantic.Testing.Set" +OpMemoryModel Logical GLSL450 +OpEntryPoint Fragment %main "main" +OpExecutionMode %main OriginUpperLeft +%void = OpTypeVoid +%test = OpExtInst %void %extinst 3 +%void_fn = OpTypeFunction %void +%main = OpFunction %void None %void_fn +%entry = OpLabel +OpReturn +OpFunctionEnd +)"; + + CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_6); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_6)); +} + } // namespace } // namespace val } // namespace spvtools diff --git a/test/val/val_version_test.cpp b/test/val/val_version_test.cpp index 98565ddb..a7cb0bad 100644 --- a/test/val/val_version_test.cpp +++ b/test/val/val_version_test.cpp @@ -74,6 +74,11 @@ std::string version(spv_target_env env) { case SPV_ENV_UNIVERSAL_1_4: case SPV_ENV_VULKAN_1_1_SPIRV_1_4: return "1.4"; + case SPV_ENV_UNIVERSAL_1_5: + case SPV_ENV_VULKAN_1_2: + return "1.5"; + case SPV_ENV_UNIVERSAL_1_6: + return "1.6"; default: return "0"; } @@ -103,8 +108,13 @@ INSTANTIATE_TEST_SUITE_P(Universal, ValidateVersion, std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_5, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_6, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_VULKAN_1_0, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_VULKAN_1_1, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_VULKAN_1_1_SPIRV_1_4,vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_OPENGL_4_0, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_OPENGL_4_1, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_OPENGL_4_2, vulkan_spirv, true), @@ -115,8 +125,13 @@ INSTANTIATE_TEST_SUITE_P(Universal, ValidateVersion, std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_UNIVERSAL_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_UNIVERSAL_1_5, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_UNIVERSAL_1_6, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_VULKAN_1_1, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_1, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), @@ -127,8 +142,13 @@ INSTANTIATE_TEST_SUITE_P(Universal, ValidateVersion, std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_5, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_6, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_VULKAN_1_1, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), @@ -139,13 +159,69 @@ INSTANTIATE_TEST_SUITE_P(Universal, ValidateVersion, std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_UNIVERSAL_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_UNIVERSAL_1_5, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_UNIVERSAL_1_6, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_1, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_OPENGL_4_3, vulkan_spirv, false), - std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_OPENGL_4_5, vulkan_spirv, false) + std::make_tuple(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_OPENGL_4_5, vulkan_spirv, false), + + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_UNIVERSAL_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_UNIVERSAL_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_UNIVERSAL_1_5, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_UNIVERSAL_1_6, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_VULKAN_1_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_OPENGL_4_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_4, SPV_ENV_OPENGL_4_5, vulkan_spirv, false), + + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_UNIVERSAL_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_UNIVERSAL_1_4, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_UNIVERSAL_1_5, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_UNIVERSAL_1_6, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_VULKAN_1_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_OPENGL_4_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_5, SPV_ENV_OPENGL_4_5, vulkan_spirv, false), + + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_UNIVERSAL_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_UNIVERSAL_1_4, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_UNIVERSAL_1_5, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_UNIVERSAL_1_6, vulkan_spirv, true), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_VULKAN_1_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_VULKAN_1_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_OPENGL_4_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_UNIVERSAL_1_6, SPV_ENV_OPENGL_4_5, vulkan_spirv, false) ) ); @@ -156,27 +232,69 @@ INSTANTIATE_TEST_SUITE_P(Vulkan, ValidateVersion, std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_UNIVERSAL_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_UNIVERSAL_1_5, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_UNIVERSAL_1_6, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_0, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_OPENGL_4_0, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_OPENGL_4_1, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_OPENGL_4_2, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_OPENGL_4_3, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_OPENGL_4_5, vulkan_spirv, true), - std::make_tuple(SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_UNIVERSAL_1_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_UNIVERSAL_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_UNIVERSAL_1_5, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_UNIVERSAL_1_6, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_1, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_OPENGL_4_3, vulkan_spirv, false), std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_OPENGL_4_5, vulkan_spirv, false), - std::make_tuple(SPV_ENV_VULKAN_1_1, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, true) + + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_UNIVERSAL_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_UNIVERSAL_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_UNIVERSAL_1_5, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_UNIVERSAL_1_6, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_VULKAN_1_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_OPENGL_4_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_1_SPIRV_1_4, SPV_ENV_OPENGL_4_5, vulkan_spirv, false), + + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_UNIVERSAL_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_UNIVERSAL_1_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_UNIVERSAL_1_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_UNIVERSAL_1_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_UNIVERSAL_1_4, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_UNIVERSAL_1_5, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_UNIVERSAL_1_6, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_1_SPIRV_1_4, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_VULKAN_1_2, vulkan_spirv, true), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_OPENGL_4_0, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_OPENGL_4_1, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_OPENGL_4_2, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_OPENGL_4_3, vulkan_spirv, false), + std::make_tuple(SPV_ENV_VULKAN_1_2, SPV_ENV_OPENGL_4_5, vulkan_spirv, false) ) ); @@ -187,6 +305,9 @@ INSTANTIATE_TEST_SUITE_P(OpenCL, ValidateVersion, std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_UNIVERSAL_1_1, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_UNIVERSAL_1_2, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_UNIVERSAL_1_3, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_UNIVERSAL_1_4, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_UNIVERSAL_1_5, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_UNIVERSAL_1_6, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_OPENCL_2_0, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_OPENCL_2_1, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_2_0, SPV_ENV_OPENCL_2_2, opencl_spirv, true), @@ -199,6 +320,9 @@ INSTANTIATE_TEST_SUITE_P(OpenCL, ValidateVersion, std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_UNIVERSAL_1_1, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_UNIVERSAL_1_2, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_UNIVERSAL_1_3, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_UNIVERSAL_1_4, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_UNIVERSAL_1_5, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_UNIVERSAL_1_6, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_OPENCL_2_0, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_OPENCL_2_1, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_2_1, SPV_ENV_OPENCL_2_2, opencl_spirv, true), @@ -211,6 +335,9 @@ INSTANTIATE_TEST_SUITE_P(OpenCL, ValidateVersion, std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_UNIVERSAL_1_1, opencl_spirv, false), std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_UNIVERSAL_1_2, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_UNIVERSAL_1_3, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_UNIVERSAL_1_4, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_UNIVERSAL_1_5, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_UNIVERSAL_1_6, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_OPENCL_2_0, opencl_spirv, false), std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_OPENCL_2_1, opencl_spirv, false), std::make_tuple(SPV_ENV_OPENCL_2_2, SPV_ENV_OPENCL_2_2, opencl_spirv, true), @@ -223,6 +350,9 @@ INSTANTIATE_TEST_SUITE_P(OpenCL, ValidateVersion, std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_UNIVERSAL_1_1, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_UNIVERSAL_1_2, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_UNIVERSAL_1_3, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_UNIVERSAL_1_4, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_UNIVERSAL_1_5, opencl_spirv, true), + std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_UNIVERSAL_1_6, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_OPENCL_2_0, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_OPENCL_2_1, opencl_spirv, true), std::make_tuple(SPV_ENV_OPENCL_1_2, SPV_ENV_OPENCL_2_2, opencl_spirv, true), diff --git a/tools/as/as.cpp b/tools/as/as.cpp index c8a44456..506b0585 100644 --- a/tools/as/as.cpp +++ b/tools/as/as.cpp @@ -48,7 +48,7 @@ Options: argv0, argv0, target_env_list.c_str()); } -static const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_5; +static const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_6; int main(int argc, char** argv) { const char* inFile = nullptr; diff --git a/tools/cfg/cfg.cpp b/tools/cfg/cfg.cpp index 6a5faa18..5380c21e 100644 --- a/tools/cfg/cfg.cpp +++ b/tools/cfg/cfg.cpp @@ -44,7 +44,7 @@ Options: argv0, argv0); } -static const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_5; +static const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_6; int main(int argc, char** argv) { const char* inFile = nullptr; diff --git a/tools/link/linker.cpp b/tools/link/linker.cpp index 359e8030..5c4223ed 100644 --- a/tools/link/linker.cpp +++ b/tools/link/linker.cpp @@ -25,7 +25,7 @@ namespace { -const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_5; +const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_6; void print_usage(const char* program) { std::string target_env_list = spvTargetEnvList(16, 80); diff --git a/tools/lint/lint.cpp b/tools/lint/lint.cpp index 5c2a82ac..d37df830 100644 --- a/tools/lint/lint.cpp +++ b/tools/lint/lint.cpp @@ -19,7 +19,7 @@ #include "tools/io.h" #include "tools/util/cli_consumer.h" -const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_5; +const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_6; namespace { // Status and actions to perform after parsing command-line arguments. diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index f60d1104..3dff43f6 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -59,7 +59,7 @@ std::string GetListOfPassesAsString(const spvtools::Optimizer& optimizer) { return ss.str(); } -const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_5; +const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_6; std::string GetLegalizationPasses() { spvtools::Optimizer optimizer(kDefaultEnvironment); diff --git a/tools/reduce/reduce.cpp b/tools/reduce/reduce.cpp index 4447b356..37600543 100644 --- a/tools/reduce/reduce.cpp +++ b/tools/reduce/reduce.cpp @@ -262,7 +262,7 @@ void DumpShader(spvtools::opt::IRContext* context, const char* filename) { DumpShader(binary, filename); } -const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_5; +const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_6; int main(int argc, const char** argv) { std::string in_binary_file; diff --git a/tools/val/val.cpp b/tools/val/val.cpp index 55321dab..d03262bb 100644 --- a/tools/val/val.cpp +++ b/tools/val/val.cpp @@ -77,7 +77,7 @@ Options: int main(int argc, char** argv) { const char* inFile = nullptr; - spv_target_env target_env = SPV_ENV_UNIVERSAL_1_5; + spv_target_env target_env = SPV_ENV_UNIVERSAL_1_6; spvtools::ValidatorOptions options; bool continue_processing = true; int return_code = 0; @@ -111,17 +111,19 @@ int main(int argc, char** argv) { printf("%s\n", spvSoftwareVersionDetailsString()); printf( "Targets:\n %s\n %s\n %s\n %s\n %s\n %s\n %s\n %s\n %s\n " - "%s\n", + "%s\n %s\n %s\n", spvTargetEnvDescription(SPV_ENV_UNIVERSAL_1_0), spvTargetEnvDescription(SPV_ENV_UNIVERSAL_1_1), spvTargetEnvDescription(SPV_ENV_UNIVERSAL_1_2), spvTargetEnvDescription(SPV_ENV_UNIVERSAL_1_3), spvTargetEnvDescription(SPV_ENV_UNIVERSAL_1_4), spvTargetEnvDescription(SPV_ENV_UNIVERSAL_1_5), + spvTargetEnvDescription(SPV_ENV_UNIVERSAL_1_6), spvTargetEnvDescription(SPV_ENV_OPENCL_2_2), spvTargetEnvDescription(SPV_ENV_VULKAN_1_0), spvTargetEnvDescription(SPV_ENV_VULKAN_1_1), - spvTargetEnvDescription(SPV_ENV_VULKAN_1_1_SPIRV_1_4)); + spvTargetEnvDescription(SPV_ENV_VULKAN_1_1_SPIRV_1_4), + spvTargetEnvDescription(SPV_ENV_VULKAN_1_2)); continue_processing = false; return_code = 0; } else if (0 == strcmp(cur_arg, "--help") || 0 == strcmp(cur_arg, "-h")) {