mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-10-18 19:20:05 +00:00
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
This commit is contained in:
parent
01a3b9ce36
commit
8ddd4ec102
@ -136,8 +136,7 @@ spv_result_t Disassembler::HandleHeader(spv_endianness_t endian,
|
|||||||
spvGeneratorStr(SPV_GENERATOR_TOOL_PART(generator));
|
spvGeneratorStr(SPV_GENERATOR_TOOL_PART(generator));
|
||||||
stream_ << "; SPIR-V\n"
|
stream_ << "; SPIR-V\n"
|
||||||
<< "; Version: " << SPV_SPIRV_VERSION_MAJOR_PART(version) << "."
|
<< "; Version: " << SPV_SPIRV_VERSION_MAJOR_PART(version) << "."
|
||||||
<< SPV_SPIRV_VERSION_MINOR_PART(version) << "."
|
<< SPV_SPIRV_VERSION_MINOR_PART(version) << "\n"
|
||||||
<< SPV_SPIRV_VERSION_REVISION_PART(version) << "\n"
|
|
||||||
<< "; Generator: " << generator_tool;
|
<< "; Generator: " << generator_tool;
|
||||||
// For unknown tools, print the numeric tool value.
|
// For unknown tools, print the numeric tool value.
|
||||||
if (0 == strcmp("Unknown", generator_tool)) {
|
if (0 == strcmp("Unknown", generator_tool)) {
|
||||||
|
@ -32,16 +32,13 @@
|
|||||||
// Version number macros.
|
// Version number macros.
|
||||||
|
|
||||||
// Evaluates to a well-formed version header word, given valid
|
// Evaluates to a well-formed version header word, given valid
|
||||||
// SPIR-V version major, minor, and revision numbers.
|
// SPIR-V version major and minor version numbers.
|
||||||
#define SPV_SPIRV_VERSION_WORD(MAJOR, MINOR, REVISION) \
|
#define SPV_SPIRV_VERSION_WORD(MAJOR, MINOR) \
|
||||||
((uint32_t(uint8_t(MAJOR)) << 16) | (uint32_t(uint8_t(MINOR)) << 8) | \
|
((uint32_t(uint8_t(MAJOR)) << 16) | (uint32_t(uint8_t(MINOR)) << 8))
|
||||||
uint8_t(REVISION))
|
|
||||||
// Returns the major version extracted from a version header word.
|
// Returns the major version extracted from a version header word.
|
||||||
#define SPV_SPIRV_VERSION_MAJOR_PART(WORD) ((uint32_t(WORD) >> 16) & 0xff)
|
#define SPV_SPIRV_VERSION_MAJOR_PART(WORD) ((uint32_t(WORD) >> 16) & 0xff)
|
||||||
// Returns the minor version extracted from a version header word.
|
// Returns the minor version extracted from a version header word.
|
||||||
#define SPV_SPIRV_VERSION_MINOR_PART(WORD) ((uint32_t(WORD) >> 8) & 0xff)
|
#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
|
// Header indices
|
||||||
|
|
||||||
|
@ -668,8 +668,7 @@ SetHeader(uint32_t* words, const uint32_t bound) {
|
|||||||
|
|
||||||
words[SPV_INDEX_MAGIC_NUMBER] = SpvMagicNumber;
|
words[SPV_INDEX_MAGIC_NUMBER] = SpvMagicNumber;
|
||||||
words[SPV_INDEX_VERSION_NUMBER] =
|
words[SPV_INDEX_VERSION_NUMBER] =
|
||||||
SPV_SPIRV_VERSION_WORD(SPV_SPIRV_VERSION_MAJOR, SPV_SPIRV_VERSION_MINOR,
|
SPV_SPIRV_VERSION_WORD(SPV_SPIRV_VERSION_MAJOR, SPV_SPIRV_VERSION_MINOR);
|
||||||
SPV_SPIRV_VERSION_REVISION);
|
|
||||||
words[SPV_INDEX_GENERATOR_NUMBER] =
|
words[SPV_INDEX_GENERATOR_NUMBER] =
|
||||||
SPV_GENERATOR_WORD(SPV_GENERATOR_KHRONOS_ASSEMBLER, kAssemblerVersion);
|
SPV_GENERATOR_WORD(SPV_GENERATOR_KHRONOS_ASSEMBLER, kAssemblerVersion);
|
||||||
words[SPV_INDEX_BOUND] = bound;
|
words[SPV_INDEX_BOUND] = bound;
|
||||||
|
@ -408,8 +408,7 @@ TEST_F(TextToBinaryTest, VersionString) {
|
|||||||
|
|
||||||
EXPECT_EQ(1, SPV_SPIRV_VERSION_MAJOR);
|
EXPECT_EQ(1, SPV_SPIRV_VERSION_MAJOR);
|
||||||
EXPECT_EQ(0, SPV_SPIRV_VERSION_MINOR);
|
EXPECT_EQ(0, SPV_SPIRV_VERSION_MINOR);
|
||||||
EXPECT_EQ(2, SPV_SPIRV_VERSION_REVISION);
|
EXPECT_THAT(decoded_text->str, HasSubstr("Version: 1.0\n"))
|
||||||
EXPECT_THAT(decoded_text->str, HasSubstr("Version: 1.0.2\n"))
|
|
||||||
<< EncodeAndDecodeSuccessfully("");
|
<< EncodeAndDecodeSuccessfully("");
|
||||||
spvTextDestroy(decoded_text);
|
spvTextDestroy(decoded_text);
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ OpFunctionEnd
|
|||||||
)";
|
)";
|
||||||
const std::string spirv_header =
|
const std::string spirv_header =
|
||||||
R"(; SPIR-V
|
R"(; SPIR-V
|
||||||
; Version: 1.0.2
|
; Version: 1.0
|
||||||
; Generator: Khronos SPIR-V Tools Assembler; 0
|
; Generator: Khronos SPIR-V Tools Assembler; 0
|
||||||
; Bound: 9
|
; Bound: 9
|
||||||
; Schema: 0)";
|
; Schema: 0)";
|
||||||
|
Loading…
Reference in New Issue
Block a user