2020-03-02 01:00:35 +00:00
|
|
|
#ifndef __TRACY__TEXTURECOMPRESSION_HPP__
|
|
|
|
#define __TRACY__TEXTURECOMPRESSION_HPP__
|
|
|
|
|
2020-03-14 13:35:57 +00:00
|
|
|
#include <atomic>
|
|
|
|
|
2020-03-02 01:00:35 +00:00
|
|
|
#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();
|
|
|
|
|
2020-03-14 13:35:57 +00:00
|
|
|
uint32_t Pack( struct ZSTD_CCtx_s* ctx, char*& buf, size_t& bufsz, const char* image, uint32_t inBytes );
|
2020-03-02 01:00:35 +00:00
|
|
|
|
|
|
|
template<size_t Size>
|
|
|
|
const char* Pack( const char* image, uint32_t inBytes, uint32_t& csz, Slab<Size>& slab )
|
|
|
|
{
|
2020-03-02 01:08:14 +00:00
|
|
|
const auto outsz = Pack( m_cctx, m_buf, m_bufSize, image, inBytes );
|
2020-03-02 01:00:35 +00:00
|
|
|
auto ptr = (char*)slab.AllocBig( outsz );
|
|
|
|
memcpy( ptr, m_buf, outsz );
|
|
|
|
csz = outsz;
|
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* Unpack( const FrameImage& image );
|
|
|
|
|
2020-03-14 13:35:57 +00:00
|
|
|
uint64_t GetInputBytesCount() const { return m_inputBytes.load( std::memory_order_relaxed ); }
|
|
|
|
uint64_t GetOutputBytesCount() const { return m_outputBytes.load( std::memory_order_relaxed ); }
|
|
|
|
|
2020-03-02 01:00:35 +00:00
|
|
|
private:
|
|
|
|
char* m_buf;
|
|
|
|
size_t m_bufSize;
|
|
|
|
struct ZSTD_CCtx_s* m_cctx;
|
|
|
|
struct ZSTD_DCtx_s* m_dctx;
|
2020-03-14 13:35:57 +00:00
|
|
|
|
|
|
|
std::atomic<uint64_t> m_inputBytes { 0 };
|
|
|
|
std::atomic<uint64_t> m_outputBytes { 0 };
|
2020-03-02 01:00:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|