mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-13 17:25:54 +00:00
Add Deserialise class to deallocate nested Vulkan structs
Currently deallocating VkDeviceCreateInfo and VkPipelineLayoutCreateInfo. Still more to be done.
This commit is contained in:
@@ -432,6 +432,18 @@ class Serialiser
|
||||
DebugPrint("%s: %s\n", name, ToStr::Get<T>(el).c_str());
|
||||
}
|
||||
|
||||
// object to serialise a single element
|
||||
// used to instantiate destructors for structs
|
||||
// with allocated members
|
||||
template<class T>
|
||||
class Deserialise : public T {
|
||||
public:
|
||||
Deserialise(T t) : T(t) {}
|
||||
Deserialise() {}
|
||||
virtual ~Deserialise() {}
|
||||
Mode m_Mode;
|
||||
};
|
||||
|
||||
template<typename X>
|
||||
void Serialise(const char *name, std::vector<X> &el)
|
||||
{
|
||||
@@ -759,10 +771,12 @@ class ScopedContext
|
||||
// can be overridden to locally cache the serialiser pointer (e.g. for TLS lookup)
|
||||
#define GET_SERIALISER GetSerialiser()
|
||||
|
||||
#define SCOPED_SERIALISE_CONTEXT(n) ScopedContext scope(GET_SERIALISER, GetChunkName(n), n, false);
|
||||
#define SCOPED_SERIALISE_CONTEXT(n) ScopedContext scope(GET_SERIALISER, GetChunkName(n), n, false);
|
||||
#define SCOPED_SERIALISE_SMALL_CONTEXT(n) ScopedContext scope(GET_SERIALISER, GetChunkName(n), n, true);
|
||||
|
||||
#define SERIALISE_ELEMENT(type, name, inValue) type name; if(m_State >= WRITING) name = (inValue); GET_SERIALISER->Serialise(#name, name);
|
||||
#define SERIALISE_ELEMENT_CLASS(type, name, inValue) Serialiser::Deserialise<type> name; if(m_State >= WRITING) { static_cast<type&>(name) = (inValue); name.m_Mode = Serialiser::WRITING; } else name.m_Mode = Serialiser::READING; GET_SERIALISER->Serialise(#name, static_cast<type&>(name));
|
||||
#define SERIALISE_ELEMENT_OPT(type, name, inValue, Condition) type name = type(); if(Condition) { if(m_State >= WRITING) name = (inValue); GET_SERIALISER->Serialise(#name, name); }
|
||||
#define SERIALISE_ELEMENT_ARR(type, name, inValues, count) type *name = new type[count]; for(size_t serialiseIdx=0; serialiseIdx < count; serialiseIdx++) { if(m_State >= WRITING) name[serialiseIdx] = (inValues)[serialiseIdx]; GET_SERIALISER->Serialise(#name, name[serialiseIdx]); }
|
||||
#define SERIALISE_ELEMENT_ARR_OPT(type, name, inValues, count, Condition) type *name = NULL; if(Condition) { name = new type[count]; for(size_t serialiseIdx=0; serialiseIdx < count; serialiseIdx++) { if(m_State >= WRITING) name[serialiseIdx] = (inValues)[serialiseIdx]; GET_SERIALISER->Serialise(#name, name[serialiseIdx]); } }
|
||||
|
||||
Reference in New Issue
Block a user