From a654b642ef772dfcf2343fcc6191e721f74e96e4 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 7 Jun 2019 00:22:00 +0200 Subject: [PATCH] Compress frame images to ETC1 before sending. --- client/TracyProfiler.cpp | 14 +++++++++++--- client/TracyProfiler.hpp | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 137806af..07492fab 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -48,6 +48,7 @@ #include "../common/tracy_lz4.hpp" #include "tracy_rpmalloc.hpp" #include "TracyCallstack.hpp" +#include "TracyEtc1.hpp" #include "TracyScoped.hpp" #include "TracyProfiler.hpp" #include "TracyThread.hpp" @@ -1451,10 +1452,18 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token ) tracy_free( (void*)ptr ); break; case QueueType::FrameImage: + { ptr = MemRead( &item->frameImage.image ); - SendLongString( ptr, (const char*)ptr, QueueType::FrameImageData ); + const auto w = MemRead( &item->frameImage.w ); + const auto h = MemRead( &item->frameImage.h ); + const auto csz = w * h / 2; + auto c = (char*)tracy_malloc( csz ); + CompressImageEtc1( (const char*)ptr, c, w, h ); tracy_free( (void*)ptr ); + SendLongString( ptr, (const char*)c, csz, QueueType::FrameImageData ); + tracy_free( (void*)c ); break; + } default: assert( false ); break; @@ -1576,7 +1585,7 @@ void Profiler::SendString( uint64_t str, const char* ptr, QueueType type ) AppendDataUnsafe( ptr, l16 ); } -void Profiler::SendLongString( uint64_t str, const char* ptr, QueueType type ) +void Profiler::SendLongString( uint64_t str, const char* ptr, size_t len, QueueType type ) { assert( type == QueueType::FrameImageData ); @@ -1584,7 +1593,6 @@ void Profiler::SendLongString( uint64_t str, const char* ptr, QueueType type ) MemWrite( &item.hdr.type, type ); MemWrite( &item.stringTransfer.ptr, str ); - auto len = strlen( ptr ); assert( len <= std::numeric_limits::max() ); assert( QueueDataSize[(int)type] + sizeof( uint32_t ) + len <= TargetFrameSize ); auto l32 = uint32_t( len ); diff --git a/client/TracyProfiler.hpp b/client/TracyProfiler.hpp index 38c7dabb..3018836f 100644 --- a/client/TracyProfiler.hpp +++ b/client/TracyProfiler.hpp @@ -441,7 +441,7 @@ private: bool SendData( const char* data, size_t len ); void SendString( uint64_t ptr, const char* str, QueueType type ); - void SendLongString( uint64_t ptr, const char* str, QueueType type ); + void SendLongString( uint64_t ptr, const char* str, size_t len, QueueType type ); void SendSourceLocation( uint64_t ptr ); void SendSourceLocationPayload( uint64_t ptr ); void SendCallstackPayload( uint64_t ptr );