From c3744403791ee3fad0de23e270915bc4791d0f6f Mon Sep 17 00:00:00 2001 From: Marcos Slomp Date: Thu, 8 Feb 2024 15:14:41 -0800 Subject: [PATCH] adding blit pass and render pass interfaces --- public/tracy/TracyMetal.hmm | 54 +++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/public/tracy/TracyMetal.hmm b/public/tracy/TracyMetal.hmm index a3c107cc..cbe12fe9 100644 --- a/public/tracy/TracyMetal.hmm +++ b/public/tracy/TracyMetal.hmm @@ -352,6 +352,60 @@ public: Profiler::QueueSerialFinish(); } + tracy_force_inline MetalZoneScope( MetalCtx* ctx, MTLBlitPassDescriptor* desc, const SourceLocationData* srcloc, bool is_active ) +#ifdef TRACY_ON_DEMAND + : m_active( is_active && GetProfiler().IsConnected() ) +#else + : m_active( is_active ) +#endif + { + if ( !m_active ) return; + if (desc == nil) TracyMetalPanic("pass descriptor is nil."); + m_ctx = ctx; + + auto queryId = m_queryId = ctx->NextQueryId(2); + desc.sampleBufferAttachments[0].sampleBuffer = ctx->m_counterSampleBuffer; + desc.sampleBufferAttachments[0].startOfEncoderSampleIndex = queryId; + desc.sampleBufferAttachments[0].endOfEncoderSampleIndex = queryId+1; + + auto* item = Profiler::QueueSerial(); + MemWrite( &item->hdr.type, QueueType::GpuZoneBeginSerial ); + MemWrite( &item->gpuZoneBegin.cpuTime, Profiler::GetTime() ); + MemWrite( &item->gpuZoneBegin.srcloc, (uint64_t)srcloc ); + MemWrite( &item->gpuZoneBegin.thread, GetThreadHandle() ); + MemWrite( &item->gpuZoneBegin.queryId, uint16_t( queryId ) ); + MemWrite( &item->gpuZoneBegin.context, ctx->GetContextId() ); + Profiler::QueueSerialFinish(); + } + + tracy_force_inline MetalZoneScope( MetalCtx* ctx, MTLRenderPassDescriptor* desc, const SourceLocationData* srcloc, bool is_active ) +#ifdef TRACY_ON_DEMAND + : m_active( is_active && GetProfiler().IsConnected() ) +#else + : m_active( is_active ) +#endif + { + if ( !m_active ) return; + if (desc == nil) TracyMetalPanic("pass descriptor is nil."); + m_ctx = ctx; + + auto queryId = m_queryId = ctx->NextQueryId(2); + desc.sampleBufferAttachments[0].sampleBuffer = ctx->m_counterSampleBuffer; + desc.sampleBufferAttachments[0].startOfVertexSampleIndex = queryId; + desc.sampleBufferAttachments[0].endOfVertexSampleIndex = MTLCounterDontSample; + desc.sampleBufferAttachments[0].startOfFragmentSampleIndex = MTLCounterDontSample; + desc.sampleBufferAttachments[0].endOfFragmentSampleIndex = queryId+1; + + auto* item = Profiler::QueueSerial(); + MemWrite( &item->hdr.type, QueueType::GpuZoneBeginSerial ); + MemWrite( &item->gpuZoneBegin.cpuTime, Profiler::GetTime() ); + MemWrite( &item->gpuZoneBegin.srcloc, (uint64_t)srcloc ); + MemWrite( &item->gpuZoneBegin.thread, GetThreadHandle() ); + MemWrite( &item->gpuZoneBegin.queryId, uint16_t( queryId ) ); + MemWrite( &item->gpuZoneBegin.context, ctx->GetContextId() ); + Profiler::QueueSerialFinish(); + } + #if 0 tracy_force_inline MetalZoneScope( MetalCtx* ctx, id cmdEncoder, const SourceLocationData* srcloc, bool is_active ) #ifdef TRACY_ON_DEMAND