Add version checking to serialiser

This commit is contained in:
baldurk
2018-05-04 12:51:51 +01:00
parent 4023bf75d8
commit 2402ac7fa0
8 changed files with 25 additions and 1 deletions
+2
View File
@@ -145,6 +145,7 @@ WrappedID3D11DeviceContext::WrappedID3D11DeviceContext(WrappedID3D11Device *real
}
m_ScratchSerialiser.SetUserData(GetResourceManager());
m_ScratchSerialiser.SetVersion(D3D11InitParams::CurrentVersion);
m_SuccessfulCapture = true;
m_FailureReason = CaptureSucceeded;
@@ -1109,6 +1110,7 @@ ReplayStatus WrappedID3D11DeviceContext::ReplayLog(CaptureState readType, uint32
ser.SetStringDatabase(&m_StringDB);
ser.SetUserData(GetResourceManager());
ser.SetVersion(m_pDevice->GetLogVersion());
if(IsLoading(m_State) || IsStructuredExporting(m_State))
{
+3
View File
@@ -71,6 +71,7 @@ WrappedID3D11Device::WrappedID3D11Device(ID3D11Device *realDevice, D3D11InitPara
flags |= WriteSerialiser::ChunkCallstack;
m_ScratchSerialiser.SetChunkMetadataRecording(flags);
m_ScratchSerialiser.SetVersion(D3D11InitParams::CurrentVersion);
m_StructuredFile = &m_StoredStructuredData;
@@ -983,6 +984,8 @@ ReplayStatus WrappedID3D11Device::ReadLogInitialisation(RDCFile *rdc, bool store
m_StoredStructuredData.version = m_StructuredFile->version = m_SectionVersion;
ser.SetVersion(m_SectionVersion);
int chunkIdx = 0;
struct chunkinfo
@@ -533,6 +533,7 @@ ReplayStatus WrappedID3D12CommandQueue::ReplayLog(CaptureState readType, uint32_
ser.SetStringDatabase(&m_StringDB);
ser.SetUserData(GetResourceManager());
ser.SetVersion(m_pDevice->GetLogVersion());
if(IsLoading(m_State) || IsStructuredExporting(m_State))
{
+3 -1
View File
@@ -2059,8 +2059,8 @@ WriteSerialiser &WrappedID3D12Device::GetThreadSerialiser()
flags |= WriteSerialiser::ChunkCallstack;
ser->SetChunkMetadataRecording(flags);
ser->SetUserData(GetResourceManager());
ser->SetVersion(D3D12InitParams::CurrentVersion);
Threading::SetTLSValue(threadSerialiserTLSSlot, (void *)ser);
@@ -2522,6 +2522,8 @@ ReplayStatus WrappedID3D12Device::ReadLogInitialisation(RDCFile *rdc, bool store
m_StoredStructuredData.version = m_StructuredFile->version = m_SectionVersion;
ser.SetVersion(m_SectionVersion);
int chunkIdx = 0;
struct chunkinfo
+1
View File
@@ -418,6 +418,7 @@ public:
m_InitParams = params;
m_SectionVersion = sectionVersion;
}
uint64_t GetLogVersion() { return m_SectionVersion; }
CaptureState GetState() { return m_State; }
D3D12Replay *GetReplay() { return &m_Replay; }
WrappedID3D12CommandQueue *GetQueue() { return m_Queue; }
+4
View File
@@ -499,6 +499,7 @@ WrappedOpenGL::WrappedOpenGL(const GLHookSet &funcs, GLPlatform &platform)
flags |= WriteSerialiser::ChunkCallstack;
m_ScratchSerialiser.SetChunkMetadataRecording(flags);
m_ScratchSerialiser.SetVersion(GLInitParams::CurrentVersion);
m_SectionVersion = GLInitParams::CurrentVersion;
@@ -2344,6 +2345,8 @@ ReplayStatus WrappedOpenGL::ReadLogInitialisation(RDCFile *rdc, bool storeStruct
m_StoredStructuredData.version = m_StructuredFile->version = m_SectionVersion;
ser.SetVersion(m_SectionVersion);
int chunkIdx = 0;
struct chunkinfo
@@ -3931,6 +3934,7 @@ ReplayStatus WrappedOpenGL::ContextReplayLog(CaptureState readType, uint32_t sta
ser.SetStringDatabase(&m_StringDB);
ser.SetUserData(GetResourceManager());
ser.SetVersion(m_SectionVersion);
SDFile *prevFile = m_StructuredFile;
+4
View File
@@ -458,6 +458,7 @@ WriteSerialiser &WrappedVulkan::GetThreadSerialiser()
ser->SetChunkMetadataRecording(flags);
ser->SetUserData(GetResourceManager());
ser->SetVersion(VkInitParams::CurrentVersion);
Threading::SetTLSValue(threadSerialiserTLSSlot, (void *)ser);
@@ -1588,6 +1589,8 @@ ReplayStatus WrappedVulkan::ReadLogInitialisation(RDCFile *rdc, bool storeStruct
m_StoredStructuredData.version = m_StructuredFile->version = m_SectionVersion;
ser.SetVersion(m_SectionVersion);
int chunkIdx = 0;
struct chunkinfo
@@ -1711,6 +1714,7 @@ ReplayStatus WrappedVulkan::ContextReplayLog(CaptureState readType, uint32_t sta
ser.SetStringDatabase(&m_StringDB);
ser.SetUserData(GetResourceManager());
ser.SetVersion(m_SectionVersion);
SDFile *prevFile = m_StructuredFile;
+7
View File
@@ -126,6 +126,12 @@ public:
// jumps to the byte after the current chunk, can be called any time after BeginChunk
void SkipCurrentChunk();
//////////////////////////////////////////
// Version checking
void SetVersion(uint64_t version) { m_Version = version; }
// assume that we always write the latest version, so on writing the version check always passes.
bool VersionCheck(uint64_t req) { return IsWriting() || m_Version >= req; }
// enable 'streaming mode' for ephemeral transfers like temporary I/O over sockets, where there's
// no need for the chunk length - avoids needing to seek internally in a stream that might not
// support seeking to fixup lengths, while also not requiring conservative length estimates
@@ -1566,6 +1572,7 @@ private:
}
void *m_pUserData = NULL;
uint64_t m_Version;
uint64_t m_StructArg = 0;