From bb76ace72bee5d44189b6ee6c81cda174ce9ea30 Mon Sep 17 00:00:00 2001 From: Greg Daniel Date: Fri, 29 Sep 2017 15:58:22 -0400 Subject: Fall back to non mipped Texture when we can't copy base to mipped texture TBR: bsalomon@google.com Bug: skia:7094 Change-Id: I9d2ba78c4d4332a22e2357cde0598de51299067d Reviewed-on: https://skia-review.googlesource.com/53541 Commit-Queue: Greg Daniel Reviewed-by: Robert Phillips --- src/gpu/GrBitmapTextureMaker.cpp | 6 ++++++ src/gpu/SkGr.cpp | 4 ++++ src/gpu/gl/GrGLCaps.h | 9 +++++++++ src/gpu/mock/GrMockCaps.h | 4 ++++ src/gpu/mtl/GrMtlCaps.h | 4 ++++ src/gpu/vk/GrVkCaps.h | 4 ++++ 6 files changed, 31 insertions(+) (limited to 'src') diff --git a/src/gpu/GrBitmapTextureMaker.cpp b/src/gpu/GrBitmapTextureMaker.cpp index 00dd48d0a9..ab8ee249a9 100644 --- a/src/gpu/GrBitmapTextureMaker.cpp +++ b/src/gpu/GrBitmapTextureMaker.cpp @@ -55,6 +55,12 @@ sk_sp GrBitmapTextureMaker::refOriginalTextureProxy(bool willBeM } else { proxy = GrCopyBaseMipMapToTextureProxy(this->context(), originalProxy.get(), dstColorSpace); + if (!proxy) { + // We failed to make a mipped proxy with the base copied into it. This could have + // been from failure to make the proxy or failure to do the copy. Thus we will fall + // back to just using the non mipped proxy; See skbug.com/7094. + return originalProxy; + } } } if (!proxy) { diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index e26de49e36..8035027732 100644 --- a/src/gpu/SkGr.cpp +++ b/src/gpu/SkGr.cpp @@ -223,6 +223,10 @@ sk_sp GrCopyBaseMipMapToTextureProxy(GrContext* ctx, SkColorSpace* dstColorSpace) { SkASSERT(baseProxy); + if (!ctx->caps()->isConfigCopyable(baseProxy->config())) { + return nullptr; + } + SkDestinationSurfaceColorMode colorMode = dstColorSpace ? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware : SkDestinationSurfaceColorMode::kLegacy; diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h index 1ce6094a6b..68cbc9bf16 100644 --- a/src/gpu/gl/GrGLCaps.h +++ b/src/gpu/gl/GrGLCaps.h @@ -125,6 +125,15 @@ public: return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kRenderable_Flag); } } + + bool isConfigCopyable(GrPixelConfig config) const override { + // In GL we have three ways to be able to copy. CopyTexImage, blit, and draw. CopyTexImage + // requires the src to be an FBO attachment, blit requires both src and dst to be FBO + // attachments, and draw requires the dst to be an FBO attachment. Thus to copy from and to + // the same config, we need that config to be renderable so we can attach it to an FBO. + return this->isConfigRenderable(config, false); + } + bool canConfigBeImageStorage(GrPixelConfig config) const override { return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kCanUseAsImageStorage_Flag); } diff --git a/src/gpu/mock/GrMockCaps.h b/src/gpu/mock/GrMockCaps.h index b1d9a84bcf..90cc8243cc 100644 --- a/src/gpu/mock/GrMockCaps.h +++ b/src/gpu/mock/GrMockCaps.h @@ -31,6 +31,10 @@ public: bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const override { return fOptions.fConfigOptions[config].fRenderable[withMSAA]; } + bool isConfigCopyable(GrPixelConfig config) const override { + return false; + } + bool canConfigBeImageStorage(GrPixelConfig) const override { return false; } bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc, bool* rectsMustMatch, bool* disallowSubrect) const override { diff --git a/src/gpu/mtl/GrMtlCaps.h b/src/gpu/mtl/GrMtlCaps.h index 9590bb9e12..b793159ad5 100644 --- a/src/gpu/mtl/GrMtlCaps.h +++ b/src/gpu/mtl/GrMtlCaps.h @@ -39,6 +39,10 @@ public: } } + bool isConfigCopyable(GrPixelConfig config) const override { + return true; + } + bool canConfigBeImageStorage(GrPixelConfig) const override { return false; } #if 0 diff --git a/src/gpu/vk/GrVkCaps.h b/src/gpu/vk/GrVkCaps.h index 0161bf7e37..ad514953b9 100644 --- a/src/gpu/vk/GrVkCaps.h +++ b/src/gpu/vk/GrVkCaps.h @@ -39,6 +39,10 @@ public: return SkToBool(ConfigInfo::kRenderable_Flag & fConfigTable[config].fOptimalFlags); } + bool isConfigCopyable(GrPixelConfig config) const override { + return true; + } + bool canConfigBeImageStorage(GrPixelConfig) const override { return false; } bool isConfigTexturableLinearly(GrPixelConfig config) const { -- cgit v1.2.3