diff --git a/renderdoc/driver/d3d11/d3d11_context.cpp b/renderdoc/driver/d3d11/d3d11_context.cpp index ce1d38547..7d833f76a 100644 --- a/renderdoc/driver/d3d11/d3d11_context.cpp +++ b/renderdoc/driver/d3d11/d3d11_context.cpp @@ -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)) { diff --git a/renderdoc/driver/d3d11/d3d11_device.cpp b/renderdoc/driver/d3d11/d3d11_device.cpp index 0ccbb14fa..aeffb049c 100644 --- a/renderdoc/driver/d3d11/d3d11_device.cpp +++ b/renderdoc/driver/d3d11/d3d11_device.cpp @@ -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 diff --git a/renderdoc/driver/d3d12/d3d12_commands.cpp b/renderdoc/driver/d3d12/d3d12_commands.cpp index 7c5e7c19d..863f1877f 100644 --- a/renderdoc/driver/d3d12/d3d12_commands.cpp +++ b/renderdoc/driver/d3d12/d3d12_commands.cpp @@ -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)) { diff --git a/renderdoc/driver/d3d12/d3d12_device.cpp b/renderdoc/driver/d3d12/d3d12_device.cpp index cd5efb7b0..31d2bbb33 100644 --- a/renderdoc/driver/d3d12/d3d12_device.cpp +++ b/renderdoc/driver/d3d12/d3d12_device.cpp @@ -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 diff --git a/renderdoc/driver/d3d12/d3d12_device.h b/renderdoc/driver/d3d12/d3d12_device.h index 153361666..08b924c0a 100644 --- a/renderdoc/driver/d3d12/d3d12_device.h +++ b/renderdoc/driver/d3d12/d3d12_device.h @@ -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; } diff --git a/renderdoc/driver/gl/gl_driver.cpp b/renderdoc/driver/gl/gl_driver.cpp index 62ab8fee5..bd0712b5f 100644 --- a/renderdoc/driver/gl/gl_driver.cpp +++ b/renderdoc/driver/gl/gl_driver.cpp @@ -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; diff --git a/renderdoc/driver/vulkan/vk_core.cpp b/renderdoc/driver/vulkan/vk_core.cpp index 2f7564adf..8f1420440 100644 --- a/renderdoc/driver/vulkan/vk_core.cpp +++ b/renderdoc/driver/vulkan/vk_core.cpp @@ -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; diff --git a/renderdoc/serialise/serialiser.h b/renderdoc/serialise/serialiser.h index 0ce6ebd19..74f78d5b6 100644 --- a/renderdoc/serialise/serialiser.h +++ b/renderdoc/serialise/serialiser.h @@ -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;