mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Add LZ4HC support to FileWrite.
This commit is contained in:
parent
0f0528ca3d
commit
b3b12f76f3
@ -132,6 +132,7 @@
|
||||
<ClCompile Include="..\..\..\common\TracySocket.cpp" />
|
||||
<ClCompile Include="..\..\..\common\TracySystem.cpp" />
|
||||
<ClCompile Include="..\..\..\common\tracy_lz4.cpp" />
|
||||
<ClCompile Include="..\..\..\common\tracy_lz4hc.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyMemory.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyWorker.cpp" />
|
||||
<ClCompile Include="..\..\src\capture.cpp" />
|
||||
@ -148,6 +149,7 @@
|
||||
<ClInclude Include="..\..\..\common\TracySystem.hpp" />
|
||||
<ClInclude Include="..\..\..\common\tracy_benaphore.h" />
|
||||
<ClInclude Include="..\..\..\common\tracy_lz4.hpp" />
|
||||
<ClInclude Include="..\..\..\common\tracy_lz4hc.hpp" />
|
||||
<ClInclude Include="..\..\..\common\tracy_sema.h" />
|
||||
<ClInclude Include="..\..\..\server\TracyCharUtil.hpp" />
|
||||
<ClInclude Include="..\..\..\server\TracyEvent.hpp" />
|
||||
|
@ -33,6 +33,9 @@
|
||||
<ClCompile Include="..\..\src\getopt.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\common\tracy_lz4hc.cpp">
|
||||
<Filter>common</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\common\tracy_lz4.hpp">
|
||||
@ -98,5 +101,8 @@
|
||||
<ClInclude Include="..\..\..\common\tracy_sema.h">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\common\tracy_lz4hc.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -96,6 +96,7 @@
|
||||
<ClCompile Include="..\..\..\common\TracySocket.cpp" />
|
||||
<ClCompile Include="..\..\..\common\TracySystem.cpp" />
|
||||
<ClCompile Include="..\..\..\common\tracy_lz4.cpp" />
|
||||
<ClCompile Include="..\..\..\common\tracy_lz4hc.cpp" />
|
||||
<ClCompile Include="..\..\..\imguicolortextedit\TextEditor.cpp" />
|
||||
<ClCompile Include="..\..\..\imgui\imgui.cpp" />
|
||||
<ClCompile Include="..\..\..\imgui\imgui_demo.cpp" />
|
||||
@ -126,6 +127,7 @@
|
||||
<ClInclude Include="..\..\..\common\TracySystem.hpp" />
|
||||
<ClInclude Include="..\..\..\common\tracy_benaphore.h" />
|
||||
<ClInclude Include="..\..\..\common\tracy_lz4.hpp" />
|
||||
<ClInclude Include="..\..\..\common\tracy_lz4hc.hpp" />
|
||||
<ClInclude Include="..\..\..\common\tracy_sema.h" />
|
||||
<ClInclude Include="..\..\..\imguicolortextedit\TextEditor.h" />
|
||||
<ClInclude Include="..\..\..\imgui\imconfig.h" />
|
||||
|
@ -81,6 +81,9 @@
|
||||
<ClCompile Include="..\..\src\winmainArchDiscovery.cpp">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\common\tracy_lz4hc.cpp">
|
||||
<Filter>common</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\common\tracy_lz4.hpp">
|
||||
@ -230,6 +233,9 @@
|
||||
<ClInclude Include="..\..\..\server\IconsFontAwesome5.h">
|
||||
<Filter>server</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\common\tracy_lz4hc.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Natvis Include="DebugVis.natvis" />
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "TracyFileHeader.hpp"
|
||||
#include "../common/tracy_lz4.hpp"
|
||||
#include "../common/tracy_lz4hc.hpp"
|
||||
#include "../common/TracyForceInline.hpp"
|
||||
|
||||
namespace tracy
|
||||
@ -15,10 +16,10 @@ namespace tracy
|
||||
class FileWrite
|
||||
{
|
||||
public:
|
||||
static FileWrite* Open( const char* fn )
|
||||
static FileWrite* Open( const char* fn, bool hc = false )
|
||||
{
|
||||
auto f = fopen( fn, "wb" );
|
||||
return f ? new FileWrite( f ) : nullptr;
|
||||
return f ? new FileWrite( f, hc ) : nullptr;
|
||||
}
|
||||
|
||||
~FileWrite()
|
||||
@ -28,7 +29,9 @@ public:
|
||||
WriteLz4Block();
|
||||
}
|
||||
fclose( m_file );
|
||||
LZ4_freeStream( m_stream );
|
||||
|
||||
if( m_stream ) LZ4_freeStream( m_stream );
|
||||
if( m_streamHC ) LZ4_freeStreamHC( m_streamHC );
|
||||
}
|
||||
|
||||
tracy_force_inline void Write( const void* ptr, size_t size )
|
||||
@ -44,13 +47,23 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
FileWrite( FILE* f )
|
||||
: m_stream( LZ4_createStream() )
|
||||
FileWrite( FILE* f, bool hc )
|
||||
: m_stream( nullptr )
|
||||
, m_streamHC( nullptr )
|
||||
, m_file( f )
|
||||
, m_buf( m_bufData[0] )
|
||||
, m_second( m_bufData[1] )
|
||||
, m_offset( 0 )
|
||||
{
|
||||
if( hc )
|
||||
{
|
||||
m_streamHC = LZ4_createStreamHC();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_stream = LZ4_createStream();
|
||||
}
|
||||
|
||||
fwrite( Lz4Header, 1, sizeof( Lz4Header ), m_file );
|
||||
}
|
||||
|
||||
@ -81,7 +94,15 @@ private:
|
||||
void WriteLz4Block()
|
||||
{
|
||||
char lz4[LZ4Size];
|
||||
const uint32_t sz = LZ4_compress_fast_continue( m_stream, m_buf, lz4, m_offset, LZ4Size, 1 );
|
||||
uint32_t sz;
|
||||
if( m_stream )
|
||||
{
|
||||
sz = LZ4_compress_fast_continue( m_stream, m_buf, lz4, m_offset, LZ4Size, 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
sz = LZ4_compress_HC_continue( m_streamHC, m_buf, lz4, m_offset, LZ4Size );
|
||||
}
|
||||
fwrite( &sz, 1, sizeof( sz ), m_file );
|
||||
fwrite( lz4, 1, sz, m_file );
|
||||
m_offset = 0;
|
||||
@ -92,6 +113,7 @@ private:
|
||||
enum { LZ4Size = LZ4_COMPRESSBOUND( BufSize ) };
|
||||
|
||||
LZ4_stream_t* m_stream;
|
||||
LZ4_streamHC_t* m_streamHC;
|
||||
FILE* m_file;
|
||||
char m_bufData[2][BufSize];
|
||||
char* m_buf;
|
||||
|
@ -132,6 +132,7 @@
|
||||
<ClCompile Include="..\..\..\common\TracySocket.cpp" />
|
||||
<ClCompile Include="..\..\..\common\TracySystem.cpp" />
|
||||
<ClCompile Include="..\..\..\common\tracy_lz4.cpp" />
|
||||
<ClCompile Include="..\..\..\common\tracy_lz4hc.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyMemory.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyWorker.cpp" />
|
||||
<ClCompile Include="..\..\src\update.cpp" />
|
||||
@ -147,6 +148,7 @@
|
||||
<ClInclude Include="..\..\..\common\TracySystem.hpp" />
|
||||
<ClInclude Include="..\..\..\common\tracy_benaphore.h" />
|
||||
<ClInclude Include="..\..\..\common\tracy_lz4.hpp" />
|
||||
<ClInclude Include="..\..\..\common\tracy_lz4hc.hpp" />
|
||||
<ClInclude Include="..\..\..\common\tracy_sema.h" />
|
||||
<ClInclude Include="..\..\..\server\TracyCharUtil.hpp" />
|
||||
<ClInclude Include="..\..\..\server\TracyEvent.hpp" />
|
||||
|
@ -30,6 +30,9 @@
|
||||
<ClCompile Include="..\..\src\update.cpp">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\common\tracy_lz4hc.cpp">
|
||||
<Filter>common</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\common\tracy_lz4.hpp">
|
||||
@ -92,5 +95,8 @@
|
||||
<ClInclude Include="..\..\..\common\tracy_sema.h">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\common\tracy_lz4hc.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user