Reland "Require mips to be allocated at texture creation time and disable late allocations."
This reverts commit0c78238e29
. Reason for revert: <INSERT REASONING HERE> Original change's description: > Revert "Require mips to be allocated at texture creation time and disable late allocations." > > This reverts commitcd2c3f9055
. > > Reason for revert: Looks to be causing angle failures on initial clear test > > Original change's description: > > Require mips to be allocated at texture creation time and disable late allocations. > > > > If we get a non-mipped texture for a draw that wants to be use mip map filter, we > > will copy the texture into a new mipped texture. > > > > Clean up of unused code in the GPU backends for reallocating for mips will be done > > in a follow up CL. > > > > Bug: skia: > > Change-Id: Idab588c1abf4bbbf7eeceb3727d500e5df274188 > > Reviewed-on: https://skia-review.googlesource.com/132830 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > > > Change-Id: I49f0ace52f2586d61b451630b2e6aae84b420b81 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/133041 > Reviewed-by: Greg Daniel <egdaniel@google.com> > Commit-Queue: Greg Daniel <egdaniel@google.com> Bug: skia: Change-Id: I004447a5f1ec72c3be2318ddea803f57efb12ea4 Reviewed-on: https://skia-review.googlesource.com/133340 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
parent
fff19667cc
commit
9eb36b9eb8
@ -37,7 +37,11 @@ protected:
|
|||||||
auto srgb = SkColorSpace::MakeSRGB();
|
auto srgb = SkColorSpace::MakeSRGB();
|
||||||
SkImageInfo info =
|
SkImageInfo info =
|
||||||
SkImageInfo::Make(fW, fH, kRGBA_8888_SkColorType, kPremul_SkAlphaType, srgb);
|
SkImageInfo::Make(fW, fH, kRGBA_8888_SkColorType, kPremul_SkAlphaType, srgb);
|
||||||
fSurface = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info);
|
// 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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear surface once:
|
// Clear surface once:
|
||||||
|
@ -63,20 +63,9 @@ public:
|
|||||||
GrMipMapped, bool useNextPow2 = false);
|
GrMipMapped, bool useNextPow2 = false);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setDoesNotSupportMipMaps() {
|
|
||||||
SkASSERT(this->asTexture());
|
|
||||||
fSurfaceFlags |= GrInternalSurfaceFlags::kDoesNotSupportMipMaps;
|
|
||||||
}
|
|
||||||
bool doesNotSupportMipMaps() const {
|
|
||||||
return fSurfaceFlags & GrInternalSurfaceFlags::kDoesNotSupportMipMaps;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setIsGLTextureRectangleOrExternal() {
|
void setIsGLTextureRectangleOrExternal() {
|
||||||
SkASSERT(this->asTexture());
|
SkASSERT(this->asTexture());
|
||||||
fSurfaceFlags |= GrInternalSurfaceFlags::kIsGLTextureRectangleOrExternal;
|
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 {
|
bool isGLTextureRectangleOrExternal() const {
|
||||||
return fSurfaceFlags & GrInternalSurfaceFlags::kIsGLTextureRectangleOrExternal;
|
return fSurfaceFlags & GrInternalSurfaceFlags::kIsGLTextureRectangleOrExternal;
|
||||||
|
@ -100,18 +100,8 @@ protected:
|
|||||||
|
|
||||||
sk_sp<GrSurface> createSurface(GrResourceProvider*) const override;
|
sk_sp<GrSurface> createSurface(GrResourceProvider*) const override;
|
||||||
|
|
||||||
void setDoesNotSupportMipMaps() {
|
|
||||||
fSurfaceFlags |= GrInternalSurfaceFlags::kDoesNotSupportMipMaps;
|
|
||||||
}
|
|
||||||
bool doesNotSupportMipMaps() const {
|
|
||||||
return fSurfaceFlags & GrInternalSurfaceFlags::kDoesNotSupportMipMaps;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setIsGLTextureRectangleOrExternal() {
|
void setIsGLTextureRectangleOrExternal() {
|
||||||
fSurfaceFlags |= GrInternalSurfaceFlags::kIsGLTextureRectangleOrExternal;
|
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 {
|
bool isGLTextureRectangleOrExternal() const {
|
||||||
return fSurfaceFlags & GrInternalSurfaceFlags::kIsGLTextureRectangleOrExternal;
|
return fSurfaceFlags & GrInternalSurfaceFlags::kIsGLTextureRectangleOrExternal;
|
||||||
|
@ -868,20 +868,14 @@ enum class GrInternalSurfaceFlags {
|
|||||||
|
|
||||||
// Texture-only flags
|
// 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
|
// 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
|
// 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).
|
// 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
|
// Note: Ganesh does not internally create these types of textures so they will only occur on
|
||||||
// resources passed into Ganesh.
|
// resources passed into Ganesh.
|
||||||
kIsGLTextureRectangleOrExternal = 1 << 2,
|
kIsGLTextureRectangleOrExternal = 1 << 1,
|
||||||
|
|
||||||
kTextureMask = kDoesNotSupportMipMaps | kIsGLTextureRectangleOrExternal,
|
kTextureMask = kIsGLTextureRectangleOrExternal,
|
||||||
|
|
||||||
// RT-only
|
// RT-only
|
||||||
|
|
||||||
@ -891,17 +885,17 @@ enum class GrInternalSurfaceFlags {
|
|||||||
// this is disabled for FBO0
|
// this is disabled for FBO0
|
||||||
// but, otherwise, is enabled whenever MSAA is enabled and GrCaps reports mixed samples
|
// but, otherwise, is enabled whenever MSAA is enabled and GrCaps reports mixed samples
|
||||||
// are supported
|
// are supported
|
||||||
kMixedSampled = 1 << 3,
|
kMixedSampled = 1 << 2,
|
||||||
|
|
||||||
// For internal resources:
|
// For internal resources:
|
||||||
// this is enabled whenever GrCaps reports window rect support
|
// this is enabled whenever GrCaps reports window rect support
|
||||||
// For wrapped resources1
|
// For wrapped resources1
|
||||||
// this is disabled for FBO0
|
// this is disabled for FBO0
|
||||||
// but, otherwise, is enabled whenever GrCaps reports window rect support
|
// but, otherwise, is enabled whenever GrCaps reports window rect support
|
||||||
kWindowRectsSupport = 1 << 4,
|
kWindowRectsSupport = 1 << 3,
|
||||||
|
|
||||||
// This flag is for use with GL only. It tells us that the internal render target wraps FBO 0.
|
// This flag is for use with GL only. It tells us that the internal render target wraps FBO 0.
|
||||||
kGLRTFBOIDIs0 = 1 << 5,
|
kGLRTFBOIDIs0 = 1 << 4,
|
||||||
|
|
||||||
kRenderTargetMask = kMixedSampled | kWindowRectsSupport | kGLRTFBOIDIs0,
|
kRenderTargetMask = kMixedSampled | kWindowRectsSupport | kGLRTFBOIDIs0,
|
||||||
};
|
};
|
||||||
|
@ -180,12 +180,6 @@ sk_sp<GrTextureProxy> GrBackendTextureImageGenerator::onGenerateTexture(
|
|||||||
return nullptr;
|
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 &&
|
if (0 == origin.fX && 0 == origin.fY &&
|
||||||
info.width() == fBackendTexture.width() && info.height() == fBackendTexture.height() &&
|
info.width() == fBackendTexture.width() && info.height() == fBackendTexture.height() &&
|
||||||
(!willNeedMipMaps || GrMipMapped::kYes == proxy->mipMapped())) {
|
(!willNeedMipMaps || GrMipMapped::kYes == proxy->mipMapped())) {
|
||||||
|
@ -89,10 +89,6 @@ sk_sp<GrTextureProxy> GrBitmapTextureMaker::refOriginalTextureProxy(bool willBeM
|
|||||||
}
|
}
|
||||||
return mippedProxy;
|
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;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -50,13 +50,34 @@ bool GrGpu::IsACopyNeededForTextureParams(const GrCaps* caps, GrTextureProxy* te
|
|||||||
const GrSamplerState& textureParams,
|
const GrSamplerState& textureParams,
|
||||||
GrTextureProducer::CopyParams* copyParams,
|
GrTextureProducer::CopyParams* copyParams,
|
||||||
SkScalar scaleAdjust[2]) {
|
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) {
|
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
|
// If the texture format itself doesn't support repeat wrap mode or mipmapping (and
|
||||||
// those capabilities are required) force a copy.
|
// those capabilities are required) force a copy.
|
||||||
if ((textureParams.isRepeated() && texProxy->texPriv().isClampOnly()) ||
|
if ((textureParams.isRepeated() && texProxy->texPriv().isClampOnly()) ||
|
||||||
(GrSamplerState::Filter::kMipMap == textureParams.filter() &&
|
(willNeedMips && texProxy->mipMapped() == GrMipMapped::kNo)) {
|
||||||
texProxy->texPriv().doesNotSupportMipMaps())) {
|
|
||||||
copyParams->fFilter = GrSamplerState::Filter::kNearest;
|
copyParams->fFilter = GrSamplerState::Filter::kNearest;
|
||||||
copyParams->fWidth = texProxy->width();
|
copyParams->fWidth = texProxy->width();
|
||||||
copyParams->fHeight = texProxy->height();
|
copyParams->fHeight = texProxy->height();
|
||||||
@ -64,26 +85,6 @@ 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,13 +139,7 @@ sk_sp<GrTexture> GrGpu::wrapBackendTexture(const GrBackendTexture& backendTex,
|
|||||||
backendTex.height() > this->caps()->maxTextureSize()) {
|
backendTex.height() > this->caps()->maxTextureSize()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
sk_sp<GrTexture> tex = this->onWrapBackendTexture(backendTex, ownership);
|
return 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,
|
sk_sp<GrTexture> GrGpu::wrapRenderableBackendTexture(const GrBackendTexture& backendTex,
|
||||||
@ -163,11 +158,6 @@ sk_sp<GrTexture> GrGpu::wrapRenderableBackendTexture(const GrBackendTexture& bac
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
sk_sp<GrTexture> tex = this->onWrapRenderableBackendTexture(backendTex, sampleCnt, ownership);
|
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());
|
SkASSERT(!tex || tex->asRenderTarget());
|
||||||
return tex;
|
return tex;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,6 @@ public:
|
|||||||
|
|
||||||
GrInternalSurfaceFlags flags() const { return fSurface->fSurfaceFlags; }
|
GrInternalSurfaceFlags flags() const { return fSurface->fSurfaceFlags; }
|
||||||
|
|
||||||
bool doesNotSupportMipMaps() const { return fSurface->doesNotSupportMipMaps(); }
|
|
||||||
bool isGLTextureRectangleOrExternal() const {
|
bool isGLTextureRectangleOrExternal() const {
|
||||||
return fSurface->isGLTextureRectangleOrExternal();
|
return fSurface->isGLTextureRectangleOrExternal();
|
||||||
}
|
}
|
||||||
|
@ -25,14 +25,8 @@ void GrTexture::markMipMapsDirty() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GrTexture::markMipMapsClean() {
|
void GrTexture::markMipMapsClean() {
|
||||||
const bool sizeChanged = GrMipMapsStatus::kNotAllocated == fMipMapsStatus;
|
SkASSERT(GrMipMapsStatus::kNotAllocated != fMipMapsStatus);
|
||||||
fMipMapsStatus = GrMipMapsStatus::kValid;
|
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 {
|
size_t GrTexture::onGpuMemorySize() const {
|
||||||
|
@ -43,10 +43,11 @@ sk_sp<GrTextureProxy> GrTextureAdjuster::refTextureProxyCopy(const CopyParams& c
|
|||||||
|
|
||||||
GrUniqueKey key;
|
GrUniqueKey key;
|
||||||
this->makeCopyKey(copyParams, &key, nullptr);
|
this->makeCopyKey(copyParams, &key, nullptr);
|
||||||
|
sk_sp<GrTextureProxy> cachedCopy;
|
||||||
if (key.isValid()) {
|
if (key.isValid()) {
|
||||||
sk_sp<GrTextureProxy> cachedCopy =
|
cachedCopy = proxyProvider->findOrCreateProxyByUniqueKey(key,
|
||||||
proxyProvider->findOrCreateProxyByUniqueKey(key, this->originalProxy()->origin());
|
this->originalProxy()->origin());
|
||||||
if (cachedCopy) {
|
if (cachedCopy && (!willBeMipped || GrMipMapped::kYes == cachedCopy->mipMapped())) {
|
||||||
return cachedCopy;
|
return cachedCopy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -57,6 +58,14 @@ sk_sp<GrTextureProxy> GrTextureAdjuster::refTextureProxyCopy(const CopyParams& c
|
|||||||
if (copy) {
|
if (copy) {
|
||||||
if (key.isValid()) {
|
if (key.isValid()) {
|
||||||
SkASSERT(copy->origin() == this->originalProxy()->origin());
|
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());
|
proxyProvider->assignUniqueKeyToProxy(key, copy.get());
|
||||||
this->didCacheCopy(key);
|
this->didCacheCopy(key);
|
||||||
}
|
}
|
||||||
@ -89,7 +98,8 @@ sk_sp<GrTextureProxy> GrTextureAdjuster::onRefTextureProxyForParams(
|
|||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool willBeMipped = GrSamplerState::Filter::kMipMap == params.filter();
|
bool willBeMipped = GrSamplerState::Filter::kMipMap == params.filter() &&
|
||||||
|
fContext->contextPriv().caps()->mipMapSupport();
|
||||||
return this->refTextureProxyCopy(copyParams, willBeMipped);
|
return this->refTextureProxyCopy(copyParams, willBeMipped);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,10 +44,6 @@ public:
|
|||||||
return fTexture->fMaxMipMapLevel;
|
return fTexture->fMaxMipMapLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDoesNotSupportMipMaps() {
|
|
||||||
fTexture->setDoesNotSupportMipMaps();
|
|
||||||
}
|
|
||||||
|
|
||||||
GrSLType samplerType() const { return fTexture->fSamplerType; }
|
GrSLType samplerType() const { return fTexture->fSamplerType; }
|
||||||
|
|
||||||
/** The filter used is clamped to this value in GrProcessor::TextureSampler. */
|
/** The filter used is clamped to this value in GrProcessor::TextureSampler. */
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "GrProxyProvider.h"
|
#include "GrProxyProvider.h"
|
||||||
#include "GrRenderTargetContext.h"
|
#include "GrRenderTargetContext.h"
|
||||||
#include "GrTextureProxy.h"
|
#include "GrTextureProxy.h"
|
||||||
|
#include "SkGr.h"
|
||||||
#include "SkRectPriv.h"
|
#include "SkRectPriv.h"
|
||||||
#include "effects/GrBicubicEffect.h"
|
#include "effects/GrBicubicEffect.h"
|
||||||
#include "effects/GrSimpleTextureEffect.h"
|
#include "effects/GrSimpleTextureEffect.h"
|
||||||
@ -24,6 +25,24 @@ sk_sp<GrTextureProxy> GrTextureProducer::CopyOnGpu(GrContext* context,
|
|||||||
const SkRect dstRect = SkRect::MakeIWH(copyParams.fWidth, copyParams.fHeight);
|
const SkRect dstRect = SkRect::MakeIWH(copyParams.fWidth, copyParams.fHeight);
|
||||||
GrMipMapped mipMapped = dstWillRequireMipMaps ? GrMipMapped::kYes : GrMipMapped::kNo;
|
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 =
|
sk_sp<GrRenderTargetContext> copyRTC =
|
||||||
context->contextPriv().makeDeferredRenderTargetContextWithFallback(
|
context->contextPriv().makeDeferredRenderTargetContextWithFallback(
|
||||||
SkBackingFit::kExact, dstRect.width(), dstRect.height(), inputProxy->config(),
|
SkBackingFit::kExact, dstRect.width(), dstRect.height(), inputProxy->config(),
|
||||||
@ -33,14 +52,6 @@ sk_sp<GrTextureProxy> GrTextureProducer::CopyOnGpu(GrContext* context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
GrPaint paint;
|
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) {
|
if (needsDomain) {
|
||||||
const SkRect domain = localRect.makeInset(0.5f, 0.5f);
|
const SkRect domain = localRect.makeInset(0.5f, 0.5f);
|
||||||
|
@ -31,7 +31,6 @@ public:
|
|||||||
// been instantiated or not.
|
// been instantiated or not.
|
||||||
GrMipMapped proxyMipMapped() const { return fTextureProxy->fMipMapped; }
|
GrMipMapped proxyMipMapped() const { return fTextureProxy->fMipMapped; }
|
||||||
|
|
||||||
bool doesNotSupportMipMaps() const { return fTextureProxy->doesNotSupportMipMaps(); }
|
|
||||||
bool isGLTextureRectangleOrExternal() const {
|
bool isGLTextureRectangleOrExternal() const {
|
||||||
return fTextureProxy->isGLTextureRectangleOrExternal();
|
return fTextureProxy->isGLTextureRectangleOrExternal();
|
||||||
}
|
}
|
||||||
@ -41,10 +40,6 @@ public:
|
|||||||
// We only support the clamp wrap mode with gl rectangle or external textures.
|
// We only support the clamp wrap mode with gl rectangle or external textures.
|
||||||
bool isClampOnly() const { return fTextureProxy->isGLTextureRectangleOrExternal(); }
|
bool isClampOnly() const { return fTextureProxy->isGLTextureRectangleOrExternal(); }
|
||||||
|
|
||||||
void setDoesNotSupportMipMaps() {
|
|
||||||
fTextureProxy->setDoesNotSupportMipMaps();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit GrTextureProxyPriv(GrTextureProxy* textureProxy) : fTextureProxy(textureProxy) {}
|
explicit GrTextureProxyPriv(GrTextureProxy* textureProxy) : fTextureProxy(textureProxy) {}
|
||||||
GrTextureProxyPriv(const GrTextureProxyPriv&) {} // unimpl
|
GrTextureProxyPriv(const GrTextureProxyPriv&) {} // unimpl
|
||||||
|
@ -1338,12 +1338,15 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
|
|||||||
bool disableR8TexStorageForANGLEGL = false;
|
bool disableR8TexStorageForANGLEGL = false;
|
||||||
bool disableSRGBRenderWithMSAAForMacAMD = false;
|
bool disableSRGBRenderWithMSAAForMacAMD = false;
|
||||||
bool disableRGB8ForMali400 = false;
|
bool disableRGB8ForMali400 = false;
|
||||||
|
bool disableGrayLumFBOForMesa = false;
|
||||||
|
|
||||||
if (!contextOptions.fDisableDriverCorrectnessWorkarounds) {
|
if (!contextOptions.fDisableDriverCorrectnessWorkarounds) {
|
||||||
// ARB_texture_rg is part of OpenGL 3.0, but osmesa doesn't support GL_RED
|
// ARB_texture_rg is part of OpenGL 3.0, but osmesa doesn't support GL_RED
|
||||||
// and GL_RG on FBO textures.
|
// and GL_RG on FBO textures.
|
||||||
disableTextureRedForMesa = kOSMesa_GrGLRenderer == ctxInfo.renderer();
|
disableTextureRedForMesa = kOSMesa_GrGLRenderer == ctxInfo.renderer();
|
||||||
|
|
||||||
|
disableGrayLumFBOForMesa = kOSMesa_GrGLRenderer == ctxInfo.renderer();
|
||||||
|
|
||||||
bool isX86PowerVR = false;
|
bool isX86PowerVR = false;
|
||||||
#if defined(SK_CPU_X86)
|
#if defined(SK_CPU_X86)
|
||||||
if (kPowerVRRogue_GrGLRenderer == ctxInfo.renderer()) {
|
if (kPowerVRRogue_GrGLRenderer == ctxInfo.renderer()) {
|
||||||
@ -1742,17 +1745,16 @@ void GrGLCaps::initConfigTable(const GrContextOptions& contextOptions,
|
|||||||
grayRedInfo.fSwizzle = GrSwizzle::RRRA();
|
grayRedInfo.fSwizzle = GrSwizzle::RRRA();
|
||||||
grayRedInfo.fFlags = ConfigInfo::kTextureable_Flag;
|
grayRedInfo.fFlags = ConfigInfo::kTextureable_Flag;
|
||||||
|
|
||||||
#if 0 // Leaving Gray8 as non-renderable, to keep things simple and match raster. Needs to be
|
// Leaving Gray8 as non-renderable, to keep things simple and match raster. However, we do
|
||||||
// updated to support Gray8_as_Lum and Gray8_as_red if this is ever enabled.
|
// enable the FBOColorAttachment_Flag so that we can bind it to an FBO for copies.
|
||||||
if (this->textureRedSupport() ||
|
grayRedInfo.fFlags |= ConfigInfo::kFBOColorAttachment_Flag;;
|
||||||
(kDesktop_ARB_MSFBOType == this->msFBOType() &&
|
if (kStandard_MSFBOType == this->msFBOType() && kGL_GrGLStandard == standard &&
|
||||||
ctxInfo.renderer() != kOSMesa_GrGLRenderer)) {
|
!disableGrayLumFBOForMesa) {
|
||||||
// desktop ARB extension/3.0+ supports LUMINANCE8 as renderable.
|
// desktop ARB extension/3.0+ supports LUMINANCE8 as renderable.
|
||||||
// However, osmesa fails if it used even when GL_ARB_framebuffer_object is present.
|
// 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.
|
// Core profile removes LUMINANCE8 support, but we should have chosen R8 in that case.
|
||||||
fConfigTable[kGray_8_GrPixelConfig].fFlags |= allRenderFlags;
|
grayLumInfo.fFlags |= ConfigInfo::kFBOColorAttachment_Flag;;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (texStorageSupported && !isCommandBufferES2) {
|
if (texStorageSupported && !isCommandBufferES2) {
|
||||||
if (!disableR8TexStorageForANGLEGL) {
|
if (!disableR8TexStorageForANGLEGL) {
|
||||||
grayLumInfo.fFlags |= ConfigInfo::kCanUseTexStorage_Flag;
|
grayLumInfo.fFlags |= ConfigInfo::kCanUseTexStorage_Flag;
|
||||||
|
@ -123,8 +123,8 @@ public:
|
|||||||
// In GL we have three ways to be able to copy. CopyTexImage, blit, and draw. CopyTexImage
|
// 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
|
// 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
|
// 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.
|
// the same config, we need that config to be bindable to an FBO.
|
||||||
return this->isConfigRenderable(config, false);
|
return this->canConfigBeFBOColorAttachment(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool canConfigBeFBOColorAttachment(GrPixelConfig config) const {
|
bool canConfigBeFBOColorAttachment(GrPixelConfig config) const {
|
||||||
|
@ -2854,6 +2854,8 @@ void GrGLGpu::generateMipmaps(const GrSamplerState& params, GrGLTexture* texture
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SkASSERT(texture->texturePriv().mipMapped() == GrMipMapped::kYes);
|
||||||
|
|
||||||
// If the mips aren't dirty, we're done:
|
// If the mips aren't dirty, we're done:
|
||||||
if (!texture->texturePriv().mipMapsAreDirty()) {
|
if (!texture->texturePriv().mipMapsAreDirty()) {
|
||||||
return;
|
return;
|
||||||
|
@ -1046,10 +1046,16 @@ GR_DRAW_OP_TEST_DEFINE(TextureOp) {
|
|||||||
desc.fHeight = random->nextULessThan(90) + 10;
|
desc.fHeight = random->nextULessThan(90) + 10;
|
||||||
desc.fWidth = random->nextULessThan(90) + 10;
|
desc.fWidth = random->nextULessThan(90) + 10;
|
||||||
auto origin = random->nextBool() ? kTopLeft_GrSurfaceOrigin : kBottomLeft_GrSurfaceOrigin;
|
auto origin = random->nextBool() ? kTopLeft_GrSurfaceOrigin : kBottomLeft_GrSurfaceOrigin;
|
||||||
SkBackingFit fit = random->nextBool() ? SkBackingFit::kApprox : SkBackingFit::kExact;
|
GrMipMapped mipMapped = random->nextBool() ? GrMipMapped::kYes : GrMipMapped::kNo;
|
||||||
|
SkBackingFit fit = SkBackingFit::kExact;
|
||||||
|
if (mipMapped == GrMipMapped::kNo) {
|
||||||
|
fit = random->nextBool() ? SkBackingFit::kApprox : SkBackingFit::kExact;
|
||||||
|
}
|
||||||
|
|
||||||
GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
|
GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
|
||||||
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(desc, origin, fit, SkBudgeted::kNo);
|
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(desc, origin, mipMapped, fit,
|
||||||
|
SkBudgeted::kNo,
|
||||||
|
GrInternalSurfaceFlags::kNone);
|
||||||
|
|
||||||
SkRect rect = GrTest::TestRect(random);
|
SkRect rect = GrTest::TestRect(random);
|
||||||
SkRect srcRect;
|
SkRect srcRect;
|
||||||
@ -1061,6 +1067,10 @@ GR_DRAW_OP_TEST_DEFINE(TextureOp) {
|
|||||||
GrColor color = SkColorToPremulGrColor(random->nextU());
|
GrColor color = SkColorToPremulGrColor(random->nextU());
|
||||||
GrSamplerState::Filter filter = (GrSamplerState::Filter)random->nextULessThan(
|
GrSamplerState::Filter filter = (GrSamplerState::Filter)random->nextULessThan(
|
||||||
static_cast<uint32_t>(GrSamplerState::Filter::kMipMap) + 1);
|
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);
|
auto csxf = GrTest::TestColorXform(random);
|
||||||
GrAAType aaType = GrAAType::kNone;
|
GrAAType aaType = GrAAType::kNone;
|
||||||
if (random->nextBool()) {
|
if (random->nextBool()) {
|
||||||
|
@ -621,6 +621,7 @@ static void prepare_sampled_images(const GrResourceIOProcessor& processor,
|
|||||||
|
|
||||||
// Check if we need to regenerate any mip maps
|
// Check if we need to regenerate any mip maps
|
||||||
if (GrSamplerState::Filter::kMipMap == sampler.samplerState().filter()) {
|
if (GrSamplerState::Filter::kMipMap == sampler.samplerState().filter()) {
|
||||||
|
SkASSERT(vkTexture->texturePriv().mipMapped() == GrMipMapped::kYes);
|
||||||
if (vkTexture->texturePriv().mipMapsAreDirty()) {
|
if (vkTexture->texturePriv().mipMapsAreDirty()) {
|
||||||
gpu->generateMipmap(vkTexture, sampler.proxy()->origin());
|
gpu->generateMipmap(vkTexture, sampler.proxy()->origin());
|
||||||
vkTexture->texturePriv().markMipMapsClean();
|
vkTexture->texturePriv().markMipMapsClean();
|
||||||
|
@ -663,8 +663,7 @@ private:
|
|||||||
static GrInternalSurfaceFlags get_flags_from_format(const GrBackendFormat& backendFormat) {
|
static GrInternalSurfaceFlags get_flags_from_format(const GrBackendFormat& backendFormat) {
|
||||||
if (const GrGLenum* target = backendFormat.getGLTarget()) {
|
if (const GrGLenum* target = backendFormat.getGLTarget()) {
|
||||||
if (GR_GL_TEXTURE_RECTANGLE == *target || GR_GL_TEXTURE_EXTERNAL == *target) {
|
if (GR_GL_TEXTURE_RECTANGLE == *target || GR_GL_TEXTURE_EXTERNAL == *target) {
|
||||||
return GrInternalSurfaceFlags::kDoesNotSupportMipMaps |
|
return GrInternalSurfaceFlags::kIsGLTextureRectangleOrExternal;
|
||||||
GrInternalSurfaceFlags::kIsGLTextureRectangleOrExternal;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -706,6 +705,15 @@ sk_sp<SkImage> SkImage_Gpu::MakePromiseTexture(GrContext* context,
|
|||||||
return nullptr;
|
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();
|
GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
|
||||||
|
|
||||||
GrSurfaceDesc desc;
|
GrSurfaceDesc desc;
|
||||||
@ -716,16 +724,6 @@ sk_sp<SkImage> SkImage_Gpu::MakePromiseTexture(GrContext* context,
|
|||||||
PromiseImageHelper promiseHelper(textureFulfillProc, textureReleaseProc, promiseDoneProc,
|
PromiseImageHelper promiseHelper(textureFulfillProc, textureReleaseProc, promiseDoneProc,
|
||||||
textureContext);
|
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(
|
sk_sp<GrTextureProxy> proxy = proxyProvider->createLazyProxy(
|
||||||
[promiseHelper, config] (GrResourceProvider* resourceProvider) mutable {
|
[promiseHelper, config] (GrResourceProvider* resourceProvider) mutable {
|
||||||
if (!resourceProvider) {
|
if (!resourceProvider) {
|
||||||
|
@ -862,10 +862,6 @@ sk_sp<GrTextureProxy> SkImage_Lazy::lockTextureProxy(GrContext* ctx,
|
|||||||
set_key_on_proxy(proxyProvider, mippedProxy.get(), proxy.get(), key);
|
set_key_on_proxy(proxyProvider, mippedProxy.get(), proxy.get(), key);
|
||||||
return mippedProxy;
|
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,
|
SK_HISTOGRAM_ENUMERATION("LockTexturePath", kFailure_LockTexturePath,
|
||||||
|
@ -846,26 +846,31 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(DDLTextureFlagsTest, reporter, ctxInfo) {
|
|||||||
SkDeferredDisplayListRecorder recorder(characterization);
|
SkDeferredDisplayListRecorder recorder(characterization);
|
||||||
|
|
||||||
for (GrGLenum target : { GR_GL_TEXTURE_EXTERNAL, GR_GL_TEXTURE_RECTANGLE, GR_GL_TEXTURE_2D } ) {
|
for (GrGLenum target : { GR_GL_TEXTURE_EXTERNAL, GR_GL_TEXTURE_RECTANGLE, GR_GL_TEXTURE_2D } ) {
|
||||||
GrBackendFormat format = GrBackendFormat::MakeGL(GR_GL_RGBA8, target);
|
for (auto mipMapped : { GrMipMapped::kNo, GrMipMapped::kYes }) {
|
||||||
|
GrBackendFormat format = GrBackendFormat::MakeGL(GR_GL_RGBA8, target);
|
||||||
|
|
||||||
sk_sp<SkImage> image = recorder.makePromiseTexture(format, 32, 32, GrMipMapped::kYes,
|
sk_sp<SkImage> image = recorder.makePromiseTexture(format, 32, 32, mipMapped,
|
||||||
kTopLeft_GrSurfaceOrigin,
|
kTopLeft_GrSurfaceOrigin,
|
||||||
kRGBA_8888_SkColorType,
|
kRGBA_8888_SkColorType,
|
||||||
kPremul_SkAlphaType, nullptr,
|
kPremul_SkAlphaType, nullptr,
|
||||||
dummy_fulfill_proc,
|
dummy_fulfill_proc,
|
||||||
dummy_release_proc,
|
dummy_release_proc,
|
||||||
dummy_done_proc,
|
dummy_done_proc,
|
||||||
nullptr);
|
nullptr);
|
||||||
REPORTER_ASSERT(reporter, image);
|
if (GR_GL_TEXTURE_2D != target && mipMapped == GrMipMapped::kYes) {
|
||||||
|
REPORTER_ASSERT(reporter, !image);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
REPORTER_ASSERT(reporter, image);
|
||||||
|
|
||||||
GrTextureProxy* backingProxy = ((SkImage_Gpu*) image.get())->peekProxy();
|
GrTextureProxy* backingProxy = ((SkImage_Gpu*) image.get())->peekProxy();
|
||||||
|
|
||||||
if (GR_GL_TEXTURE_2D == target) {
|
REPORTER_ASSERT(reporter, backingProxy->mipMapped() == mipMapped);
|
||||||
REPORTER_ASSERT(reporter, !backingProxy->texPriv().doesNotSupportMipMaps());
|
if (GR_GL_TEXTURE_2D == target) {
|
||||||
REPORTER_ASSERT(reporter, !backingProxy->texPriv().isClampOnly());
|
REPORTER_ASSERT(reporter, !backingProxy->texPriv().isClampOnly());
|
||||||
} else {
|
} else {
|
||||||
REPORTER_ASSERT(reporter, backingProxy->texPriv().doesNotSupportMipMaps());
|
REPORTER_ASSERT(reporter, backingProxy->texPriv().isClampOnly());
|
||||||
REPORTER_ASSERT(reporter, backingProxy->texPriv().isClampOnly());
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "GrTest.h"
|
#include "GrTest.h"
|
||||||
#include "GrTexture.h"
|
#include "GrTexture.h"
|
||||||
#include "GrTextureContext.h"
|
#include "GrTextureContext.h"
|
||||||
|
#include "GrTexturePriv.h"
|
||||||
#include "GrTextureProxyPriv.h"
|
#include "GrTextureProxyPriv.h"
|
||||||
#include "gl/GLTestContext.h"
|
#include "gl/GLTestContext.h"
|
||||||
#include "gl/GrGLGpu.h"
|
#include "gl/GrGLGpu.h"
|
||||||
@ -166,8 +167,9 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GrTextureProxy* proxy = surfaceContext->asTextureProxy();
|
GrTextureProxy* proxy = surfaceContext->asTextureProxy();
|
||||||
REPORTER_ASSERT(reporter, proxy->texPriv().doesNotSupportMipMaps());
|
REPORTER_ASSERT(reporter, proxy->mipMapped() == GrMipMapped::kNo);
|
||||||
REPORTER_ASSERT(reporter, proxy->priv().peekTexture()->surfacePriv().doesNotSupportMipMaps());
|
REPORTER_ASSERT(reporter,
|
||||||
|
proxy->priv().peekTexture()->texturePriv().mipMapped() == GrMipMapped::kNo);
|
||||||
|
|
||||||
REPORTER_ASSERT(reporter, proxy->texPriv().isGLTextureRectangleOrExternal());
|
REPORTER_ASSERT(reporter, proxy->texPriv().isGLTextureRectangleOrExternal());
|
||||||
REPORTER_ASSERT(reporter,
|
REPORTER_ASSERT(reporter,
|
||||||
|
@ -273,7 +273,8 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages, int ma
|
|||||||
dummyDesc.fHeight = 18;
|
dummyDesc.fHeight = 18;
|
||||||
dummyDesc.fConfig = kRGBA_8888_GrPixelConfig;
|
dummyDesc.fConfig = kRGBA_8888_GrPixelConfig;
|
||||||
proxies[0] = proxyProvider->createProxy(dummyDesc, kBottomLeft_GrSurfaceOrigin,
|
proxies[0] = proxyProvider->createProxy(dummyDesc, kBottomLeft_GrSurfaceOrigin,
|
||||||
SkBackingFit::kExact, SkBudgeted::kNo);
|
GrMipMapped::kYes, SkBackingFit::kExact,
|
||||||
|
SkBudgeted::kNo, GrInternalSurfaceFlags::kNone);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
GrSurfaceDesc dummyDesc;
|
GrSurfaceDesc dummyDesc;
|
||||||
@ -282,7 +283,8 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages, int ma
|
|||||||
dummyDesc.fHeight = 22;
|
dummyDesc.fHeight = 22;
|
||||||
dummyDesc.fConfig = kAlpha_8_GrPixelConfig;
|
dummyDesc.fConfig = kAlpha_8_GrPixelConfig;
|
||||||
proxies[1] = proxyProvider->createProxy(dummyDesc, kTopLeft_GrSurfaceOrigin,
|
proxies[1] = proxyProvider->createProxy(dummyDesc, kTopLeft_GrSurfaceOrigin,
|
||||||
SkBackingFit::kExact, SkBudgeted::kNo);
|
GrMipMapped::kYes, SkBackingFit::kExact,
|
||||||
|
SkBudgeted::kNo, GrInternalSurfaceFlags::kNone);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!proxies[0] || !proxies[1]) {
|
if (!proxies[0] || !proxies[1]) {
|
||||||
|
@ -27,27 +27,31 @@ DEF_GPUTEST_FOR_NULLGL_CONTEXT(GrTextureMipMapInvalidationTest, reporter, ctxInf
|
|||||||
|
|
||||||
GrContext* context = ctxInfo.grContext();
|
GrContext* context = ctxInfo.grContext();
|
||||||
auto info = SkImageInfo::MakeN32Premul(256, 256);
|
auto info = SkImageInfo::MakeN32Premul(256, 256);
|
||||||
auto surf1 = SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, info);
|
for (auto allocateMips : {false, true}) {
|
||||||
auto surf2 = SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, info);
|
auto surf1 = SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, info, 0,
|
||||||
// Draw something just in case we ever had a solid color optimization
|
kBottomLeft_GrSurfaceOrigin, nullptr,
|
||||||
surf1->getCanvas()->drawCircle(128, 128, 50, SkPaint());
|
allocateMips);
|
||||||
surf1->getCanvas()->flush();
|
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
|
// No mipmaps initially
|
||||||
REPORTER_ASSERT(reporter, !isMipped(surf1.get()));
|
REPORTER_ASSERT(reporter, isMipped(surf1.get()) == allocateMips);
|
||||||
|
|
||||||
// Painting with downscale and medium filter quality should result in mipmap creation
|
// Painting with downscale and medium filter quality should result in mipmap creation
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
paint.setFilterQuality(kMedium_SkFilterQuality);
|
paint.setFilterQuality(kMedium_SkFilterQuality);
|
||||||
surf2->getCanvas()->scale(0.2f, 0.2f);
|
surf2->getCanvas()->scale(0.2f, 0.2f);
|
||||||
surf2->getCanvas()->drawImage(surf1->makeImageSnapshot(), 0, 0, &paint);
|
surf2->getCanvas()->drawImage(surf1->makeImageSnapshot(), 0, 0, &paint);
|
||||||
surf2->getCanvas()->flush();
|
surf2->getCanvas()->flush();
|
||||||
REPORTER_ASSERT(reporter, isMipped(surf1.get()));
|
REPORTER_ASSERT(reporter, isMipped(surf1.get()) == allocateMips);
|
||||||
REPORTER_ASSERT(reporter, !mipsAreDirty(surf1.get()));
|
REPORTER_ASSERT(reporter, !allocateMips || !mipsAreDirty(surf1.get()));
|
||||||
|
|
||||||
// Changing the contents of the surface should invalidate the mipmap, but not de-allocate
|
// Changing the contents of the surface should invalidate the mipmap, but not de-allocate
|
||||||
surf1->getCanvas()->drawCircle(128, 128, 100, SkPaint());
|
surf1->getCanvas()->drawCircle(128, 128, 100, SkPaint());
|
||||||
surf1->getCanvas()->flush();
|
surf1->getCanvas()->flush();
|
||||||
REPORTER_ASSERT(reporter, isMipped(surf1.get()));
|
REPORTER_ASSERT(reporter, isMipped(surf1.get()) == allocateMips);
|
||||||
REPORTER_ASSERT(reporter, mipsAreDirty(surf1.get()));
|
REPORTER_ASSERT(reporter, mipsAreDirty(surf1.get()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -443,10 +443,6 @@ DEF_GPUTEST(LazyProxyUninstantiateTest, reporter, /* options */) {
|
|||||||
|
|
||||||
REPORTER_ASSERT(reporter, lazyProxy.get());
|
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));
|
rtc->priv().testingOnly_addDrawOp(LazyUninstantiateTestOp::Make(ctx.get(), lazyProxy));
|
||||||
|
|
||||||
ctx->flush();
|
ctx->flush();
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "GrRenderTargetContext.h"
|
#include "GrRenderTargetContext.h"
|
||||||
#include "GrSurfacePriv.h"
|
#include "GrSurfacePriv.h"
|
||||||
#include "GrTest.h"
|
#include "GrTest.h"
|
||||||
|
#include "GrTexturePriv.h"
|
||||||
#include "GrTextureProxyPriv.h"
|
#include "GrTextureProxyPriv.h"
|
||||||
#include "gl/GLTestContext.h"
|
#include "gl/GLTestContext.h"
|
||||||
#include "gl/GrGLGpu.h"
|
#include "gl/GrGLGpu.h"
|
||||||
@ -136,8 +137,8 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(RectangleTexture, reporter, ctxInfo) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkASSERT(rectProxy->texPriv().doesNotSupportMipMaps());
|
SkASSERT(rectProxy->mipMapped() == GrMipMapped::kNo);
|
||||||
SkASSERT(rectProxy->priv().peekTexture()->surfacePriv().doesNotSupportMipMaps());
|
SkASSERT(rectProxy->priv().peekTexture()->texturePriv().mipMapped() == GrMipMapped::kNo);
|
||||||
|
|
||||||
SkASSERT(rectProxy->texPriv().isGLTextureRectangleOrExternal());
|
SkASSERT(rectProxy->texPriv().isGLTextureRectangleOrExternal());
|
||||||
SkASSERT(rectProxy->priv().peekTexture()->surfacePriv().isGLTextureRectangleOrExternal());
|
SkASSERT(rectProxy->priv().peekTexture()->surfacePriv().isGLTextureRectangleOrExternal());
|
||||||
|
Loading…
Reference in New Issue
Block a user