mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-05 01:20:42 +00:00
Don't allocate memory for arrays when structured serialising
This commit is contained in:
@@ -117,6 +117,7 @@ public:
|
||||
Serialiser(const Serialiser &other) = delete;
|
||||
|
||||
bool IsErrored() { return IsReading() ? m_Read->IsErrored() : m_Write->IsErrored(); }
|
||||
bool IsDummy() { return m_Dummy; }
|
||||
StreamWriter *GetWriter() { return m_Write; }
|
||||
StreamReader *GetReader() { return m_Read; }
|
||||
uint32_t GetChunkMetadataRecording() { return m_ChunkFlags; }
|
||||
@@ -299,7 +300,7 @@ public:
|
||||
// ScopedDeseralise* classes. We can verify with e.g. valgrind that there are no leaks, so to keep
|
||||
// the analysis non-spammy we just don't allocate for coverity builds
|
||||
#if !defined(__COVERITY__)
|
||||
if(flags & SerialiserFlags::AllocateMemory)
|
||||
if(!m_Dummy && (flags & SerialiserFlags::AllocateMemory))
|
||||
{
|
||||
if(byteSize > 0)
|
||||
el = AllocAlignedBuffer(byteSize);
|
||||
@@ -702,7 +703,7 @@ public:
|
||||
// ScopedDeseralise* classes. We can verify with e.g. valgrind that there are no leaks, so to keep
|
||||
// the analysis non-spammy we just don't allocate for coverity builds
|
||||
#if !defined(__COVERITY__)
|
||||
if(IsReading() && (flags & SerialiserFlags::AllocateMemory))
|
||||
if(IsReading() && !m_Dummy && (flags & SerialiserFlags::AllocateMemory))
|
||||
{
|
||||
if(arrayCount > 0)
|
||||
el = new T[(size_t)arrayCount];
|
||||
@@ -737,7 +738,7 @@ public:
|
||||
// ScopedDeseralise* classes. We can verify with e.g. valgrind that there are no leaks, so to keep
|
||||
// the analysis non-spammy we just don't allocate for coverity builds
|
||||
#if !defined(__COVERITY__)
|
||||
if(IsReading() && (flags & SerialiserFlags::AllocateMemory))
|
||||
if(IsReading() && !m_Dummy && (flags & SerialiserFlags::AllocateMemory))
|
||||
{
|
||||
if(arrayCount > 0)
|
||||
el = new T[(size_t)arrayCount];
|
||||
@@ -1487,6 +1488,7 @@ protected:
|
||||
Serialiser(StreamWriter *writer, Ownership own);
|
||||
Serialiser(StreamReader *reader, Ownership own, SDObject *rootStructuredObj);
|
||||
|
||||
void SetDummy(bool dummy) { m_Dummy = dummy; }
|
||||
private:
|
||||
static const uint64_t ChunkAlignment = 64;
|
||||
template <class SerialiserMode, typename T, bool isEnum = std::is_enum<T>::value>
|
||||
@@ -1550,6 +1552,7 @@ private:
|
||||
// See SetStreamingMode
|
||||
bool m_DataStreaming = false;
|
||||
bool m_DrawChunk = false;
|
||||
bool m_Dummy = false;
|
||||
|
||||
uint64_t m_LastChunkOffset = 0;
|
||||
uint64_t m_ChunkFixup = 0;
|
||||
@@ -1617,6 +1620,7 @@ public:
|
||||
{
|
||||
ConfigureStructuredExport(lookup, false);
|
||||
SetStreamingMode(true);
|
||||
SetDummy(true);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user