diff --git a/server/TracyTextureCompression.cpp b/server/TracyTextureCompression.cpp index ebff4c70..5bb33e7b 100644 --- a/server/TracyTextureCompression.cpp +++ b/server/TracyTextureCompression.cpp @@ -21,7 +21,7 @@ TextureCompression::~TextureCompression() ZSTD_freeDCtx( m_dctx ); } -void TextureCompression::Pack( struct ZSTD_CCtx_s* ctx, char*& buf, size_t& bufsz, const char* image, uint32_t inBytes, uint32_t& csz ) const +uint32_t TextureCompression::Pack( struct ZSTD_CCtx_s* ctx, char*& buf, size_t& bufsz, const char* image, uint32_t inBytes ) const { const auto maxout = ZSTD_COMPRESSBOUND( inBytes ); if( bufsz < maxout ) @@ -31,21 +31,7 @@ void TextureCompression::Pack( struct ZSTD_CCtx_s* ctx, char*& buf, size_t& bufs buf = new char[maxout]; } assert( ctx ); - const auto outsz = ZSTD_compressCCtx( ctx, buf, maxout, image, inBytes, 3 ); - csz = uint32_t( outsz ); -} - -uint32_t TextureCompression::PackImpl( const char* image, uint32_t inBytes ) -{ - const auto maxout = ZSTD_COMPRESSBOUND( inBytes ); - if( m_bufSize < maxout ) - { - m_bufSize = maxout; - delete[] m_buf; - m_buf = new char[maxout]; - } - assert( m_cctx ); - return (uint32_t)ZSTD_compressCCtx( m_cctx, m_buf, maxout, image, inBytes, 1 ); + return (uint32_t)ZSTD_compressCCtx( ctx, buf, maxout, image, inBytes, 3 ); } const char* TextureCompression::Unpack( const FrameImage& image ) diff --git a/server/TracyTextureCompression.hpp b/server/TracyTextureCompression.hpp index 2dacfed4..5c5d8ebe 100644 --- a/server/TracyTextureCompression.hpp +++ b/server/TracyTextureCompression.hpp @@ -20,12 +20,12 @@ public: TextureCompression(); ~TextureCompression(); - void Pack( struct ZSTD_CCtx_s* ctx, char*& buf, size_t& bufsz, const char* image, uint32_t inBytes, uint32_t& csz ) const; + uint32_t Pack( struct ZSTD_CCtx_s* ctx, char*& buf, size_t& bufsz, const char* image, uint32_t inBytes ) const; template const char* Pack( const char* image, uint32_t inBytes, uint32_t& csz, Slab& slab ) { - const auto outsz = PackImpl( image, inBytes ); + const auto outsz = Pack( m_cctx, m_buf, m_bufSize, image, inBytes ); auto ptr = (char*)slab.AllocBig( outsz ); memcpy( ptr, m_buf, outsz ); csz = outsz; @@ -35,8 +35,6 @@ public: const char* Unpack( const FrameImage& image ); private: - uint32_t PackImpl( const char* image, uint32_t inBytes ); - char* m_buf; size_t m_bufSize; struct ZSTD_CCtx_s* m_cctx; diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 2483d0ac..11d42fc2 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -1473,7 +1473,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks ) data[idx].state.store( JobData::InProgress, std::memory_order_release ); td->Queue( [this, &data, idx, fi] { - m_texcomp.Pack( data[idx].ctx, data[idx].outbuf, data[idx].outsz, data[idx].buf, fi->w * fi->h / 2, fi->csz ); + fi->csz = m_texcomp.Pack( data[idx].ctx, data[idx].outbuf, data[idx].outsz, data[idx].buf, fi->w * fi->h / 2 ); data[idx].state.store( JobData::DataReady, std::memory_order_release ); } );