mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-05 01:20:42 +00:00
Add method for inserting deferred constants in SPIR-V
* Our iterators currently don't update when insertions are made before them, so adding constants while modifying a function is a problem. However we can just reserve an ID and add the constant later.
This commit is contained in:
@@ -143,6 +143,10 @@ void Editor::CreateEmpty(uint32_t major, uint32_t minor)
|
||||
|
||||
Editor::~Editor()
|
||||
{
|
||||
for(const Operation &op : m_DeferredConstants)
|
||||
AddConstant(op);
|
||||
m_DeferredConstants.clear();
|
||||
|
||||
m_ExternalSPIRV.clear();
|
||||
m_ExternalSPIRV.reserve(m_SPIRV.size());
|
||||
|
||||
|
||||
@@ -210,6 +210,22 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Id AddConstantDeferred(T t)
|
||||
{
|
||||
Id typeId = DeclareType(scalar<T>());
|
||||
Id retId = MakeId();
|
||||
rdcarray<uint32_t> words = {typeId.value(), retId.value()};
|
||||
|
||||
words.resize(words.size() + (sizeof(T) + 3) / 4);
|
||||
|
||||
memcpy(&words[2], &t, sizeof(T));
|
||||
|
||||
m_DeferredConstants.add(Operation(Op::Constant, words));
|
||||
|
||||
return retId;
|
||||
}
|
||||
|
||||
private:
|
||||
using Processor::Parse;
|
||||
inline void addWords(size_t offs, size_t num) { addWords(offs, (int32_t)num); }
|
||||
@@ -246,6 +262,8 @@ private:
|
||||
template <typename SPIRVType>
|
||||
const std::map<SPIRVType, Id> &GetTable() const;
|
||||
|
||||
OperationList m_DeferredConstants;
|
||||
|
||||
rdcarray<uint32_t> &m_ExternalSPIRV;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user