mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
compressing redundant code
This commit is contained in:
parent
1ed4b71afc
commit
4f42a75df2
@ -79,6 +79,14 @@ namespace tracy
|
|||||||
int64_t m_prevCalibration = 0;
|
int64_t m_prevCalibration = 0;
|
||||||
int64_t m_qpcToNs = int64_t{ 1000000000 / GetFrequencyQpc() };
|
int64_t m_qpcToNs = int64_t{ 1000000000 / GetFrequencyQpc() };
|
||||||
|
|
||||||
|
tracy_force_inline void SubmitQueueItem(tracy::QueueItem* item)
|
||||||
|
{
|
||||||
|
#ifdef TRACY_ON_DEMAND
|
||||||
|
GetProfiler().DeferItem(*item);
|
||||||
|
#endif
|
||||||
|
Profiler::QueueSerialFinish();
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
D3D12QueueCtx(ID3D12Device* device, ID3D12CommandQueue* queue)
|
D3D12QueueCtx(ID3D12Device* device, ID3D12CommandQueue* queue)
|
||||||
: m_device(device)
|
: m_device(device)
|
||||||
@ -167,12 +175,7 @@ namespace tracy
|
|||||||
MemWrite(&item->gpuNewContext.context, m_context);
|
MemWrite(&item->gpuNewContext.context, m_context);
|
||||||
MemWrite(&item->gpuNewContext.flags, GpuContextCalibration);
|
MemWrite(&item->gpuNewContext.flags, GpuContextCalibration);
|
||||||
MemWrite(&item->gpuNewContext.type, GpuContextType::Direct3D12);
|
MemWrite(&item->gpuNewContext.type, GpuContextType::Direct3D12);
|
||||||
|
SubmitQueueItem(item);
|
||||||
#ifdef TRACY_ON_DEMAND
|
|
||||||
GetProfiler().DeferItem(*item);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Profiler::QueueSerialFinish();
|
|
||||||
|
|
||||||
m_initialized = true;
|
m_initialized = true;
|
||||||
}
|
}
|
||||||
@ -201,10 +204,7 @@ namespace tracy
|
|||||||
MemWrite( &item->gpuContextNameFat.context, m_context );
|
MemWrite( &item->gpuContextNameFat.context, m_context );
|
||||||
MemWrite( &item->gpuContextNameFat.ptr, (uint64_t)ptr );
|
MemWrite( &item->gpuContextNameFat.ptr, (uint64_t)ptr );
|
||||||
MemWrite( &item->gpuContextNameFat.size, len );
|
MemWrite( &item->gpuContextNameFat.size, len );
|
||||||
#ifdef TRACY_ON_DEMAND
|
SubmitQueueItem(item);
|
||||||
GetProfiler().DeferItem( *item );
|
|
||||||
#endif
|
|
||||||
Profiler::QueueSerialFinish();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Collect()
|
void Collect()
|
||||||
@ -318,8 +318,18 @@ namespace tracy
|
|||||||
ID3D12GraphicsCommandList* m_cmdList = nullptr;
|
ID3D12GraphicsCommandList* m_cmdList = nullptr;
|
||||||
uint32_t m_queryId = 0; // Used for tracking in nested zones.
|
uint32_t m_queryId = 0; // Used for tracking in nested zones.
|
||||||
|
|
||||||
public:
|
tracy_force_inline void WriteQueueItem(QueueItem* item, QueueType type, uint64_t srcLocation)
|
||||||
tracy_force_inline D3D12ZoneScope(D3D12QueueCtx* ctx, ID3D12GraphicsCommandList* cmdList, const SourceLocationData* srcLocation, bool active)
|
{
|
||||||
|
MemWrite(&item->hdr.type, type);
|
||||||
|
MemWrite(&item->gpuZoneBegin.cpuTime, Profiler::GetTime());
|
||||||
|
MemWrite(&item->gpuZoneBegin.srcloc, srcLocation);
|
||||||
|
MemWrite(&item->gpuZoneBegin.thread, GetThreadHandle());
|
||||||
|
MemWrite(&item->gpuZoneBegin.queryId, static_cast<uint16_t>(m_queryId));
|
||||||
|
MemWrite(&item->gpuZoneBegin.context, m_ctx->GetId());
|
||||||
|
Profiler::QueueSerialFinish();
|
||||||
|
}
|
||||||
|
|
||||||
|
tracy_force_inline D3D12ZoneScope(D3D12QueueCtx* ctx, ID3D12GraphicsCommandList* cmdList, bool active)
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
: m_active(active&& GetProfiler().IsConnected())
|
: m_active(active&& GetProfiler().IsConnected())
|
||||||
#else
|
#else
|
||||||
@ -331,100 +341,49 @@ namespace tracy
|
|||||||
m_ctx = ctx;
|
m_ctx = ctx;
|
||||||
m_cmdList = cmdList;
|
m_cmdList = cmdList;
|
||||||
|
|
||||||
m_queryId = ctx->NextQueryId();
|
m_queryId = m_ctx->NextQueryId();
|
||||||
cmdList->EndQuery(ctx->m_queryHeap.Get(), D3D12_QUERY_TYPE_TIMESTAMP, m_queryId);
|
m_cmdList->EndQuery(m_ctx->m_queryHeap.Get(), D3D12_QUERY_TYPE_TIMESTAMP, m_queryId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
tracy_force_inline D3D12ZoneScope(D3D12QueueCtx* ctx, ID3D12GraphicsCommandList* cmdList, const SourceLocationData* srcLocation, bool active)
|
||||||
|
: D3D12ZoneScope(ctx, cmdList, active)
|
||||||
|
{
|
||||||
|
if (!m_active) return;
|
||||||
|
|
||||||
auto* item = Profiler::QueueSerial();
|
auto* item = Profiler::QueueSerial();
|
||||||
MemWrite(&item->hdr.type, QueueType::GpuZoneBeginSerial);
|
WriteQueueItem(item, QueueType::GpuZoneBeginSerial, reinterpret_cast<uint64_t>(srcLocation));
|
||||||
MemWrite(&item->gpuZoneBegin.cpuTime, Profiler::GetTime());
|
|
||||||
MemWrite(&item->gpuZoneBegin.srcloc, reinterpret_cast<uint64_t>(srcLocation));
|
|
||||||
MemWrite(&item->gpuZoneBegin.thread, GetThreadHandle());
|
|
||||||
MemWrite(&item->gpuZoneBegin.queryId, static_cast<uint16_t>(m_queryId));
|
|
||||||
MemWrite(&item->gpuZoneBegin.context, ctx->GetId());
|
|
||||||
|
|
||||||
Profiler::QueueSerialFinish();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tracy_force_inline D3D12ZoneScope(D3D12QueueCtx* ctx, ID3D12GraphicsCommandList* cmdList, const SourceLocationData* srcLocation, int depth, bool active)
|
tracy_force_inline D3D12ZoneScope(D3D12QueueCtx* ctx, ID3D12GraphicsCommandList* cmdList, const SourceLocationData* srcLocation, int depth, bool active)
|
||||||
#ifdef TRACY_ON_DEMAND
|
: D3D12ZoneScope(ctx, cmdList, active)
|
||||||
: m_active(active&& GetProfiler().IsConnected())
|
|
||||||
#else
|
|
||||||
: m_active(active)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
if (!m_active) return;
|
if (!m_active) return;
|
||||||
|
|
||||||
m_ctx = ctx;
|
|
||||||
m_cmdList = cmdList;
|
|
||||||
|
|
||||||
m_queryId = ctx->NextQueryId();
|
|
||||||
cmdList->EndQuery(ctx->m_queryHeap.Get(), D3D12_QUERY_TYPE_TIMESTAMP, m_queryId);
|
|
||||||
|
|
||||||
auto* item = Profiler::QueueSerialCallstack(Callstack(depth));
|
auto* item = Profiler::QueueSerialCallstack(Callstack(depth));
|
||||||
MemWrite(&item->hdr.type, QueueType::GpuZoneBeginCallstackSerial);
|
WriteQueueItem(item, QueueType::GpuZoneBeginCallstackSerial, reinterpret_cast<uint64_t>(srcLocation));
|
||||||
MemWrite(&item->gpuZoneBegin.cpuTime, Profiler::GetTime());
|
|
||||||
MemWrite(&item->gpuZoneBegin.srcloc, reinterpret_cast<uint64_t>(srcLocation));
|
|
||||||
MemWrite(&item->gpuZoneBegin.thread, GetThreadHandle());
|
|
||||||
MemWrite(&item->gpuZoneBegin.queryId, static_cast<uint16_t>(m_queryId));
|
|
||||||
MemWrite(&item->gpuZoneBegin.context, ctx->GetId());
|
|
||||||
|
|
||||||
Profiler::QueueSerialFinish();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tracy_force_inline D3D12ZoneScope(D3D12QueueCtx* ctx, uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, const char* name, size_t nameSz, ID3D12GraphicsCommandList* cmdList, bool active)
|
tracy_force_inline D3D12ZoneScope(D3D12QueueCtx* ctx, uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, const char* name, size_t nameSz, ID3D12GraphicsCommandList* cmdList, bool active)
|
||||||
#ifdef TRACY_ON_DEMAND
|
: D3D12ZoneScope(ctx, cmdList, active)
|
||||||
: m_active(active&& GetProfiler().IsConnected())
|
|
||||||
#else
|
|
||||||
: m_active(active)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
if (!m_active) return;
|
if (!m_active) return;
|
||||||
|
|
||||||
m_ctx = ctx;
|
|
||||||
m_cmdList = cmdList;
|
|
||||||
|
|
||||||
m_queryId = ctx->NextQueryId();
|
|
||||||
cmdList->EndQuery(ctx->m_queryHeap.Get(), D3D12_QUERY_TYPE_TIMESTAMP, m_queryId);
|
|
||||||
|
|
||||||
const auto sourceLocation = Profiler::AllocSourceLocation(line, source, sourceSz, function, functionSz, name, nameSz);
|
const auto sourceLocation = Profiler::AllocSourceLocation(line, source, sourceSz, function, functionSz, name, nameSz);
|
||||||
|
|
||||||
auto* item = Profiler::QueueSerial();
|
auto* item = Profiler::QueueSerial();
|
||||||
MemWrite(&item->hdr.type, QueueType::GpuZoneBeginAllocSrcLocSerial);
|
WriteQueueItem(item, QueueType::GpuZoneBeginAllocSrcLocSerial, sourceLocation);
|
||||||
MemWrite(&item->gpuZoneBegin.cpuTime, Profiler::GetTime());
|
|
||||||
MemWrite(&item->gpuZoneBegin.srcloc, sourceLocation);
|
|
||||||
MemWrite(&item->gpuZoneBegin.thread, GetThreadHandle());
|
|
||||||
MemWrite(&item->gpuZoneBegin.queryId, static_cast<uint16_t>(m_queryId));
|
|
||||||
MemWrite(&item->gpuZoneBegin.context, ctx->GetId());
|
|
||||||
|
|
||||||
Profiler::QueueSerialFinish();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tracy_force_inline D3D12ZoneScope(D3D12QueueCtx* ctx, uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, const char* name, size_t nameSz, ID3D12GraphicsCommandList* cmdList, int depth, bool active)
|
tracy_force_inline D3D12ZoneScope(D3D12QueueCtx* ctx, uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, const char* name, size_t nameSz, ID3D12GraphicsCommandList* cmdList, int depth, bool active)
|
||||||
#ifdef TRACY_ON_DEMAND
|
: D3D12ZoneScope(ctx, cmdList, active)
|
||||||
: m_active(active&& GetProfiler().IsConnected())
|
|
||||||
#else
|
|
||||||
: m_active(active)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
if (!m_active) return;
|
if (!m_active) return;
|
||||||
|
|
||||||
m_ctx = ctx;
|
|
||||||
m_cmdList = cmdList;
|
|
||||||
|
|
||||||
m_queryId = ctx->NextQueryId();
|
|
||||||
cmdList->EndQuery(ctx->m_queryHeap.Get(), D3D12_QUERY_TYPE_TIMESTAMP, m_queryId);
|
|
||||||
|
|
||||||
const auto sourceLocation = Profiler::AllocSourceLocation(line, source, sourceSz, function, functionSz, name, nameSz);
|
const auto sourceLocation = Profiler::AllocSourceLocation(line, source, sourceSz, function, functionSz, name, nameSz);
|
||||||
|
|
||||||
auto* item = Profiler::QueueSerialCallstack(Callstack(depth));
|
auto* item = Profiler::QueueSerialCallstack(Callstack(depth));
|
||||||
MemWrite(&item->hdr.type, QueueType::GpuZoneBeginAllocSrcLocCallstackSerial);
|
WriteQueueItem(item, QueueType::GpuZoneBeginAllocSrcLocCallstackSerial, sourceLocation);
|
||||||
MemWrite(&item->gpuZoneBegin.cpuTime, Profiler::GetTime());
|
|
||||||
MemWrite(&item->gpuZoneBegin.srcloc, sourceLocation);
|
|
||||||
MemWrite(&item->gpuZoneBegin.thread, GetThreadHandle());
|
|
||||||
MemWrite(&item->gpuZoneBegin.queryId, static_cast<uint16_t>(m_queryId));
|
|
||||||
MemWrite(&item->gpuZoneBegin.context, ctx->GetId());
|
|
||||||
|
|
||||||
Profiler::QueueSerialFinish();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tracy_force_inline ~D3D12ZoneScope()
|
tracy_force_inline ~D3D12ZoneScope()
|
||||||
@ -440,7 +399,6 @@ namespace tracy
|
|||||||
MemWrite(&item->gpuZoneEnd.thread, GetThreadHandle());
|
MemWrite(&item->gpuZoneEnd.thread, GetThreadHandle());
|
||||||
MemWrite(&item->gpuZoneEnd.queryId, static_cast<uint16_t>(queryId));
|
MemWrite(&item->gpuZoneEnd.queryId, static_cast<uint16_t>(queryId));
|
||||||
MemWrite(&item->gpuZoneEnd.context, m_ctx->GetId());
|
MemWrite(&item->gpuZoneEnd.context, m_ctx->GetId());
|
||||||
|
|
||||||
Profiler::QueueSerialFinish();
|
Profiler::QueueSerialFinish();
|
||||||
|
|
||||||
m_cmdList->ResolveQueryData(m_ctx->m_queryHeap.Get(), D3D12_QUERY_TYPE_TIMESTAMP, m_queryId, 2, m_ctx->m_readbackBuffer.Get(), m_queryId * sizeof(uint64_t));
|
m_cmdList->ResolveQueryData(m_ctx->m_queryHeap.Get(), D3D12_QUERY_TYPE_TIMESTAMP, m_queryId, 2, m_ctx->m_readbackBuffer.Get(), m_queryId * sizeof(uint64_t));
|
||||||
|
Loading…
Reference in New Issue
Block a user