mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 22:44:34 +00:00
Remove VisData.
Its functionality is now incorporated into TimelineItem. For purposes of maintaining visibility of frame sets and locks a much simpler ptr -> bool map is now used.
This commit is contained in:
parent
ad2fc03125
commit
44efb15df1
@ -44,45 +44,4 @@ void TimelineController::End( double pxns, int offset, const ImVec2& wpos, bool
|
|||||||
m_scroll = scrollPos;
|
m_scroll = scrollPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
float TimelineController::AdjustThreadPosition( VisData& vis, float wy, int& offset )
|
|
||||||
{
|
|
||||||
if( vis.offset < offset )
|
|
||||||
{
|
|
||||||
vis.offset = offset;
|
|
||||||
}
|
|
||||||
else if( vis.offset > offset )
|
|
||||||
{
|
|
||||||
const auto diff = vis.offset - offset;
|
|
||||||
const auto move = std::max( 2.0, diff * 10.0 * ImGui::GetIO().DeltaTime );
|
|
||||||
offset = vis.offset = int( std::max<double>( vis.offset - move, offset ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return offset + wy;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TimelineController::AdjustThreadHeight( VisData& vis, int oldOffset, int& offset )
|
|
||||||
{
|
|
||||||
const auto h = offset - oldOffset;
|
|
||||||
if( vis.height > h )
|
|
||||||
{
|
|
||||||
vis.height = h;
|
|
||||||
offset = oldOffset + vis.height;
|
|
||||||
}
|
|
||||||
else if( vis.height < h )
|
|
||||||
{
|
|
||||||
if( m_firstFrame )
|
|
||||||
{
|
|
||||||
vis.height = h;
|
|
||||||
offset = oldOffset + h;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const auto diff = h - vis.height;
|
|
||||||
const auto move = std::max( 2.0, diff * 10.0 * ImGui::GetIO().DeltaTime );
|
|
||||||
vis.height = int( std::min<double>( vis.height + move, h ) );
|
|
||||||
offset = oldOffset + vis.height;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,15 +13,6 @@ namespace tracy
|
|||||||
|
|
||||||
class TimelineController
|
class TimelineController
|
||||||
{
|
{
|
||||||
struct VisData
|
|
||||||
{
|
|
||||||
bool visible = true;
|
|
||||||
bool showFull = true;
|
|
||||||
bool ghost = false;
|
|
||||||
int offset = 0;
|
|
||||||
int height = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TimelineController( View& view, Worker& worker );
|
TimelineController( View& view, Worker& worker );
|
||||||
|
|
||||||
@ -38,12 +29,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
float GetHeight() const { return m_height; }
|
float GetHeight() const { return m_height; }
|
||||||
const unordered_flat_map<const void*, VisData>& GetVisData() const { return m_visData; }
|
|
||||||
const unordered_flat_map<const void*, std::unique_ptr<TimelineItem>>& GetItemMap() const { return m_itemMap; }
|
const unordered_flat_map<const void*, std::unique_ptr<TimelineItem>>& GetItemMap() const { return m_itemMap; }
|
||||||
|
|
||||||
void AdjustThreadHeight( VisData& vis, int oldOffset, int& offset );
|
|
||||||
float AdjustThreadPosition( VisData& vis, float wy, int& offset );
|
|
||||||
|
|
||||||
tracy_force_inline TimelineItem& GetItem( const void* data )
|
tracy_force_inline TimelineItem& GetItem( const void* data )
|
||||||
{
|
{
|
||||||
auto it = m_itemMap.find( data );
|
auto it = m_itemMap.find( data );
|
||||||
@ -51,22 +38,10 @@ public:
|
|||||||
return *it->second;
|
return *it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
tracy_force_inline VisData& Vis( const void* ptr )
|
|
||||||
{
|
|
||||||
auto it = m_visData.find( ptr );
|
|
||||||
if( it == m_visData.end() )
|
|
||||||
{
|
|
||||||
it = m_visData.emplace( ptr, VisData {} ).first;
|
|
||||||
}
|
|
||||||
return it->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<TimelineItem*> m_items;
|
std::vector<TimelineItem*> m_items;
|
||||||
unordered_flat_map<const void*, std::unique_ptr<TimelineItem>> m_itemMap;
|
unordered_flat_map<const void*, std::unique_ptr<TimelineItem>> m_itemMap;
|
||||||
|
|
||||||
unordered_flat_map<const void*, VisData> m_visData;
|
|
||||||
|
|
||||||
float m_height;
|
float m_height;
|
||||||
float m_offset;
|
float m_offset;
|
||||||
float m_scroll;
|
float m_scroll;
|
||||||
|
@ -840,7 +840,7 @@ bool View::DrawImpl()
|
|||||||
if( ImGui::SmallButton( " " ICON_FA_CARET_LEFT " " ) ) ZoomToPrevFrame();
|
if( ImGui::SmallButton( " " ICON_FA_CARET_LEFT " " ) ) ZoomToPrevFrame();
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
{
|
{
|
||||||
const auto vis = m_tc.Vis( m_frames ).visible;
|
const auto vis = Vis( m_frames );
|
||||||
if( !vis )
|
if( !vis )
|
||||||
{
|
{
|
||||||
ImGui::PushStyleColor( ImGuiCol_Text, GImGui->Style.Colors[ImGuiCol_TextDisabled] );
|
ImGui::PushStyleColor( ImGuiCol_Text, GImGui->Style.Colors[ImGuiCol_TextDisabled] );
|
||||||
|
@ -392,6 +392,13 @@ private:
|
|||||||
static const char* DecodeContextSwitchReason( uint8_t reason );
|
static const char* DecodeContextSwitchReason( uint8_t reason );
|
||||||
static const char* DecodeContextSwitchReasonCode( uint8_t reason );
|
static const char* DecodeContextSwitchReasonCode( uint8_t reason );
|
||||||
|
|
||||||
|
tracy_force_inline bool& Vis( const void* ptr )
|
||||||
|
{
|
||||||
|
auto it = m_visMap.find( ptr );
|
||||||
|
if( it == m_visMap.end() ) it = m_visMap.emplace( ptr, true ).first;
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
Worker m_worker;
|
Worker m_worker;
|
||||||
std::string m_filename, m_filenameStaging;
|
std::string m_filename, m_filenameStaging;
|
||||||
bool m_staticView;
|
bool m_staticView;
|
||||||
@ -561,6 +568,8 @@ private:
|
|||||||
unordered_flat_map<int16_t, StatisticsCache> m_statCache;
|
unordered_flat_map<int16_t, StatisticsCache> m_statCache;
|
||||||
unordered_flat_map<int16_t, StatisticsCache> m_gpuStatCache;
|
unordered_flat_map<int16_t, StatisticsCache> m_gpuStatCache;
|
||||||
|
|
||||||
|
unordered_flat_map<const void*, bool> m_visMap;
|
||||||
|
|
||||||
void(*m_cbMainThread)(std::function<void()>, bool);
|
void(*m_cbMainThread)(std::function<void()>, bool);
|
||||||
|
|
||||||
int m_gpuIdx = 0;
|
int m_gpuIdx = 0;
|
||||||
|
@ -362,7 +362,7 @@ int View::DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos,
|
|||||||
for( const auto& v : m_worker.GetLockMap() )
|
for( const auto& v : m_worker.GetLockMap() )
|
||||||
{
|
{
|
||||||
const auto& lockmap = *v.second;
|
const auto& lockmap = *v.second;
|
||||||
if( !lockmap.valid || !m_tc.Vis( &lockmap ).visible ) continue;
|
if( !lockmap.valid || !Vis( &lockmap ) ) continue;
|
||||||
if( m_vd.onlyContendedLocks && ( lockmap.threadList.size() == 1 || !lockmap.isContended ) && m_lockInfoWindow != v.first ) continue;
|
if( m_vd.onlyContendedLocks && ( lockmap.threadList.size() == 1 || !lockmap.isContended ) && m_lockInfoWindow != v.first ) continue;
|
||||||
|
|
||||||
auto it = lockmap.threadMap.find( tid );
|
auto it = lockmap.threadMap.find( tid );
|
||||||
|
@ -189,9 +189,9 @@ void View::DrawNotificationArea()
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
bool hidden = false;
|
bool hidden = false;
|
||||||
for( auto& v : m_tc.GetVisData() )
|
for( auto& v : m_visMap )
|
||||||
{
|
{
|
||||||
if( !v.second.visible )
|
if( !v.second )
|
||||||
{
|
{
|
||||||
hidden = true;
|
hidden = true;
|
||||||
break;
|
break;
|
||||||
|
@ -283,7 +283,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
for( const auto& l : m_worker.GetLockMap() )
|
for( const auto& l : m_worker.GetLockMap() )
|
||||||
{
|
{
|
||||||
m_tc.Vis( l.second ).visible = true;
|
Vis( l.second ) = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -291,7 +291,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
for( const auto& l : m_worker.GetLockMap() )
|
for( const auto& l : m_worker.GetLockMap() )
|
||||||
{
|
{
|
||||||
m_tc.Vis( l.second ).visible = false;
|
Vis( l.second ) = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -307,7 +307,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
for( const auto& l : m_worker.GetLockMap() )
|
for( const auto& l : m_worker.GetLockMap() )
|
||||||
{
|
{
|
||||||
if( l.second->threadList.size() != 1 && l.second->isContended ) m_tc.Vis( l.second ).visible = true;
|
if( l.second->threadList.size() != 1 && l.second->isContended ) Vis( l.second ) = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -315,7 +315,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
for( const auto& l : m_worker.GetLockMap() )
|
for( const auto& l : m_worker.GetLockMap() )
|
||||||
{
|
{
|
||||||
if( l.second->threadList.size() != 1 && l.second->isContended ) m_tc.Vis( l.second ).visible = false;
|
if( l.second->threadList.size() != 1 && l.second->isContended ) Vis( l.second ) = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -335,7 +335,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
sprintf( buf, "%" PRIu32 ": %s", l.first, m_worker.GetString( m_worker.GetSourceLocation( l.second->srcloc ).function ) );
|
sprintf( buf, "%" PRIu32 ": %s", l.first, m_worker.GetString( m_worker.GetSourceLocation( l.second->srcloc ).function ) );
|
||||||
}
|
}
|
||||||
SmallCheckbox( buf, &m_tc.Vis( l.second ).visible );
|
SmallCheckbox( buf, &Vis( l.second ) );
|
||||||
if( ImGui::IsItemHovered() )
|
if( ImGui::IsItemHovered() )
|
||||||
{
|
{
|
||||||
m_lockHoverHighlight = l.first;
|
m_lockHoverHighlight = l.first;
|
||||||
@ -385,7 +385,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
for( const auto& l : m_worker.GetLockMap() )
|
for( const auto& l : m_worker.GetLockMap() )
|
||||||
{
|
{
|
||||||
if( l.second->threadList.size() != 1 && !l.second->isContended ) m_tc.Vis( l.second ).visible = true;
|
if( l.second->threadList.size() != 1 && !l.second->isContended ) Vis( l.second ) = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -393,7 +393,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
for( const auto& l : m_worker.GetLockMap() )
|
for( const auto& l : m_worker.GetLockMap() )
|
||||||
{
|
{
|
||||||
if( l.second->threadList.size() != 1 && !l.second->isContended ) m_tc.Vis( l.second ).visible = false;
|
if( l.second->threadList.size() != 1 && !l.second->isContended ) Vis( l.second ) = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,7 +413,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
sprintf( buf, "%" PRIu32 ": %s", l.first, m_worker.GetString( m_worker.GetSourceLocation( l.second->srcloc ).function ) );
|
sprintf( buf, "%" PRIu32 ": %s", l.first, m_worker.GetString( m_worker.GetSourceLocation( l.second->srcloc ).function ) );
|
||||||
}
|
}
|
||||||
SmallCheckbox( buf, &m_tc.Vis( l.second ).visible );
|
SmallCheckbox( buf, &Vis( l.second ) );
|
||||||
if( ImGui::IsItemHovered() )
|
if( ImGui::IsItemHovered() )
|
||||||
{
|
{
|
||||||
m_lockHoverHighlight = l.first;
|
m_lockHoverHighlight = l.first;
|
||||||
@ -463,7 +463,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
for( const auto& l : m_worker.GetLockMap() )
|
for( const auto& l : m_worker.GetLockMap() )
|
||||||
{
|
{
|
||||||
if( l.second->threadList.size() == 1 ) m_tc.Vis( l.second ).visible = true;
|
if( l.second->threadList.size() == 1 ) Vis( l.second ) = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -471,7 +471,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
for( const auto& l : m_worker.GetLockMap() )
|
for( const auto& l : m_worker.GetLockMap() )
|
||||||
{
|
{
|
||||||
if( l.second->threadList.size() == 1 ) m_tc.Vis( l.second ).visible = false;
|
if( l.second->threadList.size() == 1 ) Vis( l.second ) = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -491,7 +491,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
sprintf( buf, "%" PRIu32 ": %s", l.first, m_worker.GetString( m_worker.GetSourceLocation( l.second->srcloc ).function ) );
|
sprintf( buf, "%" PRIu32 ": %s", l.first, m_worker.GetString( m_worker.GetSourceLocation( l.second->srcloc ).function ) );
|
||||||
}
|
}
|
||||||
SmallCheckbox( buf, &m_tc.Vis( l.second ).visible );
|
SmallCheckbox( buf, &Vis( l.second ) );
|
||||||
if( ImGui::IsItemHovered() )
|
if( ImGui::IsItemHovered() )
|
||||||
{
|
{
|
||||||
m_lockHoverHighlight = l.first;
|
m_lockHoverHighlight = l.first;
|
||||||
@ -707,7 +707,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
for( const auto& fd : m_worker.GetFrames() )
|
for( const auto& fd : m_worker.GetFrames() )
|
||||||
{
|
{
|
||||||
m_tc.Vis( fd ).visible = true;
|
Vis( fd ) = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -715,7 +715,7 @@ void View::DrawOptions()
|
|||||||
{
|
{
|
||||||
for( const auto& fd : m_worker.GetFrames() )
|
for( const auto& fd : m_worker.GetFrames() )
|
||||||
{
|
{
|
||||||
m_tc.Vis( fd ).visible = false;
|
Vis( fd ) = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -723,7 +723,7 @@ void View::DrawOptions()
|
|||||||
for( const auto& fd : m_worker.GetFrames() )
|
for( const auto& fd : m_worker.GetFrames() )
|
||||||
{
|
{
|
||||||
ImGui::PushID( idx++ );
|
ImGui::PushID( idx++ );
|
||||||
SmallCheckbox( GetFrameSetName( *fd ), &m_tc.Vis( fd ).visible );
|
SmallCheckbox( GetFrameSetName( *fd ), &Vis( fd ) );
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::TextDisabled( "%s %sframes", RealToString( fd->frames.size() ), fd->continuous ? "" : "discontinuous " );
|
ImGui::TextDisabled( "%s %sframes", RealToString( fd->frames.size() ), fd->continuous ? "" : "discontinuous " );
|
||||||
|
@ -301,7 +301,7 @@ void View::DrawTimeline()
|
|||||||
auto& frames = m_worker.GetFrames();
|
auto& frames = m_worker.GetFrames();
|
||||||
for( auto fd : frames )
|
for( auto fd : frames )
|
||||||
{
|
{
|
||||||
if( m_tc.Vis( fd ).visible )
|
if( Vis( fd ) )
|
||||||
{
|
{
|
||||||
DrawTimelineFrames( *fd );
|
DrawTimelineFrames( *fd );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user