From 2966d3ad08eb574cbc94f151812cf50e6efd5db3 Mon Sep 17 00:00:00 2001 From: Loko Kung Date: Wed, 3 May 2023 07:33:18 +0000 Subject: [PATCH] Adds pass labels into the commands and plumbs through for Metal. Bug: dawn:1784 Change-Id: Ie71360d83c4f3c47821916ebf8a187662e3f286f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/131100 Commit-Queue: Loko Kung Kokoro: Kokoro Reviewed-by: Austin Eng --- src/dawn/native/CommandEncoder.cpp | 2 ++ src/dawn/native/Commands.h | 3 +++ src/dawn/native/metal/CommandBufferMTL.mm | 2 ++ 3 files changed, 7 insertions(+) diff --git a/src/dawn/native/CommandEncoder.cpp b/src/dawn/native/CommandEncoder.cpp index 6d40a523c2..2adea97f03 100644 --- a/src/dawn/native/CommandEncoder.cpp +++ b/src/dawn/native/CommandEncoder.cpp @@ -764,6 +764,7 @@ Ref CommandEncoder::BeginComputePass(const ComputePassDescri if (descriptor == nullptr) { return {}; } + cmd->label = std::string(descriptor->label ? descriptor->label : ""); // Record timestamp writes at the beginning and end of compute pass. The timestamp write // at the end also be needed in BeginComputePassCmd because it's required by compute @@ -839,6 +840,7 @@ Ref CommandEncoder::BeginRenderPass(const RenderPassDescripto mEncodingContext.WillBeginRenderPass(); BeginRenderPassCmd* cmd = allocator->Allocate(Command::BeginRenderPass); + cmd->label = std::string(descriptor->label ? descriptor->label : ""); cmd->attachmentState = device->GetOrCreateAttachmentState(descriptor); attachmentState = cmd->attachmentState; diff --git a/src/dawn/native/Commands.h b/src/dawn/native/Commands.h index 06ea16ea8b..8e388f298d 100644 --- a/src/dawn/native/Commands.h +++ b/src/dawn/native/Commands.h @@ -17,6 +17,7 @@ #include #include +#include #include #include "dawn/common/Constants.h" @@ -83,6 +84,7 @@ struct BeginComputePassCmd { TimestampWrite beginTimestamp; TimestampWrite endTimestamp; + std::string label; }; struct BeginOcclusionQueryCmd { @@ -135,6 +137,7 @@ struct BeginRenderPassCmd { Ref occlusionQuerySet; TimestampWrite beginTimestamp; TimestampWrite endTimestamp; + std::string label; }; struct BufferCopy { diff --git a/src/dawn/native/metal/CommandBufferMTL.mm b/src/dawn/native/metal/CommandBufferMTL.mm index 1cd1516588..30a58c2069 100644 --- a/src/dawn/native/metal/CommandBufferMTL.mm +++ b/src/dawn/native/metal/CommandBufferMTL.mm @@ -1227,6 +1227,7 @@ MaybeError CommandBuffer::EncodeComputePass(CommandRecordingContext* commandCont } } } + SetDebugName(GetDevice(), encoder, "Dawn_ComputePassEncoder", computePassCmd->label); Command type; while (mCommands.NextCommandId(&type)) { @@ -1388,6 +1389,7 @@ MaybeError CommandBuffer::EncodeRenderPass(id encoder, withBarrier:YES]; } } + SetDebugName(GetDevice(), encoder, "Dawn_RenderPassEncoder", renderPassCmd->label); auto EncodeRenderBundleCommand = [&](CommandIterator* iter, Command type) { switch (type) {