From 8ddd4ec1022cb828dd40e22c32a45ff44a4bb1f6 Mon Sep 17 00:00:00 2001 From: David Neto Date: Tue, 17 Nov 2015 16:37:10 -0500 Subject: [PATCH] Bottom byte of version header word should be 0 The assembler should always make it 0. The disassembler should ignore it. Remove the macro support for supplying a value for it. Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/6 --- source/disassemble.cpp | 3 +-- source/spirv_constant.h | 9 +++------ source/text.cpp | 3 +-- test/BinaryToText.cpp | 3 +-- test/ExtInstGLSLstd450.cpp | 2 +- 5 files changed, 7 insertions(+), 13 deletions(-) diff --git a/source/disassemble.cpp b/source/disassemble.cpp index 4572afa..c4b4c69 100644 --- a/source/disassemble.cpp +++ b/source/disassemble.cpp @@ -136,8 +136,7 @@ spv_result_t Disassembler::HandleHeader(spv_endianness_t endian, spvGeneratorStr(SPV_GENERATOR_TOOL_PART(generator)); stream_ << "; SPIR-V\n" << "; Version: " << SPV_SPIRV_VERSION_MAJOR_PART(version) << "." - << SPV_SPIRV_VERSION_MINOR_PART(version) << "." - << SPV_SPIRV_VERSION_REVISION_PART(version) << "\n" + << SPV_SPIRV_VERSION_MINOR_PART(version) << "\n" << "; Generator: " << generator_tool; // For unknown tools, print the numeric tool value. if (0 == strcmp("Unknown", generator_tool)) { diff --git a/source/spirv_constant.h b/source/spirv_constant.h index cbf33cc..347131c 100644 --- a/source/spirv_constant.h +++ b/source/spirv_constant.h @@ -32,16 +32,13 @@ // Version number macros. // Evaluates to a well-formed version header word, given valid -// SPIR-V version major, minor, and revision numbers. -#define SPV_SPIRV_VERSION_WORD(MAJOR, MINOR, REVISION) \ - ((uint32_t(uint8_t(MAJOR)) << 16) | (uint32_t(uint8_t(MINOR)) << 8) | \ - uint8_t(REVISION)) +// SPIR-V version major and minor version numbers. +#define SPV_SPIRV_VERSION_WORD(MAJOR, MINOR) \ + ((uint32_t(uint8_t(MAJOR)) << 16) | (uint32_t(uint8_t(MINOR)) << 8)) // Returns the major version extracted from a version header word. #define SPV_SPIRV_VERSION_MAJOR_PART(WORD) ((uint32_t(WORD) >> 16) & 0xff) // Returns the minor version extracted from a version header word. #define SPV_SPIRV_VERSION_MINOR_PART(WORD) ((uint32_t(WORD) >> 8) & 0xff) -// Returns the revision number extracted from a version header word. -#define SPV_SPIRV_VERSION_REVISION_PART(WORD) (uint32_t(WORD) & 0xff) // Header indices diff --git a/source/text.cpp b/source/text.cpp index d33d773..3ebde21 100644 --- a/source/text.cpp +++ b/source/text.cpp @@ -668,8 +668,7 @@ SetHeader(uint32_t* words, const uint32_t bound) { words[SPV_INDEX_MAGIC_NUMBER] = SpvMagicNumber; words[SPV_INDEX_VERSION_NUMBER] = - SPV_SPIRV_VERSION_WORD(SPV_SPIRV_VERSION_MAJOR, SPV_SPIRV_VERSION_MINOR, - SPV_SPIRV_VERSION_REVISION); + SPV_SPIRV_VERSION_WORD(SPV_SPIRV_VERSION_MAJOR, SPV_SPIRV_VERSION_MINOR); words[SPV_INDEX_GENERATOR_NUMBER] = SPV_GENERATOR_WORD(SPV_GENERATOR_KHRONOS_ASSEMBLER, kAssemblerVersion); words[SPV_INDEX_BOUND] = bound; diff --git a/test/BinaryToText.cpp b/test/BinaryToText.cpp index 55156cc..3156d07 100644 --- a/test/BinaryToText.cpp +++ b/test/BinaryToText.cpp @@ -408,8 +408,7 @@ TEST_F(TextToBinaryTest, VersionString) { EXPECT_EQ(1, SPV_SPIRV_VERSION_MAJOR); EXPECT_EQ(0, SPV_SPIRV_VERSION_MINOR); - EXPECT_EQ(2, SPV_SPIRV_VERSION_REVISION); - EXPECT_THAT(decoded_text->str, HasSubstr("Version: 1.0.2\n")) + EXPECT_THAT(decoded_text->str, HasSubstr("Version: 1.0\n")) << EncodeAndDecodeSuccessfully(""); spvTextDestroy(decoded_text); } diff --git a/test/ExtInstGLSLstd450.cpp b/test/ExtInstGLSLstd450.cpp index 41b34e2..4e21f3a 100644 --- a/test/ExtInstGLSLstd450.cpp +++ b/test/ExtInstGLSLstd450.cpp @@ -66,7 +66,7 @@ OpFunctionEnd )"; const std::string spirv_header = R"(; SPIR-V -; Version: 1.0.2 +; Version: 1.0 ; Generator: Khronos SPIR-V Tools Assembler; 0 ; Bound: 9 ; Schema: 0)"; -- 2.7.4