diff --git a/renderdoc/api/replay/renderdoc_replay.h b/renderdoc/api/replay/renderdoc_replay.h index 97e5efd13..fc191b3c3 100644 --- a/renderdoc/api/replay/renderdoc_replay.h +++ b/renderdoc/api/replay/renderdoc_replay.h @@ -1103,6 +1103,13 @@ and construction of files. )"); struct ICaptureAccess { + DOCUMENT(R"(Retrieve the total number of available sections. + +:return: The number of sections in the capture +:rtype: ``int``. +)"); + virtual int GetSectionCount() = 0; + DOCUMENT(R"(Locate the index of a section by its name. Returns ``-1`` if the section is not found. This index should not be cached, as writing sections could re-order the indices. diff --git a/renderdoc/core/remote_server.cpp b/renderdoc/core/remote_server.cpp index 37777ea4a..c6e5148d5 100644 --- a/renderdoc/core/remote_server.cpp +++ b/renderdoc/core/remote_server.cpp @@ -35,7 +35,7 @@ #include "strings/string_utils.h" #include "replay_proxy.h" -static const uint32_t RemoteServerProtocolVersion = 2; +static const uint32_t RemoteServerProtocolVersion = 3; enum RemoteServerPacket { @@ -61,6 +61,7 @@ enum RemoteServerPacket eRemoteServer_ListDir, eRemoteServer_ExecuteAndInject, eRemoteServer_ShutdownServer, + eRemoteServer_GetSectionCount, eRemoteServer_FindSectionByName, eRemoteServer_FindSectionByType, eRemoteServer_GetSectionProperties, @@ -559,6 +560,18 @@ static void ActiveRemoteClientThread(ClientThread *threadData) SERIALISE_ELEMENT(StackFrames); } } + else if(type == eRemoteServer_GetSectionCount) + { + reader.EndChunk(); + + int count = rdc ? rdc->NumSections() : 0; + + { + WRITE_DATA_SCOPE(); + SCOPED_SERIALISE_CHUNK(eRemoteServer_GetSectionCount); + SERIALISE_ELEMENT(count); + } + } else if(type == eRemoteServer_FindSectionByName) { std::string name; @@ -1408,6 +1421,37 @@ public: rend->Shutdown(); } + int GetSectionCount() + { + if(!Connected()) + return 0; + + { + WRITE_DATA_SCOPE(); + SCOPED_SERIALISE_CHUNK(eRemoteServer_GetSectionCount); + } + + int count = 0; + + { + READ_DATA_SCOPE(); + RemoteServerPacket type = ser.ReadChunk(); + + if(type == eRemoteServer_GetSectionCount) + { + SERIALISE_ELEMENT(count); + } + else + { + RDCERR("Unexpected response to GetSectionCount"); + } + + ser.EndChunk(); + } + + return count; + } + int FindSectionByName(const char *name) { if(!Connected()) diff --git a/renderdoc/replay/capture_file.cpp b/renderdoc/replay/capture_file.cpp index b4a0ce283..9e07b9c64 100644 --- a/renderdoc/replay/capture_file.cpp +++ b/renderdoc/replay/capture_file.cpp @@ -165,6 +165,7 @@ public: // ICaptureAccess + int GetSectionCount(); int FindSectionByName(const char *name); int FindSectionByType(SectionType type); SectionProperties GetSectionProperties(int index); @@ -603,6 +604,14 @@ Thumbnail CaptureFile::GetThumbnail(FileType type, uint32_t maxsize) return ret; } +int CaptureFile::GetSectionCount() +{ + if(!m_RDC) + return 0; + + return m_RDC->NumSections(); +} + int CaptureFile::FindSectionByName(const char *name) { if(!m_RDC)