Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/server.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ set(TRACY_SERVER_SOURCES
TracyTextureCompression.cpp
TracyThreadCompress.cpp
TracyWorker.cpp
TracyContext.cpp
)

list(TRANSFORM TRACY_SERVER_SOURCES PREPEND "${TRACY_SERVER_DIR}/")
Expand Down
45 changes: 17 additions & 28 deletions profiler/src/profiler/TracyTimelineItemGpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const char* TimelineItemGpu::HeaderLabel() const
}
else
{
sprintf( buf, "%s context %i", GpuContextNames[(int)m_gpu->type], m_idx );
sprintf( buf, "%s context %i", ZoneContextNames[(int)m_gpu->type], m_idx );
}
return buf;
}
Expand All @@ -40,13 +40,13 @@ void TimelineItemGpu::HeaderTooltip( const char* label ) const
{
const bool dynamicColors = m_view.GetViewData().dynamicColors;
const bool isMultithreaded =
( m_gpu->type == GpuContextType::Vulkan ) ||
( m_gpu->type == GpuContextType::OpenCL ) ||
( m_gpu->type == GpuContextType::Direct3D12 ) ||
( m_gpu->type == GpuContextType::Metal );
( m_gpu->type == ZoneContextType::Vulkan ) ||
( m_gpu->type == ZoneContextType::OpenCL ) ||
( m_gpu->type == ZoneContextType::Direct3D12 ) ||
( m_gpu->type == ZoneContextType::Metal );

char buf[64];
sprintf( buf, "%s context %i", GpuContextNames[(int)m_gpu->type], m_idx );
sprintf( buf, "%s context %i", ZoneContextNames[(int)m_gpu->type], m_idx );

ImGui::BeginTooltip();
if( m_gpu->name.Active() ) TextFocused( "Name:", m_worker.GetString( m_gpu->name ) );
Expand All @@ -66,18 +66,7 @@ void TimelineItemGpu::HeaderTooltip( const char* label ) const
auto tid = it->first;
if( tid == 0 )
{
if( !it->second.timeline.empty() )
{
if( it->second.timeline.is_magic() )
{
auto& tl = *(Vector<GpuEvent>*)&it->second.timeline;
tid = m_worker.DecompressThread( tl.begin()->Thread() );
}
else
{
tid = m_worker.DecompressThread( (*it->second.timeline.begin())->Thread() );
}
}
tid = it->second->id;
}
SmallColorBox( GetThreadColor( tid, 0, dynamicColors ) );
ImGui::SameLine();
Expand Down Expand Up @@ -134,7 +123,7 @@ void TimelineItemGpu::HeaderExtraContents( const TimelineContext& ctx, int offse
const auto ty = ImGui::GetTextLineHeight();

char buf[64];
sprintf( buf, "%s context %i", GpuContextNames[(int)m_gpu->type], m_idx );
sprintf( buf, "%s context %i", ZoneContextNames[(int)m_gpu->type], m_idx );
draw->AddText( ctx.wpos + ImVec2( ty * 1.5f + labelWidth, offset ), HeaderColorInactive(), buf );
}
}
Expand All @@ -145,13 +134,13 @@ int64_t TimelineItemGpu::RangeBegin() const
for( auto& td : m_gpu->threadData )
{
int64_t t0;
if( td.second.timeline.is_magic() )
if( td.second->timeline.is_magic() )
{
t0 = ((Vector<GpuEvent>*)&td.second.timeline)->front().GpuStart();
t0 = ((Vector<ZoneEvent>*)&td.second->timeline)->front().Start();
}
else
{
t0 = td.second.timeline.front()->GpuStart();
t0 = td.second->timeline.front()->Start();
}
if( t0 >= 0 )
{
Expand All @@ -167,23 +156,23 @@ int64_t TimelineItemGpu::RangeEnd() const
for( auto& td : m_gpu->threadData )
{
int64_t t0;
if( td.second.timeline.is_magic() )
if( td.second->timeline.is_magic() )
{
t0 = ((Vector<GpuEvent>*)&td.second.timeline)->front().GpuStart();
t0 = ((Vector<ZoneEvent>*)&td.second->timeline)->front().Start();
}
else
{
t0 = td.second.timeline.front()->GpuStart();
t0 = td.second->timeline.front()->Start();
}
if( t0 >= 0 )
{
if( td.second.timeline.is_magic() )
if( td.second->timeline.is_magic() )
{
t = std::max( t, std::min( m_worker.GetLastTime(), m_worker.GetZoneEnd( ((Vector<GpuEvent>*)&td.second.timeline)->back() ) ) );
t = std::max( t, std::min( m_worker.GetLastTime(), m_worker.GetZoneEnd( ((Vector<ZoneEvent>*)&td.second->timeline)->back() ) ) );
}
else
{
t = std::max( t, std::min( m_worker.GetLastTime(), m_worker.GetZoneEnd( *td.second.timeline.back() ) ) );
t = std::max( t, std::min( m_worker.GetLastTime(), m_worker.GetZoneEnd( *td.second->timeline.back() ) ) );
}
}
}
Expand Down
1 change: 1 addition & 0 deletions profiler/src/profiler/TracyTimelineItemGpu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define __TRACYTIMELINEITEMGPU_HPP__

#include "TracyEvent.hpp"
#include "TracyContext.hpp"
#include "TracyTimelineItem.hpp"

namespace tracy
Expand Down
72 changes: 43 additions & 29 deletions profiler/src/profiler/TracyTimelineItemThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ bool TimelineItemThread::IsEmpty() const
{
auto& crash = m_worker.GetCrashEvent();
return crash.thread != m_thread->id &&
m_thread->timeline.empty() &&
m_thread->messages.empty() &&
m_thread->ghostZones.empty();
m_thread->timeline.empty() &&
m_thread->messages.empty() &&
( m_thread->ctx->type != ZoneContextType::CPU ||
static_cast<const CPUThreadData*>( m_thread )->ghostZones.empty() );
}

uint32_t TimelineItemThread::HeaderColor() const
Expand Down Expand Up @@ -220,14 +221,18 @@ void TimelineItemThread::HeaderTooltip( const char* label ) const
{
TextFocused( "Running state regions:", RealToString( ctx->v.size() ) );
}
if( !m_thread->samples.empty() )
if( m_thread->ctx->type != ZoneContextType::CPU )
{
TextFocused( "Call stack samples:", RealToString( m_thread->samples.size() ) );
if( m_thread->kernelSampleCnt != 0 )
auto cpu_thread = static_cast<const CPUThreadData*>( m_thread );
if( !cpu_thread->samples.empty() )
{
TextFocused( "Kernel samples:", RealToString( m_thread->kernelSampleCnt ) );
ImGui::SameLine();
ImGui::TextDisabled( "(%.2f%%)", 100.f * m_thread->kernelSampleCnt / m_thread->samples.size() );
TextFocused( "Call stack samples:", RealToString( cpu_thread->samples.size() ) );
if( cpu_thread->kernelSampleCnt != 0 )
{
TextFocused( "Kernel samples:", RealToString( cpu_thread->kernelSampleCnt ) );
ImGui::SameLine();
ImGui::TextDisabled( "(%.2f%%)", 100.f * cpu_thread->kernelSampleCnt / cpu_thread->samples.size() );
}
}
}
ImGui::EndTooltip();
Expand All @@ -238,21 +243,25 @@ void TimelineItemThread::HeaderExtraContents( const TimelineContext& ctx, int of
m_view.DrawThreadMessagesList( ctx, m_msgDraw, offset, m_thread->id );

#ifndef TRACY_NO_STATISTICS
const bool hasGhostZones = m_worker.AreGhostZonesReady() && !m_thread->ghostZones.empty();
if( hasGhostZones && !m_thread->timeline.empty() )
if( m_thread->ctx->type == ZoneContextType::CPU )
{
auto draw = ImGui::GetWindowDrawList();
const auto ty = ImGui::GetTextLineHeight();
auto cpu_thread = static_cast<const CPUThreadData*>( m_thread );
const bool hasGhostZones = m_worker.AreGhostZonesReady() && !cpu_thread->ghostZones.empty();
if( hasGhostZones && !m_thread->timeline.empty() )
{
auto draw = ImGui::GetWindowDrawList();
const auto ty = ImGui::GetTextLineHeight();

const auto color = m_ghost ? 0xFFAA9999 : 0x88AA7777;
draw->AddText( ctx.wpos + ImVec2( 1.5f * ty + labelWidth, offset ), color, ICON_FA_GHOST );
float ghostSz = ImGui::CalcTextSize( ICON_FA_GHOST ).x;
const auto color = m_ghost ? 0xFFAA9999 : 0x88AA7777;
draw->AddText( ctx.wpos + ImVec2( 1.5f * ty + labelWidth, offset ), color, ICON_FA_GHOST );
float ghostSz = ImGui::CalcTextSize( ICON_FA_GHOST ).x;

if( ctx.hover && ImGui::IsMouseHoveringRect( ctx.wpos + ImVec2( 1.5f * ty + labelWidth, offset ), ctx.wpos + ImVec2( 1.5f * ty + labelWidth + ghostSz, offset + ty ) ) )
{
if( IsMouseClicked( 0 ) )
if( ctx.hover && ImGui::IsMouseHoveringRect( ctx.wpos + ImVec2( 1.5f * ty + labelWidth, offset ), ctx.wpos + ImVec2( 1.5f * ty + labelWidth + ghostSz, offset + ty ) ) )
{
m_ghost = !m_ghost;
if( IsMouseClicked( 0 ) )
{
m_ghost = !m_ghost;
}
}
}
}
Expand Down Expand Up @@ -309,9 +318,10 @@ void TimelineItemThread::Preprocess( const TimelineContext& ctx, TaskDispatch& t

td.Queue( [this, &ctx, visible] {
#ifndef TRACY_NO_STATISTICS
if( m_worker.AreGhostZonesReady() && ( m_ghost || ( m_view.GetViewData().ghostZones && m_thread->timeline.empty() ) ) )
if( m_thread->ctx->type == ZoneContextType::CPU && m_worker.AreGhostZonesReady() && ( m_ghost || ( m_view.GetViewData().ghostZones && m_thread->timeline.empty() ) ) )
{
m_depth = PreprocessGhostLevel( ctx, m_thread->ghostZones, 0, visible );
auto cpu_thread = static_cast<const CPUThreadData*>( m_thread );
m_depth = PreprocessGhostLevel( ctx, cpu_thread->ghostZones, 0, visible );
}
else
#endif
Expand All @@ -336,12 +346,16 @@ void TimelineItemThread::Preprocess( const TimelineContext& ctx, TaskDispatch& t
}
}

m_hasSamples = false;
if( vd.drawSamples && !m_thread->samples.empty() )
if( m_thread->ctx->type == ZoneContextType::CPU )
{
td.Queue( [this, &ctx, visible, yPos] {
PreprocessSamples( ctx, m_thread->samples, visible, yPos );
} );
auto cpu_thread = static_cast<const CPUThreadData*>( m_thread );
m_hasSamples = false;
if( vd.drawSamples && !cpu_thread->samples.empty() )
{
td.Queue( [this, &ctx, visible, yPos, cpu_thread] {
PreprocessSamples( ctx, cpu_thread->samples, visible, yPos );
} );
}
}

m_hasMessages = false;
Expand Down Expand Up @@ -525,7 +539,6 @@ void TimelineItemThread::PreprocessContextSwitches( const TimelineContext& ctx,
if( !visible ) return;

const auto MinCtxNs = int64_t( round( GetScale() * MinCtxSize * nspx ) );
const auto& sampleData = m_thread->samples;

bool first = true;
while( it < citend )
Expand All @@ -535,8 +548,9 @@ void TimelineItemThread::PreprocessContextSwitches( const TimelineContext& ctx,
{
first = false;
}
else
else if ( m_thread->ctx->type == ZoneContextType::CPU )
{
const Vector<SampleData>& sampleData = static_cast<const CPUThreadData*>( m_thread )->samples;
uint32_t waitStack = 0;
if( !sampleData.empty() )
{
Expand Down
1 change: 1 addition & 0 deletions profiler/src/profiler/TracyTimelineItemThread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define __TRACYTIMELINEITEMTHREAD_HPP__

#include "TracyEvent.hpp"
#include "TracyContext.hpp"
#include "TracyTimelineDraw.hpp"
#include "TracyTimelineItem.hpp"

Expand Down
1 change: 1 addition & 0 deletions profiler/src/profiler/TracyUtility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "imgui.h"
#include "../server/TracyEvent.hpp"
#include "../server/TracyContext.hpp"

namespace tracy
{
Expand Down
1 change: 0 additions & 1 deletion profiler/src/profiler/TracyView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,6 @@ bool View::DrawImpl()
ImGui::End();

m_zoneHighlight = nullptr;
m_gpuHighlight = nullptr;

DrawInfoWindow();

Expand Down
Loading
Loading