From e08e5f0692593e6ef917b67bf3a8684495cf2933 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 24 Nov 2017 11:35:49 +0000 Subject: [PATCH] Move some common chunks into SystemChunk from API Chunks * This makes API-agnostic processing over strucutred data a *little* easier. At least it's possible to differentiate initialisation from frame capture chunks. --- renderdoc/core/core.cpp | 3 + renderdoc/core/core.h | 3 + renderdoc/driver/d3d11/d3d11_common.h | 3 - renderdoc/driver/d3d11/d3d11_context.cpp | 45 +++++++++------ renderdoc/driver/d3d11/d3d11_device.cpp | 11 ++-- renderdoc/driver/d3d11/d3d11_device.h | 2 +- renderdoc/driver/d3d11/d3d11_stringise.cpp | 5 +- renderdoc/driver/d3d12/d3d12_commands.cpp | 50 +++++++++------- renderdoc/driver/d3d12/d3d12_common.h | 5 +- renderdoc/driver/d3d12/d3d12_device.cpp | 15 +++-- renderdoc/driver/d3d12/d3d12_device.h | 2 +- renderdoc/driver/d3d12/d3d12_stringise.cpp | 5 +- renderdoc/driver/gl/gl_common.h | 4 +- renderdoc/driver/gl/gl_driver.cpp | 67 +++++++++++----------- renderdoc/driver/gl/gl_driver.h | 2 +- renderdoc/driver/gl/gl_stringise.cpp | 5 +- renderdoc/driver/vulkan/vk_common.h | 3 - renderdoc/driver/vulkan/vk_core.cpp | 62 ++++++++++---------- renderdoc/driver/vulkan/vk_core.h | 2 +- renderdoc/driver/vulkan/vk_stringise.cpp | 5 +- 20 files changed, 154 insertions(+), 145 deletions(-) diff --git a/renderdoc/core/core.cpp b/renderdoc/core/core.cpp index 429075a9b..eda12c565 100644 --- a/renderdoc/core/core.cpp +++ b/renderdoc/core/core.cpp @@ -161,6 +161,9 @@ std::string DoStringise(const SystemChunk &el) STRINGISE_ENUM_CLASS_NAMED(DriverInit, "Driver Initialisation Parameters"); STRINGISE_ENUM_CLASS_NAMED(InitialContentsList, "List of Initial Contents Resources"); STRINGISE_ENUM_CLASS_NAMED(InitialContents, "Initial Contents"); + STRINGISE_ENUM_CLASS_NAMED(CaptureBegin, "Beginning of Capture"); + STRINGISE_ENUM_CLASS_NAMED(CaptureScope, "Frame Metadata"); + STRINGISE_ENUM_CLASS_NAMED(CaptureEnd, "End of Capture"); } END_ENUM_STRINGISE(); } diff --git a/renderdoc/core/core.h b/renderdoc/core/core.h index ceb5ad375..569438e72 100644 --- a/renderdoc/core/core.h +++ b/renderdoc/core/core.h @@ -153,6 +153,9 @@ enum class SystemChunk : uint32_t DriverInit = 1, InitialContentsList, InitialContents, + CaptureBegin, + CaptureScope, + CaptureEnd, FirstDriverChunk = 1000, }; diff --git a/renderdoc/driver/d3d11/d3d11_common.h b/renderdoc/driver/d3d11/d3d11_common.h index e597ca913..f2b7b09f1 100644 --- a/renderdoc/driver/d3d11/d3d11_common.h +++ b/renderdoc/driver/d3d11/d3d11_common.h @@ -266,9 +266,6 @@ public: enum class D3D11Chunk : uint32_t { DeviceInitialisation = (uint32_t)SystemChunk::FirstDriverChunk, - CaptureBegin, - CaptureEnd, - CaptureScope, SetResourceName, ReleaseResource, CreateSwapBuffer, diff --git a/renderdoc/driver/d3d11/d3d11_context.cpp b/renderdoc/driver/d3d11/d3d11_context.cpp index 3c42b10b7..5e5fa095b 100644 --- a/renderdoc/driver/d3d11/d3d11_context.cpp +++ b/renderdoc/driver/d3d11/d3d11_context.cpp @@ -426,7 +426,7 @@ void WrappedID3D11DeviceContext::VerifyState() void WrappedID3D11DeviceContext::BeginCaptureFrame() { WriteSerialiser &ser = m_ScratchSerialiser; - SCOPED_SERIALISE_CHUNK(D3D11Chunk::CaptureBegin); + SCOPED_SERIALISE_CHUNK(SystemChunk::CaptureBegin); Serialise_BeginCaptureFrame(ser, false); @@ -503,7 +503,7 @@ void WrappedID3D11DeviceContext::EndCaptureFrame() { WriteSerialiser &ser = m_ScratchSerialiser; ser.SetDrawChunk(); - SCOPED_SERIALISE_CHUNK(D3D11Chunk::CaptureEnd); + SCOPED_SERIALISE_CHUNK(SystemChunk::CaptureEnd); SERIALISE_ELEMENT(m_ResourceID).Named("Context ID"); @@ -837,27 +837,34 @@ bool WrappedID3D11DeviceContext::ProcessChunk(ReadSerialiser &ser, D3D11Chunk ch m_PresentChunk = true; break; } - - case D3D11Chunk::CaptureEnd: + default: { - if(IsLoading(m_State)) + SystemChunk system = (SystemChunk)chunk; + + if(system == SystemChunk::CaptureEnd) { - if(!m_PresentChunk) - AddEvent(); + if(IsLoading(m_State)) + { + if(!m_PresentChunk) + AddEvent(); - DrawcallDescription draw; - draw.name = "End of Frame"; - draw.flags |= DrawFlags::Present; + DrawcallDescription draw; + draw.name = "End of Frame"; + draw.flags |= DrawFlags::Present; - draw.copyDestination = m_pDevice->GetBackbufferResourceID(); + draw.copyDestination = m_pDevice->GetBackbufferResourceID(); - AddDrawcall(draw, true); + AddDrawcall(draw, true); + } + + ret = true; } - - ret = true; + else + { + RDCERR("Unrecognised Chunk type %d", chunk); + } + break; } - break; - default: RDCERR("Unrecognised Chunk type %d", chunk); break; } if(IsLoading(m_State) && m_CurEventID > 0) @@ -1115,8 +1122,8 @@ ReplayStatus WrappedID3D11DeviceContext::ReplayLog(CaptureState readType, uint32 m_DoStateVerify = true; - D3D11Chunk header = ser.ReadChunk(); - RDCASSERTEQUAL(header, D3D11Chunk::CaptureBegin); + SystemChunk header = ser.ReadChunk(); + RDCASSERTEQUAL(header, SystemChunk::CaptureBegin); Serialise_BeginCaptureFrame(ser, !partial); @@ -1180,7 +1187,7 @@ ReplayStatus WrappedID3D11DeviceContext::ReplayLog(CaptureState readType, uint32 RenderDoc::Inst().SetProgress( FrameEventsRead, float(m_CurChunkOffset - startOffset) / float(ser.GetReader()->GetSize())); - if(chunktype == D3D11Chunk::CaptureEnd) + if((SystemChunk)chunktype == SystemChunk::CaptureEnd) break; m_CurEventID++; diff --git a/renderdoc/driver/d3d11/d3d11_device.cpp b/renderdoc/driver/d3d11/d3d11_device.cpp index 2c4ec816d..de94edc23 100644 --- a/renderdoc/driver/d3d11/d3d11_device.cpp +++ b/renderdoc/driver/d3d11/d3d11_device.cpp @@ -855,7 +855,6 @@ bool WrappedID3D11Device::ProcessChunk(ReadSerialiser &ser, D3D11Chunk context) IID nul; return Serialise_OpenSharedResource(ser, 0, nul, NULL); } - case D3D11Chunk::CaptureScope: return Serialise_CaptureScope(ser); case D3D11Chunk::SetShaderDebugPath: return Serialise_SetShaderDebugPath(ser, NULL, NULL); default: { @@ -877,6 +876,10 @@ bool WrappedID3D11Device::ProcessChunk(ReadSerialiser &ser, D3D11Chunk context) { return Serialise_InitialState(ser, ResourceId(), NULL); } + else if(system == SystemChunk::CaptureScope) + { + return Serialise_CaptureScope(ser); + } else if(system < SystemChunk::FirstDriverChunk) { RDCERR("Unexpected system chunk in capture data: %u", system); @@ -1009,7 +1012,7 @@ ReplayStatus WrappedID3D11Device::ReadLogInitialisation(RDCFile *rdc, bool store RenderDoc::Inst().SetProgress(FileInitialRead, float(offsetEnd) / float(reader->GetSize())); - if(context == D3D11Chunk::CaptureScope) + if((SystemChunk)context == SystemChunk::CaptureScope) { m_FrameRecord.frameInfo.fileOffset = offsetStart; @@ -1031,7 +1034,7 @@ ReplayStatus WrappedID3D11Device::ReadLogInitialisation(RDCFile *rdc, bool store chunkInfos[context].totalsize += offsetEnd - offsetStart; chunkInfos[context].count++; - if(context == D3D11Chunk::CaptureScope || reader->IsErrored() || reader->AtEnd()) + if((SystemChunk)context == SystemChunk::CaptureScope || reader->IsErrored() || reader->AtEnd()) break; } @@ -1702,7 +1705,7 @@ bool WrappedID3D11Device::EndFrameCapture(void *dev, void *wnd) { // remember to update this estimated chunk length if you add more parameters - SCOPED_SERIALISE_CHUNK(D3D11Chunk::CaptureScope, 16); + SCOPED_SERIALISE_CHUNK(SystemChunk::CaptureScope, 16); Serialise_CaptureScope(ser); } diff --git a/renderdoc/driver/d3d11/d3d11_device.h b/renderdoc/driver/d3d11/d3d11_device.h index a6a0e2fa4..d80849663 100644 --- a/renderdoc/driver/d3d11/d3d11_device.h +++ b/renderdoc/driver/d3d11/d3d11_device.h @@ -62,7 +62,7 @@ struct D3D11InitParams D3D_FEATURE_LEVEL FeatureLevels[16]; // check if a frame capture section version is supported - static const uint64_t CurrentVersion = 0xC; + static const uint64_t CurrentVersion = 0xD; static bool IsSupportedVersion(uint64_t ver); }; diff --git a/renderdoc/driver/d3d11/d3d11_stringise.cpp b/renderdoc/driver/d3d11/d3d11_stringise.cpp index 100a772b4..802844771 100644 --- a/renderdoc/driver/d3d11/d3d11_stringise.cpp +++ b/renderdoc/driver/d3d11/d3d11_stringise.cpp @@ -59,7 +59,7 @@ std::string DoStringise(const D3D11ResourceType &el) template <> std::string DoStringise(const D3D11Chunk &el) { - RDCCOMPILE_ASSERT((uint32_t)D3D11Chunk::Max == 1131, "Chunks changed without updating names"); + RDCCOMPILE_ASSERT((uint32_t)D3D11Chunk::Max == 1128, "Chunks changed without updating names"); BEGIN_ENUM_STRINGISE(D3D11Chunk) { @@ -98,7 +98,6 @@ std::string DoStringise(const D3D11Chunk &el) STRINGISE_ENUM_CLASS_NAMED(CreateDeferredContext, "ID3D11Device::CreateDeferredContext"); STRINGISE_ENUM_CLASS_NAMED(SetExceptionMode, "ID3D11Device::SetExceptionMode"); STRINGISE_ENUM_CLASS_NAMED(OpenSharedResource, "ID3D11Device::OpenSharedResource"); - STRINGISE_ENUM_CLASS_NAMED(CaptureScope, "Frame Capture Metadata"); STRINGISE_ENUM_CLASS_NAMED(IASetInputLayout, "ID3D11DeviceContext::IASetInputLayout"); STRINGISE_ENUM_CLASS_NAMED(IASetVertexBuffers, "ID3D11DeviceContext::IASetVertexBuffers"); STRINGISE_ENUM_CLASS_NAMED(IASetIndexBuffer, "ID3D11DeviceContext::IASetIndexBuffer"); @@ -193,8 +192,6 @@ std::string DoStringise(const D3D11Chunk &el) STRINGISE_ENUM_CLASS_NAMED(PushMarker, "Push Debug Region"); STRINGISE_ENUM_CLASS_NAMED(SetMarker, "Set Marker"); STRINGISE_ENUM_CLASS_NAMED(PopMarker, "Pop Debug Region"); - STRINGISE_ENUM_CLASS_NAMED(CaptureBegin, "Beginning of Capture"); - STRINGISE_ENUM_CLASS_NAMED(CaptureEnd, "End of Capture"); STRINGISE_ENUM_CLASS_NAMED(SetShaderDebugPath, "SetShaderDebugPath"); STRINGISE_ENUM_CLASS_NAMED(DiscardResource, "ID3D11DeviceContext1::DiscardResource"); STRINGISE_ENUM_CLASS_NAMED(DiscardView, "ID3D11DeviceContext1::DiscardView"); diff --git a/renderdoc/driver/d3d12/d3d12_commands.cpp b/renderdoc/driver/d3d12/d3d12_commands.cpp index 14fa6fbd0..35c5578b1 100644 --- a/renderdoc/driver/d3d12/d3d12_commands.cpp +++ b/renderdoc/driver/d3d12/d3d12_commands.cpp @@ -456,31 +456,39 @@ bool WrappedID3D12CommandQueue::ProcessChunk(ReadSerialiser &ser, D3D12Chunk chu case D3D12Chunk::Resource_WriteToSubresource: ret = m_pDevice->Serialise_WriteToSubresource(ser, NULL, 0, NULL, NULL, 0, 0); break; - - case D3D12Chunk::CaptureEnd: + default: { - SERIALISE_ELEMENT_LOCAL(PresentedImage, ResourceId()); + SystemChunk system = (SystemChunk)chunk; - SERIALISE_CHECK_READ_ERRORS(); - - m_BackbufferID = PresentedImage; - - if(IsLoading(m_State)) + if(system == SystemChunk::CaptureEnd) { - m_Cmd.AddEvent(); + SERIALISE_ELEMENT_LOCAL(PresentedImage, ResourceId()); - DrawcallDescription draw; - draw.name = "Present()"; - draw.flags |= DrawFlags::Present; + SERIALISE_CHECK_READ_ERRORS(); - draw.copyDestination = m_BackbufferID; + m_BackbufferID = PresentedImage; - m_Cmd.AddDrawcall(draw, true); + if(IsLoading(m_State)) + { + m_Cmd.AddEvent(); + + DrawcallDescription draw; + draw.name = "Present()"; + draw.flags |= DrawFlags::Present; + + draw.copyDestination = m_BackbufferID; + + m_Cmd.AddDrawcall(draw, true); + } + + ret = true; } - - ret = true; + else + { + RDCERR("Unrecognised Chunk type %s", ToStr(chunk).c_str()); + } + break; } - default: RDCERR("Unrecognised Chunk type %s", ToStr(chunk).c_str()); break; } if(IsLoading(m_State)) @@ -538,8 +546,8 @@ ReplayStatus WrappedID3D12CommandQueue::ReplayLog(CaptureState readType, uint32_ m_Cmd.m_StructuredFile = m_StructuredFile; - D3D12Chunk header = ser.ReadChunk(); - RDCASSERTEQUAL(header, D3D12Chunk::CaptureBegin); + SystemChunk header = ser.ReadChunk(); + RDCASSERTEQUAL(header, SystemChunk::CaptureBegin); m_pDevice->Serialise_BeginCaptureFrame(ser, !partial); @@ -625,9 +633,7 @@ ReplayStatus WrappedID3D12CommandQueue::ReplayLog(CaptureState readType, uint32_ RenderDoc::Inst().SetProgress(FileInitialRead, float(m_Cmd.m_CurChunkOffset - startOffset) / float(ser.GetReader()->GetSize())); - // for now just abort after capture scope. Really we'd need to support multiple frames - // but for now this will do. - if(context == D3D12Chunk::CaptureEnd) + if((SystemChunk)context == SystemChunk::CaptureEnd) break; // break out if we were only executing one event diff --git a/renderdoc/driver/d3d12/d3d12_common.h b/renderdoc/driver/d3d12/d3d12_common.h index 077853680..57cc28af7 100644 --- a/renderdoc/driver/d3d12/d3d12_common.h +++ b/renderdoc/driver/d3d12/d3d12_common.h @@ -457,10 +457,7 @@ DECLARE_DESERIALISE_TYPE(D3D12_COMMAND_SIGNATURE_DESC); enum class D3D12Chunk : uint32_t { - CaptureBegin = (uint32_t)SystemChunk::FirstDriverChunk, - CaptureEnd, - CaptureScope, - SetName, + SetName = (uint32_t)SystemChunk::FirstDriverChunk, PushMarker, SetMarker, PopMarker, diff --git a/renderdoc/driver/d3d12/d3d12_device.cpp b/renderdoc/driver/d3d12/d3d12_device.cpp index c787352e4..c79670a26 100644 --- a/renderdoc/driver/d3d12/d3d12_device.cpp +++ b/renderdoc/driver/d3d12/d3d12_device.cpp @@ -1215,7 +1215,7 @@ void WrappedID3D12Device::EndCaptureFrame(ID3D12Resource *presentImage) { WriteSerialiser &ser = GetThreadSerialiser(); ser.SetDrawChunk(); - SCOPED_SERIALISE_CHUNK(D3D12Chunk::CaptureEnd); + SCOPED_SERIALISE_CHUNK(SystemChunk::CaptureEnd); SERIALISE_ELEMENT_LOCAL(PresentedBackbuffer, GetResID(presentImage)); @@ -1275,7 +1275,7 @@ void WrappedID3D12Device::StartFrameCapture(void *dev, void *wnd) { CACHE_THREAD_SERIALISER(); - SCOPED_SERIALISE_CHUNK(D3D12Chunk::CaptureBegin); + SCOPED_SERIALISE_CHUNK(SystemChunk::CaptureBegin); Serialise_BeginCaptureFrame(ser, false); @@ -1609,7 +1609,7 @@ bool WrappedID3D12Device::EndFrameCapture(void *dev, void *wnd) GetResourceManager()->Serialise_InitialContentsNeeded(ser); { - SCOPED_SERIALISE_CHUNK(D3D12Chunk::CaptureScope, 16); + SCOPED_SERIALISE_CHUNK(SystemChunk::CaptureScope, 16); Serialise_CaptureScope(ser); } @@ -2310,7 +2310,6 @@ bool WrappedID3D12Device::ProcessChunk(ReadSerialiser &ser, D3D12Chunk context) case D3D12Chunk::CreateSwapBuffer: return Serialise_WrapSwapchainBuffer(ser, NULL, NULL, 0, NULL); break; - case D3D12Chunk::CaptureScope: return Serialise_CaptureScope(ser); break; default: { SystemChunk system = (SystemChunk)context; @@ -2331,6 +2330,10 @@ bool WrappedID3D12Device::ProcessChunk(ReadSerialiser &ser, D3D12Chunk context) { return GetResourceManager()->Serialise_InitialState(ser, ResourceId(), NULL); } + else if(system == SystemChunk::CaptureScope) + { + return Serialise_CaptureScope(ser); + } else if(system < SystemChunk::FirstDriverChunk) { RDCERR("Unexpected system chunk in capture data: %u", system); @@ -2453,7 +2456,7 @@ ReplayStatus WrappedID3D12Device::ReadLogInitialisation(RDCFile *rdc, bool store RenderDoc::Inst().SetProgress(FileInitialRead, float(offsetEnd) / float(reader->GetSize())); - if(context == D3D12Chunk::CaptureScope) + if((SystemChunk)context == SystemChunk::CaptureScope) { m_FrameRecord.frameInfo.fileOffset = offsetStart; @@ -2475,7 +2478,7 @@ ReplayStatus WrappedID3D12Device::ReadLogInitialisation(RDCFile *rdc, bool store chunkInfos[context].totalsize += offsetEnd - offsetStart; chunkInfos[context].count++; - if(context == D3D12Chunk::CaptureScope || reader->IsErrored() || reader->AtEnd()) + if((SystemChunk)context == SystemChunk::CaptureScope || reader->IsErrored() || reader->AtEnd()) break; } diff --git a/renderdoc/driver/d3d12/d3d12_device.h b/renderdoc/driver/d3d12/d3d12_device.h index 0ec3dadea..4aa16920a 100644 --- a/renderdoc/driver/d3d12/d3d12_device.h +++ b/renderdoc/driver/d3d12/d3d12_device.h @@ -47,7 +47,7 @@ struct D3D12InitParams D3D_FEATURE_LEVEL MinimumFeatureLevel; // check if a frame capture section version is supported - static const uint64_t CurrentVersion = 0x2; + static const uint64_t CurrentVersion = 0x3; static bool IsSupportedVersion(uint64_t ver); }; diff --git a/renderdoc/driver/d3d12/d3d12_stringise.cpp b/renderdoc/driver/d3d12/d3d12_stringise.cpp index 77c91ed69..e06f5f4ad 100644 --- a/renderdoc/driver/d3d12/d3d12_stringise.cpp +++ b/renderdoc/driver/d3d12/d3d12_stringise.cpp @@ -28,13 +28,10 @@ template <> std::string DoStringise(const D3D12Chunk &el) { - RDCCOMPILE_ASSERT((uint32_t)D3D12Chunk::Max == 1085, "Chunks changed without updating names"); + RDCCOMPILE_ASSERT((uint32_t)D3D12Chunk::Max == 1082, "Chunks changed without updating names"); BEGIN_ENUM_STRINGISE(D3D12Chunk) { - STRINGISE_ENUM_CLASS_NAMED(CaptureBegin, "Beginning of Capture"); - STRINGISE_ENUM_CLASS_NAMED(CaptureEnd, "End of Capture"); - STRINGISE_ENUM_CLASS_NAMED(CaptureScope, "Frame Capture Metadata"); STRINGISE_ENUM_CLASS_NAMED(SetName, "ID3D12Resource::SetName"); STRINGISE_ENUM_CLASS_NAMED(PushMarker, "Push Debug Region"); STRINGISE_ENUM_CLASS_NAMED(SetMarker, "Set Marker"); diff --git a/renderdoc/driver/gl/gl_common.h b/renderdoc/driver/gl/gl_common.h index 237a95396..ca378c7f9 100644 --- a/renderdoc/driver/gl/gl_common.h +++ b/renderdoc/driver/gl/gl_common.h @@ -566,9 +566,7 @@ enum class GLChunk : uint32_t { DeviceInitialisation = (uint32_t)SystemChunk::FirstDriverChunk, - CaptureBegin, - CaptureEnd, - CaptureScope, + MakeContextCurrent, vrapi_CreateTextureSwapChain, vrapi_CreateTextureSwapChain2, diff --git a/renderdoc/driver/gl/gl_driver.cpp b/renderdoc/driver/gl/gl_driver.cpp index fee36bab5..65d282e33 100644 --- a/renderdoc/driver/gl/gl_driver.cpp +++ b/renderdoc/driver/gl/gl_driver.cpp @@ -1138,7 +1138,7 @@ void WrappedOpenGL::ActivateContext(GLWindowingData winData) } USE_SCRATCH_SERIALISER(); - SCOPED_SERIALISE_CHUNK(GLChunk::CaptureBegin); + SCOPED_SERIALISE_CHUNK(GLChunk::MakeContextCurrent); Serialise_BeginCaptureFrame(ser); m_ContextRecord->AddChunk(scope.Get()); } @@ -2466,7 +2466,7 @@ bool WrappedOpenGL::EndFrameCapture(void *dev, void *wnd) GetResourceManager()->Serialise_InitialContentsNeeded(ser); { - SCOPED_SERIALISE_CHUNK(GLChunk::CaptureScope, 16); + SCOPED_SERIALISE_CHUNK(SystemChunk::CaptureScope, 16); Serialise_CaptureScope(ser); } @@ -2773,7 +2773,7 @@ void WrappedOpenGL::ContextEndFrame() { USE_SCRATCH_SERIALISER(); ser.SetDrawChunk(); - SCOPED_SERIALISE_CHUNK(GLChunk::CaptureEnd); + SCOPED_SERIALISE_CHUNK(SystemChunk::CaptureEnd); m_ContextRecord->AddChunk(scope.Get()); } @@ -2869,7 +2869,7 @@ bool WrappedOpenGL::Serialise_BeginCaptureFrame(SerialiserType &ser) void WrappedOpenGL::BeginCaptureFrame() { USE_SCRATCH_SERIALISER(); - SCOPED_SERIALISE_CHUNK(GLChunk::CaptureBegin); + SCOPED_SERIALISE_CHUNK(SystemChunk::CaptureBegin); Serialise_BeginCaptureFrame(ser); @@ -3131,7 +3131,7 @@ ReplayStatus WrappedOpenGL::ReadLogInitialisation(RDCFile *rdc, bool storeStruct RenderDoc::Inst().SetProgress(FileInitialRead, float(offsetEnd) / float(reader->GetSize())); - if(context == GLChunk::CaptureScope) + if((SystemChunk)context == SystemChunk::CaptureScope) { m_FrameRecord.frameInfo.fileOffset = offsetStart; @@ -3152,7 +3152,7 @@ ReplayStatus WrappedOpenGL::ReadLogInitialisation(RDCFile *rdc, bool storeStruct chunkInfos[context].totalsize += offsetEnd - offsetStart; chunkInfos[context].count++; - if(context == GLChunk::CaptureScope || reader->IsErrored() || reader->AtEnd()) + if((SystemChunk)context == SystemChunk::CaptureScope || reader->IsErrored() || reader->AtEnd()) break; } @@ -3234,6 +3234,27 @@ bool WrappedOpenGL::ProcessChunk(ReadSerialiser &ser, GLChunk chunk) return GetResourceManager()->Serialise_InitialState(ser, ResourceId(), GLResource(MakeNullResource)); } + else if(system == SystemChunk::CaptureScope) + { + return Serialise_CaptureScope(ser); + } + else if(system == SystemChunk::CaptureEnd) + { + if(IsLoading(m_State)) + { + AddEvent(); + + DrawcallDescription draw; + draw.name = "SwapBuffers()"; + draw.flags |= DrawFlags::Present; + + draw.copyDestination = GetResourceManager()->GetOriginalID( + GetResourceManager()->GetID(TextureRes(GetCtx(), m_FakeBB_Color))); + + AddDrawcall(draw, true); + } + return true; + } else if(system < SystemChunk::FirstDriverChunk) { RDCERR("Unexpected system chunk in capture data: %u", system); @@ -4294,6 +4315,10 @@ bool WrappedOpenGL::ProcessChunk(ReadSerialiser &ser, GLChunk chunk) // nothing to do, these chunks are just markers return true; + case GLChunk::MakeContextCurrent: + // re-use the serialisation for beginning of the frame + return Serialise_BeginCaptureFrame(ser); + // these functions are not currently serialised - they do nothing on replay and are not // serialised for information (it would be harmless and perhaps useful for the user to see // where and how they're called). @@ -4613,30 +4638,6 @@ bool WrappedOpenGL::ProcessChunk(ReadSerialiser &ser, GLChunk chunk) RDCERR("Unexpected chunk, or missing case for processing! Skipping..."); ser.SkipCurrentChunk(); return false; - - case GLChunk::CaptureScope: return Serialise_CaptureScope(ser); - case GLChunk::CaptureBegin: - // normally this would be handled as a special case when we start processing the frame, - // but it can be emitted mid-frame if MakeCurrent is called on a different context. - // when processed here, we always want to apply the contents - return Serialise_BeginCaptureFrame(ser); - case GLChunk::CaptureEnd: - { - if(IsLoading(m_State)) - { - AddEvent(); - - DrawcallDescription draw; - draw.name = "SwapBuffers()"; - draw.flags |= DrawFlags::Present; - - draw.copyDestination = GetResourceManager()->GetOriginalID( - GetResourceManager()->GetID(TextureRes(GetCtx(), m_FakeBB_Color))); - - AddDrawcall(draw, true); - } - return true; - } } return false; @@ -4663,8 +4664,8 @@ ReplayStatus WrappedOpenGL::ContextReplayLog(CaptureState readType, uint32_t sta m_StructuredFile = &ser.GetStructuredFile(); } - GLChunk header = ser.ReadChunk(); - RDCASSERTEQUAL(header, GLChunk::CaptureBegin); + SystemChunk header = ser.ReadChunk(); + RDCASSERTEQUAL(header, SystemChunk::CaptureBegin); if(IsActiveReplaying(m_State) && !partial) { @@ -4763,7 +4764,7 @@ ReplayStatus WrappedOpenGL::ContextReplayLog(CaptureState readType, uint32_t sta RenderDoc::Inst().SetProgress( FileInitialRead, float(m_CurChunkOffset - startOffset) / float(ser.GetReader()->GetSize())); - if(chunktype == GLChunk::CaptureEnd) + if((SystemChunk)chunktype == SystemChunk::CaptureEnd) break; m_CurEventID++; diff --git a/renderdoc/driver/gl/gl_driver.h b/renderdoc/driver/gl/gl_driver.h index 6dbd07175..bf054647d 100644 --- a/renderdoc/driver/gl/gl_driver.h +++ b/renderdoc/driver/gl/gl_driver.h @@ -53,7 +53,7 @@ struct GLInitParams uint32_t height; // check if a frame capture section version is supported - static const uint64_t CurrentVersion = 0x17; + static const uint64_t CurrentVersion = 0x18; static bool IsSupportedVersion(uint64_t ver); }; diff --git a/renderdoc/driver/gl/gl_stringise.cpp b/renderdoc/driver/gl/gl_stringise.cpp index a2429cf55..d15697466 100644 --- a/renderdoc/driver/gl/gl_stringise.cpp +++ b/renderdoc/driver/gl/gl_stringise.cpp @@ -32,9 +32,8 @@ std::string DoStringise(const GLChunk &el) BEGIN_ENUM_STRINGISE(GLChunk) { STRINGISE_ENUM_CLASS(DeviceInitialisation); - STRINGISE_ENUM_CLASS(CaptureBegin); - STRINGISE_ENUM_CLASS(CaptureEnd); - STRINGISE_ENUM_CLASS(CaptureScope); + + STRINGISE_ENUM_CLASS_NAMED(MakeContextCurrent, "MakeContextCurrent"); STRINGISE_ENUM_CLASS(vrapi_CreateTextureSwapChain); STRINGISE_ENUM_CLASS(vrapi_CreateTextureSwapChain2); diff --git a/renderdoc/driver/vulkan/vk_common.h b/renderdoc/driver/vulkan/vk_common.h index ed6131acc..08a61ba0e 100644 --- a/renderdoc/driver/vulkan/vk_common.h +++ b/renderdoc/driver/vulkan/vk_common.h @@ -379,9 +379,6 @@ enum class VulkanChunk : uint32_t SetShaderDebugPath, vkRegisterDeviceEventEXT, vkRegisterDisplayEventEXT, - CaptureScope, - CaptureBegin, - CaptureEnd, Max, }; diff --git a/renderdoc/driver/vulkan/vk_core.cpp b/renderdoc/driver/vulkan/vk_core.cpp index c0ee917e9..2e7444bd3 100644 --- a/renderdoc/driver/vulkan/vk_core.cpp +++ b/renderdoc/driver/vulkan/vk_core.cpp @@ -791,7 +791,7 @@ void WrappedVulkan::EndCaptureFrame(VkImage presentImage) { CACHE_THREAD_SERIALISER(); ser.SetDrawChunk(); - SCOPED_SERIALISE_CHUNK(VulkanChunk::CaptureEnd); + SCOPED_SERIALISE_CHUNK(SystemChunk::CaptureEnd); SERIALISE_ELEMENT_LOCAL(PresentedImage, GetResID(presentImage)); @@ -910,7 +910,7 @@ void WrappedVulkan::StartFrameCapture(void *dev, void *wnd) { CACHE_THREAD_SERIALISER(); - SCOPED_SERIALISE_CHUNK(VulkanChunk::CaptureBegin); + SCOPED_SERIALISE_CHUNK(SystemChunk::CaptureBegin); Serialise_BeginCaptureFrame(ser); @@ -1338,7 +1338,7 @@ bool WrappedVulkan::EndFrameCapture(void *dev, void *wnd) GetResourceManager()->Serialise_InitialContentsNeeded(ser); { - SCOPED_SERIALISE_CHUNK(VulkanChunk::CaptureScope, 16); + SCOPED_SERIALISE_CHUNK(SystemChunk::CaptureScope, 16); Serialise_CaptureScope(ser); } @@ -1498,7 +1498,7 @@ ReplayStatus WrappedVulkan::ReadLogInitialisation(RDCFile *rdc, bool storeStruct RenderDoc::Inst().SetProgress(FileInitialRead, float(offsetEnd) / float(reader->GetSize())); - if(context == VulkanChunk::CaptureScope) + if((SystemChunk)context == SystemChunk::CaptureScope) { m_FrameRecord.frameInfo.fileOffset = offsetStart; @@ -1517,7 +1517,7 @@ ReplayStatus WrappedVulkan::ReadLogInitialisation(RDCFile *rdc, bool storeStruct chunkInfos[context].totalsize += offsetEnd - offsetStart; chunkInfos[context].count++; - if(context == VulkanChunk::CaptureScope || reader->IsErrored() || reader->AtEnd()) + if((SystemChunk)context == SystemChunk::CaptureScope || reader->IsErrored() || reader->AtEnd()) break; } @@ -1582,8 +1582,8 @@ ReplayStatus WrappedVulkan::ContextReplayLog(CaptureState readType, uint32_t sta m_StructuredFile = &ser.GetStructuredFile(); } - VulkanChunk header = ser.ReadChunk(); - RDCASSERTEQUAL(header, VulkanChunk::CaptureBegin); + SystemChunk header = ser.ReadChunk(); + RDCASSERTEQUAL(header, SystemChunk::CaptureBegin); if(partial) ser.SkipCurrentChunk(); @@ -1672,7 +1672,7 @@ ReplayStatus WrappedVulkan::ContextReplayLog(CaptureState readType, uint32_t sta RenderDoc::Inst().SetProgress( FileInitialRead, float(m_CurChunkOffset - startOffset) / float(ser.GetReader()->GetSize())); - if(chunktype == VulkanChunk::CaptureEnd) + if((SystemChunk)chunktype == SystemChunk::CaptureEnd) break; // break out if we were only executing one event @@ -2159,27 +2159,6 @@ bool WrappedVulkan::ProcessChunk(ReadSerialiser &ser, VulkanChunk chunk) return Serialise_vkCreateSwapchainKHR(ser, VK_NULL_HANDLE, NULL, NULL, NULL); break; - case VulkanChunk::CaptureScope: return Serialise_CaptureScope(ser); break; - case VulkanChunk::CaptureEnd: - { - SERIALISE_ELEMENT_LOCAL(PresentedImage, ResourceId()); - - SERIALISE_CHECK_READ_ERRORS(); - - if(IsLoading(m_State)) - { - AddEvent(); - - DrawcallDescription draw; - draw.name = "vkQueuePresentKHR()"; - draw.flags |= DrawFlags::Present; - - draw.copyDestination = PresentedImage; - - AddDrawcall(draw, true); - } - break; - } default: { SystemChunk system = (SystemChunk)chunk; @@ -2202,6 +2181,31 @@ bool WrappedVulkan::ProcessChunk(ReadSerialiser &ser, VulkanChunk chunk) { return Serialise_InitialState(ser, ResourceId(), NULL); } + else if(system == SystemChunk::CaptureScope) + { + return Serialise_CaptureScope(ser); + } + else if(system == SystemChunk::CaptureEnd) + { + SERIALISE_ELEMENT_LOCAL(PresentedImage, ResourceId()); + + SERIALISE_CHECK_READ_ERRORS(); + + if(IsLoading(m_State)) + { + AddEvent(); + + DrawcallDescription draw; + draw.name = "vkQueuePresentKHR()"; + draw.flags |= DrawFlags::Present; + + draw.copyDestination = PresentedImage; + + AddDrawcall(draw, true); + } + + return true; + } else if(system < SystemChunk::FirstDriverChunk) { RDCERR("Unexpected system chunk in capture data: %u", system); diff --git a/renderdoc/driver/vulkan/vk_core.h b/renderdoc/driver/vulkan/vk_core.h index febdbdec4..d805538f0 100644 --- a/renderdoc/driver/vulkan/vk_core.h +++ b/renderdoc/driver/vulkan/vk_core.h @@ -52,7 +52,7 @@ struct VkInitParams uint32_t GetSerialiseSize(); // check if a frame capture section version is supported - static const uint64_t CurrentVersion = 0x8; + static const uint64_t CurrentVersion = 0x9; static bool IsSupportedVersion(uint64_t ver); }; diff --git a/renderdoc/driver/vulkan/vk_stringise.cpp b/renderdoc/driver/vulkan/vk_stringise.cpp index e48ff5b43..75dcd6706 100644 --- a/renderdoc/driver/vulkan/vk_stringise.cpp +++ b/renderdoc/driver/vulkan/vk_stringise.cpp @@ -28,7 +28,7 @@ template <> std::string DoStringise(const VulkanChunk &el) { - RDCCOMPILE_ASSERT((uint32_t)VulkanChunk::Max == 1100, "Chunks changed without updating names"); + RDCCOMPILE_ASSERT((uint32_t)VulkanChunk::Max == 1097, "Chunks changed without updating names"); BEGIN_ENUM_STRINGISE(VulkanChunk) { @@ -129,9 +129,6 @@ std::string DoStringise(const VulkanChunk &el) STRINGISE_ENUM_CLASS(SetShaderDebugPath); STRINGISE_ENUM_CLASS(vkRegisterDeviceEventEXT); STRINGISE_ENUM_CLASS(vkRegisterDisplayEventEXT); - STRINGISE_ENUM_CLASS_NAMED(CaptureScope, "Frame Capture Metadata"); - STRINGISE_ENUM_CLASS_NAMED(CaptureBegin, "Beginning of Capture"); - STRINGISE_ENUM_CLASS_NAMED(CaptureEnd, "End of Capture"); STRINGISE_ENUM_CLASS_NAMED(Max, "Max Chunk"); } END_ENUM_STRINGISE()