[metal] Add label support
Bug: skia:13446 Change-Id: If1cb6a27858cfcee10439c70cdac2e66761e05a3 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/557392 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Jim Van Verth <jvanverth@google.com>
This commit is contained in:
parent
090b06557d
commit
4e085a7ab0
@ -51,6 +51,8 @@ private:
|
||||
void validate() const;
|
||||
#endif
|
||||
|
||||
void onSetLabel() override;
|
||||
|
||||
bool fIsDynamic;
|
||||
id<MTLBuffer> fMtlBuffer;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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<GrMtlAttachment> fColorAttachment;
|
||||
sk_sp<GrMtlAttachment> 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.
|
||||
|
@ -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
|
||||
|
@ -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<GrMtlAttachment> fTexture;
|
||||
|
||||
using INHERITED = GrTexture;
|
||||
|
@ -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
|
||||
|
@ -63,7 +63,7 @@ private:
|
||||
|
||||
size_t onGpuMemorySize() const override;
|
||||
|
||||
void onSetLabel() override{}
|
||||
void onSetLabel() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -162,4 +162,9 @@ size_t GrMtlTextureRenderTarget::onGpuMemorySize() const {
|
||||
1 /*colorSamplesPerPixel*/, this->mipmapped());
|
||||
}
|
||||
|
||||
void GrMtlTextureRenderTarget::onSetLabel() {
|
||||
GrMtlRenderTarget::onSetLabel();
|
||||
GrMtlTexture::onSetLabel();
|
||||
}
|
||||
|
||||
GR_NORETAIN_END
|
||||
|
Loading…
Reference in New Issue
Block a user