Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/wolfpld/tracy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartosz Taudul <wolf.pld@gmail.com>2020-03-02 04:00:35 +0300
committerBartosz Taudul <wolf.pld@gmail.com>2020-03-02 04:00:35 +0300
commitaa0bf47ec3ea03c5e7c78263e1956af5ab018131 (patch)
tree6d48f977c76d220e305bb672991d603228142248 /server/TracyTextureCompression.hpp
parent0df309b45c971a4f80a9a88e0637cfe05453b542 (diff)
Extract texture compression functionality.
Diffstat (limited to 'server/TracyTextureCompression.hpp')
-rw-r--r--server/TracyTextureCompression.hpp48
1 files changed, 48 insertions, 0 deletions
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 <stdint.h>
+#include <stdlib.h>
+
+#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<size_t Size>
+ const char* Pack( const char* image, uint32_t inBytes, uint32_t& csz, Slab<Size>& 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