mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-25 23:44:35 +00:00
Migrate CPU data to timeline item system.
This commit is contained in:
parent
827b390e34
commit
ad2fc03125
@ -138,6 +138,7 @@
|
||||
<ClCompile Include="..\..\..\server\TracyThreadCompress.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyTimelineController.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyTimelineItem.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyTimelineItemCpuData.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyTimelineItemGpu.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyTimelineItemPlot.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyTimelineItemThread.cpp" />
|
||||
@ -279,6 +280,7 @@
|
||||
<ClInclude Include="..\..\..\server\TracyThreadCompress.hpp" />
|
||||
<ClInclude Include="..\..\..\server\TracyTimelineController.hpp" />
|
||||
<ClInclude Include="..\..\..\server\TracyTimelineItem.hpp" />
|
||||
<ClInclude Include="..\..\..\server\TracyTimelineItemCpuData.hpp" />
|
||||
<ClInclude Include="..\..\..\server\TracyTimelineItemGpu.hpp" />
|
||||
<ClInclude Include="..\..\..\server\TracyTimelineItemPlot.hpp" />
|
||||
<ClInclude Include="..\..\..\server\TracyTimelineItemThread.hpp" />
|
||||
|
@ -372,6 +372,9 @@
|
||||
<ClCompile Include="..\..\..\server\TracyView_GpuTimeline.cpp">
|
||||
<Filter>server</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\server\TracyTimelineItemCpuData.cpp">
|
||||
<Filter>server</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\server\TracyEvent.hpp">
|
||||
@ -752,6 +755,9 @@
|
||||
<ClInclude Include="..\..\..\server\TracyTimelineItemGpu.hpp">
|
||||
<Filter>server</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\server\TracyTimelineItemCpuData.hpp">
|
||||
<Filter>server</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Natvis Include="DebugVis.natvis" />
|
||||
|
46
server/TracyTimelineItemCpuData.cpp
Normal file
46
server/TracyTimelineItemCpuData.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
#include "TracyImGui.hpp"
|
||||
#include "TracyPrint.hpp"
|
||||
#include "TracyTimelineItemCpuData.hpp"
|
||||
#include "TracyUtility.hpp"
|
||||
#include "TracyView.hpp"
|
||||
#include "TracyWorker.hpp"
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
TimelineItemCpuData::TimelineItemCpuData( View& view, Worker& worker, void* )
|
||||
: TimelineItem( view, worker )
|
||||
{
|
||||
}
|
||||
|
||||
void TimelineItemCpuData::SetVisible( bool visible )
|
||||
{
|
||||
m_view.GetViewData().drawCpuData = visible;
|
||||
}
|
||||
|
||||
bool TimelineItemCpuData::IsVisible() const
|
||||
{
|
||||
return m_view.GetViewData().drawCpuData;
|
||||
}
|
||||
|
||||
bool TimelineItemCpuData::IsEmpty() const
|
||||
{
|
||||
return m_worker.GetCpuDataCpuCount() == 0;
|
||||
}
|
||||
|
||||
int64_t TimelineItemCpuData::RangeBegin() const
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int64_t TimelineItemCpuData::RangeEnd() const
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool TimelineItemCpuData::DrawContents( double pxns, int& offset, const ImVec2& wpos, bool hover, float yMin, float yMax )
|
||||
{
|
||||
return m_view.DrawCpuData( pxns, offset, wpos, hover, yMin, yMax );
|
||||
}
|
||||
|
||||
}
|
34
server/TracyTimelineItemCpuData.hpp
Normal file
34
server/TracyTimelineItemCpuData.hpp
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef __TRACYTIMELINEITEMCPUDATA_HPP__
|
||||
#define __TRACYTIMELINEITEMCPUDATA_HPP__
|
||||
|
||||
#include "TracyEvent.hpp"
|
||||
#include "TracyTimelineItem.hpp"
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
class TimelineItemCpuData final : public TimelineItem
|
||||
{
|
||||
public:
|
||||
TimelineItemCpuData( View& view, Worker& worker, void* );
|
||||
|
||||
void SetVisible( bool visible ) override;
|
||||
bool IsVisible() const override;
|
||||
|
||||
protected:
|
||||
uint32_t HeaderColor() const override { return 0xFFDD88DD; }
|
||||
uint32_t HeaderColorInactive() const override { return 0xFF6E446E; }
|
||||
uint32_t HeaderLineColor() const override { return 0x66DD88DD; }
|
||||
const char* HeaderLabel() const override { return "CPU data"; }
|
||||
|
||||
int64_t RangeBegin() const override;
|
||||
int64_t RangeEnd() const override;
|
||||
|
||||
bool DrawContents( double pxns, int& offset, const ImVec2& wpos, bool hover, float yMin, float yMax ) override;
|
||||
|
||||
bool IsEmpty() const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -123,6 +123,7 @@ public:
|
||||
void DrawThreadMessages( const ThreadData& thread, double pxns, int offset, const ImVec2& wpos, bool hover );
|
||||
void DrawThreadOverlays( const ThreadData& thread, const ImVec2& ul, const ImVec2& dr );
|
||||
bool DrawGpu( const GpuCtxData& gpu, double pxns, int& offset, const ImVec2& wpos, bool hover, float yMin, float yMax );
|
||||
bool DrawCpuData( double pxns, int& offset, const ImVec2& wpos, bool hover, float yMin, float yMax );
|
||||
|
||||
bool m_showRanges = false;
|
||||
Range m_statRange;
|
||||
@ -222,7 +223,6 @@ private:
|
||||
int DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos, int offset, LockHighlight& highlight, float yMin, float yMax );
|
||||
void DrawPlotPoint( const ImVec2& wpos, float x, float y, int offset, uint32_t color, bool hover, bool hasPrev, const PlotItem* item, double prev, bool merged, PlotType type, PlotValueFormatting format, float PlotHeight, uint64_t name );
|
||||
void DrawPlotPoint( const ImVec2& wpos, float x, float y, int offset, uint32_t color, bool hover, bool hasPrev, double val, double prev, bool merged, PlotValueFormatting format, float PlotHeight );
|
||||
int DrawCpuData( int offset, double pxns, const ImVec2& wpos, bool hover, float yMin, float yMax );
|
||||
void DrawOptions();
|
||||
void DrawMessages();
|
||||
void DrawMessageLine( const MessageData& msg, bool hasCallstack, int& idx );
|
||||
|
@ -11,11 +11,11 @@ namespace tracy
|
||||
|
||||
constexpr float MinVisSize = 3;
|
||||
|
||||
int View::DrawCpuData( int offset, double pxns, const ImVec2& wpos, bool hover, float yMin, float yMax )
|
||||
bool View::DrawCpuData( double pxns, int& offset, const ImVec2& wpos, bool hover, float yMin, float yMax )
|
||||
{
|
||||
auto cpuData = m_worker.GetCpuData();
|
||||
const auto cpuCnt = m_worker.GetCpuDataCpuCount();
|
||||
if( cpuCnt == 0 ) return offset;
|
||||
assert( cpuCnt != 0 );
|
||||
|
||||
const auto w = ImGui::GetContentRegionAvail().x - 1;
|
||||
const auto ty = ImGui::GetTextLineHeight();
|
||||
@ -27,45 +27,6 @@ int View::DrawCpuData( int offset, double pxns, const ImVec2& wpos, bool hover,
|
||||
const auto th = ( ty - to ) * sqrt( 3 ) * 0.5;
|
||||
const auto dpos = wpos + ImVec2( 0.5f, 0.5f );
|
||||
|
||||
static int cpuDataVisStub;
|
||||
auto& vis = m_tc.Vis( &cpuDataVisStub );
|
||||
bool& showFull = vis.showFull;
|
||||
ImGui::PushID( &vis );
|
||||
|
||||
const auto yPos = m_tc.AdjustThreadPosition( vis, wpos.y, offset );
|
||||
const auto oldOffset = offset;
|
||||
ImGui::PushClipRect( wpos, wpos + ImVec2( w, offset + vis.height ), true );
|
||||
if( yPos + ty >= yMin && yPos <= yMax )
|
||||
{
|
||||
if( showFull )
|
||||
{
|
||||
draw->AddTriangleFilled( wpos + ImVec2( to/2, offset + to/2 ), wpos + ImVec2( ty - to/2, offset + to/2 ), wpos + ImVec2( ty * 0.5, offset + to/2 + th ), 0xFFDD88DD );
|
||||
}
|
||||
else
|
||||
{
|
||||
draw->AddTriangle( wpos + ImVec2( to/2, offset + to/2 ), wpos + ImVec2( to/2, offset + ty - to/2 ), wpos + ImVec2( to/2 + th, offset + ty * 0.5 ), 0xFF6E446E, 2.0f );
|
||||
}
|
||||
|
||||
float txtx = ImGui::CalcTextSize( "CPU data" ).x;
|
||||
DrawTextContrast( draw, wpos + ImVec2( ty, offset ), showFull ? 0xFFDD88DD : 0xFF6E446E, "CPU data" );
|
||||
DrawLine( draw, dpos + ImVec2( 0, offset + ty - 1 ), dpos + ImVec2( w, offset + ty - 1 ), 0x66DD88DD );
|
||||
|
||||
if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( 0, offset ), wpos + ImVec2( ty + txtx, offset + ty ) ) )
|
||||
{
|
||||
if( IsMouseClicked( 0 ) )
|
||||
{
|
||||
showFull = !showFull;
|
||||
}
|
||||
if( IsMouseClicked( 1 ) )
|
||||
{
|
||||
ImGui::OpenPopup( "menuPopup" );
|
||||
}
|
||||
}
|
||||
}
|
||||
offset += ostep;
|
||||
|
||||
if( showFull )
|
||||
{
|
||||
#ifdef TRACY_NO_STATISTICS
|
||||
if( m_vd.drawCpuUsageGraph )
|
||||
#else
|
||||
@ -452,24 +413,7 @@ int View::DrawCpuData( int offset, double pxns, const ImVec2& wpos, bool hover,
|
||||
}
|
||||
|
||||
ImGui::PopFont();
|
||||
}
|
||||
|
||||
if( ImGui::BeginPopup( "menuPopup" ) )
|
||||
{
|
||||
if( ImGui::MenuItem( ICON_FA_EYE_SLASH " Hide" ) )
|
||||
{
|
||||
m_vd.drawCpuData = false;
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
offset += ostep * 0.2f;
|
||||
m_tc.AdjustThreadHeight( vis, oldOffset, offset );
|
||||
ImGui::PopClipRect();
|
||||
ImGui::PopID();
|
||||
|
||||
return offset;
|
||||
return true;
|
||||
}
|
||||
|
||||
void View::DrawCpuDataWindow()
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "TracyMouse.hpp"
|
||||
#include "TracyPrint.hpp"
|
||||
#include "TracySourceView.hpp"
|
||||
#include "TracyTimelineItemCpuData.hpp"
|
||||
#include "TracyTimelineItemGpu.hpp"
|
||||
#include "TracyTimelineItemPlot.hpp"
|
||||
#include "TracyTimelineItemThread.hpp"
|
||||
@ -349,7 +350,8 @@ void View::DrawTimeline()
|
||||
}
|
||||
if( m_vd.drawCpuData && m_worker.HasContextSwitches() )
|
||||
{
|
||||
offset = DrawCpuData( offset, pxns, wpos, hover, yMin, yMax );
|
||||
static char uptr;
|
||||
m_tc.AddItem<TimelineItemCpuData>( &uptr );
|
||||
}
|
||||
if( m_vd.drawZones )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user