mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-26 16:04:34 +00:00
Count number of input and compressed frame image bytes.
This commit is contained in:
parent
0776dddc35
commit
b8cc3f59d6
@ -21,7 +21,7 @@ TextureCompression::~TextureCompression()
|
||||
ZSTD_freeDCtx( m_dctx );
|
||||
}
|
||||
|
||||
uint32_t TextureCompression::Pack( struct ZSTD_CCtx_s* ctx, char*& buf, size_t& bufsz, const char* image, uint32_t inBytes ) const
|
||||
uint32_t TextureCompression::Pack( struct ZSTD_CCtx_s* ctx, char*& buf, size_t& bufsz, const char* image, uint32_t inBytes )
|
||||
{
|
||||
const auto maxout = ZSTD_COMPRESSBOUND( inBytes );
|
||||
if( bufsz < maxout )
|
||||
@ -31,7 +31,12 @@ uint32_t TextureCompression::Pack( struct ZSTD_CCtx_s* ctx, char*& buf, size_t&
|
||||
buf = new char[maxout];
|
||||
}
|
||||
assert( ctx );
|
||||
return (uint32_t)ZSTD_compressCCtx( ctx, buf, maxout, image, inBytes, 3 );
|
||||
auto ret = (uint32_t)ZSTD_compressCCtx( ctx, buf, maxout, image, inBytes, 3 );
|
||||
#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 )
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef __TRACY__TEXTURECOMPRESSION_HPP__
|
||||
#define __TRACY__TEXTURECOMPRESSION_HPP__
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -20,7 +22,7 @@ public:
|
||||
TextureCompression();
|
||||
~TextureCompression();
|
||||
|
||||
uint32_t Pack( struct ZSTD_CCtx_s* ctx, char*& buf, size_t& bufsz, const char* image, uint32_t inBytes ) const;
|
||||
uint32_t Pack( struct ZSTD_CCtx_s* ctx, char*& buf, size_t& bufsz, const char* image, uint32_t inBytes );
|
||||
|
||||
template<size_t Size>
|
||||
const char* Pack( const char* image, uint32_t inBytes, uint32_t& csz, Slab<Size>& slab )
|
||||
@ -34,11 +36,17 @@ public:
|
||||
|
||||
const char* Unpack( const FrameImage& image );
|
||||
|
||||
uint64_t GetInputBytesCount() const { return m_inputBytes.load( std::memory_order_relaxed ); }
|
||||
uint64_t GetOutputBytesCount() const { return m_outputBytes.load( std::memory_order_relaxed ); }
|
||||
|
||||
private:
|
||||
char* m_buf;
|
||||
size_t m_bufSize;
|
||||
struct ZSTD_CCtx_s* m_cctx;
|
||||
struct ZSTD_DCtx_s* m_dctx;
|
||||
|
||||
std::atomic<uint64_t> m_inputBytes { 0 };
|
||||
std::atomic<uint64_t> m_outputBytes { 0 };
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -11999,6 +11999,18 @@ void View::DrawInfo()
|
||||
}
|
||||
TextFocused( "Call stack samples:", RealToString( m_worker.GetCallstackSampleCount() ) );
|
||||
TextFocused( "Frame images:", RealToString( ficnt ) );
|
||||
if( ficnt != 0 && ImGui::IsItemHovered() )
|
||||
{
|
||||
const auto bytes = m_worker.GetTextureCompressionBytes();
|
||||
ImGui::BeginTooltip();
|
||||
TextFocused( "Input data:", MemSizeToString( bytes.first ) );
|
||||
TextFocused( "Compressed:", MemSizeToString( bytes.second ) );
|
||||
char buf[64];
|
||||
auto ptr = PrintFloat( buf, buf+62, 100. * bytes.second / bytes.first, 2 );
|
||||
memcpy( ptr, "%", 2 );
|
||||
TextFocused( "Ratio:", buf );
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
TextFocused( "Context switch regions:", RealToString( m_worker.GetContextSwitchCount() ) );
|
||||
if( ImGui::IsItemHovered() )
|
||||
{
|
||||
|
@ -493,6 +493,8 @@ public:
|
||||
const decltype(DataBlock::cpuTopology)& GetCpuTopology() const { return m_data.cpuTopology; }
|
||||
const CpuThreadTopology* GetThreadTopology( uint32_t cpuThread ) const;
|
||||
|
||||
std::pair<uint64_t, uint64_t> GetTextureCompressionBytes() const { return std::make_pair( m_texcomp.GetInputBytesCount(), m_texcomp.GetOutputBytesCount() ); }
|
||||
|
||||
private:
|
||||
void Network();
|
||||
void Exec();
|
||||
|
Loading…
Reference in New Issue
Block a user