From ebe1318f720116f1bc772df5e5cd985765be2028 Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 9 Nov 2017 15:12:06 +0000 Subject: [PATCH] When exporting struct buffers we must always allocate memory to readback * If the external code has a NULL pointer and doesn't want to allocate but we are exporting buffer data, we still need to read the data somewhere so make a temporary allocation to read it into. --- renderdoc/serialise/serialiser.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/renderdoc/serialise/serialiser.h b/renderdoc/serialise/serialiser.h index 442527a74..932c33a17 100644 --- a/renderdoc/serialise/serialiser.h +++ b/renderdoc/serialise/serialiser.h @@ -234,6 +234,8 @@ public: obj.type.byteSize = byteSize; } + byte *tempAlloc = NULL; + { if(IsWriting()) { @@ -261,6 +263,17 @@ public: else el = NULL; } + + // if we're exporting the buffers, make sure to always alloc space to read the data, so we + // can save it out, even if the external code has no use for it and has asked for no + // allocation. + if(el == NULL && ExportStructure() && m_ExportBuffers) + { + if(byteSize > 0) + el = tempAlloc = AllocAlignedBuffer(byteSize); + else + el = NULL; + } #endif m_Read->Read(el, byteSize); @@ -286,6 +299,12 @@ public: m_StructureStack.pop_back(); } + if(tempAlloc) + { + FreeAlignedBuffer(tempAlloc); + el = NULL; + } + return *this; }