Disallow direct readback of compressed textures in Metal
Bug: skia:12592 Change-Id: Ic07b68c7101850a5d2b7aa921f592a93dbfff196 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/470836 Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
152299ee42
commit
e96b25c622
@ -129,8 +129,8 @@ bool SurfaceContext::readPixels(GrDirectContext* dContext, GrPixmap dst, SkIPoin
|
|||||||
dContext->priv().validPMUPMConversionExists();
|
dContext->priv().validPMUPMConversionExists();
|
||||||
|
|
||||||
// Since the validPMUPMConversionExists function actually submits work to the gpu to do its
|
// 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
|
// tests, it is possible that during that call we have abandoned the context. Thus, we do
|
||||||
// another abanoned check here to make sure we are still valid.
|
// another abandoned check here to make sure we are still valid.
|
||||||
RETURN_FALSE_IF_ABANDONED
|
RETURN_FALSE_IF_ABANDONED
|
||||||
|
|
||||||
auto readFlag = caps->surfaceSupportsReadPixels(srcSurface);
|
auto readFlag = caps->surfaceSupportsReadPixels(srcSurface);
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "src/gpu/GrShaderCaps.h"
|
#include "src/gpu/GrShaderCaps.h"
|
||||||
#include "src/gpu/GrSurfaceProxy.h"
|
#include "src/gpu/GrSurfaceProxy.h"
|
||||||
#include "src/gpu/mtl/GrMtlRenderTarget.h"
|
#include "src/gpu/mtl/GrMtlRenderTarget.h"
|
||||||
|
#include "src/gpu/mtl/GrMtlTexture.h"
|
||||||
#include "src/gpu/mtl/GrMtlUtil.h"
|
#include "src/gpu/mtl/GrMtlUtil.h"
|
||||||
|
|
||||||
#if !__has_feature(objc_arc)
|
#if !__has_feature(objc_arc)
|
||||||
@ -968,6 +969,13 @@ bool GrMtlCaps::onSurfaceSupportsWritePixels(const GrSurface* surface) const {
|
|||||||
|
|
||||||
GrCaps::SurfaceReadPixelsSupport GrMtlCaps::surfaceSupportsReadPixels(
|
GrCaps::SurfaceReadPixelsSupport GrMtlCaps::surfaceSupportsReadPixels(
|
||||||
const GrSurface* surface) const {
|
const GrSurface* surface) const {
|
||||||
|
if (auto tex = static_cast<const GrMtlTexture*>(surface->asTexture())) {
|
||||||
|
// We disallow reading back directly from compressed textures.
|
||||||
|
if (GrMtlFormatIsCompressed(tex->attachment()->mtlFormat())) {
|
||||||
|
return SurfaceReadPixelsSupport::kCopyToTexture2D;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (auto mtlRT = static_cast<const GrMtlRenderTarget*>(surface->asRenderTarget())) {
|
if (auto mtlRT = static_cast<const GrMtlRenderTarget*>(surface->asRenderTarget())) {
|
||||||
if (mtlRT->numSamples() > 1 && !mtlRT->resolveAttachment()) {
|
if (mtlRT->numSamples() > 1 && !mtlRT->resolveAttachment()) {
|
||||||
return SurfaceReadPixelsSupport::kCopyToTexture2D;
|
return SurfaceReadPixelsSupport::kCopyToTexture2D;
|
||||||
|
Loading…
Reference in New Issue
Block a user