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,