mirror of
https://github.com/wolfpld/tracy
synced 2025-05-09 16:23:54 +00:00
Allow viewing source from zone trace.
This commit is contained in:
parent
fb876344e3
commit
410616f7f8
@ -703,6 +703,7 @@ bool View::DrawImpl()
|
|||||||
|
|
||||||
m_callstackBuzzAnim.Update( io.DeltaTime );
|
m_callstackBuzzAnim.Update( io.DeltaTime );
|
||||||
m_callstackTreeBuzzAnim.Update( io.DeltaTime );
|
m_callstackTreeBuzzAnim.Update( io.DeltaTime );
|
||||||
|
m_zoneinfoBuzzAnim.Update( io.DeltaTime );
|
||||||
|
|
||||||
return keepOpen;
|
return keepOpen;
|
||||||
}
|
}
|
||||||
@ -3350,7 +3351,7 @@ void View::DrawInfoWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void DrawZoneTrace( T zone, const std::vector<T>& trace, const Worker& worker, std::function<void(T)> showZone )
|
void DrawZoneTrace( T zone, const std::vector<T>& trace, const Worker& worker, BuzzAnim<const void*>& anim, View& view, std::function<void(T)> showZone )
|
||||||
{
|
{
|
||||||
bool expand = ImGui::TreeNode( "Zone trace" );
|
bool expand = ImGui::TreeNode( "Zone trace" );
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
@ -3396,14 +3397,35 @@ void DrawZoneTrace( T zone, const std::vector<T>& trace, const Worker& worker, s
|
|||||||
ImGui::TextDisabled( "%s", worker.GetString( frame->name ) );
|
ImGui::TextDisabled( "%s", worker.GetString( frame->name ) );
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
ImGui::SameLine();
|
if( anim.Match( frame ) )
|
||||||
if( frame->line == 0 )
|
|
||||||
{
|
{
|
||||||
ImGui::TextDisabled( "%s", worker.GetString( frame->file ) );
|
const auto time = anim.Time();
|
||||||
|
const auto indentVal = sin( time * 60.f ) * 10.f * time;
|
||||||
|
ImGui::SameLine( 0, ImGui::GetStyle().ItemSpacing.x + indentVal );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ImGui::TextDisabled( "%s:%i", worker.GetString( frame->file ), frame->line );
|
ImGui::SameLine();
|
||||||
|
}
|
||||||
|
const auto fileName = worker.GetString( frame->file );
|
||||||
|
if( frame->line == 0 )
|
||||||
|
{
|
||||||
|
ImGui::TextDisabled( "%s", fileName );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ImGui::TextDisabled( "%s:%i", fileName, frame->line );
|
||||||
|
}
|
||||||
|
if( ImGui::IsItemClicked( 1 ) )
|
||||||
|
{
|
||||||
|
if( frame->line != 0 && FileExists( fileName ) )
|
||||||
|
{
|
||||||
|
view.SetTextEditorFile( fileName, frame->line );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
anim.Enable( frame, 0.5f );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3428,14 +3450,35 @@ void DrawZoneTrace( T zone, const std::vector<T>& trace, const Worker& worker, s
|
|||||||
ImGui::TextDisabled( "%s", worker.GetString( frame->name ) );
|
ImGui::TextDisabled( "%s", worker.GetString( frame->name ) );
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
ImGui::SameLine();
|
if( anim.Match( frame ) )
|
||||||
if( frame->line == 0 )
|
|
||||||
{
|
{
|
||||||
ImGui::TextDisabled( "%s", worker.GetString( frame->file ) );
|
const auto time = anim.Time();
|
||||||
|
const auto indentVal = sin( time * 60.f ) * 10.f * time;
|
||||||
|
ImGui::SameLine( 0, ImGui::GetStyle().ItemSpacing.x + indentVal );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ImGui::TextDisabled( "%s:%i", worker.GetString( frame->file ), frame->line );
|
ImGui::SameLine();
|
||||||
|
}
|
||||||
|
const auto fileName = worker.GetString( frame->file );
|
||||||
|
if( frame->line == 0 )
|
||||||
|
{
|
||||||
|
ImGui::TextDisabled( "%s", fileName );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ImGui::TextDisabled( "%s:%i", fileName, frame->line );
|
||||||
|
}
|
||||||
|
if( ImGui::IsItemClicked( 1 ) )
|
||||||
|
{
|
||||||
|
if( frame->line != 0 && FileExists( fileName ) )
|
||||||
|
{
|
||||||
|
view.SetTextEditorFile( fileName, frame->line );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
anim.Enable( frame, 0.5f );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3699,15 +3742,36 @@ void View::DrawZoneInfoWindow()
|
|||||||
parent = GetZoneParent( *parent );
|
parent = GetZoneParent( *parent );
|
||||||
}
|
}
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
DrawZoneTrace<const ZoneEvent*>( &ev, zoneTrace, m_worker, [&idx, this] ( const ZoneEvent* v ) {
|
DrawZoneTrace<const ZoneEvent*>( &ev, zoneTrace, m_worker, m_zoneinfoBuzzAnim, *this, [&idx, this] ( const ZoneEvent* v ) {
|
||||||
const auto& srcloc = m_worker.GetSourceLocation( v->srcloc );
|
const auto& srcloc = m_worker.GetSourceLocation( v->srcloc );
|
||||||
const auto txt = m_worker.GetZoneName( *v, srcloc );
|
const auto txt = m_worker.GetZoneName( *v, srcloc );
|
||||||
ImGui::PushID( idx++ );
|
ImGui::PushID( idx++ );
|
||||||
auto sel = ImGui::Selectable( txt, false );
|
auto sel = ImGui::Selectable( txt, false );
|
||||||
auto hover = ImGui::IsItemHovered();
|
auto hover = ImGui::IsItemHovered();
|
||||||
ImGui::SameLine();
|
const auto fileName = m_worker.GetString( srcloc.file );
|
||||||
ImGui::TextDisabled( "(%s) %s:%i", TimeToString( m_worker.GetZoneEnd( *v ) - v->start ), m_worker.GetString( srcloc.file ), srcloc.line );
|
if( m_zoneinfoBuzzAnim.Match( v ) )
|
||||||
|
{
|
||||||
|
const auto time = m_zoneinfoBuzzAnim.Time();
|
||||||
|
const auto indentVal = sin( time * 60.f ) * 10.f * time;
|
||||||
|
ImGui::SameLine( 0, ImGui::GetStyle().ItemSpacing.x + indentVal );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ImGui::SameLine();
|
||||||
|
}
|
||||||
|
ImGui::TextDisabled( "(%s) %s:%i", TimeToString( m_worker.GetZoneEnd( *v ) - v->start ), fileName, srcloc.line );
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
|
if( ImGui::IsItemClicked( 1 ) )
|
||||||
|
{
|
||||||
|
if( FileExists( fileName ) )
|
||||||
|
{
|
||||||
|
SetTextEditorFile( fileName, srcloc.line );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_zoneinfoBuzzAnim.Enable( v, 0.5f );
|
||||||
|
}
|
||||||
|
}
|
||||||
if( sel )
|
if( sel )
|
||||||
{
|
{
|
||||||
ShowZoneInfo( *v );
|
ShowZoneInfo( *v );
|
||||||
@ -3929,15 +3993,36 @@ void View::DrawGpuInfoWindow()
|
|||||||
parent = GetZoneParent( *parent );
|
parent = GetZoneParent( *parent );
|
||||||
}
|
}
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
DrawZoneTrace<const GpuEvent*>( &ev, zoneTrace, m_worker, [&idx, this] ( const GpuEvent* v ) {
|
DrawZoneTrace<const GpuEvent*>( &ev, zoneTrace, m_worker, m_zoneinfoBuzzAnim, *this, [&idx, this] ( const GpuEvent* v ) {
|
||||||
const auto& srcloc = m_worker.GetSourceLocation( v->srcloc );
|
const auto& srcloc = m_worker.GetSourceLocation( v->srcloc );
|
||||||
const auto txt = m_worker.GetZoneName( *v, srcloc );
|
const auto txt = m_worker.GetZoneName( *v, srcloc );
|
||||||
ImGui::PushID( idx++ );
|
ImGui::PushID( idx++ );
|
||||||
auto sel = ImGui::Selectable( txt, false );
|
auto sel = ImGui::Selectable( txt, false );
|
||||||
auto hover = ImGui::IsItemHovered();
|
auto hover = ImGui::IsItemHovered();
|
||||||
ImGui::SameLine();
|
const auto fileName = m_worker.GetString( srcloc.file );
|
||||||
ImGui::TextDisabled( "(%s) %s:%i", TimeToString( m_worker.GetZoneEnd( *v ) - v->gpuStart ), m_worker.GetString( srcloc.file ), srcloc.line );
|
if( m_zoneinfoBuzzAnim.Match( v ) )
|
||||||
|
{
|
||||||
|
const auto time = m_zoneinfoBuzzAnim.Time();
|
||||||
|
const auto indentVal = sin( time * 60.f ) * 10.f * time;
|
||||||
|
ImGui::SameLine( 0, ImGui::GetStyle().ItemSpacing.x + indentVal );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ImGui::SameLine();
|
||||||
|
}
|
||||||
|
ImGui::TextDisabled( "(%s) %s:%i", TimeToString( m_worker.GetZoneEnd( *v ) - v->gpuStart ), fileName, srcloc.line );
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
|
if( ImGui::IsItemClicked( 1 ) )
|
||||||
|
{
|
||||||
|
if( FileExists( fileName ) )
|
||||||
|
{
|
||||||
|
SetTextEditorFile( fileName, srcloc.line );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_zoneinfoBuzzAnim.Enable( v, 0.5f );
|
||||||
|
}
|
||||||
|
}
|
||||||
if( sel )
|
if( sel )
|
||||||
{
|
{
|
||||||
ShowZoneInfo( *v, m_gpuInfoWindowThread );
|
ShowZoneInfo( *v, m_gpuInfoWindowThread );
|
||||||
|
@ -54,6 +54,7 @@ public:
|
|||||||
static bool Draw();
|
static bool Draw();
|
||||||
|
|
||||||
void NotifyRootWindowSize( float w, float h ) { m_rootWidth = w; m_rootHeight = h; }
|
void NotifyRootWindowSize( float w, float h ) { m_rootWidth = w; m_rootHeight = h; }
|
||||||
|
void SetTextEditorFile( const char* fileName, int line );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class Namespace : uint8_t
|
enum class Namespace : uint8_t
|
||||||
@ -64,7 +65,6 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
void InitTextEditor();
|
void InitTextEditor();
|
||||||
void SetTextEditorFile( const char* fileName, int line );
|
|
||||||
|
|
||||||
const char* ShortenNamespace( const char* name ) const;
|
const char* ShortenNamespace( const char* name ) const;
|
||||||
|
|
||||||
@ -239,6 +239,7 @@ private:
|
|||||||
Animation m_zoomAnim;
|
Animation m_zoomAnim;
|
||||||
BuzzAnim<int> m_callstackBuzzAnim;
|
BuzzAnim<int> m_callstackBuzzAnim;
|
||||||
BuzzAnim<int> m_callstackTreeBuzzAnim;
|
BuzzAnim<int> m_callstackTreeBuzzAnim;
|
||||||
|
BuzzAnim<const void*> m_zoneinfoBuzzAnim;
|
||||||
|
|
||||||
Vector<const ZoneEvent*> m_zoneInfoStack;
|
Vector<const ZoneEvent*> m_zoneInfoStack;
|
||||||
Vector<const GpuEvent*> m_gpuInfoStack;
|
Vector<const GpuEvent*> m_gpuInfoStack;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user