diff --git a/qrenderdoc/Windows/Dialogs/LiveCapture.cpp b/qrenderdoc/Windows/Dialogs/LiveCapture.cpp index 80cf71f0d..7853d5cf6 100644 --- a/qrenderdoc/Windows/Dialogs/LiveCapture.cpp +++ b/qrenderdoc/Windows/Dialogs/LiveCapture.cpp @@ -673,11 +673,14 @@ QString LiveCapture::MakeText(Capture *cap) text += lit("\n") + cap->api; if(cap->frameNumber == ~0U) - text += tr("\nUser-defined Capture "); + text += tr("\nUser-defined Capture"); else - text += tr("\nFrame #%1 ").arg(cap->frameNumber); + text += tr("\nFrame #%1").arg(cap->frameNumber); - text += cap->timestamp.toString(lit("yyyy-MM-dd HH:mm:ss")); + if(cap->byteSize > 0) + text += QFormatStr(" (%1 MB)").arg(double(cap->byteSize) / 1000000.0, 0, 'f', 2); + + text += cap->timestamp.toString(lit("\nyyyy-MM-dd HH:mm:ss")); return text; } @@ -1045,6 +1048,7 @@ void LiveCapture::captureAdded(const NewCaptureData &newCapture) cap->timestamp = QDateTime(QDate(1970, 1, 1), QTime(0, 0, 0), Qt::UTC).addSecs(newCapture.timestamp).toLocalTime(); + cap->byteSize = newCapture.byteSize; cap->thumb = QImage(newCapture.thumbnail.data(), newCapture.thumbWidth, newCapture.thumbHeight, newCapture.thumbWidth * 3, QImage::Format_RGB888) diff --git a/qrenderdoc/Windows/Dialogs/LiveCapture.h b/qrenderdoc/Windows/Dialogs/LiveCapture.h index 510aeb03d..3a45e5e1f 100644 --- a/qrenderdoc/Windows/Dialogs/LiveCapture.h +++ b/qrenderdoc/Windows/Dialogs/LiveCapture.h @@ -103,6 +103,7 @@ private: QString api; QDateTime timestamp; uint32_t frameNumber; + uint64_t byteSize; QImage thumb; diff --git a/renderdoc/api/replay/control_types.h b/renderdoc/api/replay/control_types.h index 4d91b6de7..6b573a98e 100644 --- a/renderdoc/api/replay/control_types.h +++ b/renderdoc/api/replay/control_types.h @@ -468,6 +468,8 @@ struct NewCaptureData uint32_t frameNumber = 0; DOCUMENT("The time the capture was created, as a unix timestamp in UTC."); uint64_t timestamp = 0; + DOCUMENT("The size of the capture, in bytes."); + uint64_t byteSize = 0; DOCUMENT("The raw bytes that contain the capture thumbnail, as RGB8 data."); bytebuf thumbnail; DOCUMENT("The width of the image contained in :data:`thumbnail`."); diff --git a/renderdoc/core/target_control.cpp b/renderdoc/core/target_control.cpp index b6666cd67..7a44ab6ab 100644 --- a/renderdoc/core/target_control.cpp +++ b/renderdoc/core/target_control.cpp @@ -32,7 +32,7 @@ #include "replay/replay_driver.h" #include "serialise/serialiser.h" -static const uint32_t TargetControlProtocolVersion = 5; +static const uint32_t TargetControlProtocolVersion = 6; static bool IsProtocolVersionSupported(const uint32_t protocolVersion) { @@ -48,6 +48,10 @@ static bool IsProtocolVersionSupported(const uint32_t protocolVersion) if(protocolVersion == 4) return true; + // 5 -> 6 return byte size with new captures + if(protocolVersion == 5) + return true; + if(protocolVersion == TargetControlProtocolVersion) return true; @@ -232,6 +236,11 @@ void RenderDoc::TargetControlClientThread(uint32_t version, Network::Socket *cli { SERIALISE_ELEMENT(captures.back().frameNumber); } + if(version >= 6) + { + uint64_t byteSize = FileIO::GetFileSize(captures.back().path); + SERIALISE_ELEMENT(byteSize); + } } } else if(childprocs.size() != children.size()) @@ -755,6 +764,14 @@ public: { msg.newCapture.frameNumber = msg.newCapture.captureId + 1; } + if(m_Version >= 6) + { + SERIALISE_ELEMENT(msg.newCapture.byteSize).Named("byteSize"_lit); + } + else + { + msg.newCapture.byteSize = 0; + } } if(driver != RDCDriver::Unknown) @@ -762,9 +779,9 @@ public: msg.newCapture.local = FileIO::exists(msg.newCapture.path.c_str()); - RDCLOG("Got a new capture: %d (frame %u) (time %llu) %d byte thumbnail", - msg.newCapture.captureId, msg.newCapture.frameNumber, msg.newCapture.timestamp, - thumbnail.count()); + RDCLOG("Got a new capture: %d (frame %u) (%u bytes) (time %llu) %d byte thumbnail", + msg.newCapture.captureId, msg.newCapture.frameNumber, msg.newCapture.byteSize, + msg.newCapture.timestamp, thumbnail.count()); int w = 0; int h = 0; diff --git a/renderdoc/os/os_specific.h b/renderdoc/os/os_specific.h index b5f796d59..39867b27d 100644 --- a/renderdoc/os/os_specific.h +++ b/renderdoc/os/os_specific.h @@ -291,6 +291,7 @@ void GetExecutableFilename(rdcstr &selfName); void GetLibraryFilename(rdcstr &selfName); uint64_t GetModifiedTimestamp(const rdcstr &filename); +uint64_t GetFileSize(const rdcstr &filename); bool Copy(const char *from, const char *to, bool allowOverwrite); bool Move(const char *from, const char *to, bool allowOverwrite); diff --git a/renderdoc/os/posix/posix_stringio.cpp b/renderdoc/os/posix/posix_stringio.cpp index dbd28659a..a0db5799c 100644 --- a/renderdoc/os/posix/posix_stringio.cpp +++ b/renderdoc/os/posix/posix_stringio.cpp @@ -249,6 +249,19 @@ uint64_t GetModifiedTimestamp(const rdcstr &filename) return 0; } +uint64_t GetFileSize(const rdcstr &filename) +{ + struct ::stat st; + int res = stat(filename.c_str(), &st); + + if(res == 0) + { + return (uint64_t)st.st_size; + } + + return 0; +} + bool Copy(const char *from, const char *to, bool allowOverwrite) { if(from[0] == 0 || to[0] == 0) diff --git a/renderdoc/os/win32/win32_stringio.cpp b/renderdoc/os/win32/win32_stringio.cpp index 18771f8ef..abad26e0d 100644 --- a/renderdoc/os/win32/win32_stringio.cpp +++ b/renderdoc/os/win32/win32_stringio.cpp @@ -430,6 +430,21 @@ uint64_t GetModifiedTimestamp(const rdcstr &filename) return 0; } +uint64_t GetFileSize(const rdcstr &filename) +{ + rdcwstr wfn = StringFormat::UTF82Wide(filename); + + struct __stat64 st; + int res = _wstat64(wfn.c_str(), &st); + + if(res == 0) + { + return (uint64_t)st.st_size; + } + + return 0; +} + bool Copy(const char *from, const char *to, bool allowOverwrite) { rdcwstr wfrom = StringFormat::UTF82Wide(from); @@ -696,7 +711,7 @@ rdcstr logfile_readall(const char *filename) } else { - DWORD len = GetFileSize(h, NULL); + DWORD len = ::GetFileSize(h, NULL); if(len == INVALID_FILE_SIZE) {