mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-26 07:54:36 +00:00
Parallelize timeline item preprocessing.
This commit is contained in:
parent
66d3c2a472
commit
1e1833edc2
@ -1,4 +1,5 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
#include "TracyTimelineItem.hpp"
|
#include "TracyTimelineItem.hpp"
|
||||||
#include "TracyTimelineContext.hpp"
|
#include "TracyTimelineContext.hpp"
|
||||||
@ -16,6 +17,11 @@ TimelineController::TimelineController( View& view, Worker& worker )
|
|||||||
, m_firstFrame( true )
|
, m_firstFrame( true )
|
||||||
, m_view( view )
|
, m_view( view )
|
||||||
, m_worker( worker )
|
, m_worker( worker )
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
, m_td( 1 )
|
||||||
|
#else
|
||||||
|
, m_td( std::max( 1u, std::thread::hardware_concurrency() - 2 ) )
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,9 +137,10 @@ void TimelineController::End( double pxns, const ImVec2& wpos, bool hover, bool
|
|||||||
{
|
{
|
||||||
if( item->WantPreprocess() && item->IsVisible() )
|
if( item->WantPreprocess() && item->IsVisible() )
|
||||||
{
|
{
|
||||||
item->Preprocess( ctx );
|
item->Preprocess( ctx, m_td );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
m_td.Sync();
|
||||||
|
|
||||||
int yOffset = 0;
|
int yOffset = 0;
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "TracyImGui.hpp"
|
#include "TracyImGui.hpp"
|
||||||
|
#include "TracyTaskDispatch.hpp"
|
||||||
#include "../public/common/TracyForceInline.hpp"
|
#include "../public/common/TracyForceInline.hpp"
|
||||||
#include "tracy_robin_hood.h"
|
#include "tracy_robin_hood.h"
|
||||||
|
|
||||||
@ -61,6 +62,8 @@ private:
|
|||||||
|
|
||||||
View& m_view;
|
View& m_view;
|
||||||
Worker& m_worker;
|
Worker& m_worker;
|
||||||
|
|
||||||
|
TaskDispatch m_td;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ namespace tracy
|
|||||||
{
|
{
|
||||||
|
|
||||||
struct TimelineContext;
|
struct TimelineContext;
|
||||||
|
class TaskDispatch;
|
||||||
class View;
|
class View;
|
||||||
class Worker;
|
class Worker;
|
||||||
|
|
||||||
@ -23,7 +24,7 @@ public:
|
|||||||
void Draw( bool firstFrame, const TimelineContext& ctx, int yOffset );
|
void Draw( bool firstFrame, const TimelineContext& ctx, int yOffset );
|
||||||
|
|
||||||
bool WantPreprocess() const { return m_wantPreprocess; }
|
bool WantPreprocess() const { return m_wantPreprocess; }
|
||||||
virtual void Preprocess( const TimelineContext& ctx ) { assert( false ); }
|
virtual void Preprocess( const TimelineContext& ctx, TaskDispatch& td ) { assert( false ); }
|
||||||
|
|
||||||
void VisibilityCheckbox();
|
void VisibilityCheckbox();
|
||||||
virtual void SetVisible( bool visible ) { m_visible = visible; }
|
virtual void SetVisible( bool visible ) { m_visible = visible; }
|
||||||
|
@ -277,20 +277,22 @@ void TimelineItemThread::DrawFinished()
|
|||||||
m_draw.clear();
|
m_draw.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimelineItemThread::Preprocess( const TimelineContext& ctx )
|
void TimelineItemThread::Preprocess( const TimelineContext& ctx, TaskDispatch& td )
|
||||||
{
|
{
|
||||||
assert( m_draw.empty() );
|
assert( m_draw.empty() );
|
||||||
|
|
||||||
|
td.Queue( [this, &ctx] {
|
||||||
#ifndef TRACY_NO_STATISTICS
|
#ifndef TRACY_NO_STATISTICS
|
||||||
if( m_worker.AreGhostZonesReady() && ( m_ghost || ( m_view.GetViewData().ghostZones && m_thread->timeline.empty() ) ) )
|
if( m_worker.AreGhostZonesReady() && ( m_ghost || ( m_view.GetViewData().ghostZones && m_thread->timeline.empty() ) ) )
|
||||||
{
|
{
|
||||||
m_depth = PreprocessGhostLevel( ctx, m_thread->ghostZones, 0 );
|
m_depth = PreprocessGhostLevel( ctx, m_thread->ghostZones, 0 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
m_depth = PreprocessZoneLevel( ctx, m_thread->timeline, 0 );
|
m_depth = PreprocessZoneLevel( ctx, m_thread->timeline, 0 );
|
||||||
}
|
}
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TRACY_NO_STATISTICS
|
#ifndef TRACY_NO_STATISTICS
|
||||||
|
@ -31,7 +31,7 @@ protected:
|
|||||||
|
|
||||||
bool IsEmpty() const override;
|
bool IsEmpty() const override;
|
||||||
|
|
||||||
void Preprocess( const TimelineContext& ctx ) override;
|
void Preprocess( const TimelineContext& ctx, TaskDispatch& td ) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifndef TRACY_NO_STATISTICS
|
#ifndef TRACY_NO_STATISTICS
|
||||||
|
Loading…
Reference in New Issue
Block a user