mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 10:41:50 +00:00
Add texture packer with zstd dict support.
This commit is contained in:
parent
a53f5702b1
commit
925a23a053
@ -39,6 +39,24 @@ uint32_t TextureCompression::Pack( struct ZSTD_CCtx_s* ctx, char*& buf, size_t&
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t TextureCompression::Pack( struct ZSTD_CCtx_s* ctx, const struct ZSTD_CDict_s* dict, char*& buf, size_t& bufsz, const char* image, uint32_t inBytes )
|
||||||
|
{
|
||||||
|
const auto maxout = ZSTD_COMPRESSBOUND( inBytes );
|
||||||
|
if( bufsz < maxout )
|
||||||
|
{
|
||||||
|
bufsz = maxout;
|
||||||
|
delete[] buf;
|
||||||
|
buf = new char[maxout];
|
||||||
|
}
|
||||||
|
assert( ctx );
|
||||||
|
auto ret = (uint32_t)ZSTD_compress_usingCDict( ctx, buf, maxout, image, inBytes, dict );
|
||||||
|
#ifndef TRACY_NO_STATISTICS
|
||||||
|
m_inputBytes.fetch_add( inBytes, std::memory_order_relaxed );
|
||||||
|
m_outputBytes.fetch_add( ret, std::memory_order_relaxed );
|
||||||
|
#endif
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
const char* TextureCompression::Unpack( const FrameImage& image )
|
const char* TextureCompression::Unpack( const FrameImage& image )
|
||||||
{
|
{
|
||||||
const auto outsz = size_t( image.w ) * size_t( image.h ) / 2;
|
const auto outsz = size_t( image.w ) * size_t( image.h ) / 2;
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
struct ZSTD_CCtx_s;
|
struct ZSTD_CCtx_s;
|
||||||
struct ZSTD_DCtx_s;
|
struct ZSTD_DCtx_s;
|
||||||
|
struct ZSTD_CDict_s;
|
||||||
|
|
||||||
namespace tracy
|
namespace tracy
|
||||||
{
|
{
|
||||||
@ -23,6 +24,7 @@ public:
|
|||||||
~TextureCompression();
|
~TextureCompression();
|
||||||
|
|
||||||
uint32_t Pack( struct ZSTD_CCtx_s* ctx, char*& buf, size_t& bufsz, const char* image, uint32_t inBytes );
|
uint32_t Pack( struct ZSTD_CCtx_s* ctx, char*& buf, size_t& bufsz, const char* image, uint32_t inBytes );
|
||||||
|
uint32_t Pack( struct ZSTD_CCtx_s* ctx, const struct ZSTD_CDict_s* dict, char*& buf, size_t& bufsz, const char* image, uint32_t inBytes );
|
||||||
|
|
||||||
template<size_t Size>
|
template<size_t Size>
|
||||||
const char* Pack( const char* image, uint32_t inBytes, uint32_t& csz, Slab<Size>& slab )
|
const char* Pack( const char* image, uint32_t inBytes, uint32_t& csz, Slab<Size>& slab )
|
||||||
|
Loading…
Reference in New Issue
Block a user