diff --git a/src/gpu/ganesh/mtl/GrMtlBuffer.h b/src/gpu/ganesh/mtl/GrMtlBuffer.h index 2ebde68c9d..f4b47f57cb 100644 --- a/src/gpu/ganesh/mtl/GrMtlBuffer.h +++ b/src/gpu/ganesh/mtl/GrMtlBuffer.h @@ -51,6 +51,8 @@ private: void validate() const; #endif + void onSetLabel() override; + bool fIsDynamic; id fMtlBuffer; diff --git a/src/gpu/ganesh/mtl/GrMtlBuffer.mm b/src/gpu/ganesh/mtl/GrMtlBuffer.mm index 0c18a44c7e..0c8d7dded4 100644 --- a/src/gpu/ganesh/mtl/GrMtlBuffer.mm +++ b/src/gpu/ganesh/mtl/GrMtlBuffer.mm @@ -196,4 +196,12 @@ void GrMtlBuffer::validate() const { } #endif +void GrMtlBuffer::onSetLabel() { + SkASSERT(fMtlBuffer); + if (!this->getLabel().empty()) { + NSString* labelStr = @(this->getLabel().c_str()); + fMtlBuffer.label = [@"_Skia_" stringByAppendingString:labelStr]; + } +} + GR_NORETAIN_END diff --git a/src/gpu/ganesh/mtl/GrMtlRenderTarget.h b/src/gpu/ganesh/mtl/GrMtlRenderTarget.h index fe602946de..0d6b277cf0 100644 --- a/src/gpu/ganesh/mtl/GrMtlRenderTarget.h +++ b/src/gpu/ganesh/mtl/GrMtlRenderTarget.h @@ -72,6 +72,8 @@ protected: // This returns zero since the memory should all be handled by the attachments size_t onGpuMemorySize() const override { return 0; } + void onSetLabel() override; + sk_sp fColorAttachment; sk_sp fResolveAttachment; @@ -87,8 +89,6 @@ private: bool completeStencilAttachment(GrAttachment* stencil, bool useMSAASurface) override; - void onSetLabel() override{} - // We can have a renderpass with and without resolve attachment or stencil attachment, // both of these being completely orthogonal. Thus we have a total of 4 types of render passes. // We then cache a framebuffer for each type of these render passes. diff --git a/src/gpu/ganesh/mtl/GrMtlRenderTarget.mm b/src/gpu/ganesh/mtl/GrMtlRenderTarget.mm index a8e33dc97f..f3de931455 100644 --- a/src/gpu/ganesh/mtl/GrMtlRenderTarget.mm +++ b/src/gpu/ganesh/mtl/GrMtlRenderTarget.mm @@ -166,4 +166,19 @@ bool GrMtlRenderTarget::completeStencilAttachment(GrAttachment* stencil, bool us return true; } +void GrMtlRenderTarget::onSetLabel() { + SkASSERT(fColorAttachment); + if (!this->getLabel().empty()) { + NSString* labelStr = @(this->getLabel().c_str()); + if (fResolveAttachment) { + fColorAttachment->mtlTexture().label = + [@"_Skia_MSAA_" stringByAppendingString:labelStr]; + fResolveAttachment->mtlTexture().label = + [@"_Skia_Resolve_" stringByAppendingString:labelStr]; + } else { + fColorAttachment->mtlTexture().label = [@"_Skia_" stringByAppendingString:labelStr]; + } + } +} + GR_NORETAIN_END diff --git a/src/gpu/ganesh/mtl/GrMtlTexture.h b/src/gpu/ganesh/mtl/GrMtlTexture.h index dcf13740ca..344205f05b 100644 --- a/src/gpu/ganesh/mtl/GrMtlTexture.h +++ b/src/gpu/ganesh/mtl/GrMtlTexture.h @@ -65,6 +65,8 @@ protected: return false; } + void onSetLabel() override; + private: enum Wrapped { kWrapped }; @@ -84,8 +86,6 @@ private: GrIOType, std::string_view label); - void onSetLabel() override{} - sk_sp fTexture; using INHERITED = GrTexture; diff --git a/src/gpu/ganesh/mtl/GrMtlTexture.mm b/src/gpu/ganesh/mtl/GrMtlTexture.mm index 7bd8cb54f4..baa343b163 100644 --- a/src/gpu/ganesh/mtl/GrMtlTexture.mm +++ b/src/gpu/ganesh/mtl/GrMtlTexture.mm @@ -139,4 +139,12 @@ GrBackendFormat GrMtlTexture::backendFormat() const { return GrBackendFormat::MakeMtl(fTexture->mtlFormat()); } +void GrMtlTexture::onSetLabel() { + SkASSERT(fTexture); + if (!this->getLabel().empty()) { + NSString* labelStr = @(this->getLabel().c_str()); + fTexture->mtlTexture().label = [@"_Skia_" stringByAppendingString:labelStr]; + } +} + GR_NORETAIN_END diff --git a/src/gpu/ganesh/mtl/GrMtlTextureRenderTarget.h b/src/gpu/ganesh/mtl/GrMtlTextureRenderTarget.h index 1c3b609fb1..eadaa41046 100644 --- a/src/gpu/ganesh/mtl/GrMtlTextureRenderTarget.h +++ b/src/gpu/ganesh/mtl/GrMtlTextureRenderTarget.h @@ -63,7 +63,7 @@ private: size_t onGpuMemorySize() const override; - void onSetLabel() override{} + void onSetLabel() override; }; #endif diff --git a/src/gpu/ganesh/mtl/GrMtlTextureRenderTarget.mm b/src/gpu/ganesh/mtl/GrMtlTextureRenderTarget.mm index d3c2454669..020ee66782 100644 --- a/src/gpu/ganesh/mtl/GrMtlTextureRenderTarget.mm +++ b/src/gpu/ganesh/mtl/GrMtlTextureRenderTarget.mm @@ -162,4 +162,9 @@ size_t GrMtlTextureRenderTarget::onGpuMemorySize() const { 1 /*colorSamplesPerPixel*/, this->mipmapped()); } +void GrMtlTextureRenderTarget::onSetLabel() { + GrMtlRenderTarget::onSetLabel(); + GrMtlTexture::onSetLabel(); +} + GR_NORETAIN_END