mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-28 21:01:04 +00:00
Don't clear important data when using StructuredSerialiser
This commit is contained in:
@@ -130,7 +130,7 @@ void DoSerialise(SerialiserType &ser, D3D12_CPU_DESCRIPTOR_HANDLE &el)
|
||||
if(rm)
|
||||
el.ptr = (SIZE_T)DescriptorFromPortableHandle(rm, ph);
|
||||
else
|
||||
el.ptr = 0;
|
||||
ser.ClearObj(el.ptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ void DoSerialise(SerialiserType &ser, D3D12_GPU_DESCRIPTOR_HANDLE &el)
|
||||
if(rm)
|
||||
el.ptr = (SIZE_T)DescriptorFromPortableHandle(rm, ph);
|
||||
else
|
||||
el.ptr = 0;
|
||||
ser.ClearObj(el.ptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ void DoSerialise(SerialiserType &ser, D3D12BufferLocation &el)
|
||||
if(rm && buffer != ResourceId() && rm->HasLiveResource(buffer))
|
||||
el.Location = rm->GetLiveAs<ID3D12Resource>(buffer)->GetGPUVirtualAddress() + offs;
|
||||
else
|
||||
el.Location = 0;
|
||||
ser.ClearObj(el.Location);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -188,6 +188,13 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void ClearObj(T &el)
|
||||
{
|
||||
if(IsReading())
|
||||
m_Read->Clear(&el, sizeof(T));
|
||||
}
|
||||
|
||||
// serialise an object (either loose, or a structure member).
|
||||
template <class T>
|
||||
Serialiser &Serialise(const rdcliteral &name, T &el,
|
||||
@@ -1912,9 +1919,12 @@ struct ScopedDeserialiseArray<SerialiserType, byte *>
|
||||
GET_SERIALISER, obj); \
|
||||
GET_SERIALISER.Serialise(STRING_LITERAL(#obj), obj)
|
||||
|
||||
// for _TYPED serialises, we need to first clear the object to 0 since the typed alias might not
|
||||
// write it all. This is mostly only when co-oercing a BOOL type to bool, where only one byte gets
|
||||
// written. We go via ClearObj() so that when StructuredSerialiser is in use and the reader is a
|
||||
// dummy, it can skip the write.
|
||||
#define SERIALISE_ELEMENT_TYPED(type, obj) \
|
||||
if(ser.IsReading()) \
|
||||
obj = decltype(obj)(); \
|
||||
ser.ClearObj(obj); \
|
||||
union \
|
||||
{ \
|
||||
type *t; \
|
||||
@@ -1948,8 +1958,7 @@ struct ScopedDeserialiseArray<SerialiserType, byte *>
|
||||
#define SERIALISE_MEMBER(obj) ser.Serialise(STRING_LITERAL(#obj), el.obj)
|
||||
|
||||
#define SERIALISE_MEMBER_TYPED(type, obj) \
|
||||
if(ser.IsReading()) \
|
||||
el.obj = decltype(el.obj)(); \
|
||||
ser.ClearObj(el.obj); \
|
||||
union \
|
||||
{ \
|
||||
type *t; \
|
||||
@@ -1962,8 +1971,8 @@ struct ScopedDeserialiseArray<SerialiserType, byte *>
|
||||
ser.Serialise(STRING_LITERAL(#arrayObj), el.arrayObj, el.countObj, SerialiserFlags::AllocateMemory)
|
||||
|
||||
#define SERIALISE_MEMBER_ARRAY_TYPED(type, arrayObj, countObj) \
|
||||
if(ser.IsReading()) \
|
||||
el.arrayObj = NULL; \
|
||||
RDCCOMPILE_ASSERT(sizeof(*el.arrayObj) == sizeof(type), \
|
||||
"Array serialised co-erced type must be identically sized"); \
|
||||
union \
|
||||
{ \
|
||||
type **t; \
|
||||
|
||||
@@ -118,6 +118,12 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
void Clear(void *data, size_t numBytes)
|
||||
{
|
||||
if(!m_Dummy)
|
||||
memset(data, 0, numBytes);
|
||||
}
|
||||
|
||||
bool Read(void *data, uint64_t numBytes)
|
||||
{
|
||||
if(numBytes == 0 || m_Dummy)
|
||||
|
||||
Reference in New Issue
Block a user