From 63c5b548c530df7fe598a543aa20ba7eaa2b5eb4 Mon Sep 17 00:00:00 2001 From: comex Date: Tue, 24 Nov 2020 18:24:28 -0500 Subject: [PATCH] Fix OpExtension. There were two issues: - The word0 was omitted entirely. - The word count didn't account for the nul terminator. --- src/sirit.cpp | 4 +++- src/stream.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/sirit.cpp b/src/sirit.cpp index a2043ae..3c9d97d 100644 --- a/src/sirit.cpp +++ b/src/sirit.cpp @@ -42,8 +42,10 @@ std::vector Module::Assemble() const { } for (const std::string_view extension_name : extensions) { + size_t count = WordsInString(extension_name); + words.push_back(MakeWord0(spv::Op::OpExtension, count + 1)); size_t insert_index = words.size(); - words.resize(words.size() + WordsInString(extension_name)); + words.resize(words.size() + count); InsertStringView(words, insert_index, extension_name); } diff --git a/src/stream.h b/src/stream.h index cbea1d4..fecc6d0 100644 --- a/src/stream.h +++ b/src/stream.h @@ -35,7 +35,7 @@ struct OpId { struct EndOp {}; constexpr size_t WordsInString(std::string_view string) { - return string.size() / sizeof(u32); + return string.size() / sizeof(u32) + 1; } inline void InsertStringView(std::vector& words, size_t& insert_index,