diff options
author | David Neto <dneto@google.com> | 2017-03-30 21:49:42 +0300 |
---|---|---|
committer | David Neto <dneto@google.com> | 2017-10-05 00:52:39 +0300 |
commit | dc938c27b34dee5492c29c4e92b49bd0c32e604f (patch) | |
tree | 1723181e0578bdbd80240ced97d44ab6e7fcba14 | |
parent | c87e9671abb881cf83fccce2fe062e08d22c354b (diff) |
WIP: Support SPIR-V 1.3, and Vulkan 1.1vulkan-1.1-rc1
Includes support for:
- New subgroup functionality SPIR-V!64
- fix for 16bit storage capabilities dependency SPIR-V#137
- OpenCL.std.h enum fixes SPIR-V!72
- OpenCL.std.h fix missing comma SPIR-V!75
- SPV_KHR_variable_pointers
- SPV_KHR_storage_buffer_storage_class spirv-extensions!73
- Vulkan 1.1 subgroups capability fixes for BuiltIns: SPIR-V#135
33 files changed, 174 insertions, 67 deletions
diff --git a/include/spirv-tools/libspirv.h b/include/spirv-tools/libspirv.h index b7bcc0f50..f497f36aa 100644 --- a/include/spirv-tools/libspirv.h +++ b/include/spirv-tools/libspirv.h @@ -383,6 +383,8 @@ typedef enum { // There is no variant for OpenGL 4.4. SPV_ENV_OPENGL_4_5, // OpenGL 4.5 plus GL_ARB_gl_spirv, latest revisions. SPV_ENV_UNIVERSAL_1_2, // SPIR-V 1.2, latest revision, no other restrictions. + SPV_ENV_UNIVERSAL_1_3, // SPIR-V 1.3, latest revision, no other restrictions. + SPV_ENV_VULKAN_1_1, // Vulkan 1.1 latest revision. } spv_target_env; // SPIR-V Validator can be parameterized with the following Universal Limits. diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index dd5a5a837..f2265cfbc 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -51,7 +51,7 @@ macro(spvtools_enum_string_mapping VERSION) list(APPEND ENUM_STRING_MAPPING_CPP_DEPENDS ${GRAMMAR_ENUM_STRING_MAPPING_INC_FILE}) endmacro(spvtools_enum_string_mapping) -macro(spvtools_vimsyntax VERSION CLVERSION) +macro(spvtools_vimsyntax VERSION) set(GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${VERSION}/spirv.core.grammar.json") set(GLSL_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${VERSION}/extinst.glsl.std.450.grammar.json") set(OPENCL_GRAMMAR_JSON_FILE "${SPIRV_HEADER_INCLUDE_DIR}/spirv/${VERSION}/extinst.opencl.std.100.grammar.json") @@ -112,7 +112,8 @@ endmacro(spvtools_vendor_tables) spvtools_core_tables("1.0") spvtools_core_tables("1.1") spvtools_core_tables("1.2") -spvtools_enum_string_mapping("1.2") +spvtools_core_tables("1.3") +spvtools_enum_string_mapping("1.3") spvtools_opencl_tables("1.0") spvtools_glsl_tables("1.0") spvtools_vendor_tables("spv-amd-shader-explicit-vertex-parameter") @@ -120,7 +121,7 @@ spvtools_vendor_tables("spv-amd-shader-trinary-minmax") spvtools_vendor_tables("spv-amd-gcn-shader") spvtools_vendor_tables("spv-amd-shader-ballot") -spvtools_vimsyntax("1.2" "1.0") +spvtools_vimsyntax("1.3") add_custom_target(spirv-tools-vimsyntax DEPENDS ${VIMSYNTAX_FILE}) set_property(TARGET spirv-tools-vimsyntax PROPERTY FOLDER "SPIRV-Tools utilities") diff --git a/source/assembly_grammar.h b/source/assembly_grammar.h index cd89a1b12..57712eb5d 100644 --- a/source/assembly_grammar.h +++ b/source/assembly_grammar.h @@ -17,7 +17,7 @@ #include "operand.h" #include "spirv-tools/libspirv.h" -#include "spirv/1.2/spirv.h" +#include "spirv/1.3/spirv.h" #include "table.h" namespace libspirv { diff --git a/source/binary.cpp b/source/binary.cpp index 2ade2546b..91556e81a 100644 --- a/source/binary.cpp +++ b/source/binary.cpp @@ -27,7 +27,7 @@ #include "ext_inst.h" #include "opcode.h" #include "operand.h" -#include "spirv/1.2/spirv.h" +#include "spirv/1.3/spirv.h" #include "spirv_constant.h" #include "spirv_endian.h" diff --git a/source/enum_set.h b/source/enum_set.h index 6d3ec73b1..aa7bdacda 100644 --- a/source/enum_set.h +++ b/source/enum_set.h @@ -21,7 +21,7 @@ #include <set> #include <utility> -#include "spirv/1.2/spirv.h" +#include "spirv/1.3/spirv.h" namespace libspirv { diff --git a/source/enum_string_mapping.h b/source/enum_string_mapping.h index 773d40c4c..05bb5dc59 100644 --- a/source/enum_string_mapping.h +++ b/source/enum_string_mapping.h @@ -17,7 +17,7 @@ #include <string> -#include "spirv/1.1/spirv.h" +#include "spirv/1.3/spirv.h" namespace libspirv { diff --git a/source/ext_inst.cpp b/source/ext_inst.cpp index 71f72fc9a..a5fc47452 100644 --- a/source/ext_inst.cpp +++ b/source/ext_inst.cpp @@ -86,6 +86,8 @@ spv_result_t spvExtInstTableGet(spv_ext_inst_table* pExtInstTable, case SPV_ENV_OPENGL_4_2: case SPV_ENV_OPENGL_4_3: case SPV_ENV_OPENGL_4_5: + case SPV_ENV_UNIVERSAL_1_3: + case SPV_ENV_VULKAN_1_1: *pExtInstTable = &table_1_0; return SPV_SUCCESS; default: diff --git a/source/instruction.h b/source/instruction.h index 2afa6d45d..f93d4b719 100644 --- a/source/instruction.h +++ b/source/instruction.h @@ -19,7 +19,7 @@ #include <vector> #include "spirv-tools/libspirv.h" -#include "spirv/1.2/spirv.h" +#include "spirv/1.3/spirv.h" // Describes an instruction. struct spv_instruction_t { diff --git a/source/name_mapper.cpp b/source/name_mapper.cpp index 1accc9439..8120da56a 100644 --- a/source/name_mapper.cpp +++ b/source/name_mapper.cpp @@ -23,7 +23,7 @@ #include <unordered_set> #include "spirv-tools/libspirv.h" -#include "spirv/1.2/spirv.h" +#include "spirv/1.3/spirv.h" #include "parsed_operand.h" diff --git a/source/opcode.cpp b/source/opcode.cpp index 9bb8cb736..7c3966e95 100644 --- a/source/opcode.cpp +++ b/source/opcode.cpp @@ -32,12 +32,12 @@ struct OpcodeDescPtrLen { uint32_t len; }; -OpcodeDescPtrLen getOpcodeTableEntries_1_2() { - static const spv_opcode_desc_t opcodeTableEntries_1_2[] = { -#include "core.insts-1.2.inc" +OpcodeDescPtrLen getOpcodeTableEntries_1_3() { + static const spv_opcode_desc_t opcodeTableEntries_1_3[] = { +#include "core.insts-1.3.inc" }; - return {opcodeTableEntries_1_2, ARRAY_SIZE(opcodeTableEntries_1_2)}; + return {opcodeTableEntries_1_3, ARRAY_SIZE(opcodeTableEntries_1_3)}; } // Represents a vendor tool entry in the SPIR-V XML Regsitry. @@ -90,14 +90,19 @@ spv_result_t spvOpcodeTableGet(spv_opcode_table* pInstTable, static const spv_opcode_desc_t opcodeTableEntries_1_1[] = { #include "core.insts-1.1.inc" }; + static const spv_opcode_desc_t opcodeTableEntries_1_2[] = { +#include "core.insts-1.2.inc" + }; - const auto ptr_len = getOpcodeTableEntries_1_2(); + const auto ptr_len = getOpcodeTableEntries_1_3(); static const spv_opcode_table_t table_1_0 = { ARRAY_SIZE(opcodeTableEntries_1_0), opcodeTableEntries_1_0}; static const spv_opcode_table_t table_1_1 = { ARRAY_SIZE(opcodeTableEntries_1_1), opcodeTableEntries_1_1}; - static const spv_opcode_table_t table_1_2 = {ptr_len.len, ptr_len.ptr}; + static const spv_opcode_table_t table_1_2 = { + ARRAY_SIZE(opcodeTableEntries_1_2), opcodeTableEntries_1_2}; + static const spv_opcode_table_t table_1_3 = {ptr_len.len, ptr_len.ptr}; switch (env) { case SPV_ENV_UNIVERSAL_1_0: @@ -116,6 +121,9 @@ spv_result_t spvOpcodeTableGet(spv_opcode_table* pInstTable, case SPV_ENV_UNIVERSAL_1_2: case SPV_ENV_OPENCL_2_2: *pInstTable = &table_1_2; + case SPV_ENV_UNIVERSAL_1_3: + case SPV_ENV_VULKAN_1_1: + *pInstTable = &table_1_3; return SPV_SUCCESS; } assert(0 && "Unknown spv_target_env in spvOpcodeTableGet()"); @@ -183,7 +191,7 @@ void spvInstructionCopy(const uint32_t* words, const SpvOp opcode, const char* spvOpcodeString(const SpvOp opcode) { // Use the latest SPIR-V version, which should be backward-compatible with all // previous ones. - const auto entries = getOpcodeTableEntries_1_2(); + const auto entries = getOpcodeTableEntries_1_3(); for (uint32_t i = 0; i < entries.len; ++i) { if (entries.ptr[i].opcode == opcode) return entries.ptr[i].name; diff --git a/source/opcode.h b/source/opcode.h index 4e06efdf2..7c59162d7 100644 --- a/source/opcode.h +++ b/source/opcode.h @@ -17,7 +17,7 @@ #include "instruction.h" #include "spirv-tools/libspirv.h" -#include "spirv/1.2/spirv.h" +#include "spirv/1.3/spirv.h" #include "table.h" // Returns the name of a registered SPIR-V generator as a null-terminated diff --git a/source/operand.cpp b/source/operand.cpp index 3176eb7d0..ba17ba3ea 100644 --- a/source/operand.cpp +++ b/source/operand.cpp @@ -27,6 +27,7 @@ spv_result_t spvOperandTableGet(spv_operand_table* pOperandTable, #include "operand.kinds-1.0.inc" #include "operand.kinds-1.1.inc" #include "operand.kinds-1.2.inc" +#include "operand.kinds-1.3.inc" static const spv_operand_table_t table_1_0 = { ARRAY_SIZE(pygen_variable_OperandInfoTable_1_0), @@ -37,6 +38,9 @@ spv_result_t spvOperandTableGet(spv_operand_table* pOperandTable, static const spv_operand_table_t table_1_2 = { ARRAY_SIZE(pygen_variable_OperandInfoTable_1_2), pygen_variable_OperandInfoTable_1_2}; + static const spv_operand_table_t table_1_3 = { + ARRAY_SIZE(pygen_variable_OperandInfoTable_1_3), + pygen_variable_OperandInfoTable_1_3}; switch (env) { case SPV_ENV_UNIVERSAL_1_0: @@ -55,6 +59,9 @@ spv_result_t spvOperandTableGet(spv_operand_table* pOperandTable, case SPV_ENV_UNIVERSAL_1_2: case SPV_ENV_OPENCL_2_2: *pOperandTable = &table_1_2; + case SPV_ENV_UNIVERSAL_1_3: + case SPV_ENV_VULKAN_1_1: + *pOperandTable = &table_1_3; return SPV_SUCCESS; } assert(0 && "Unknown spv_target_env in spvOperandTableGet()"); diff --git a/source/opt/instruction.h b/source/opt/instruction.h index 89c9da0be..225e1a669 100644 --- a/source/opt/instruction.h +++ b/source/opt/instruction.h @@ -23,7 +23,7 @@ #include "operand.h" #include "spirv-tools/libspirv.h" -#include "spirv/1.2/spirv.h" +#include "spirv/1.3/spirv.h" namespace spvtools { namespace ir { diff --git a/source/opt/reflect.h b/source/opt/reflect.h index 16ea0bd45..5909a2a50 100644 --- a/source/opt/reflect.h +++ b/source/opt/reflect.h @@ -15,7 +15,7 @@ #ifndef LIBSPIRV_OPT_REFLECT_H_ #define LIBSPIRV_OPT_REFLECT_H_ -#include "spirv/1.2/spirv.h" +#include "spirv/1.3/spirv.h" namespace spvtools { namespace ir { diff --git a/source/opt/types.h b/source/opt/types.h index b6b62c536..6942a6836 100644 --- a/source/opt/types.h +++ b/source/opt/types.h @@ -22,7 +22,7 @@ #include <vector> #include "spirv-tools/libspirv.h" -#include "spirv/1.2/spirv.h" +#include "spirv/1.3/spirv.h" namespace spvtools { namespace opt { diff --git a/source/spirv_constant.h b/source/spirv_constant.h index c70ade103..2458110c2 100644 --- a/source/spirv_constant.h +++ b/source/spirv_constant.h @@ -16,7 +16,7 @@ #define LIBSPIRV_SPIRV_CONSTANT_H_ #include "spirv-tools/libspirv.h" -#include "spirv/1.2/spirv.h" +#include "spirv/1.3/spirv.h" // Version number macros. diff --git a/source/spirv_definition.h b/source/spirv_definition.h index b82bda16d..46cd1ccb4 100644 --- a/source/spirv_definition.h +++ b/source/spirv_definition.h @@ -17,7 +17,7 @@ #include <cstdint> -#include "spirv/1.2/spirv.h" +#include "spirv/1.3/spirv.h" #define spvIsInBitfield(value, bitfield) ((value) == ((value)&bitfield)) diff --git a/source/spirv_target_env.cpp b/source/spirv_target_env.cpp index ed47f525e..99fdc3df5 100644 --- a/source/spirv_target_env.cpp +++ b/source/spirv_target_env.cpp @@ -42,6 +42,10 @@ const char* spvTargetEnvDescription(spv_target_env env) { return "SPIR-V 1.0 (under OpenCL 4.5 semantics)"; case SPV_ENV_UNIVERSAL_1_2: return "SPIR-V 1.2"; + case SPV_ENV_UNIVERSAL_1_3: + return "SPIR-V 1.3"; + case SPV_ENV_VULKAN_1_1: + return "SPIR-V 1.3 (under Vulkan 1.1 semantics)"; } assert(0 && "Unhandled SPIR-V target environment"); return ""; @@ -63,6 +67,9 @@ uint32_t spvVersionForTargetEnv(spv_target_env env) { case SPV_ENV_UNIVERSAL_1_2: case SPV_ENV_OPENCL_2_2: return SPV_SPIRV_VERSION_WORD(1, 2); + case SPV_ENV_UNIVERSAL_1_3: + case SPV_ENV_VULKAN_1_1: + return SPV_SPIRV_VERSION_WORD(1, 3); } assert(0 && "Unhandled SPIR-V target environment"); return SPV_SPIRV_VERSION_WORD(0, 0); @@ -75,6 +82,9 @@ bool spvParseTargetEnv(const char* s, spv_target_env* env) { if (match("vulkan1.0")) { if (env) *env = SPV_ENV_VULKAN_1_0; return true; + } else if (match("vulkan1.1")) { + if (env) *env = SPV_ENV_VULKAN_1_1; + return true; } else if (match("spv1.0")) { if (env) *env = SPV_ENV_UNIVERSAL_1_0; return true; @@ -84,6 +94,9 @@ bool spvParseTargetEnv(const char* s, spv_target_env* env) { } else if (match("spv1.2")) { if (env) *env = SPV_ENV_UNIVERSAL_1_2; return true; + } else if (match("spv1.3")) { + if (env) *env = SPV_ENV_UNIVERSAL_1_3; + return true; } else if (match("opencl2.1")) { if (env) *env = SPV_ENV_OPENCL_2_1; return true; diff --git a/source/table.cpp b/source/table.cpp index b8fb809c7..218d9d54b 100644 --- a/source/table.cpp +++ b/source/table.cpp @@ -20,6 +20,7 @@ spv_context spvContextCreate(spv_target_env env) { switch (env) { case SPV_ENV_UNIVERSAL_1_0: case SPV_ENV_VULKAN_1_0: + case SPV_ENV_VULKAN_1_1: case SPV_ENV_UNIVERSAL_1_1: case SPV_ENV_OPENCL_2_1: case SPV_ENV_OPENCL_2_2: @@ -29,6 +30,7 @@ spv_context spvContextCreate(spv_target_env env) { case SPV_ENV_OPENGL_4_3: case SPV_ENV_OPENGL_4_5: case SPV_ENV_UNIVERSAL_1_2: + case SPV_ENV_UNIVERSAL_1_3: break; default: return nullptr; diff --git a/source/table.h b/source/table.h index a7dffaafb..7dc0b0b42 100644 --- a/source/table.h +++ b/source/table.h @@ -15,7 +15,7 @@ #ifndef LIBSPIRV_TABLE_H_ #define LIBSPIRV_TABLE_H_ -#include "spirv/1.2/spirv.h" +#include "spirv/1.3/spirv.h" #include "extensions.h" #include "message.h" diff --git a/source/val/basic_block.h b/source/val/basic_block.h index 81f0f6663..b0419c49d 100644 --- a/source/val/basic_block.h +++ b/source/val/basic_block.h @@ -15,7 +15,7 @@ #ifndef LIBSPIRV_VAL_BASICBLOCK_H_ #define LIBSPIRV_VAL_BASICBLOCK_H_ -#include "spirv/1.2/spirv.h" +#include "spirv/1.3/spirv.h" #include <cstdint> diff --git a/source/val/function.h b/source/val/function.h index 7eb8dcdf2..57c4e65e9 100644 --- a/source/val/function.h +++ b/source/val/function.h @@ -22,7 +22,7 @@ #include <vector> #include "spirv-tools/libspirv.h" -#include "spirv/1.2/spirv.h" +#include "spirv/1.3/spirv.h" #include "val/basic_block.h" #include "val/construct.h" diff --git a/source/val/validation_state.h b/source/val/validation_state.h index ad56703f6..45ab500df 100644 --- a/source/val/validation_state.h +++ b/source/val/validation_state.h @@ -27,7 +27,7 @@ #include "diagnostic.h" #include "enum_set.h" #include "spirv-tools/libspirv.h" -#include "spirv/1.2/spirv.h" +#include "spirv/1.3/spirv.h" #include "spirv_definition.h" #include "val/function.h" #include "val/instruction.h" diff --git a/test/binary_header_get_test.cpp b/test/binary_header_get_test.cpp index 9ccd0a950..d6efe5af0 100644 --- a/test/binary_header_get_test.cpp +++ b/test/binary_header_get_test.cpp @@ -50,7 +50,7 @@ TEST_F(BinaryHeaderGet, Default) { ASSERT_EQ(SPV_SUCCESS, spvBinaryHeaderGet(&const_bin, endian, &header)); ASSERT_EQ(static_cast<uint32_t>(SpvMagicNumber), header.magic); - ASSERT_EQ(0x00010200u, header.version); + ASSERT_EQ(0x00010300u, header.version); ASSERT_EQ(static_cast<uint32_t>(SPV_GENERATOR_CODEPLAY), header.generator); ASSERT_EQ(1u, header.bound); ASSERT_EQ(0u, header.schema); diff --git a/test/binary_to_text_test.cpp b/test/binary_to_text_test.cpp index fcbf8835b..de54799a5 100644 --- a/test/binary_to_text_test.cpp +++ b/test/binary_to_text_test.cpp @@ -240,7 +240,7 @@ INSTANTIATE_TEST_CASE_P( NumericLiterals, RoundTripInstructionsTest, // This test is independent of environment, so just test the one. Combine(::testing::Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1, - SPV_ENV_UNIVERSAL_1_2), + SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_3), ::testing::ValuesIn(std::vector<std::string>{ "%1 = OpTypeInt 12 0\n%2 = OpConstant %1 1867\n", "%1 = OpTypeInt 12 1\n%2 = OpConstant %1 1867\n", @@ -274,7 +274,7 @@ INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P( MemoryAccessMasks, RoundTripInstructionsTest, Combine(::testing::Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1, - SPV_ENV_UNIVERSAL_1_2), + SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_3), ::testing::ValuesIn(std::vector<std::string>{ "OpStore %1 %2\n", // 3 words long. "OpStore %1 %2 None\n", // 4 words long, explicit final 0. @@ -290,7 +290,7 @@ INSTANTIATE_TEST_CASE_P( FPFastMathModeMasks, RoundTripInstructionsTest, Combine( ::testing::Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1, - SPV_ENV_UNIVERSAL_1_2), + SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_3), ::testing::ValuesIn(std::vector<std::string>{ "OpDecorate %1 FPFastMathMode None\n", "OpDecorate %1 FPFastMathMode NotNaN\n", @@ -307,7 +307,7 @@ INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P( LoopControlMasks, RoundTripInstructionsTest, Combine(::testing::Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1, - SPV_ENV_UNIVERSAL_1_2), + SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_3), ::testing::ValuesIn(std::vector<std::string>{ "OpLoopMerge %1 %2 None\n", "OpLoopMerge %1 %2 Unroll\n", "OpLoopMerge %1 %2 DontUnroll\n", @@ -316,7 +316,8 @@ INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(LoopControlMasksV11, RoundTripInstructionsTest, Combine(::testing::Values(SPV_ENV_UNIVERSAL_1_1, - SPV_ENV_UNIVERSAL_1_2), + SPV_ENV_UNIVERSAL_1_2, + SPV_ENV_UNIVERSAL_1_3), ::testing::ValuesIn(std::vector<std::string>{ "OpLoopMerge %1 %2 DependencyInfinite\n", "OpLoopMerge %1 %2 DependencyLength 8\n", @@ -325,7 +326,7 @@ INSTANTIATE_TEST_CASE_P(LoopControlMasksV11, RoundTripInstructionsTest, INSTANTIATE_TEST_CASE_P( SelectionControlMasks, RoundTripInstructionsTest, Combine(::testing::Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1, - SPV_ENV_UNIVERSAL_1_2), + SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_3), ::testing::ValuesIn(std::vector<std::string>{ "OpSelectionMerge %1 None\n", "OpSelectionMerge %1 Flatten\n", "OpSelectionMerge %1 DontFlatten\n", @@ -335,7 +336,7 @@ INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P( FunctionControlMasks, RoundTripInstructionsTest, Combine(::testing::Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1, - SPV_ENV_UNIVERSAL_1_2), + SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_3), ::testing::ValuesIn(std::vector<std::string>{ "%2 = OpFunction %1 None %3\n", "%2 = OpFunction %1 Inline %3\n", @@ -348,7 +349,7 @@ INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P( ImageMasks, RoundTripInstructionsTest, Combine(::testing::Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1, - SPV_ENV_UNIVERSAL_1_2), + SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_3), ::testing::ValuesIn(std::vector<std::string>{ "%2 = OpImageFetch %1 %3 %4\n", "%2 = OpImageFetch %1 %3 %4 None\n", @@ -370,7 +371,7 @@ INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P( NewInstructionsInSPIRV1_2, RoundTripInstructionsTest, - Combine(::testing::Values(SPV_ENV_UNIVERSAL_1_2), + Combine(::testing::Values(SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_3), ::testing::ValuesIn(std::vector<std::string>{ "OpExecutionModeId %1 SubgroupsPerWorkgroupId %2\n", "OpExecutionModeId %1 LocalSizeId %2 %3 %4\n", @@ -379,6 +380,8 @@ INSTANTIATE_TEST_CASE_P( "OpDecorateId %1 MaxByteOffsetId %2\n", })), ); +// TODO(dneto): New instructions and enums in SPIR-V 1.3 + using MaskSorting = TextToBinaryTest; TEST_F(MaskSorting, MasksAreSortedFromLSBToMSB) { diff --git a/test/target_env_test.cpp b/test/target_env_test.cpp index 0c8389dab..76f0985f2 100644 --- a/test/target_env_test.cpp +++ b/test/target_env_test.cpp @@ -41,7 +41,7 @@ TEST_P(TargetEnvTest, ValidDescription) { TEST_P(TargetEnvTest, ValidSpirvVersion) { auto spirv_version = spvVersionForTargetEnv(GetParam()); - ASSERT_THAT(spirv_version, AnyOf(0x10000, 0x10100, 0x10200)); + ASSERT_THAT(spirv_version, AnyOf(0x10000, 0x10100, 0x10200, 0x10300)); } INSTANTIATE_TEST_CASE_P(AllTargetEnvs, TargetEnvTest, @@ -74,7 +74,9 @@ INSTANTIATE_TEST_CASE_P(TargetParsing, TargetParseTest, {"spv1.0", true, SPV_ENV_UNIVERSAL_1_0}, {"spv1.1", true, SPV_ENV_UNIVERSAL_1_1}, {"spv1.2", true, SPV_ENV_UNIVERSAL_1_2}, + {"spv1.3", true, SPV_ENV_UNIVERSAL_1_3}, {"vulkan1.0", true, SPV_ENV_VULKAN_1_0}, + {"vulkan1.1", true, SPV_ENV_VULKAN_1_1}, {"opencl2.1", true, SPV_ENV_OPENCL_2_1}, {"opencl2.2", true, SPV_ENV_OPENCL_2_2}, {"opengl4.0", true, SPV_ENV_OPENGL_4_0}, @@ -82,6 +84,10 @@ INSTANTIATE_TEST_CASE_P(TargetParsing, TargetParseTest, {"opengl4.2", true, SPV_ENV_OPENGL_4_2}, {"opengl4.3", true, SPV_ENV_OPENGL_4_3}, {"opengl4.5", true, SPV_ENV_OPENGL_4_5}, + {"opencl2.3", false, SPV_ENV_UNIVERSAL_1_0}, + {"opencl3.0", false, SPV_ENV_UNIVERSAL_1_0}, + {"vulkan1.2", false, SPV_ENV_UNIVERSAL_1_0}, + {"vulkan2.0", false, SPV_ENV_UNIVERSAL_1_0}, {nullptr, false, SPV_ENV_UNIVERSAL_1_0}, {"", false, SPV_ENV_UNIVERSAL_1_0}, {"abc", false, SPV_ENV_UNIVERSAL_1_0}, diff --git a/test/text_to_binary.extension_test.cpp b/test/text_to_binary.extension_test.cpp index 4b7c25c8f..bcf9ddaff 100644 --- a/test/text_to_binary.extension_test.cpp +++ b/test/text_to_binary.extension_test.cpp @@ -156,6 +156,61 @@ INSTANTIATE_TEST_CASE_P( SpvBuiltInSubgroupLtMaskKHR})}, })), ); +INSTANTIATE_TEST_CASE_P( + SPV_KHR_shader_ballot_vulkan_1_1, ExtensionRoundTripTest, + // In SPIR-V 1.3 and Vulkan 1.1 we can drop the KHR suffix on the + // builtin enums. + Combine(Values(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_1), + ValuesIn(std::vector<AssemblyCase>{ + {"OpCapability SubgroupBallotKHR\n", + MakeInstruction(SpvOpCapability, + {SpvCapabilitySubgroupBallotKHR})}, + {"%2 = OpSubgroupBallotKHR %1 %3\n", + MakeInstruction(SpvOpSubgroupBallotKHR, {1, 2, 3})}, + {"%2 = OpSubgroupFirstInvocationKHR %1 %3\n", + MakeInstruction(SpvOpSubgroupFirstInvocationKHR, {1, 2, 3})}, + {"OpDecorate %1 BuiltIn SubgroupEqMask\n", + MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn, + SpvBuiltInSubgroupEqMask})}, + {"OpDecorate %1 BuiltIn SubgroupGeMask\n", + MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn, + SpvBuiltInSubgroupGeMask})}, + {"OpDecorate %1 BuiltIn SubgroupGtMask\n", + MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn, + SpvBuiltInSubgroupGtMask})}, + {"OpDecorate %1 BuiltIn SubgroupLeMask\n", + MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn, + SpvBuiltInSubgroupLeMask})}, + {"OpDecorate %1 BuiltIn SubgroupLtMask\n", + MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn, + SpvBuiltInSubgroupLtMask})}, + })), ); + +// The old builtin names (with KHR suffix) still work in the assmebler, and +// map to the enums without the KHR. +INSTANTIATE_TEST_CASE_P( + SPV_KHR_shader_ballot_vulkan_1_1_alias_check, ExtensionAssemblyTest, + // In SPIR-V 1.3 and Vulkan 1.1 we can drop the KHR suffix on the + // builtin enums. + Combine(Values(SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_1), + ValuesIn(std::vector<AssemblyCase>{ + {"OpDecorate %1 BuiltIn SubgroupEqMaskKHR\n", + MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn, + SpvBuiltInSubgroupEqMask})}, + {"OpDecorate %1 BuiltIn SubgroupGeMaskKHR\n", + MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn, + SpvBuiltInSubgroupGeMask})}, + {"OpDecorate %1 BuiltIn SubgroupGtMaskKHR\n", + MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn, + SpvBuiltInSubgroupGtMask})}, + {"OpDecorate %1 BuiltIn SubgroupLeMaskKHR\n", + MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn, + SpvBuiltInSubgroupLeMask})}, + {"OpDecorate %1 BuiltIn SubgroupLtMaskKHR\n", + MakeInstruction(SpvOpDecorate, {1, SpvDecorationBuiltIn, + SpvBuiltInSubgroupLtMask})}, + })), ); + // SPV_KHR_shader_draw_parameters INSTANTIATE_TEST_CASE_P( @@ -164,7 +219,7 @@ INSTANTIATE_TEST_CASE_P( // environments, and at least one specific environment. Combine( Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1, - SPV_ENV_VULKAN_1_0), + SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1), ValuesIn(std::vector<AssemblyCase>{ {"OpCapability DrawParameters\n", MakeInstruction(SpvOpCapability, {SpvCapabilityDrawParameters})}, @@ -187,7 +242,7 @@ INSTANTIATE_TEST_CASE_P( // environments, and at least one specific environment. Combine( Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1, - SPV_ENV_VULKAN_1_0), + SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1), ValuesIn(std::vector<AssemblyCase>{ {"OpCapability SubgroupVoteKHR\n", MakeInstruction(SpvOpCapability, {SpvCapabilitySubgroupVoteKHR})}, @@ -206,7 +261,8 @@ INSTANTIATE_TEST_CASE_P( // We'll get coverage over operand tables by trying the universal // environments, and at least one specific environment. Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1, - SPV_ENV_VULKAN_1_0), + SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_0, + SPV_ENV_VULKAN_1_1), ValuesIn(std::vector<AssemblyCase>{ {"OpCapability StorageBuffer16BitAccess\n", MakeInstruction(SpvOpCapability, @@ -232,7 +288,8 @@ INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P( SPV_KHR_16bit_storage_alias_check, ExtensionAssemblyTest, Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1, - SPV_ENV_VULKAN_1_0), + SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_0, + SPV_ENV_VULKAN_1_1), ValuesIn(std::vector<AssemblyCase>{ // The old name maps to the new enum. {"OpCapability StorageUniformBufferBlock16\n", @@ -252,7 +309,8 @@ INSTANTIATE_TEST_CASE_P( // We'll get coverage over operand tables by trying the universal // environments, and at least one specific environment. Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1, - SPV_ENV_VULKAN_1_0), + SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_0, + SPV_ENV_VULKAN_1_1), ValuesIn(std::vector<AssemblyCase>{ {"OpCapability DeviceGroup\n", MakeInstruction(SpvOpCapability, {SpvCapabilityDeviceGroup})}, @@ -268,7 +326,8 @@ INSTANTIATE_TEST_CASE_P( // We'll get coverage over operand tables by trying the universal // environments, and at least one specific environment. Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1, - SPV_ENV_VULKAN_1_0), + SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_0, + SPV_ENV_VULKAN_1_1), ValuesIn(std::vector<AssemblyCase>{ {"OpCapability MultiView\n", MakeInstruction(SpvOpCapability, {SpvCapabilityMultiView})}, @@ -353,8 +412,8 @@ INSTANTIATE_TEST_CASE_P( SPV_AMD_gcn_shader, ExtensionRoundTripTest, // We'll get coverage over operand tables by trying the universal // environments, and at least one specific environment. - Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1, - SPV_ENV_VULKAN_1_0), + Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1, SPV_ENV_UNIVERSAL_1_3, + SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1), ValuesIn(std::vector<AssemblyCase>{ {PREAMBLE "%3 = OpExtInst %2 %1 CubeFaceIndexAMD %4\n", Concatenate({MakeInstruction(SpvOpExtInstImport, {1}, @@ -408,16 +467,15 @@ INSTANTIATE_TEST_CASE_P( SPV_KHR_variable_pointers, ExtensionRoundTripTest, // We'll get coverage over operand tables by trying the universal // environments, and at least one specific environment. - Combine(Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1, - SPV_ENV_VULKAN_1_0), - ValuesIn(std::vector<AssemblyCase>{ - {"OpCapability VariablePointers\n", - MakeInstruction(SpvOpCapability, - {SpvCapabilityVariablePointers})}, - {"OpCapability VariablePointersStorageBuffer\n", - MakeInstruction( - SpvOpCapability, - {SpvCapabilityVariablePointersStorageBuffer})}, - })), ); + Combine( + Values(SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1, + SPV_ENV_UNIVERSAL_1_3, SPV_ENV_VULKAN_1_0, SPV_ENV_VULKAN_1_1), + ValuesIn(std::vector<AssemblyCase>{ + {"OpCapability VariablePointers\n", + MakeInstruction(SpvOpCapability, {SpvCapabilityVariablePointers})}, + {"OpCapability VariablePointersStorageBuffer\n", + MakeInstruction(SpvOpCapability, + {SpvCapabilityVariablePointersStorageBuffer})}, + })), ); } // anonymous namespace diff --git a/test/unit_spirv.h b/test/unit_spirv.h index 47448158b..ae4e4b818 100644 --- a/test/unit_spirv.h +++ b/test/unit_spirv.h @@ -211,7 +211,8 @@ inline std::vector<spv_target_env> AllTargetEnvironments() { return {SPV_ENV_UNIVERSAL_1_0, SPV_ENV_UNIVERSAL_1_1, SPV_ENV_OPENCL_2_1, SPV_ENV_OPENCL_2_2, SPV_ENV_VULKAN_1_0, SPV_ENV_OPENGL_4_0, SPV_ENV_OPENGL_4_1, SPV_ENV_OPENGL_4_2, SPV_ENV_OPENGL_4_3, - SPV_ENV_OPENGL_4_5, SPV_ENV_UNIVERSAL_1_2}; + SPV_ENV_OPENGL_4_5, SPV_ENV_UNIVERSAL_1_2, SPV_ENV_UNIVERSAL_1_3, + SPV_ENV_VULKAN_1_1}; } // Returns the capabilities in a CapabilitySet as an ordered vector. diff --git a/tools/as/as.cpp b/tools/as/as.cpp index 475d44dab..0d9363f77 100644 --- a/tools/as/as.cpp +++ b/tools/as/as.cpp @@ -41,13 +41,14 @@ Options: Numeric IDs in the binary will have the same values as in the source. Non-numeric IDs are allocated by filling in the gaps, starting with 1 and going up. - --target-env {vulkan1.0|spv1.0|spv1.1|spv1.2} - Use Vulkan1.0/SPIR-V1.0/SPIR-V1.1/SPIR-V1.2 + --target-env {vulkan1.0|vulkan1.1|spv1.0|spv1.1|spv1.2|spv1.3} + Use Vulkan 1.0, Vulkan 1.1, SPIR-V 1.0, SPIR-V 1.1, + SPIR-V 1.2, or SPIR-V 1.3 )", argv0, argv0); } -static const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_2; +static const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_3; int main(int argc, char** argv) { const char* inFile = nullptr; diff --git a/tools/cfg/cfg.cpp b/tools/cfg/cfg.cpp index f609ddefc..9f6afdcde 100644 --- a/tools/cfg/cfg.cpp +++ b/tools/cfg/cfg.cpp @@ -45,7 +45,7 @@ Options: argv0, argv0); } -static const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_2; +static const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_3; int main(int argc, char** argv) { const char* inFile = nullptr; diff --git a/tools/dis/dis.cpp b/tools/dis/dis.cpp index 9c14b07a5..4e19ca1ce 100644 --- a/tools/dis/dis.cpp +++ b/tools/dis/dis.cpp @@ -58,7 +58,7 @@ Options: argv0, argv0); } -static const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_2; +static const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_3; int main(int argc, char** argv) { const char* inFile = nullptr; diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index ac037c51f..932fa7590 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -129,7 +129,7 @@ int main(int argc, char** argv) { const char* in_file = nullptr; const char* out_file = nullptr; - spv_target_env target_env = SPV_ENV_UNIVERSAL_1_2; + spv_target_env target_env = SPV_ENV_UNIVERSAL_1_3; spvtools::Optimizer optimizer(target_env); optimizer.SetMessageConsumer([](spv_message_level_t level, const char* source, diff --git a/tools/val/val.cpp b/tools/val/val.cpp index 2c065196e..414c70b4b 100644 --- a/tools/val/val.cpp +++ b/tools/val/val.cpp @@ -53,7 +53,7 @@ Options: int main(int argc, char** argv) { const char* inFile = nullptr; - spv_target_env target_env = SPV_ENV_UNIVERSAL_1_2; + spv_target_env target_env = SPV_ENV_UNIVERSAL_1_3; spvtools::ValidatorOptions options; bool continue_processing = true; int return_code = 0; @@ -86,10 +86,13 @@ int main(int argc, char** argv) { } else if (0 == strcmp(cur_arg, "--version")) { printf("%s\n", spvSoftwareVersionDetailsString()); // TODO(dneto): Add OpenCL 2.2 at least. - printf("Targets:\n %s\n %s\n %s\n", - spvTargetEnvDescription(SPV_ENV_UNIVERSAL_1_1), + printf("Targets:\n %s\n %s\n %s\n %s\n %s\n %s\n", + spvTargetEnvDescription(SPV_ENV_UNIVERSAL_1_0), spvTargetEnvDescription(SPV_ENV_VULKAN_1_0), - spvTargetEnvDescription(SPV_ENV_UNIVERSAL_1_2)); + spvTargetEnvDescription(SPV_ENV_UNIVERSAL_1_1), + spvTargetEnvDescription(SPV_ENV_UNIVERSAL_1_2), + spvTargetEnvDescription(SPV_ENV_UNIVERSAL_1_3), + spvTargetEnvDescription(SPV_ENV_VULKAN_1_1)); continue_processing = false; return_code = 0; } else if (0 == strcmp(cur_arg, "--help") || 0 == strcmp(cur_arg, "-h")) { |