mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-14 09:45:47 +00:00
Add utility function that expands an operation in-place with new words
This commit is contained in:
@@ -439,6 +439,29 @@ SPIRVId SPIRVEditor::DeclareStructType(std::vector<uint32_t> members)
|
||||
AddType(SPIRVOperation(spv::OpTypeStruct, members));
|
||||
return typeId;
|
||||
}
|
||||
|
||||
void SPIRVEditor::AddWord(SPIRVIterator entry, uint32_t word)
|
||||
{
|
||||
if(!entry)
|
||||
return;
|
||||
|
||||
// if it's just pointing at a SPIRVOperation, we can just push_back immediately
|
||||
if(entry.words != &spirv)
|
||||
{
|
||||
entry.words->push_back(word);
|
||||
return;
|
||||
}
|
||||
|
||||
// add word
|
||||
spirv.insert(spirv.begin() + entry.offset + entry.size(), word);
|
||||
|
||||
// fix up header
|
||||
entry.word(0) = SPIRVOperation::MakeHeader(entry.opcode(), entry.size() + 1);
|
||||
|
||||
// update offsets
|
||||
addWords(entry.offset + entry.size(), 1);
|
||||
}
|
||||
|
||||
void SPIRVEditor::addWords(size_t offs, int32_t num)
|
||||
{
|
||||
// look through every section, any that are >= this point, adjust the offsets
|
||||
|
||||
@@ -153,7 +153,7 @@ private:
|
||||
|
||||
std::vector<uint32_t>::const_iterator begin() const { return iter.it(); }
|
||||
std::vector<uint32_t>::const_iterator end() const { return iter.it() + size(); }
|
||||
inline uint32_t MakeHeader(spv::Op op, size_t WordCount)
|
||||
inline static uint32_t MakeHeader(spv::Op op, size_t WordCount)
|
||||
{
|
||||
return (uint32_t(op) & spv::OpCodeMask) | (uint16_t(WordCount) << spv::WordCountShift);
|
||||
}
|
||||
@@ -315,6 +315,8 @@ public:
|
||||
|
||||
SPIRVId MakeId();
|
||||
|
||||
void AddWord(SPIRVIterator entry, uint32_t word);
|
||||
|
||||
void SetName(uint32_t id, const char *name);
|
||||
void AddDecoration(const SPIRVOperation &op);
|
||||
void AddType(const SPIRVOperation &op);
|
||||
|
||||
Reference in New Issue
Block a user