From aa0bf47ec3ea03c5e7c78263e1956af5ab018131 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Mon, 2 Mar 2020 02:00:35 +0100 Subject: Extract texture compression functionality. --- server/TracyTextureCompression.hpp | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 server/TracyTextureCompression.hpp (limited to 'server/TracyTextureCompression.hpp') diff --git a/server/TracyTextureCompression.hpp b/server/TracyTextureCompression.hpp new file mode 100644 index 00000000..2dacfed4 --- /dev/null +++ b/server/TracyTextureCompression.hpp @@ -0,0 +1,48 @@ +#ifndef __TRACY__TEXTURECOMPRESSION_HPP__ +#define __TRACY__TEXTURECOMPRESSION_HPP__ + +#include +#include + +#include "TracySlab.hpp" + +struct ZSTD_CCtx_s; +struct ZSTD_DCtx_s; + +namespace tracy +{ + +struct FrameImage; + +class TextureCompression +{ +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; + + template + const char* Pack( const char* image, uint32_t inBytes, uint32_t& csz, Slab& slab ) + { + const auto outsz = PackImpl( image, inBytes ); + auto ptr = (char*)slab.AllocBig( outsz ); + memcpy( ptr, m_buf, outsz ); + csz = outsz; + return ptr; + } + + 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; + struct ZSTD_DCtx_s* m_dctx; +}; + +} + +#endif -- cgit v1.2.3