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 <thread>
|
||||
|
||||
#include "TracyTimelineItem.hpp"
|
||||
#include "TracyTimelineContext.hpp"
|
||||
@ -16,6 +17,11 @@ TimelineController::TimelineController( View& view, Worker& worker )
|
||||
, m_firstFrame( true )
|
||||
, m_view( view )
|
||||
, 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() )
|
||||
{
|
||||
item->Preprocess( ctx );
|
||||
item->Preprocess( ctx, m_td );
|
||||
}
|
||||
}
|
||||
m_td.Sync();
|
||||
|
||||
int yOffset = 0;
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "TracyImGui.hpp"
|
||||
#include "TracyTaskDispatch.hpp"
|
||||
#include "../public/common/TracyForceInline.hpp"
|
||||
#include "tracy_robin_hood.h"
|
||||
|
||||
@ -61,6 +62,8 @@ private:
|
||||
|
||||
View& m_view;
|
||||
Worker& m_worker;
|
||||
|
||||
TaskDispatch m_td;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ namespace tracy
|
||||
{
|
||||
|
||||
struct TimelineContext;
|
||||
class TaskDispatch;
|
||||
class View;
|
||||
class Worker;
|
||||
|
||||
@ -23,7 +24,7 @@ public:
|
||||
void Draw( bool firstFrame, const TimelineContext& ctx, int yOffset );
|
||||
|
||||
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();
|
||||
virtual void SetVisible( bool visible ) { m_visible = visible; }
|
||||
|
@ -277,10 +277,11 @@ void TimelineItemThread::DrawFinished()
|
||||
m_draw.clear();
|
||||
}
|
||||
|
||||
void TimelineItemThread::Preprocess( const TimelineContext& ctx )
|
||||
void TimelineItemThread::Preprocess( const TimelineContext& ctx, TaskDispatch& td )
|
||||
{
|
||||
assert( m_draw.empty() );
|
||||
|
||||
td.Queue( [this, &ctx] {
|
||||
#ifndef TRACY_NO_STATISTICS
|
||||
if( m_worker.AreGhostZonesReady() && ( m_ghost || ( m_view.GetViewData().ghostZones && m_thread->timeline.empty() ) ) )
|
||||
{
|
||||
@ -291,6 +292,7 @@ void TimelineItemThread::Preprocess( const TimelineContext& ctx )
|
||||
{
|
||||
m_depth = PreprocessZoneLevel( ctx, m_thread->timeline, 0 );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
#ifndef TRACY_NO_STATISTICS
|
||||
|
@ -31,7 +31,7 @@ protected:
|
||||
|
||||
bool IsEmpty() const override;
|
||||
|
||||
void Preprocess( const TimelineContext& ctx ) override;
|
||||
void Preprocess( const TimelineContext& ctx, TaskDispatch& td ) override;
|
||||
|
||||
private:
|
||||
#ifndef TRACY_NO_STATISTICS
|
||||
|
Loading…
Reference in New Issue
Block a user