diff --git a/src/gpu/SurfaceContext.cpp b/src/gpu/SurfaceContext.cpp index 86ec30b4d7..f1f815d326 100644 --- a/src/gpu/SurfaceContext.cpp +++ b/src/gpu/SurfaceContext.cpp @@ -129,8 +129,8 @@ bool SurfaceContext::readPixels(GrDirectContext* dContext, GrPixmap dst, SkIPoin dContext->priv().validPMUPMConversionExists(); // Since the validPMUPMConversionExists function actually submits work to the gpu to do its - // tests, it is possible that during that call we have abanoned the context. Thus we do - // another abanoned check here to make sure we are still valid. + // tests, it is possible that during that call we have abandoned the context. Thus, we do + // another abandoned check here to make sure we are still valid. RETURN_FALSE_IF_ABANDONED auto readFlag = caps->surfaceSupportsReadPixels(srcSurface); diff --git a/src/gpu/mtl/GrMtlCaps.mm b/src/gpu/mtl/GrMtlCaps.mm index 46e4d53b15..72ab5cf003 100644 --- a/src/gpu/mtl/GrMtlCaps.mm +++ b/src/gpu/mtl/GrMtlCaps.mm @@ -20,6 +20,7 @@ #include "src/gpu/GrShaderCaps.h" #include "src/gpu/GrSurfaceProxy.h" #include "src/gpu/mtl/GrMtlRenderTarget.h" +#include "src/gpu/mtl/GrMtlTexture.h" #include "src/gpu/mtl/GrMtlUtil.h" #if !__has_feature(objc_arc) @@ -968,6 +969,13 @@ bool GrMtlCaps::onSurfaceSupportsWritePixels(const GrSurface* surface) const { GrCaps::SurfaceReadPixelsSupport GrMtlCaps::surfaceSupportsReadPixels( const GrSurface* surface) const { + if (auto tex = static_cast(surface->asTexture())) { + // We disallow reading back directly from compressed textures. + if (GrMtlFormatIsCompressed(tex->attachment()->mtlFormat())) { + return SurfaceReadPixelsSupport::kCopyToTexture2D; + } + } + if (auto mtlRT = static_cast(surface->asRenderTarget())) { if (mtlRT->numSamples() > 1 && !mtlRT->resolveAttachment()) { return SurfaceReadPixelsSupport::kCopyToTexture2D;