mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-30 01:04:36 +00:00
Perform GPU to CPU resynchronization on each collect event.
This commit is contained in:
parent
0100266234
commit
a515bf8878
@ -102,6 +102,22 @@ public:
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
m_tail = ( m_tail + 1 ) % QueryCount;
|
||||
}
|
||||
|
||||
{
|
||||
int64_t tgpu;
|
||||
glGetInteger64v( GL_TIMESTAMP, &tgpu );
|
||||
int64_t tcpu = Profiler::GetTime();
|
||||
|
||||
Magic magic;
|
||||
auto& token = s_token.ptr;
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin<moodycamel::CanAlloc>( magic );
|
||||
item->hdr.type = QueueType::GpuResync;
|
||||
item->gpuResync.cpuTime = tcpu;
|
||||
item->gpuResync.gpuTime = tgpu;
|
||||
item->gpuResync.context = m_context;
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -26,6 +26,7 @@ enum class QueueType : uint8_t
|
||||
GpuZoneBegin,
|
||||
GpuZoneEnd,
|
||||
GpuTime,
|
||||
GpuResync,
|
||||
StringData,
|
||||
ThreadName,
|
||||
CustomStringData,
|
||||
@ -162,6 +163,13 @@ struct QueueGpuTime
|
||||
uint16_t context;
|
||||
};
|
||||
|
||||
struct QueueGpuResync
|
||||
{
|
||||
int64_t cpuTime;
|
||||
int64_t gpuTime;
|
||||
uint16_t context;
|
||||
};
|
||||
|
||||
struct QueueHeader
|
||||
{
|
||||
union
|
||||
@ -192,6 +200,7 @@ struct QueueItem
|
||||
QueueGpuZoneBegin gpuZoneBegin;
|
||||
QueueGpuZoneEnd gpuZoneEnd;
|
||||
QueueGpuTime gpuTime;
|
||||
QueueGpuResync gpuResync;
|
||||
};
|
||||
};
|
||||
|
||||
@ -219,6 +228,7 @@ static const size_t QueueDataSize[] = {
|
||||
sizeof( QueueHeader ) + sizeof( QueueGpuZoneBegin ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueGpuZoneEnd ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueGpuTime ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueGpuResync ),
|
||||
// keep all QueueStringTransfer below
|
||||
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // string data
|
||||
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // thread name
|
||||
|
@ -151,6 +151,12 @@ struct ThreadData
|
||||
Vector<MessageData*> messages;
|
||||
};
|
||||
|
||||
struct GpuCtxResync
|
||||
{
|
||||
int64_t timeDiff;
|
||||
uint16_t events;
|
||||
};
|
||||
|
||||
struct GpuCtxData
|
||||
{
|
||||
int64_t timeDiff;
|
||||
@ -159,6 +165,7 @@ struct GpuCtxData
|
||||
Vector<GpuEvent*> timeline;
|
||||
Vector<GpuEvent*> stack;
|
||||
Vector<GpuEvent*> queue;
|
||||
Vector<GpuCtxResync> resync;
|
||||
uint8_t accuracyBits;
|
||||
bool showFull;
|
||||
};
|
||||
|
@ -619,6 +619,9 @@ void View::Process( const QueueItem& ev )
|
||||
case QueueType::GpuTime:
|
||||
ProcessGpuTime( ev.gpuTime );
|
||||
break;
|
||||
case QueueType::GpuResync:
|
||||
ProcessGpuResync( ev.gpuResync );
|
||||
break;
|
||||
case QueueType::Terminate:
|
||||
m_terminate = true;
|
||||
break;
|
||||
@ -912,6 +915,44 @@ void View::ProcessGpuTime( const QueueGpuTime& ev )
|
||||
}
|
||||
|
||||
ctx->queue.erase( ctx->queue.begin() );
|
||||
if( !ctx->resync.empty() )
|
||||
{
|
||||
auto& resync = ctx->resync.front();
|
||||
assert( resync.events > 0 );
|
||||
resync.events--;
|
||||
if( resync.events == 0 )
|
||||
{
|
||||
ctx->timeDiff = resync.timeDiff;
|
||||
ctx->resync.erase( ctx->resync.begin() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void View::ProcessGpuResync( const QueueGpuResync& ev )
|
||||
{
|
||||
auto it = m_gpuCtxMap.find( ev.context );
|
||||
assert( it != m_gpuCtxMap.end() );
|
||||
auto ctx = it->second;
|
||||
|
||||
const auto timeDiff = int64_t( ev.cpuTime * m_timerMul - ev.gpuTime );
|
||||
|
||||
if( ctx->queue.empty() )
|
||||
{
|
||||
assert( ctx->resync.empty() );
|
||||
ctx->timeDiff = timeDiff;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ctx->resync.empty() )
|
||||
{
|
||||
ctx->resync.push_back( { timeDiff, uint16_t( ctx->queue.size() ) } );
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto last = ctx->resync.back().events;
|
||||
ctx->resync.push_back( { timeDiff, uint16_t( ctx->queue.size() - last ) } );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void View::CheckString( uint64_t ptr )
|
||||
|
@ -76,6 +76,7 @@ private:
|
||||
tracy_force_inline void ProcessGpuZoneBegin( const QueueGpuZoneBegin& ev );
|
||||
tracy_force_inline void ProcessGpuZoneEnd( const QueueGpuZoneEnd& ev );
|
||||
tracy_force_inline void ProcessGpuTime( const QueueGpuTime& ev );
|
||||
tracy_force_inline void ProcessGpuResync( const QueueGpuResync& ev );
|
||||
|
||||
void CheckString( uint64_t ptr );
|
||||
void CheckThreadString( uint64_t id );
|
||||
|
Loading…
Reference in New Issue
Block a user