1
0
mirror of https://github.com/wolfpld/tracy synced 2025-05-03 06:03:51 +00:00

Compress frame images to ETC1 before sending.

This commit is contained in:
Bartosz Taudul 2019-06-07 00:22:00 +02:00
parent aff3246f82
commit a654b642ef
2 changed files with 12 additions and 4 deletions

View File

@ -48,6 +48,7 @@
#include "../common/tracy_lz4.hpp" #include "../common/tracy_lz4.hpp"
#include "tracy_rpmalloc.hpp" #include "tracy_rpmalloc.hpp"
#include "TracyCallstack.hpp" #include "TracyCallstack.hpp"
#include "TracyEtc1.hpp"
#include "TracyScoped.hpp" #include "TracyScoped.hpp"
#include "TracyProfiler.hpp" #include "TracyProfiler.hpp"
#include "TracyThread.hpp" #include "TracyThread.hpp"
@ -1451,10 +1452,18 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
tracy_free( (void*)ptr ); tracy_free( (void*)ptr );
break; break;
case QueueType::FrameImage: case QueueType::FrameImage:
{
ptr = MemRead<uint64_t>( &item->frameImage.image ); ptr = MemRead<uint64_t>( &item->frameImage.image );
SendLongString( ptr, (const char*)ptr, QueueType::FrameImageData ); const auto w = MemRead<uint16_t>( &item->frameImage.w );
const auto h = MemRead<uint16_t>( &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 ); tracy_free( (void*)ptr );
SendLongString( ptr, (const char*)c, csz, QueueType::FrameImageData );
tracy_free( (void*)c );
break; break;
}
default: default:
assert( false ); assert( false );
break; break;
@ -1576,7 +1585,7 @@ void Profiler::SendString( uint64_t str, const char* ptr, QueueType type )
AppendDataUnsafe( ptr, l16 ); 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 ); 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.hdr.type, type );
MemWrite( &item.stringTransfer.ptr, str ); MemWrite( &item.stringTransfer.ptr, str );
auto len = strlen( ptr );
assert( len <= std::numeric_limits<uint32_t>::max() ); assert( len <= std::numeric_limits<uint32_t>::max() );
assert( QueueDataSize[(int)type] + sizeof( uint32_t ) + len <= TargetFrameSize ); assert( QueueDataSize[(int)type] + sizeof( uint32_t ) + len <= TargetFrameSize );
auto l32 = uint32_t( len ); auto l32 = uint32_t( len );

View File

@ -441,7 +441,7 @@ private:
bool SendData( const char* data, size_t len ); bool SendData( const char* data, size_t len );
void SendString( uint64_t ptr, const char* str, QueueType type ); 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 SendSourceLocation( uint64_t ptr );
void SendSourceLocationPayload( uint64_t ptr ); void SendSourceLocationPayload( uint64_t ptr );
void SendCallstackPayload( uint64_t ptr ); void SendCallstackPayload( uint64_t ptr );