aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--bench/GrMipMapBench.cpp6
-rw-r--r--include/gpu/GrSurface.h11
-rw-r--r--include/private/GrTextureProxy.h10
-rw-r--r--include/private/GrTypesPriv.h16
-rw-r--r--src/gpu/GrBackendTextureImageGenerator.cpp6
-rw-r--r--src/gpu/GrBitmapTextureMaker.cpp4
-rw-r--r--src/gpu/GrGpu.cpp58
-rw-r--r--src/gpu/GrSurfacePriv.h1
-rw-r--r--src/gpu/GrTexture.cpp8
-rw-r--r--src/gpu/GrTextureAdjuster.cpp18
-rw-r--r--src/gpu/GrTexturePriv.h4
-rw-r--r--src/gpu/GrTextureProducer.cpp27
-rw-r--r--src/gpu/GrTextureProxyPriv.h5
-rw-r--r--src/gpu/gl/GrGLCaps.cpp16
-rw-r--r--src/gpu/gl/GrGLCaps.h4
-rw-r--r--src/gpu/gl/GrGLGpu.cpp2
-rw-r--r--src/gpu/ops/GrTextureOp.cpp14
-rw-r--r--src/gpu/vk/GrVkGpuCommandBuffer.cpp1
-rw-r--r--src/image/SkImage_Gpu.cpp22
-rw-r--r--src/image/SkImage_Lazy.cpp4
-rw-r--r--tests/DeferredDisplayListTest.cpp41
-rw-r--r--tests/EGLImageTest.cpp6
-rw-r--r--tests/GLProgramsTest.cpp6
-rw-r--r--tests/GrTextureMipMapInvalidationTest.cpp50
-rw-r--r--tests/LazyProxyTest.cpp4
-rw-r--r--tests/RectangleTextureTest.cpp5
26 files changed, 184 insertions, 165 deletions
diff --git a/bench/GrMipMapBench.cpp b/bench/GrMipMapBench.cpp
index e7f34de9e7..e756c13bb4 100644
--- a/bench/GrMipMapBench.cpp
+++ b/bench/GrMipMapBench.cpp
@@ -37,11 +37,7 @@ protected:
auto srgb = SkColorSpace::MakeSRGB();
SkImageInfo info =
SkImageInfo::Make(fW, fH, kRGBA_8888_SkColorType, kPremul_SkAlphaType, srgb);
- // We're benching the regeneration of the mip levels not the need to allocate them every
- // frame. Thus we create the surface with mips to begin with.
- fSurface = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info, 0,
- kBottomLeft_GrSurfaceOrigin, nullptr, true);
-
+ fSurface = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info);
}
// Clear surface once:
diff --git a/include/gpu/GrSurface.h b/include/gpu/GrSurface.h
index 3a7294b26e..f3771a74e2 100644
--- a/include/gpu/GrSurface.h
+++ b/include/gpu/GrSurface.h
@@ -63,9 +63,20 @@ public:
GrMipMapped, bool useNextPow2 = false);
protected:
+ void setDoesNotSupportMipMaps() {
+ SkASSERT(this->asTexture());
+ fSurfaceFlags |= GrInternalSurfaceFlags::kDoesNotSupportMipMaps;
+ }
+ bool doesNotSupportMipMaps() const {
+ return fSurfaceFlags & GrInternalSurfaceFlags::kDoesNotSupportMipMaps;
+ }
+
void setIsGLTextureRectangleOrExternal() {
SkASSERT(this->asTexture());
fSurfaceFlags |= GrInternalSurfaceFlags::kIsGLTextureRectangleOrExternal;
+ // If we are a GL rectangle or external texture, it also means that we do not support
+ // generating mip maps.
+ this->setDoesNotSupportMipMaps();
}
bool isGLTextureRectangleOrExternal() const {
return fSurfaceFlags & GrInternalSurfaceFlags::kIsGLTextureRectangleOrExternal;
diff --git a/include/private/GrTextureProxy.h b/include/private/GrTextureProxy.h
index fc7f1c54a7..8bbdbf2959 100644
--- a/include/private/GrTextureProxy.h
+++ b/include/private/GrTextureProxy.h
@@ -100,8 +100,18 @@ protected:
sk_sp<GrSurface> createSurface(GrResourceProvider*) const override;
+ void setDoesNotSupportMipMaps() {
+ fSurfaceFlags |= GrInternalSurfaceFlags::kDoesNotSupportMipMaps;
+ }
+ bool doesNotSupportMipMaps() const {
+ return fSurfaceFlags & GrInternalSurfaceFlags::kDoesNotSupportMipMaps;
+ }
+
void setIsGLTextureRectangleOrExternal() {
fSurfaceFlags |= GrInternalSurfaceFlags::kIsGLTextureRectangleOrExternal;
+ // If we are a GL rectangle or external texture, it also means that we do not support
+ // generating mip maps.
+ this->setDoesNotSupportMipMaps();
}
bool isGLTextureRectangleOrExternal() const {
return fSurfaceFlags & GrInternalSurfaceFlags::kIsGLTextureRectangleOrExternal;
diff --git a/include/private/GrTypesPriv.h b/include/private/GrTypesPriv.h
index 32a13f2358..84461836f0 100644
--- a/include/private/GrTypesPriv.h
+++ b/include/private/GrTypesPriv.h
@@ -868,14 +868,20 @@ enum class GrInternalSurfaceFlags {
// Texture-only flags
+ // This flag is set when the internal texture target doesn't support mipmaps (e.g.,
+ // external and rectangle textures). Note that Ganesh does not internally
+ // create resources with this limitation - this flag will only appear on resources passed
+ // into Ganesh.
+ kDoesNotSupportMipMaps = 1 << 1,
+
// This flag is for GL only. It says that the GL texture we will use has a target which is
// either GL_TEXTURE_RECTANGLE or GL_GL_TEXTURE_EXTERNAL. We use this information to make
// decisions about various rendering capabilites (e.g. is clamp the only supported wrap mode).
// Note: Ganesh does not internally create these types of textures so they will only occur on
// resources passed into Ganesh.
- kIsGLTextureRectangleOrExternal = 1 << 1,
+ kIsGLTextureRectangleOrExternal = 1 << 2,
- kTextureMask = kIsGLTextureRectangleOrExternal,
+ kTextureMask = kDoesNotSupportMipMaps | kIsGLTextureRectangleOrExternal,
// RT-only
@@ -885,17 +891,17 @@ enum class GrInternalSurfaceFlags {
// this is disabled for FBO0
// but, otherwise, is enabled whenever MSAA is enabled and GrCaps reports mixed samples
// are supported
- kMixedSampled = 1 << 2,
+ kMixedSampled = 1 << 3,
// For internal resources:
// this is enabled whenever GrCaps reports window rect support
// For wrapped resources1
// this is disabled for FBO0
// but, otherwise, is enabled whenever GrCaps reports window rect support
- kWindowRectsSupport = 1 << 3,
+ kWindowRectsSupport = 1 << 4,
// This flag is for use with GL only. It tells us that the internal render target wraps FBO 0.
- kGLRTFBOIDIs0 = 1 << 4,
+ kGLRTFBOIDIs0 = 1 << 5,
kRenderTargetMask = kMixedSampled | kWindowRectsSupport | kGLRTFBOIDIs0,
};
diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp
index 4147abd2a4..56826d2857 100644
--- a/src/gpu/GrBackendTextureImageGenerator.cpp
+++ b/src/gpu/GrBackendTextureImageGenerator.cpp
@@ -180,6 +180,12 @@ sk_sp<GrTextureProxy> GrBackendTextureImageGenerator::onGenerateTexture(
return nullptr;
}
+ // We can't pass the fact that this creates a wrapped texture into createLazyProxy so we need
+ // to manually call setDoesNotSupportMipMaps.
+ if (GrMipMapped::kNo == mipMapped) {
+ proxy->texPriv().setDoesNotSupportMipMaps();
+ }
+
if (0 == origin.fX && 0 == origin.fY &&
info.width() == fBackendTexture.width() && info.height() == fBackendTexture.height() &&
(!willNeedMipMaps || GrMipMapped::kYes == proxy->mipMapped())) {
diff --git a/src/gpu/GrBitmapTextureMaker.cpp b/src/gpu/GrBitmapTextureMaker.cpp
index 4ecd761e37..d2a1fbe3e9 100644
--- a/src/gpu/GrBitmapTextureMaker.cpp
+++ b/src/gpu/GrBitmapTextureMaker.cpp
@@ -89,6 +89,10 @@ sk_sp<GrTextureProxy> GrBitmapTextureMaker::refOriginalTextureProxy(bool willBeM
}
return mippedProxy;
}
+ // 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 proxy;
}
return nullptr;
}
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 8781cbfe6d..5c2864db3c 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -50,34 +50,13 @@ bool GrGpu::IsACopyNeededForTextureParams(const GrCaps* caps, GrTextureProxy* te
const GrSamplerState& textureParams,
GrTextureProducer::CopyParams* copyParams,
SkScalar scaleAdjust[2]) {
- if (textureParams.isRepeated() && !caps->npotTextureTileSupport() &&
- (!SkIsPow2(width) || !SkIsPow2(height))) {
- SkASSERT(scaleAdjust);
- copyParams->fWidth = GrNextPow2(width);
- copyParams->fHeight = GrNextPow2(height);
- SkASSERT(scaleAdjust);
- scaleAdjust[0] = ((SkScalar)copyParams->fWidth) / width;
- scaleAdjust[1] = ((SkScalar)copyParams->fHeight) / height;
- switch (textureParams.filter()) {
- case GrSamplerState::Filter::kNearest:
- copyParams->fFilter = GrSamplerState::Filter::kNearest;
- break;
- case GrSamplerState::Filter::kBilerp:
- case GrSamplerState::Filter::kMipMap:
- // We are only ever scaling up so no reason to ever indicate kMipMap.
- copyParams->fFilter = GrSamplerState::Filter::kBilerp;
- break;
- }
- return true;
- }
if (texProxy) {
- bool willNeedMips = GrSamplerState::Filter::kMipMap == textureParams.filter() &&
- caps->mipMapSupport();
// If the texture format itself doesn't support repeat wrap mode or mipmapping (and
// those capabilities are required) force a copy.
if ((textureParams.isRepeated() && texProxy->texPriv().isClampOnly()) ||
- (willNeedMips && texProxy->mipMapped() == GrMipMapped::kNo)) {
+ (GrSamplerState::Filter::kMipMap == textureParams.filter() &&
+ texProxy->texPriv().doesNotSupportMipMaps())) {
copyParams->fFilter = GrSamplerState::Filter::kNearest;
copyParams->fWidth = texProxy->width();
copyParams->fHeight = texProxy->height();
@@ -85,6 +64,26 @@ bool GrGpu::IsACopyNeededForTextureParams(const GrCaps* caps, GrTextureProxy* te
}
}
+ if (textureParams.isRepeated() && !caps->npotTextureTileSupport() &&
+ (!SkIsPow2(width) || !SkIsPow2(height))) {
+ SkASSERT(scaleAdjust);
+ copyParams->fWidth = GrNextPow2(width);
+ copyParams->fHeight = GrNextPow2(height);
+ SkASSERT(scaleAdjust);
+ scaleAdjust[0] = ((SkScalar) copyParams->fWidth) / width;
+ scaleAdjust[1] = ((SkScalar) copyParams->fHeight) / height;
+ switch (textureParams.filter()) {
+ case GrSamplerState::Filter::kNearest:
+ copyParams->fFilter = GrSamplerState::Filter::kNearest;
+ break;
+ case GrSamplerState::Filter::kBilerp:
+ case GrSamplerState::Filter::kMipMap:
+ // We are only ever scaling up so no reason to ever indicate kMipMap.
+ copyParams->fFilter = GrSamplerState::Filter::kBilerp;
+ break;
+ }
+ return true;
+ }
return false;
}
@@ -139,7 +138,13 @@ sk_sp<GrTexture> GrGpu::wrapBackendTexture(const GrBackendTexture& backendTex,
backendTex.height() > this->caps()->maxTextureSize()) {
return nullptr;
}
- return this->onWrapBackendTexture(backendTex, ownership);
+ sk_sp<GrTexture> tex = this->onWrapBackendTexture(backendTex, ownership);
+ if (tex && !backendTex.hasMipMaps()) {
+ // Ganesh will not ever allocate mipmaps for a wrapped resource. By setting this flag here,
+ // it will be propagated to any proxy that wraps this texture.
+ tex->texturePriv().setDoesNotSupportMipMaps();
+ }
+ return tex;
}
sk_sp<GrTexture> GrGpu::wrapRenderableBackendTexture(const GrBackendTexture& backendTex,
@@ -158,6 +163,11 @@ sk_sp<GrTexture> GrGpu::wrapRenderableBackendTexture(const GrBackendTexture& bac
return nullptr;
}
sk_sp<GrTexture> tex = this->onWrapRenderableBackendTexture(backendTex, sampleCnt, ownership);
+ if (tex && !backendTex.hasMipMaps()) {
+ // Ganesh will not ever allocate mipmaps for a wrapped resource. By setting this flag here,
+ // it will be propagated to any proxy that wraps this texture.
+ tex->texturePriv().setDoesNotSupportMipMaps();
+ }
SkASSERT(!tex || tex->asRenderTarget());
return tex;
}
diff --git a/src/gpu/GrSurfacePriv.h b/src/gpu/GrSurfacePriv.h
index 45a097b780..5c98e3f773 100644
--- a/src/gpu/GrSurfacePriv.h
+++ b/src/gpu/GrSurfacePriv.h
@@ -40,6 +40,7 @@ public:
GrInternalSurfaceFlags flags() const { return fSurface->fSurfaceFlags; }
+ bool doesNotSupportMipMaps() const { return fSurface->doesNotSupportMipMaps(); }
bool isGLTextureRectangleOrExternal() const {
return fSurface->isGLTextureRectangleOrExternal();
}
diff --git a/src/gpu/GrTexture.cpp b/src/gpu/GrTexture.cpp
index 0051a225ef..cd3e7055ab 100644
--- a/src/gpu/GrTexture.cpp
+++ b/src/gpu/GrTexture.cpp
@@ -25,8 +25,14 @@ void GrTexture::markMipMapsDirty() {
}
void GrTexture::markMipMapsClean() {
- SkASSERT(GrMipMapsStatus::kNotAllocated != fMipMapsStatus);
+ const bool sizeChanged = GrMipMapsStatus::kNotAllocated == fMipMapsStatus;
fMipMapsStatus = GrMipMapsStatus::kValid;
+ if (sizeChanged) {
+ // This must not be called until after changing fMipMapsStatus.
+ this->didChangeGpuMemorySize();
+ // TODO(http://skbug.com/4548) - The desc and scratch key should be
+ // updated to reflect the newly-allocated mipmaps.
+ }
}
size_t GrTexture::onGpuMemorySize() const {
diff --git a/src/gpu/GrTextureAdjuster.cpp b/src/gpu/GrTextureAdjuster.cpp
index cb296f9ce9..cc61533044 100644
--- a/src/gpu/GrTextureAdjuster.cpp
+++ b/src/gpu/GrTextureAdjuster.cpp
@@ -43,11 +43,10 @@ sk_sp<GrTextureProxy> GrTextureAdjuster::refTextureProxyCopy(const CopyParams& c
GrUniqueKey key;
this->makeCopyKey(copyParams, &key, nullptr);
- sk_sp<GrTextureProxy> cachedCopy;
if (key.isValid()) {
- cachedCopy = proxyProvider->findOrCreateProxyByUniqueKey(key,
- this->originalProxy()->origin());
- if (cachedCopy && (!willBeMipped || GrMipMapped::kYes == cachedCopy->mipMapped())) {
+ sk_sp<GrTextureProxy> cachedCopy =
+ proxyProvider->findOrCreateProxyByUniqueKey(key, this->originalProxy()->origin());
+ if (cachedCopy) {
return cachedCopy;
}
}
@@ -58,14 +57,6 @@ sk_sp<GrTextureProxy> GrTextureAdjuster::refTextureProxyCopy(const CopyParams& c
if (copy) {
if (key.isValid()) {
SkASSERT(copy->origin() == this->originalProxy()->origin());
- if (cachedCopy) {
- SkASSERT(GrMipMapped::kYes == copy->mipMapped() &&
- GrMipMapped::kNo == cachedCopy->mipMapped());
- // If we had a cachedProxy, that means there already is a proxy in the cache which
- // matches the key, but it does not have mip levels and we require them. Thus we
- // must remove the unique key from that proxy.
- proxyProvider->removeUniqueKeyFromProxy(key, cachedCopy.get());
- }
proxyProvider->assignUniqueKeyToProxy(key, copy.get());
this->didCacheCopy(key);
}
@@ -98,8 +89,7 @@ sk_sp<GrTextureProxy> GrTextureAdjuster::onRefTextureProxyForParams(
return proxy;
}
- bool willBeMipped = GrSamplerState::Filter::kMipMap == params.filter() &&
- fContext->contextPriv().caps()->mipMapSupport();
+ bool willBeMipped = GrSamplerState::Filter::kMipMap == params.filter();
return this->refTextureProxyCopy(copyParams, willBeMipped);
}
diff --git a/src/gpu/GrTexturePriv.h b/src/gpu/GrTexturePriv.h
index 2979e8bd94..4517e9e076 100644
--- a/src/gpu/GrTexturePriv.h
+++ b/src/gpu/GrTexturePriv.h
@@ -44,6 +44,10 @@ public:
return fTexture->fMaxMipMapLevel;
}
+ void setDoesNotSupportMipMaps() {
+ fTexture->setDoesNotSupportMipMaps();
+ }
+
GrSLType samplerType() const { return fTexture->fSamplerType; }
/** The filter used is clamped to this value in GrProcessor::TextureSampler. */
diff --git a/src/gpu/GrTextureProducer.cpp b/src/gpu/GrTextureProducer.cpp
index 1e9c3acd16..d9fffbc410 100644
--- a/src/gpu/GrTextureProducer.cpp
+++ b/src/gpu/GrTextureProducer.cpp
@@ -10,7 +10,6 @@
#include "GrProxyProvider.h"
#include "GrRenderTargetContext.h"
#include "GrTextureProxy.h"
-#include "SkGr.h"
#include "SkRectPriv.h"
#include "effects/GrBicubicEffect.h"
#include "effects/GrSimpleTextureEffect.h"
@@ -25,24 +24,6 @@ sk_sp<GrTextureProxy> GrTextureProducer::CopyOnGpu(GrContext* context,
const SkRect dstRect = SkRect::MakeIWH(copyParams.fWidth, copyParams.fHeight);
GrMipMapped mipMapped = dstWillRequireMipMaps ? GrMipMapped::kYes : GrMipMapped::kNo;
- SkRect localRect = SkRect::MakeWH(inputProxy->width(), inputProxy->height());
-
- bool needsDomain = false;
- bool resizing = false;
- if (copyParams.fFilter != GrSamplerState::Filter::kNearest) {
- bool resizing = localRect.width() != dstRect.width() ||
- localRect.height() != dstRect.height();
- needsDomain = resizing && !GrProxyProvider::IsFunctionallyExact(inputProxy.get());
- }
-
- if (copyParams.fFilter == GrSamplerState::Filter::kNearest && !needsDomain && !resizing &&
- dstWillRequireMipMaps) {
- sk_sp<GrTextureProxy> proxy = GrCopyBaseMipMapToTextureProxy(context, inputProxy.get());
- if (proxy) {
- return proxy;
- }
- }
-
sk_sp<GrRenderTargetContext> copyRTC =
context->contextPriv().makeDeferredRenderTargetContextWithFallback(
SkBackingFit::kExact, dstRect.width(), dstRect.height(), inputProxy->config(),
@@ -52,6 +33,14 @@ sk_sp<GrTextureProxy> GrTextureProducer::CopyOnGpu(GrContext* context,
}
GrPaint paint;
+ SkRect localRect = SkRect::MakeWH(inputProxy->width(), inputProxy->height());
+
+ bool needsDomain = false;
+ if (copyParams.fFilter != GrSamplerState::Filter::kNearest) {
+ bool resizing = localRect.width() != dstRect.width() ||
+ localRect.height() != dstRect.height();
+ needsDomain = resizing && !GrProxyProvider::IsFunctionallyExact(inputProxy.get());
+ }
if (needsDomain) {
const SkRect domain = localRect.makeInset(0.5f, 0.5f);
diff --git a/src/gpu/GrTextureProxyPriv.h b/src/gpu/GrTextureProxyPriv.h
index 358369d516..cadd2fde63 100644
--- a/src/gpu/GrTextureProxyPriv.h
+++ b/src/gpu/GrTextureProxyPriv.h
@@ -31,6 +31,7 @@ public:
// been instantiated or not.
GrMipMapped proxyMipMapped() const { return fTextureProxy->fMipMapped; }
+ bool doesNotSupportMipMaps() const { return fTextureProxy->doesNotSupportMipMaps(); }
bool isGLTextureRectangleOrExternal() const {
return fTextureProxy->isGLTextureRectangleOrExternal();
}
@@ -40,6 +41,10 @@ public:
// We only support the clamp wrap mode with gl rectangle or external textures.
bool isClampOnly() const { return fTextureProxy->isGLTextureRectangleOrExternal(); }
+ void setDoesNotSupportMipMaps() {
+ fTextureProxy->setDoesNotSupportMipMaps();
+ }
+
private:
explicit GrTextureProxyPriv(GrTextureProxy* textureProxy) : fTextureProxy(textureProxy) {}
GrTextureProxyPriv(const GrTextureProxyPriv&) {} // unimpl
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 4f9b63fd62..e20d0137e9 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -1338,15 +1338,12 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
bool disableR8TexStorageForANGLEGL = false;
bool disableSRGBRenderWithMSAAForMacAMD = false;
bool disableRGB8ForMali400 = false;
- bool disableGrayLumFBOForMesa = false;
if (!contextOptions.fDisableDriverCorrectnessWorkarounds) {
// ARB_texture_rg is part of OpenGL 3.0, but osmesa doesn't support GL_RED
// and GL_RG on FBO textures.
disableTextureRedForMesa = kOSMesa_GrGLRenderer == ctxInfo.renderer();
- disableGrayLumFBOForMesa = kOSMesa_GrGLRenderer == ctxInfo.renderer();
-
bool isX86PowerVR = false;
#if defined(SK_CPU_X86)
if (kPowerVRRogue_GrGLRenderer == ctxInfo.renderer()) {
@@ -1745,16 +1742,17 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
grayRedInfo.fSwizzle = GrSwizzle::RRRA();
grayRedInfo.fFlags = ConfigInfo::kTextureable_Flag;
- // Leaving Gray8 as non-renderable, to keep things simple and match raster. However, we do
- // enable the FBOColorAttachment_Flag so that we can bind it to an FBO for copies.
- grayRedInfo.fFlags |= ConfigInfo::kFBOColorAttachment_Flag;;
- if (kStandard_MSFBOType == this->msFBOType() && kGL_GrGLStandard == standard &&
- !disableGrayLumFBOForMesa) {
+#if 0 // Leaving Gray8 as non-renderable, to keep things simple and match raster. Needs to be
+ // updated to support Gray8_as_Lum and Gray8_as_red if this is ever enabled.
+ if (this->textureRedSupport() ||
+ (kDesktop_ARB_MSFBOType == this->msFBOType() &&
+ ctxInfo.renderer() != kOSMesa_GrGLRenderer)) {
// desktop ARB extension/3.0+ supports LUMINANCE8 as renderable.
// However, osmesa fails if it used even when GL_ARB_framebuffer_object is present.
// Core profile removes LUMINANCE8 support, but we should have chosen R8 in that case.
- grayLumInfo.fFlags |= ConfigInfo::kFBOColorAttachment_Flag;;
+ fConfigTable[kGray_8_GrPixelConfig].fFlags |= allRenderFlags;
}
+#endif
if (texStorageSupported && !isCommandBufferES2) {
if (!disableR8TexStorageForANGLEGL) {
grayLumInfo.fFlags |= ConfigInfo::kCanUseTexStorage_Flag;
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index 1596dfd9de..e258eaa57d 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -123,8 +123,8 @@ public:
// 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 bindable to an FBO.
- return this->canConfigBeFBOColorAttachment(config);
+ // the same config, we need that config to be renderable so we can attach it to an FBO.
+ return this->isConfigRenderable(config, false);
}
bool canConfigBeFBOColorAttachment(GrPixelConfig config) const {
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index e420a09b7f..533c6b4a4a 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -2833,8 +2833,6 @@ void GrGLGpu::generateMipmaps(const GrSamplerState& params, GrGLTexture* texture
return;
}
- SkASSERT(texture->texturePriv().mipMapped() == GrMipMapped::kYes);
-
// If the mips aren't dirty, we're done:
if (!texture->texturePriv().mipMapsAreDirty()) {
return;
diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp
index ec20e245b9..e76f5bc487 100644
--- a/src/gpu/ops/GrTextureOp.cpp
+++ b/src/gpu/ops/GrTextureOp.cpp
@@ -1046,16 +1046,10 @@ GR_DRAW_OP_TEST_DEFINE(TextureOp) {
desc.fHeight = random->nextULessThan(90) + 10;
desc.fWidth = random->nextULessThan(90) + 10;
auto origin = random->nextBool() ? kTopLeft_GrSurfaceOrigin : kBottomLeft_GrSurfaceOrigin;
- GrMipMapped mipMapped = random->nextBool() ? GrMipMapped::kYes : GrMipMapped::kNo;
- SkBackingFit fit = SkBackingFit::kExact;
- if (mipMapped == GrMipMapped::kNo) {
- fit = random->nextBool() ? SkBackingFit::kApprox : SkBackingFit::kExact;
- }
+ SkBackingFit fit = random->nextBool() ? SkBackingFit::kApprox : SkBackingFit::kExact;
GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
- sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(desc, origin, mipMapped, fit,
- SkBudgeted::kNo,
- GrInternalSurfaceFlags::kNone);
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(desc, origin, fit, SkBudgeted::kNo);
SkRect rect = GrTest::TestRect(random);
SkRect srcRect;
@@ -1067,10 +1061,6 @@ GR_DRAW_OP_TEST_DEFINE(TextureOp) {
GrColor color = SkColorToPremulGrColor(random->nextU());
GrSamplerState::Filter filter = (GrSamplerState::Filter)random->nextULessThan(
static_cast<uint32_t>(GrSamplerState::Filter::kMipMap) + 1);
- while (mipMapped == GrMipMapped::kNo && filter == GrSamplerState::Filter::kMipMap) {
- filter = (GrSamplerState::Filter)random->nextULessThan(
- static_cast<uint32_t>(GrSamplerState::Filter::kMipMap) + 1);
- }
auto csxf = GrTest::TestColorXform(random);
GrAAType aaType = GrAAType::kNone;
if (random->nextBool()) {
diff --git a/src/gpu/vk/GrVkGpuCommandBuffer.cpp b/src/gpu/vk/GrVkGpuCommandBuffer.cpp
index 552e7bc801..5493dd9890 100644
--- a/src/gpu/vk/GrVkGpuCommandBuffer.cpp
+++ b/src/gpu/vk/GrVkGpuCommandBuffer.cpp
@@ -621,7 +621,6 @@ static void prepare_sampled_images(const GrResourceIOProcessor& processor,
// Check if we need to regenerate any mip maps
if (GrSamplerState::Filter::kMipMap == sampler.samplerState().filter()) {
- SkASSERT(vkTexture->texturePriv().mipMapped() == GrMipMapped::kYes);
if (vkTexture->texturePriv().mipMapsAreDirty()) {
gpu->generateMipmap(vkTexture, sampler.proxy()->origin());
vkTexture->texturePriv().markMipMapsClean();
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 01f0c1ff8a..4759f4efeb 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -663,7 +663,8 @@ private:
static GrInternalSurfaceFlags get_flags_from_format(const GrBackendFormat& backendFormat) {
if (const GrGLenum* target = backendFormat.getGLTarget()) {
if (GR_GL_TEXTURE_RECTANGLE == *target || GR_GL_TEXTURE_EXTERNAL == *target) {
- return GrInternalSurfaceFlags::kIsGLTextureRectangleOrExternal;
+ return GrInternalSurfaceFlags::kDoesNotSupportMipMaps |
+ GrInternalSurfaceFlags::kIsGLTextureRectangleOrExternal;
}
}
@@ -705,15 +706,6 @@ sk_sp<SkImage> SkImage_Gpu::MakePromiseTexture(GrContext* context,
return nullptr;
}
- GrInternalSurfaceFlags formatFlags = get_flags_from_format(backendFormat);
-
- if (mipMapped == GrMipMapped::kYes &&
- SkToBool(formatFlags & GrInternalSurfaceFlags::kIsGLTextureRectangleOrExternal)) {
- // It is invalid to have a GL_TEXTURE_EXTERNAL or GL_TEXTURE_RECTANGLE and have mips as
- // well.
- return nullptr;
- }
-
GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
GrSurfaceDesc desc;
@@ -724,6 +716,16 @@ sk_sp<SkImage> SkImage_Gpu::MakePromiseTexture(GrContext* context,
PromiseImageHelper promiseHelper(textureFulfillProc, textureReleaseProc, promiseDoneProc,
textureContext);
+ GrInternalSurfaceFlags formatFlags = get_flags_from_format(backendFormat);
+
+ // Promise images always wrap resources. So if the promise image doesn't have mip maps, we
+ // cannot allocate mips for them and thus will need a copy to use a mipped image. We can't pass
+ // the fact that this creates a wrapped texture into createLazyProxy so we need to manually set
+ // in in the passed in flags.
+ if (GrMipMapped::kNo == mipMapped) {
+ formatFlags |= GrInternalSurfaceFlags::kDoesNotSupportMipMaps;
+ }
+
sk_sp<GrTextureProxy> proxy = proxyProvider->createLazyProxy(
[promiseHelper, config] (GrResourceProvider* resourceProvider) mutable {
if (!resourceProvider) {
diff --git a/src/image/SkImage_Lazy.cpp b/src/image/SkImage_Lazy.cpp
index 33e430726e..19b324beaa 100644
--- a/src/image/SkImage_Lazy.cpp
+++ b/src/image/SkImage_Lazy.cpp
@@ -866,6 +866,10 @@ sk_sp<GrTextureProxy> SkImage_Lazy::lockTextureProxy(GrContext* ctx,
set_key_on_proxy(proxyProvider, mippedProxy.get(), proxy.get(), key);
return mippedProxy;
}
+ // 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 proxy;
}
SK_HISTOGRAM_ENUMERATION("LockTexturePath", kFailure_LockTexturePath,
diff --git a/tests/DeferredDisplayListTest.cpp b/tests/DeferredDisplayListTest.cpp
index 697f00328f..996e04fa79 100644
--- a/tests/DeferredDisplayListTest.cpp
+++ b/tests/DeferredDisplayListTest.cpp
@@ -846,31 +846,26 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(DDLTextureFlagsTest, reporter, ctxInfo) {
SkDeferredDisplayListRecorder recorder(characterization);
for (GrGLenum target : { GR_GL_TEXTURE_EXTERNAL, GR_GL_TEXTURE_RECTANGLE, GR_GL_TEXTURE_2D } ) {
- for (auto mipMapped : { GrMipMapped::kNo, GrMipMapped::kYes }) {
- GrBackendFormat format = GrBackendFormat::MakeGL(GR_GL_RGBA8, target);
-
- sk_sp<SkImage> image = recorder.makePromiseTexture(format, 32, 32, mipMapped,
- kTopLeft_GrSurfaceOrigin,
- kRGBA_8888_SkColorType,
- kPremul_SkAlphaType, nullptr,
- dummy_fulfill_proc,
- dummy_release_proc,
- dummy_done_proc,
- nullptr);
- if (GR_GL_TEXTURE_2D != target && mipMapped == GrMipMapped::kYes) {
- REPORTER_ASSERT(reporter, !image);
- continue;
- }
- REPORTER_ASSERT(reporter, image);
+ GrBackendFormat format = GrBackendFormat::MakeGL(GR_GL_RGBA8, target);
- GrTextureProxy* backingProxy = ((SkImage_Gpu*) image.get())->peekProxy();
+ sk_sp<SkImage> image = recorder.makePromiseTexture(format, 32, 32, GrMipMapped::kYes,
+ kTopLeft_GrSurfaceOrigin,
+ kRGBA_8888_SkColorType,
+ kPremul_SkAlphaType, nullptr,
+ dummy_fulfill_proc,
+ dummy_release_proc,
+ dummy_done_proc,
+ nullptr);
+ REPORTER_ASSERT(reporter, image);
- REPORTER_ASSERT(reporter, backingProxy->mipMapped() == mipMapped);
- if (GR_GL_TEXTURE_2D == target) {
- REPORTER_ASSERT(reporter, !backingProxy->texPriv().isClampOnly());
- } else {
- REPORTER_ASSERT(reporter, backingProxy->texPriv().isClampOnly());
- }
+ GrTextureProxy* backingProxy = ((SkImage_Gpu*) image.get())->peekProxy();
+
+ if (GR_GL_TEXTURE_2D == target) {
+ REPORTER_ASSERT(reporter, !backingProxy->texPriv().doesNotSupportMipMaps());
+ REPORTER_ASSERT(reporter, !backingProxy->texPriv().isClampOnly());
+ } else {
+ REPORTER_ASSERT(reporter, backingProxy->texPriv().doesNotSupportMipMaps());
+ REPORTER_ASSERT(reporter, backingProxy->texPriv().isClampOnly());
}
}
}
diff --git a/tests/EGLImageTest.cpp b/tests/EGLImageTest.cpp
index 94cbaf9c17..f2c73711e7 100644
--- a/tests/EGLImageTest.cpp
+++ b/tests/EGLImageTest.cpp
@@ -16,7 +16,6 @@
#include "GrTest.h"
#include "GrTexture.h"
#include "GrTextureContext.h"
-#include "GrTexturePriv.h"
#include "GrTextureProxyPriv.h"
#include "gl/GLTestContext.h"
#include "gl/GrGLGpu.h"
@@ -167,9 +166,8 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
}
GrTextureProxy* proxy = surfaceContext->asTextureProxy();
- REPORTER_ASSERT(reporter, proxy->mipMapped() == GrMipMapped::kNo);
- REPORTER_ASSERT(reporter,
- proxy->priv().peekTexture()->texturePriv().mipMapped() == GrMipMapped::kNo);
+ REPORTER_ASSERT(reporter, proxy->texPriv().doesNotSupportMipMaps());
+ REPORTER_ASSERT(reporter, proxy->priv().peekTexture()->surfacePriv().doesNotSupportMipMaps());
REPORTER_ASSERT(reporter, proxy->texPriv().isGLTextureRectangleOrExternal());
REPORTER_ASSERT(reporter,
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index 359527fce5..81fb21fa32 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -273,8 +273,7 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages, int ma
dummyDesc.fHeight = 18;
dummyDesc.fConfig = kRGBA_8888_GrPixelConfig;
proxies[0] = proxyProvider->createProxy(dummyDesc, kBottomLeft_GrSurfaceOrigin,
- GrMipMapped::kYes, SkBackingFit::kExact,
- SkBudgeted::kNo, GrInternalSurfaceFlags::kNone);
+ SkBackingFit::kExact, SkBudgeted::kNo);
}
{
GrSurfaceDesc dummyDesc;
@@ -283,8 +282,7 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages, int ma
dummyDesc.fHeight = 22;
dummyDesc.fConfig = kAlpha_8_GrPixelConfig;
proxies[1] = proxyProvider->createProxy(dummyDesc, kTopLeft_GrSurfaceOrigin,
- GrMipMapped::kYes, SkBackingFit::kExact,
- SkBudgeted::kNo, GrInternalSurfaceFlags::kNone);
+ SkBackingFit::kExact, SkBudgeted::kNo);
}
if (!proxies[0] || !proxies[1]) {
diff --git a/tests/GrTextureMipMapInvalidationTest.cpp b/tests/GrTextureMipMapInvalidationTest.cpp
index 8da79c9565..d832889144 100644
--- a/tests/GrTextureMipMapInvalidationTest.cpp
+++ b/tests/GrTextureMipMapInvalidationTest.cpp
@@ -27,31 +27,27 @@ DEF_GPUTEST_FOR_NULLGL_CONTEXT(GrTextureMipMapInvalidationTest, reporter, ctxInf
GrContext* context = ctxInfo.grContext();
auto info = SkImageInfo::MakeN32Premul(256, 256);
- for (auto allocateMips : {false, true}) {
- auto surf1 = SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, info, 0,
- kBottomLeft_GrSurfaceOrigin, nullptr,
- allocateMips);
- auto surf2 = SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, info);
- // Draw something just in case we ever had a solid color optimization
- surf1->getCanvas()->drawCircle(128, 128, 50, SkPaint());
- surf1->getCanvas()->flush();
-
- // No mipmaps initially
- REPORTER_ASSERT(reporter, isMipped(surf1.get()) == allocateMips);
-
- // Painting with downscale and medium filter quality should result in mipmap creation
- SkPaint paint;
- paint.setFilterQuality(kMedium_SkFilterQuality);
- surf2->getCanvas()->scale(0.2f, 0.2f);
- surf2->getCanvas()->drawImage(surf1->makeImageSnapshot(), 0, 0, &paint);
- surf2->getCanvas()->flush();
- REPORTER_ASSERT(reporter, isMipped(surf1.get()) == allocateMips);
- REPORTER_ASSERT(reporter, !allocateMips || !mipsAreDirty(surf1.get()));
-
- // Changing the contents of the surface should invalidate the mipmap, but not de-allocate
- surf1->getCanvas()->drawCircle(128, 128, 100, SkPaint());
- surf1->getCanvas()->flush();
- REPORTER_ASSERT(reporter, isMipped(surf1.get()) == allocateMips);
- REPORTER_ASSERT(reporter, mipsAreDirty(surf1.get()));
- }
+ auto surf1 = SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, info);
+ auto surf2 = SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, info);
+ // Draw something just in case we ever had a solid color optimization
+ surf1->getCanvas()->drawCircle(128, 128, 50, SkPaint());
+ surf1->getCanvas()->flush();
+
+ // No mipmaps initially
+ REPORTER_ASSERT(reporter, !isMipped(surf1.get()));
+
+ // Painting with downscale and medium filter quality should result in mipmap creation
+ SkPaint paint;
+ paint.setFilterQuality(kMedium_SkFilterQuality);
+ surf2->getCanvas()->scale(0.2f, 0.2f);
+ surf2->getCanvas()->drawImage(surf1->makeImageSnapshot(), 0, 0, &paint);
+ surf2->getCanvas()->flush();
+ REPORTER_ASSERT(reporter, isMipped(surf1.get()));
+ REPORTER_ASSERT(reporter, !mipsAreDirty(surf1.get()));
+
+ // Changing the contents of the surface should invalidate the mipmap, but not de-allocate
+ surf1->getCanvas()->drawCircle(128, 128, 100, SkPaint());
+ surf1->getCanvas()->flush();
+ REPORTER_ASSERT(reporter, isMipped(surf1.get()));
+ REPORTER_ASSERT(reporter, mipsAreDirty(surf1.get()));
}
diff --git a/tests/LazyProxyTest.cpp b/tests/LazyProxyTest.cpp
index 536ef36307..901cd29895 100644
--- a/tests/LazyProxyTest.cpp
+++ b/tests/LazyProxyTest.cpp
@@ -443,6 +443,10 @@ DEF_GPUTEST(LazyProxyUninstantiateTest, reporter, /* options */) {
REPORTER_ASSERT(reporter, lazyProxy.get());
+ // We can't pass the fact that this creates a wrapped texture into createLazyProxy so we
+ // need to manually call setDoesNotSupportMipMaps.
+ lazyProxy->texPriv().setDoesNotSupportMipMaps();
+
rtc->priv().testingOnly_addDrawOp(LazyUninstantiateTestOp::Make(ctx.get(), lazyProxy));
ctx->flush();
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index 90b723a3eb..3516acf339 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -15,7 +15,6 @@
#include "GrRenderTargetContext.h"
#include "GrSurfacePriv.h"
#include "GrTest.h"
-#include "GrTexturePriv.h"
#include "GrTextureProxyPriv.h"
#include "gl/GLTestContext.h"
#include "gl/GrGLGpu.h"
@@ -137,8 +136,8 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(RectangleTexture, reporter, ctxInfo) {
continue;
}
- SkASSERT(rectProxy->mipMapped() == GrMipMapped::kNo);
- SkASSERT(rectProxy->priv().peekTexture()->texturePriv().mipMapped() == GrMipMapped::kNo);
+ SkASSERT(rectProxy->texPriv().doesNotSupportMipMaps());
+ SkASSERT(rectProxy->priv().peekTexture()->surfacePriv().doesNotSupportMipMaps());
SkASSERT(rectProxy->texPriv().isGLTextureRectangleOrExternal());
SkASSERT(rectProxy->priv().peekTexture()->surfacePriv().isGLTextureRectangleOrExternal());