Require explicit GrWrapCacheable specification in more places.
Make all wrapped resources be kUnbudgetedUncacheable except those created by AHardwareBuffer image generators and as backings for promise images. Make all non-wrapped unbudgeted resources be kUnbudgetedUncacheable. Update unit tests to mostly use GrWrapCacheable::kNo except where they are testing the distinction. Update unit tests for new expectations. Bug: chromium:922851 Change-Id: I4d3bdaa161ffc76390f26334bcb7e2b47dd9319d Reviewed-on: https://skia-review.googlesource.com/c/185004 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
7150513754
commit
aa6ca0a8bf
@ -264,7 +264,7 @@ protected:
|
||||
// This must be called by every GrGpuObject that references any wrapped backend objects. It
|
||||
// should be called once the object is fully initialized (i.e. only from the constructors of the
|
||||
// final class).
|
||||
void registerWithCacheWrapped(GrWrapCacheable = GrWrapCacheable::kYes);
|
||||
void registerWithCacheWrapped(GrWrapCacheable);
|
||||
|
||||
GrGpuResource(GrGpu*);
|
||||
virtual ~GrGpuResource();
|
||||
@ -350,7 +350,7 @@ private:
|
||||
GrGpu* fGpu;
|
||||
mutable size_t fGpuMemorySize = kInvalidGpuMemorySize;
|
||||
|
||||
GrBudgetedType fBudgetedType = GrBudgetedType::kUnbudgetedCacheable;
|
||||
GrBudgetedType fBudgetedType = GrBudgetedType::kUnbudgetedUncacheable;
|
||||
bool fRefsWrappedObjects = false;
|
||||
const UniqueID fUniqueID;
|
||||
|
||||
|
@ -600,8 +600,11 @@ sk_sp<GrTextureProxy> GrAHardwareBufferImageGenerator::makeProxy(GrContext* cont
|
||||
SkASSERT(deleteImageProc && deleteImageCtx);
|
||||
|
||||
backendTex.fConfig = pixelConfig;
|
||||
// We make this texture cacheable to avoid recreating a GrTexture every time this
|
||||
// is invoked. We know the owning SkIamge will send an invalidation message when the
|
||||
// image is destroyed, so the texture will be removed at that time.
|
||||
sk_sp<GrTexture> tex = resourceProvider->wrapBackendTexture(
|
||||
backendTex, kBorrow_GrWrapOwnership, kRead_GrIOType);
|
||||
backendTex, kBorrow_GrWrapOwnership, GrWrapCacheable::kYes, kRead_GrIOType);
|
||||
if (!tex) {
|
||||
deleteImageProc(deleteImageCtx);
|
||||
return sk_sp<GrTexture>();
|
||||
|
@ -169,8 +169,8 @@ sk_sp<GrTextureProxy> GrBackendTextureImageGenerator::onGenerateTexture(
|
||||
// ever see the original texture, so this should be safe.
|
||||
// We make the texture uncacheable so that the release proc is called ASAP.
|
||||
tex = resourceProvider->wrapBackendTexture(
|
||||
backendTexture, kBorrow_GrWrapOwnership, kRead_GrIOType,
|
||||
GrWrapCacheable::kNo);
|
||||
backendTexture, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo,
|
||||
kRead_GrIOType);
|
||||
if (!tex) {
|
||||
return sk_sp<GrTexture>();
|
||||
}
|
||||
|
@ -947,7 +947,7 @@ sk_sp<GrTextureContext> GrContextPriv::makeBackendTextureContext(const GrBackend
|
||||
ASSERT_SINGLE_OWNER_PRIV
|
||||
|
||||
sk_sp<GrSurfaceProxy> proxy = this->proxyProvider()->wrapBackendTexture(
|
||||
tex, origin, kBorrow_GrWrapOwnership, kRW_GrIOType);
|
||||
tex, origin, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, kRW_GrIOType);
|
||||
if (!proxy) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -964,8 +964,8 @@ sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendTextureRenderTargetContex
|
||||
ASSERT_SINGLE_OWNER_PRIV
|
||||
SkASSERT(sampleCnt > 0);
|
||||
|
||||
sk_sp<GrTextureProxy> proxy(
|
||||
this->proxyProvider()->wrapRenderableBackendTexture(tex, origin, sampleCnt));
|
||||
sk_sp<GrTextureProxy> proxy(this->proxyProvider()->wrapRenderableBackendTexture(
|
||||
tex, origin, sampleCnt, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo));
|
||||
if (!proxy) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -164,7 +164,8 @@ sk_sp<GrTexture> GrGpu::wrapBackendTexture(const GrBackendTexture& backendTex,
|
||||
}
|
||||
|
||||
sk_sp<GrTexture> GrGpu::wrapRenderableBackendTexture(const GrBackendTexture& backendTex,
|
||||
int sampleCnt, GrWrapOwnership ownership) {
|
||||
int sampleCnt, GrWrapOwnership ownership,
|
||||
GrWrapCacheable cacheable) {
|
||||
this->handleDirtyContext();
|
||||
if (sampleCnt < 1) {
|
||||
return nullptr;
|
||||
@ -178,7 +179,8 @@ sk_sp<GrTexture> GrGpu::wrapRenderableBackendTexture(const GrBackendTexture& bac
|
||||
backendTex.height() > this->caps()->maxRenderTargetSize()) {
|
||||
return nullptr;
|
||||
}
|
||||
sk_sp<GrTexture> tex = this->onWrapRenderableBackendTexture(backendTex, sampleCnt, ownership);
|
||||
sk_sp<GrTexture> tex =
|
||||
this->onWrapRenderableBackendTexture(backendTex, sampleCnt, ownership, cacheable);
|
||||
SkASSERT(!tex || tex->asRenderTarget());
|
||||
return tex;
|
||||
}
|
||||
|
@ -110,8 +110,8 @@ public:
|
||||
/**
|
||||
* Implements GrResourceProvider::wrapRenderableBackendTexture
|
||||
*/
|
||||
sk_sp<GrTexture> wrapRenderableBackendTexture(const GrBackendTexture&,
|
||||
int sampleCnt, GrWrapOwnership);
|
||||
sk_sp<GrTexture> wrapRenderableBackendTexture(const GrBackendTexture&, int sampleCnt,
|
||||
GrWrapOwnership, GrWrapCacheable);
|
||||
|
||||
/**
|
||||
* Implements GrResourceProvider::wrapBackendRenderTarget
|
||||
@ -459,9 +459,8 @@ private:
|
||||
|
||||
virtual sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&, GrWrapOwnership,
|
||||
GrWrapCacheable, GrIOType) = 0;
|
||||
virtual sk_sp<GrTexture> onWrapRenderableBackendTexture(const GrBackendTexture&,
|
||||
int sampleCnt,
|
||||
GrWrapOwnership) = 0;
|
||||
virtual sk_sp<GrTexture> onWrapRenderableBackendTexture(const GrBackendTexture&, int sampleCnt,
|
||||
GrWrapOwnership, GrWrapCacheable) = 0;
|
||||
virtual sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&) = 0;
|
||||
virtual sk_sp<GrRenderTarget> onWrapBackendTextureAsRenderTarget(const GrBackendTexture&,
|
||||
int sampleCnt) = 0;
|
||||
|
@ -26,15 +26,15 @@ GrGpuResource::GrGpuResource(GrGpu* gpu) : fGpu(gpu), fUniqueID(CreateUniqueID()
|
||||
}
|
||||
|
||||
void GrGpuResource::registerWithCache(SkBudgeted budgeted) {
|
||||
SkASSERT(fBudgetedType == GrBudgetedType::kUnbudgetedCacheable);
|
||||
SkASSERT(fBudgetedType == GrBudgetedType::kUnbudgetedUncacheable);
|
||||
fBudgetedType = budgeted == SkBudgeted::kYes ? GrBudgetedType::kBudgeted
|
||||
: GrBudgetedType::kUnbudgetedCacheable;
|
||||
: GrBudgetedType::kUnbudgetedUncacheable;
|
||||
this->computeScratchKey(&fScratchKey);
|
||||
get_resource_cache(fGpu)->resourceAccess().insertResource(this);
|
||||
}
|
||||
|
||||
void GrGpuResource::registerWithCacheWrapped(GrWrapCacheable wrapType) {
|
||||
SkASSERT(fBudgetedType == GrBudgetedType::kUnbudgetedCacheable);
|
||||
SkASSERT(fBudgetedType == GrBudgetedType::kUnbudgetedUncacheable);
|
||||
// Resources referencing wrapped objects are never budgeted. They may be cached or uncached.
|
||||
fBudgetedType = wrapType == GrWrapCacheable::kNo ? GrBudgetedType::kUnbudgetedUncacheable
|
||||
: GrBudgetedType::kUnbudgetedCacheable;
|
||||
@ -188,9 +188,9 @@ void GrGpuResource::removeScratchKey() {
|
||||
void GrGpuResource::makeBudgeted() {
|
||||
// We should never make a wrapped resource budgeted.
|
||||
SkASSERT(!fRefsWrappedObjects);
|
||||
// Only wrapped resources can be in the kUnbudgetedUncacheable state.
|
||||
SkASSERT(fBudgetedType != GrBudgetedType::kUnbudgetedUncacheable);
|
||||
if (!this->wasDestroyed() && fBudgetedType == GrBudgetedType::kUnbudgetedCacheable) {
|
||||
// Only wrapped resources can be in the kUnbudgetedCacheable state.
|
||||
SkASSERT(fBudgetedType != GrBudgetedType::kUnbudgetedCacheable);
|
||||
if (!this->wasDestroyed() && fBudgetedType == GrBudgetedType::kUnbudgetedUncacheable) {
|
||||
// Currently resources referencing wrapped objects are not budgeted.
|
||||
fBudgetedType = GrBudgetedType::kBudgeted;
|
||||
get_resource_cache(fGpu)->resourceAccess().didChangeBudgetStatus(this);
|
||||
@ -200,7 +200,7 @@ void GrGpuResource::makeBudgeted() {
|
||||
void GrGpuResource::makeUnbudgeted() {
|
||||
if (!this->wasDestroyed() && fBudgetedType == GrBudgetedType::kBudgeted &&
|
||||
!fUniqueKey.isValid()) {
|
||||
fBudgetedType = GrBudgetedType::kUnbudgetedCacheable;
|
||||
fBudgetedType = GrBudgetedType::kUnbudgetedUncacheable;
|
||||
get_resource_cache(fGpu)->resourceAccess().didChangeBudgetStatus(this);
|
||||
}
|
||||
}
|
||||
|
@ -451,6 +451,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::createProxy(sk_sp<SkData> data, const GrS
|
||||
sk_sp<GrTextureProxy> GrProxyProvider::wrapBackendTexture(const GrBackendTexture& backendTex,
|
||||
GrSurfaceOrigin origin,
|
||||
GrWrapOwnership ownership,
|
||||
GrWrapCacheable cacheable,
|
||||
GrIOType ioType,
|
||||
ReleaseProc releaseProc,
|
||||
ReleaseContext releaseCtx) {
|
||||
@ -464,8 +465,8 @@ sk_sp<GrTextureProxy> GrProxyProvider::wrapBackendTexture(const GrBackendTexture
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<GrTexture> tex = fResourceProvider->wrapBackendTexture(backendTex, ownership, ioType,
|
||||
GrWrapCacheable::kYes);
|
||||
sk_sp<GrTexture> tex =
|
||||
fResourceProvider->wrapBackendTexture(backendTex, ownership, cacheable, ioType);
|
||||
if (!tex) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -486,7 +487,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::wrapBackendTexture(const GrBackendTexture
|
||||
|
||||
sk_sp<GrTextureProxy> GrProxyProvider::wrapRenderableBackendTexture(
|
||||
const GrBackendTexture& backendTex, GrSurfaceOrigin origin, int sampleCnt,
|
||||
GrWrapOwnership ownership) {
|
||||
GrWrapOwnership ownership, GrWrapCacheable cacheable) {
|
||||
if (this->isAbandoned()) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -501,8 +502,8 @@ sk_sp<GrTextureProxy> GrProxyProvider::wrapRenderableBackendTexture(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<GrTexture> tex =
|
||||
fResourceProvider->wrapRenderableBackendTexture(backendTex, sampleCnt, ownership);
|
||||
sk_sp<GrTexture> tex = fResourceProvider->wrapRenderableBackendTexture(backendTex, sampleCnt,
|
||||
ownership, cacheable);
|
||||
if (!tex) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -113,16 +113,15 @@ public:
|
||||
* kRead or kRW.
|
||||
*/
|
||||
sk_sp<GrTextureProxy> wrapBackendTexture(const GrBackendTexture&, GrSurfaceOrigin,
|
||||
GrWrapOwnership, GrIOType, ReleaseProc = nullptr,
|
||||
ReleaseContext = nullptr);
|
||||
GrWrapOwnership, GrWrapCacheable, GrIOType,
|
||||
ReleaseProc = nullptr, ReleaseContext = nullptr);
|
||||
|
||||
/*
|
||||
* Create a texture proxy that wraps a backend texture and is both texture-able and renderable
|
||||
*/
|
||||
sk_sp<GrTextureProxy> wrapRenderableBackendTexture(const GrBackendTexture&,
|
||||
GrSurfaceOrigin,
|
||||
int sampleCnt,
|
||||
GrWrapOwnership = kBorrow_GrWrapOwnership);
|
||||
sk_sp<GrTextureProxy> wrapRenderableBackendTexture(const GrBackendTexture&, GrSurfaceOrigin,
|
||||
int sampleCnt, GrWrapOwnership,
|
||||
GrWrapCacheable);
|
||||
|
||||
/*
|
||||
* Create a render target proxy that wraps a backend render target
|
||||
|
@ -235,8 +235,8 @@ sk_sp<GrTexture> GrResourceProvider::refScratchTexture(const GrSurfaceDesc& desc
|
||||
|
||||
sk_sp<GrTexture> GrResourceProvider::wrapBackendTexture(const GrBackendTexture& tex,
|
||||
GrWrapOwnership ownership,
|
||||
GrIOType ioType,
|
||||
GrWrapCacheable cacheable) {
|
||||
GrWrapCacheable cacheable,
|
||||
GrIOType ioType) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
if (this->isAbandoned()) {
|
||||
return nullptr;
|
||||
@ -246,12 +246,13 @@ sk_sp<GrTexture> GrResourceProvider::wrapBackendTexture(const GrBackendTexture&
|
||||
|
||||
sk_sp<GrTexture> GrResourceProvider::wrapRenderableBackendTexture(const GrBackendTexture& tex,
|
||||
int sampleCnt,
|
||||
GrWrapOwnership ownership) {
|
||||
GrWrapOwnership ownership,
|
||||
GrWrapCacheable cacheable) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
if (this->isAbandoned()) {
|
||||
return nullptr;
|
||||
}
|
||||
return fGpu->wrapRenderableBackendTexture(tex, sampleCnt, ownership);
|
||||
return fGpu->wrapRenderableBackendTexture(tex, sampleCnt, ownership, cacheable);
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTarget> GrResourceProvider::wrapBackendRenderTarget(
|
||||
|
@ -106,10 +106,8 @@ public:
|
||||
*
|
||||
* @return GrTexture object or NULL on failure.
|
||||
*/
|
||||
sk_sp<GrTexture> wrapBackendTexture(const GrBackendTexture& tex,
|
||||
GrWrapOwnership /* = kBorrow_GrWrapOwnership*/,
|
||||
GrIOType,
|
||||
GrWrapCacheable = GrWrapCacheable::kYes);
|
||||
sk_sp<GrTexture> wrapBackendTexture(const GrBackendTexture& tex, GrWrapOwnership,
|
||||
GrWrapCacheable, GrIOType);
|
||||
|
||||
/**
|
||||
* This makes the backend texture be renderable. If sampleCnt is > 1 and the underlying API
|
||||
@ -118,14 +116,15 @@ public:
|
||||
*/
|
||||
sk_sp<GrTexture> wrapRenderableBackendTexture(const GrBackendTexture& tex,
|
||||
int sampleCnt,
|
||||
GrWrapOwnership = kBorrow_GrWrapOwnership);
|
||||
GrWrapOwnership,
|
||||
GrWrapCacheable);
|
||||
|
||||
/**
|
||||
* Wraps an existing render target with a GrRenderTarget object. It is
|
||||
* similar to wrapBackendTexture but can be used to draw into surfaces
|
||||
* that are not also textures (e.g. FBO 0 in OpenGL, or an MSAA buffer that
|
||||
* the client will resolve to a texture). Currently wrapped render targets
|
||||
* always use the kBorrow_GrWrapOwnership semantics.
|
||||
* always use the kBorrow_GrWrapOwnership and GrWrapCacheable::kNo semantics.
|
||||
*
|
||||
* @return GrRenderTarget object or NULL on failure.
|
||||
*/
|
||||
|
@ -687,7 +687,8 @@ sk_sp<GrTexture> GrGLGpu::onWrapBackendTexture(const GrBackendTexture& backendTe
|
||||
|
||||
sk_sp<GrTexture> GrGLGpu::onWrapRenderableBackendTexture(const GrBackendTexture& backendTex,
|
||||
int sampleCnt,
|
||||
GrWrapOwnership ownership) {
|
||||
GrWrapOwnership ownership,
|
||||
GrWrapCacheable cacheable) {
|
||||
GrGLTexture::IDDesc idDesc;
|
||||
if (!check_backend_texture(backendTex, this->glCaps(), &idDesc)) {
|
||||
return nullptr;
|
||||
@ -725,8 +726,8 @@ sk_sp<GrTexture> GrGLGpu::onWrapRenderableBackendTexture(const GrBackendTexture&
|
||||
GrMipMapsStatus mipMapsStatus = backendTex.hasMipMaps() ? GrMipMapsStatus::kDirty
|
||||
: GrMipMapsStatus::kNotAllocated;
|
||||
|
||||
sk_sp<GrGLTextureRenderTarget> texRT(
|
||||
GrGLTextureRenderTarget::MakeWrapped(this, surfDesc, idDesc, rtIDDesc, mipMapsStatus));
|
||||
sk_sp<GrGLTextureRenderTarget> texRT(GrGLTextureRenderTarget::MakeWrapped(
|
||||
this, surfDesc, idDesc, rtIDDesc, cacheable, mipMapsStatus));
|
||||
texRT->baseLevelWasBoundToFBO();
|
||||
// We don't know what parameters are already set on wrapped textures.
|
||||
texRT->textureParamsModified();
|
||||
|
@ -191,9 +191,8 @@ private:
|
||||
|
||||
sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&, GrWrapOwnership, GrWrapCacheable,
|
||||
GrIOType) override;
|
||||
sk_sp<GrTexture> onWrapRenderableBackendTexture(const GrBackendTexture&,
|
||||
int sampleCnt,
|
||||
GrWrapOwnership) override;
|
||||
sk_sp<GrTexture> onWrapRenderableBackendTexture(const GrBackendTexture&, int sampleCnt,
|
||||
GrWrapOwnership, GrWrapCacheable) override;
|
||||
sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&) override;
|
||||
sk_sp<GrRenderTarget> onWrapBackendTextureAsRenderTarget(const GrBackendTexture&,
|
||||
int sampleCnt) override;
|
||||
|
@ -28,7 +28,7 @@ GrGLRenderTarget::GrGLRenderTarget(GrGLGpu* gpu,
|
||||
, INHERITED(gpu, desc, stencil) {
|
||||
this->setFlags(gpu->glCaps(), idDesc);
|
||||
this->init(desc, format, idDesc);
|
||||
this->registerWithCacheWrapped();
|
||||
this->registerWithCacheWrapped(GrWrapCacheable::kNo);
|
||||
}
|
||||
|
||||
GrGLRenderTarget::GrGLRenderTarget(GrGLGpu* gpu, const GrSurfaceDesc& desc, GrGLenum format,
|
||||
|
@ -11,7 +11,8 @@
|
||||
|
||||
GrGLSemaphore::GrGLSemaphore(GrGLGpu* gpu, bool isOwned)
|
||||
: INHERITED(gpu), fSync(0), fIsOwned(isOwned) {
|
||||
isOwned ? this->registerWithCache(SkBudgeted::kNo) : this->registerWithCacheWrapped();
|
||||
isOwned ? this->registerWithCache(SkBudgeted::kNo)
|
||||
: this->registerWithCacheWrapped(GrWrapCacheable::kNo);
|
||||
}
|
||||
|
||||
void GrGLSemaphore::onRelease() {
|
||||
|
@ -28,11 +28,12 @@ GrGLTextureRenderTarget::GrGLTextureRenderTarget(GrGLGpu* gpu,
|
||||
const GrSurfaceDesc& desc,
|
||||
const GrGLTexture::IDDesc& texIDDesc,
|
||||
const GrGLRenderTarget::IDDesc& rtIDDesc,
|
||||
GrWrapCacheable cacheable,
|
||||
GrMipMapsStatus mipMapsStatus)
|
||||
: GrSurface(gpu, desc)
|
||||
, GrGLTexture(gpu, desc, texIDDesc, mipMapsStatus)
|
||||
, GrGLRenderTarget(gpu, desc, texIDDesc.fInfo.fFormat, rtIDDesc) {
|
||||
this->registerWithCacheWrapped();
|
||||
this->registerWithCacheWrapped(cacheable);
|
||||
}
|
||||
|
||||
void GrGLTextureRenderTarget::dumpMemoryStatistics(
|
||||
@ -56,11 +57,11 @@ bool GrGLTextureRenderTarget::canAttemptStencilAttachment() const {
|
||||
}
|
||||
|
||||
sk_sp<GrGLTextureRenderTarget> GrGLTextureRenderTarget::MakeWrapped(
|
||||
GrGLGpu* gpu, const GrSurfaceDesc& desc, const GrGLTexture::IDDesc& texIDDesc,
|
||||
const GrGLRenderTarget::IDDesc& rtIDDesc, GrMipMapsStatus mipMapsStatus)
|
||||
{
|
||||
GrGLGpu* gpu, const GrSurfaceDesc& desc, const GrGLTexture::IDDesc& texIDDesc,
|
||||
const GrGLRenderTarget::IDDesc& rtIDDesc, GrWrapCacheable cacheable,
|
||||
GrMipMapsStatus mipMapsStatus) {
|
||||
return sk_sp<GrGLTextureRenderTarget>(
|
||||
new GrGLTextureRenderTarget(gpu, desc, texIDDesc, rtIDDesc, mipMapsStatus));
|
||||
new GrGLTextureRenderTarget(gpu, desc, texIDDesc, rtIDDesc, cacheable, mipMapsStatus));
|
||||
}
|
||||
|
||||
size_t GrGLTextureRenderTarget::onGpuMemorySize() const {
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
static sk_sp<GrGLTextureRenderTarget> MakeWrapped(GrGLGpu* gpu, const GrSurfaceDesc& desc,
|
||||
const GrGLTexture::IDDesc& texIDDesc,
|
||||
const GrGLRenderTarget::IDDesc& rtIDDesc,
|
||||
GrMipMapsStatus);
|
||||
GrWrapCacheable cacheble, GrMipMapsStatus);
|
||||
|
||||
GrBackendFormat backendFormat() const override {
|
||||
// It doesn't matter if we take the texture or render target path, so just pick texture.
|
||||
@ -62,6 +62,7 @@ private:
|
||||
const GrSurfaceDesc& desc,
|
||||
const GrGLTexture::IDDesc& texIDDesc,
|
||||
const GrGLRenderTarget::IDDesc& rtIDDesc,
|
||||
GrWrapCacheable,
|
||||
GrMipMapsStatus);
|
||||
|
||||
size_t onGpuMemorySize() const override;
|
||||
|
@ -125,7 +125,8 @@ sk_sp<GrTexture> GrMockGpu::onWrapBackendTexture(const GrBackendTexture& tex,
|
||||
|
||||
sk_sp<GrTexture> GrMockGpu::onWrapRenderableBackendTexture(const GrBackendTexture& tex,
|
||||
int sampleCnt,
|
||||
GrWrapOwnership ownership) {
|
||||
GrWrapOwnership ownership,
|
||||
GrWrapCacheable cacheable) {
|
||||
GrSurfaceDesc desc;
|
||||
desc.fFlags = kRenderTarget_GrSurfaceFlag;
|
||||
desc.fWidth = tex.width();
|
||||
@ -144,7 +145,7 @@ sk_sp<GrTexture> GrMockGpu::onWrapRenderableBackendTexture(const GrBackendTextur
|
||||
rtInfo.fID = NextInternalRenderTargetID();
|
||||
|
||||
return sk_sp<GrTexture>(
|
||||
new GrMockTextureRenderTarget(this, desc, mipMapsStatus, texInfo, rtInfo));
|
||||
new GrMockTextureRenderTarget(this, desc, mipMapsStatus, texInfo, rtInfo, cacheable));
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTarget> GrMockGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& rt) {
|
||||
|
@ -64,7 +64,8 @@ private:
|
||||
|
||||
sk_sp<GrTexture> onWrapRenderableBackendTexture(const GrBackendTexture&,
|
||||
int sampleCnt,
|
||||
GrWrapOwnership) override;
|
||||
GrWrapOwnership,
|
||||
GrWrapCacheable) override;
|
||||
|
||||
sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&) override;
|
||||
|
||||
|
@ -112,7 +112,7 @@ public:
|
||||
GrMockRenderTarget(GrMockGpu* gpu, Wrapped, const GrSurfaceDesc& desc,
|
||||
const GrMockRenderTargetInfo& info)
|
||||
: GrSurface(gpu, desc), INHERITED(gpu, desc), fInfo(info) {
|
||||
this->registerWithCacheWrapped();
|
||||
this->registerWithCacheWrapped(GrWrapCacheable::kNo);
|
||||
}
|
||||
|
||||
ResolveType getResolveType() const override { return kCanResolve_ResolveType; }
|
||||
@ -168,11 +168,11 @@ public:
|
||||
// Renderable wrapped backend texture.
|
||||
GrMockTextureRenderTarget(GrMockGpu* gpu, const GrSurfaceDesc& desc,
|
||||
GrMipMapsStatus mipMapsStatus, const GrMockTextureInfo& texInfo,
|
||||
const GrMockRenderTargetInfo& rtInfo)
|
||||
const GrMockRenderTargetInfo& rtInfo, GrWrapCacheable cacheble)
|
||||
: GrSurface(gpu, desc)
|
||||
, GrMockTexture(gpu, desc, mipMapsStatus, texInfo)
|
||||
, GrMockRenderTarget(gpu, desc, rtInfo) {
|
||||
this->registerWithCacheWrapped();
|
||||
this->registerWithCacheWrapped(cacheble);
|
||||
}
|
||||
|
||||
GrTexture* asTexture() override { return this; }
|
||||
|
@ -135,9 +135,8 @@ private:
|
||||
sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&, GrWrapOwnership, GrWrapCacheable,
|
||||
GrIOType) override;
|
||||
|
||||
sk_sp<GrTexture> onWrapRenderableBackendTexture(const GrBackendTexture&,
|
||||
int sampleCnt,
|
||||
GrWrapOwnership) override;
|
||||
sk_sp<GrTexture> onWrapRenderableBackendTexture(const GrBackendTexture&, int sampleCnt,
|
||||
GrWrapOwnership, GrWrapCacheable) override;
|
||||
|
||||
sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&) override;
|
||||
|
||||
|
@ -357,7 +357,8 @@ sk_sp<GrTexture> GrMtlGpu::onWrapBackendTexture(const GrBackendTexture& backendT
|
||||
|
||||
sk_sp<GrTexture> GrMtlGpu::onWrapRenderableBackendTexture(const GrBackendTexture& backendTex,
|
||||
int sampleCnt,
|
||||
GrWrapOwnership ownership) {
|
||||
GrWrapOwnership ownership,
|
||||
GrWrapCacheable cacheable) {
|
||||
id<MTLTexture> mtlTexture = get_texture_from_backend(backendTex, ownership);
|
||||
if (!mtlTexture) {
|
||||
return nullptr;
|
||||
@ -370,7 +371,8 @@ sk_sp<GrTexture> GrMtlGpu::onWrapRenderableBackendTexture(const GrBackendTexture
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return GrMtlTextureRenderTarget::MakeWrappedTextureRenderTarget(this, surfDesc, mtlTexture);
|
||||
return GrMtlTextureRenderTarget::MakeWrappedTextureRenderTarget(this, surfDesc, mtlTexture,
|
||||
cacheable);
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTarget> GrMtlGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& backendRT) {
|
||||
|
@ -46,11 +46,6 @@ public:
|
||||
GrBackendFormat backendFormat() const override;
|
||||
|
||||
protected:
|
||||
GrMtlRenderTarget(GrMtlGpu* gpu,
|
||||
const GrSurfaceDesc& desc,
|
||||
id<MTLTexture> renderTexture,
|
||||
id<MTLTexture> resolveTexture);
|
||||
|
||||
GrMtlRenderTarget(GrMtlGpu* gpu,
|
||||
const GrSurfaceDesc& desc,
|
||||
id<MTLTexture> renderTexture);
|
||||
@ -77,22 +72,12 @@ protected:
|
||||
id<MTLTexture> fResolveTexture;
|
||||
|
||||
private:
|
||||
// Extra param to disambiguate from constructor used by subclasses.
|
||||
enum Wrapped { kWrapped };
|
||||
GrMtlRenderTarget(GrMtlGpu* gpu,
|
||||
SkBudgeted,
|
||||
const GrSurfaceDesc& desc,
|
||||
id<MTLTexture> renderTexture,
|
||||
id<MTLTexture> resolveTexture);
|
||||
|
||||
GrMtlRenderTarget(GrMtlGpu* gpu,
|
||||
SkBudgeted,
|
||||
const GrSurfaceDesc& desc,
|
||||
id<MTLTexture> renderTexture);
|
||||
|
||||
static sk_sp<GrMtlRenderTarget> Make(GrMtlGpu*,
|
||||
SkBudgeted,
|
||||
const GrSurfaceDesc&,
|
||||
id<MTLTexture> renderTexture,
|
||||
bool isWrapped);
|
||||
Wrapped);
|
||||
|
||||
bool completeStencilAttachment() override;
|
||||
};
|
||||
|
@ -10,18 +10,20 @@
|
||||
#include "GrMtlGpu.h"
|
||||
#include "GrMtlUtil.h"
|
||||
|
||||
// Called for wrapped non-texture render targets.
|
||||
GrMtlRenderTarget::GrMtlRenderTarget(GrMtlGpu* gpu,
|
||||
SkBudgeted budgeted,
|
||||
const GrSurfaceDesc& desc,
|
||||
id<MTLTexture> renderTexture)
|
||||
id<MTLTexture> renderTexture,
|
||||
Wrapped)
|
||||
: GrSurface(gpu, desc)
|
||||
, GrRenderTarget(gpu, desc)
|
||||
, fRenderTexture(renderTexture)
|
||||
, fResolveTexture(nil) {
|
||||
SkASSERT(1 == desc.fSampleCnt);
|
||||
this->registerWithCache(budgeted);
|
||||
this->registerWithCacheWrapped(GrWrapCacheable::kNo);
|
||||
}
|
||||
|
||||
// Called by subclass constructors.
|
||||
GrMtlRenderTarget::GrMtlRenderTarget(GrMtlGpu* gpu,
|
||||
const GrSurfaceDesc& desc,
|
||||
id<MTLTexture> renderTexture)
|
||||
@ -38,8 +40,7 @@ GrMtlRenderTarget::MakeWrappedRenderTarget(GrMtlGpu* gpu, const GrSurfaceDesc& d
|
||||
SkASSERT(nil != renderTexture);
|
||||
SkASSERT(1 == renderTexture.mipmapLevelCount);
|
||||
SkASSERT(MTLTextureUsageRenderTarget & renderTexture.usage);
|
||||
return sk_sp<GrMtlRenderTarget>(new GrMtlRenderTarget(gpu, SkBudgeted::kNo,
|
||||
desc, renderTexture));
|
||||
return sk_sp<GrMtlRenderTarget>(new GrMtlRenderTarget(gpu, desc, renderTexture, kWrapped));
|
||||
}
|
||||
|
||||
GrMtlRenderTarget::~GrMtlRenderTarget() {
|
||||
@ -47,7 +48,6 @@ GrMtlRenderTarget::~GrMtlRenderTarget() {
|
||||
SkASSERT(nil == fResolveTexture);
|
||||
}
|
||||
|
||||
|
||||
GrBackendRenderTarget GrMtlRenderTarget::getBackendRenderTarget() const {
|
||||
GrMtlTextureInfo info;
|
||||
info.fTexture = GrGetPtrFromId(fRenderTexture);
|
||||
|
@ -21,7 +21,8 @@ public:
|
||||
|
||||
static sk_sp<GrMtlTextureRenderTarget> MakeWrappedTextureRenderTarget(GrMtlGpu*,
|
||||
const GrSurfaceDesc&,
|
||||
id<MTLTexture>);
|
||||
id<MTLTexture>,
|
||||
GrWrapCacheable);
|
||||
GrBackendFormat backendFormat() const override {
|
||||
return GrMtlTexture::backendFormat();
|
||||
}
|
||||
@ -60,14 +61,8 @@ private:
|
||||
GrMtlTextureRenderTarget(GrMtlGpu* gpu,
|
||||
const GrSurfaceDesc& desc,
|
||||
id<MTLTexture> renderTexture,
|
||||
GrMipMapsStatus);
|
||||
|
||||
static sk_sp<GrMtlTextureRenderTarget> Make(GrMtlGpu*,
|
||||
const GrSurfaceDesc&,
|
||||
id<MTLTexture> resolveTexture,
|
||||
GrMipMapsStatus,
|
||||
SkBudgeted budgeted,
|
||||
bool isWrapped);
|
||||
GrMipMapsStatus,
|
||||
GrWrapCacheable cacheable);
|
||||
|
||||
size_t onGpuMemorySize() const override {
|
||||
// TODO: When used as render targets certain formats may actually have a larger size than
|
||||
|
@ -23,58 +23,43 @@ GrMtlTextureRenderTarget::GrMtlTextureRenderTarget(GrMtlGpu* gpu,
|
||||
GrMtlTextureRenderTarget::GrMtlTextureRenderTarget(GrMtlGpu* gpu,
|
||||
const GrSurfaceDesc& desc,
|
||||
id<MTLTexture> renderTexture,
|
||||
GrMipMapsStatus mipMapsStatus)
|
||||
GrMipMapsStatus mipMapsStatus,
|
||||
GrWrapCacheable cacheable)
|
||||
: GrSurface(gpu, desc)
|
||||
, GrMtlTexture(gpu, desc, renderTexture, mipMapsStatus)
|
||||
, GrMtlRenderTarget(gpu, desc, renderTexture) {
|
||||
this->registerWithCacheWrapped();
|
||||
this->registerWithCacheWrapped(cacheable);
|
||||
}
|
||||
|
||||
sk_sp<GrMtlTextureRenderTarget>
|
||||
GrMtlTextureRenderTarget::Make(GrMtlGpu* gpu,
|
||||
const GrSurfaceDesc& desc,
|
||||
id<MTLTexture> renderTexture,
|
||||
GrMipMapsStatus mipMapsStatus,
|
||||
SkBudgeted budgeted,
|
||||
bool isWrapped) {
|
||||
SkASSERT(nil != renderTexture);
|
||||
if (desc.fSampleCnt > 1) {
|
||||
return nullptr;
|
||||
}
|
||||
SkASSERT((MTLTextureUsageShaderRead | MTLTextureUsageRenderTarget) & renderTexture.usage);
|
||||
if (!isWrapped) {
|
||||
return sk_sp<GrMtlTextureRenderTarget>(new GrMtlTextureRenderTarget(gpu,
|
||||
budgeted,
|
||||
desc,
|
||||
renderTexture,
|
||||
mipMapsStatus));
|
||||
} else {
|
||||
return sk_sp<GrMtlTextureRenderTarget>(new GrMtlTextureRenderTarget(gpu,
|
||||
desc,
|
||||
renderTexture,
|
||||
mipMapsStatus));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sk_sp<GrMtlTextureRenderTarget>
|
||||
GrMtlTextureRenderTarget::CreateNewTextureRenderTarget(GrMtlGpu* gpu,
|
||||
SkBudgeted budgeted,
|
||||
const GrSurfaceDesc& desc,
|
||||
MTLTextureDescriptor* texDesc,
|
||||
GrMipMapsStatus mipMapsStatus) {
|
||||
id<MTLTexture> texture = [gpu->device() newTextureWithDescriptor:texDesc];
|
||||
return Make(gpu, desc, texture, mipMapsStatus, budgeted, false);
|
||||
id<MTLTexture> renderTexture = [gpu->device() newTextureWithDescriptor:texDesc];
|
||||
SkASSERT(nil != renderTexture);
|
||||
if (desc.fSampleCnt > 1) {
|
||||
return nullptr;
|
||||
}
|
||||
SkASSERT((MTLTextureUsageShaderRead | MTLTextureUsageRenderTarget) & renderTexture.usage);
|
||||
return sk_sp<GrMtlTextureRenderTarget>(
|
||||
new GrMtlTextureRenderTarget(gpu, budgeted, desc, renderTexture, mipMapsStatus));
|
||||
}
|
||||
|
||||
sk_sp<GrMtlTextureRenderTarget>
|
||||
GrMtlTextureRenderTarget::MakeWrappedTextureRenderTarget(GrMtlGpu* gpu,
|
||||
const GrSurfaceDesc& desc,
|
||||
id<MTLTexture> texture) {
|
||||
|
||||
SkASSERT(nil != texture);
|
||||
GrMipMapsStatus mipMapsStatus = texture.mipmapLevelCount > 1 ? GrMipMapsStatus::kDirty
|
||||
: GrMipMapsStatus::kNotAllocated;
|
||||
return Make(gpu, desc, texture, mipMapsStatus, SkBudgeted::kNo, true);
|
||||
sk_sp<GrMtlTextureRenderTarget> GrMtlTextureRenderTarget::MakeWrappedTextureRenderTarget(
|
||||
GrMtlGpu* gpu,
|
||||
const GrSurfaceDesc& desc,
|
||||
id<MTLTexture> renderTexture,
|
||||
GrWrapCacheable cacheable) {
|
||||
SkASSERT(nil != renderTexture);
|
||||
GrMipMapsStatus mipMapsStatus = renderTexture.mipmapLevelCount > 1
|
||||
? GrMipMapsStatus::kDirty
|
||||
: GrMipMapsStatus::kNotAllocated;
|
||||
if (desc.fSampleCnt > 1) {
|
||||
return nullptr;
|
||||
}
|
||||
SkASSERT((MTLTextureUsageShaderRead | MTLTextureUsageRenderTarget) & renderTexture.usage);
|
||||
return sk_sp<GrMtlTextureRenderTarget>(
|
||||
new GrMtlTextureRenderTarget(gpu, desc, renderTexture, mipMapsStatus, cacheable));
|
||||
}
|
||||
|
||||
|
@ -1048,7 +1048,8 @@ sk_sp<GrTexture> GrVkGpu::onWrapBackendTexture(const GrBackendTexture& backendTe
|
||||
|
||||
sk_sp<GrTexture> GrVkGpu::onWrapRenderableBackendTexture(const GrBackendTexture& backendTex,
|
||||
int sampleCnt,
|
||||
GrWrapOwnership ownership) {
|
||||
GrWrapOwnership ownership,
|
||||
GrWrapCacheable cacheable) {
|
||||
GrVkImageInfo imageInfo;
|
||||
if (!backendTex.getVkImageInfo(&imageInfo)) {
|
||||
return nullptr;
|
||||
@ -1068,8 +1069,8 @@ sk_sp<GrTexture> GrVkGpu::onWrapRenderableBackendTexture(const GrBackendTexture&
|
||||
sk_sp<GrVkImageLayout> layout = backendTex.getGrVkImageLayout();
|
||||
SkASSERT(layout);
|
||||
|
||||
return GrVkTextureRenderTarget::MakeWrappedTextureRenderTarget(this, surfDesc, ownership,
|
||||
imageInfo, std::move(layout));
|
||||
return GrVkTextureRenderTarget::MakeWrappedTextureRenderTarget(
|
||||
this, surfDesc, ownership, cacheable, imageInfo, std::move(layout));
|
||||
}
|
||||
|
||||
sk_sp<GrRenderTarget> GrVkGpu::onWrapBackendRenderTarget(const GrBackendRenderTarget& backendRT){
|
||||
|
@ -188,7 +188,8 @@ private:
|
||||
GrIOType) override;
|
||||
sk_sp<GrTexture> onWrapRenderableBackendTexture(const GrBackendTexture&,
|
||||
int sampleCnt,
|
||||
GrWrapOwnership) override;
|
||||
GrWrapOwnership,
|
||||
GrWrapCacheable) override;
|
||||
sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&) override;
|
||||
|
||||
sk_sp<GrRenderTarget> onWrapBackendTextureAsRenderTarget(const GrBackendTexture&,
|
||||
|
@ -42,7 +42,7 @@ GrVkRenderTarget::GrVkRenderTarget(GrVkGpu* gpu,
|
||||
, fCachedSimpleRenderPass(nullptr) {
|
||||
SkASSERT(desc.fSampleCnt > 1);
|
||||
this->createFramebuffer(gpu);
|
||||
this->registerWithCacheWrapped();
|
||||
this->registerWithCacheWrapped(GrWrapCacheable::kNo);
|
||||
}
|
||||
|
||||
// We're virtually derived from GrSurface (via GrRenderTarget) so its
|
||||
@ -87,7 +87,7 @@ GrVkRenderTarget::GrVkRenderTarget(GrVkGpu* gpu,
|
||||
, fCachedSimpleRenderPass(nullptr) {
|
||||
SkASSERT(1 == desc.fSampleCnt);
|
||||
this->createFramebuffer(gpu);
|
||||
this->registerWithCacheWrapped();
|
||||
this->registerWithCacheWrapped(GrWrapCacheable::kNo);
|
||||
}
|
||||
|
||||
// We're virtually derived from GrSurface (via GrRenderTarget) so its
|
||||
@ -125,7 +125,7 @@ GrVkRenderTarget::GrVkRenderTarget(GrVkGpu* gpu,
|
||||
, fFramebuffer(nullptr)
|
||||
, fCachedSimpleRenderPass(renderPass)
|
||||
, fSecondaryCommandBuffer(secondaryCommandBuffer) {
|
||||
this->registerWithCacheWrapped();
|
||||
this->registerWithCacheWrapped(GrWrapCacheable::kNo);
|
||||
}
|
||||
|
||||
sk_sp<GrVkRenderTarget> GrVkRenderTarget::MakeWrappedRenderTarget(
|
||||
|
@ -46,7 +46,8 @@ GrVkSemaphore::GrVkSemaphore(GrVkGpu* gpu, VkSemaphore semaphore, bool prohibitS
|
||||
bool prohibitWait, bool isOwned)
|
||||
: INHERITED(gpu) {
|
||||
fResource = new Resource(semaphore, prohibitSignal, prohibitWait, isOwned);
|
||||
isOwned ? this->registerWithCache(SkBudgeted::kNo) : this->registerWithCacheWrapped();
|
||||
isOwned ? this->registerWithCache(SkBudgeted::kNo)
|
||||
: this->registerWithCacheWrapped(GrWrapCacheable::kNo);
|
||||
}
|
||||
|
||||
void GrVkSemaphore::onRelease() {
|
||||
|
@ -28,11 +28,11 @@ GrVkTextureRenderTarget::GrVkTextureRenderTarget(GrVkGpu* gpu,
|
||||
sk_sp<GrVkImageLayout> msaaLayout,
|
||||
const GrVkImageView* colorAttachmentView,
|
||||
const GrVkImageView* resolveAttachmentView,
|
||||
GrMipMapsStatus mipMapsStatus,
|
||||
GrBackendObjectOwnership ownership)
|
||||
GrMipMapsStatus mipMapsStatus)
|
||||
: GrSurface(gpu, desc)
|
||||
, GrVkImage(info, layout, ownership)
|
||||
, GrVkTexture(gpu, desc, info, layout, texView, mipMapsStatus, ownership)
|
||||
, GrVkImage(info, layout, GrBackendObjectOwnership::kOwned)
|
||||
, GrVkTexture(gpu, desc, info, layout, texView, mipMapsStatus,
|
||||
GrBackendObjectOwnership::kOwned)
|
||||
, GrVkRenderTarget(gpu, desc, info, layout, msaaInfo, std::move(msaaLayout),
|
||||
colorAttachmentView, resolveAttachmentView,
|
||||
GrBackendObjectOwnership::kOwned) {
|
||||
@ -46,11 +46,11 @@ GrVkTextureRenderTarget::GrVkTextureRenderTarget(GrVkGpu* gpu,
|
||||
sk_sp<GrVkImageLayout> layout,
|
||||
const GrVkImageView* texView,
|
||||
const GrVkImageView* colorAttachmentView,
|
||||
GrMipMapsStatus mipMapsStatus,
|
||||
GrBackendObjectOwnership ownership)
|
||||
GrMipMapsStatus mipMapsStatus)
|
||||
: GrSurface(gpu, desc)
|
||||
, GrVkImage(info, layout, ownership)
|
||||
, GrVkTexture(gpu, desc, info, layout, texView, mipMapsStatus, ownership)
|
||||
, GrVkImage(info, layout, GrBackendObjectOwnership::kOwned)
|
||||
, GrVkTexture(gpu, desc, info, layout, texView, mipMapsStatus,
|
||||
GrBackendObjectOwnership::kOwned)
|
||||
, GrVkRenderTarget(gpu, desc, info, layout, colorAttachmentView,
|
||||
GrBackendObjectOwnership::kOwned) {
|
||||
this->registerWithCache(budgeted);
|
||||
@ -66,13 +66,14 @@ GrVkTextureRenderTarget::GrVkTextureRenderTarget(GrVkGpu* gpu,
|
||||
const GrVkImageView* colorAttachmentView,
|
||||
const GrVkImageView* resolveAttachmentView,
|
||||
GrMipMapsStatus mipMapsStatus,
|
||||
GrBackendObjectOwnership ownership)
|
||||
GrBackendObjectOwnership ownership,
|
||||
GrWrapCacheable cacheable)
|
||||
: GrSurface(gpu, desc)
|
||||
, GrVkImage(info, layout, ownership)
|
||||
, GrVkTexture(gpu, desc, info, layout, texView, mipMapsStatus, ownership)
|
||||
, GrVkRenderTarget(gpu, desc, info, layout, msaaInfo, std::move(msaaLayout),
|
||||
colorAttachmentView, resolveAttachmentView, ownership) {
|
||||
this->registerWithCacheWrapped();
|
||||
this->registerWithCacheWrapped(cacheable);
|
||||
}
|
||||
|
||||
GrVkTextureRenderTarget::GrVkTextureRenderTarget(GrVkGpu* gpu,
|
||||
@ -82,29 +83,33 @@ GrVkTextureRenderTarget::GrVkTextureRenderTarget(GrVkGpu* gpu,
|
||||
const GrVkImageView* texView,
|
||||
const GrVkImageView* colorAttachmentView,
|
||||
GrMipMapsStatus mipMapsStatus,
|
||||
GrBackendObjectOwnership ownership)
|
||||
GrBackendObjectOwnership ownership,
|
||||
GrWrapCacheable cacheable)
|
||||
: GrSurface(gpu, desc)
|
||||
, GrVkImage(info, layout, ownership)
|
||||
, GrVkTexture(gpu, desc, info, layout, texView, mipMapsStatus, ownership)
|
||||
, GrVkRenderTarget(gpu, desc, info, layout, colorAttachmentView, ownership) {
|
||||
this->registerWithCacheWrapped();
|
||||
this->registerWithCacheWrapped(cacheable);
|
||||
}
|
||||
|
||||
sk_sp<GrVkTextureRenderTarget> GrVkTextureRenderTarget::Make(GrVkGpu* gpu,
|
||||
const GrSurfaceDesc& desc,
|
||||
const GrVkImageInfo& info,
|
||||
sk_sp<GrVkImageLayout> layout,
|
||||
GrMipMapsStatus mipMapsStatus,
|
||||
SkBudgeted budgeted,
|
||||
GrBackendObjectOwnership ownership,
|
||||
bool isWrapped) {
|
||||
namespace {
|
||||
struct Views {
|
||||
const GrVkImageView* imageView = nullptr;
|
||||
const GrVkImageView* colorAttachmentView = nullptr;
|
||||
const GrVkImageView* resolveAttachmentView = nullptr;
|
||||
GrVkImageInfo msInfo;
|
||||
sk_sp<GrVkImageLayout> msLayout;
|
||||
};
|
||||
} // anonymous namespace
|
||||
|
||||
static Views create_views(GrVkGpu* gpu, const GrSurfaceDesc& desc, const GrVkImageInfo& info) {
|
||||
VkImage image = info.fImage;
|
||||
// Create the texture ImageView
|
||||
const GrVkImageView* imageView = GrVkImageView::Create(
|
||||
gpu, image, info.fFormat, GrVkImageView::kColor_Type, info.fLevelCount,
|
||||
info.fYcbcrConversionInfo);
|
||||
if (!imageView) {
|
||||
return nullptr;
|
||||
Views views;
|
||||
views.imageView = GrVkImageView::Create(gpu, image, info.fFormat, GrVkImageView::kColor_Type,
|
||||
info.fLevelCount, info.fYcbcrConversionInfo);
|
||||
if (!views.imageView) {
|
||||
return {};
|
||||
}
|
||||
|
||||
VkFormat pixelFormat;
|
||||
@ -113,9 +118,6 @@ sk_sp<GrVkTextureRenderTarget> GrVkTextureRenderTarget::Make(GrVkGpu* gpu,
|
||||
VkImage colorImage;
|
||||
|
||||
// create msaa surface if necessary
|
||||
GrVkImageInfo msInfo;
|
||||
sk_sp<GrVkImageLayout> msLayout;
|
||||
const GrVkImageView* resolveAttachmentView = nullptr;
|
||||
if (desc.fSampleCnt > 1) {
|
||||
GrVkImage::ImageDesc msImageDesc;
|
||||
msImageDesc.fImageType = VK_IMAGE_TYPE_2D;
|
||||
@ -130,74 +132,40 @@ sk_sp<GrVkTextureRenderTarget> GrVkTextureRenderTarget::Make(GrVkGpu* gpu,
|
||||
VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
|
||||
msImageDesc.fMemProps = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
|
||||
|
||||
if (!GrVkImage::InitImageInfo(gpu, msImageDesc, &msInfo)) {
|
||||
imageView->unref(gpu);
|
||||
return nullptr;
|
||||
if (!GrVkImage::InitImageInfo(gpu, msImageDesc, &views.msInfo)) {
|
||||
views.imageView->unref(gpu);
|
||||
return {};
|
||||
}
|
||||
|
||||
// Set color attachment image
|
||||
colorImage = msInfo.fImage;
|
||||
colorImage = views.msInfo.fImage;
|
||||
|
||||
// Create resolve attachment view.
|
||||
resolveAttachmentView = GrVkImageView::Create(gpu, image, pixelFormat,
|
||||
GrVkImageView::kColor_Type,
|
||||
info.fLevelCount, GrVkYcbcrConversionInfo());
|
||||
if (!resolveAttachmentView) {
|
||||
GrVkImage::DestroyImageInfo(gpu, &msInfo);
|
||||
imageView->unref(gpu);
|
||||
return nullptr;
|
||||
views.resolveAttachmentView =
|
||||
GrVkImageView::Create(gpu, image, pixelFormat, GrVkImageView::kColor_Type,
|
||||
info.fLevelCount, GrVkYcbcrConversionInfo());
|
||||
if (!views.resolveAttachmentView) {
|
||||
GrVkImage::DestroyImageInfo(gpu, &views.msInfo);
|
||||
views.imageView->unref(gpu);
|
||||
return {};
|
||||
}
|
||||
msLayout.reset(new GrVkImageLayout(msInfo.fImageLayout));
|
||||
views.msLayout.reset(new GrVkImageLayout(views.msInfo.fImageLayout));
|
||||
} else {
|
||||
// Set color attachment image
|
||||
colorImage = info.fImage;
|
||||
}
|
||||
|
||||
const GrVkImageView* colorAttachmentView = GrVkImageView::Create(gpu, colorImage, pixelFormat,
|
||||
GrVkImageView::kColor_Type, 1,
|
||||
GrVkYcbcrConversionInfo());
|
||||
if (!colorAttachmentView) {
|
||||
views.colorAttachmentView = GrVkImageView::Create(
|
||||
gpu, colorImage, pixelFormat, GrVkImageView::kColor_Type, 1, GrVkYcbcrConversionInfo());
|
||||
if (!views.colorAttachmentView) {
|
||||
if (desc.fSampleCnt > 1) {
|
||||
resolveAttachmentView->unref(gpu);
|
||||
GrVkImage::DestroyImageInfo(gpu, &msInfo);
|
||||
views.resolveAttachmentView->unref(gpu);
|
||||
GrVkImage::DestroyImageInfo(gpu, &views.msInfo);
|
||||
}
|
||||
imageView->unref(gpu);
|
||||
return nullptr;
|
||||
views.imageView->unref(gpu);
|
||||
return {};
|
||||
}
|
||||
|
||||
sk_sp<GrVkTextureRenderTarget> texRT;
|
||||
if (desc.fSampleCnt > 1) {
|
||||
if (!isWrapped) {
|
||||
texRT = sk_sp<GrVkTextureRenderTarget>(new GrVkTextureRenderTarget(
|
||||
gpu, budgeted, desc,
|
||||
info, std::move(layout), imageView, msInfo,
|
||||
std::move(msLayout), colorAttachmentView,
|
||||
resolveAttachmentView, mipMapsStatus,
|
||||
ownership));
|
||||
} else {
|
||||
texRT = sk_sp<GrVkTextureRenderTarget>(new GrVkTextureRenderTarget(
|
||||
gpu, desc,
|
||||
info, std::move(layout), imageView, msInfo,
|
||||
std::move(msLayout), colorAttachmentView,
|
||||
resolveAttachmentView, mipMapsStatus,
|
||||
ownership));
|
||||
}
|
||||
} else {
|
||||
if (!isWrapped) {
|
||||
texRT = sk_sp<GrVkTextureRenderTarget>(new GrVkTextureRenderTarget(
|
||||
gpu, budgeted, desc,
|
||||
info, std::move(layout), imageView,
|
||||
colorAttachmentView, mipMapsStatus,
|
||||
ownership));
|
||||
} else {
|
||||
texRT = sk_sp<GrVkTextureRenderTarget>(new GrVkTextureRenderTarget(
|
||||
gpu, desc,
|
||||
info, std::move(layout), imageView,
|
||||
colorAttachmentView, mipMapsStatus,
|
||||
ownership));
|
||||
}
|
||||
}
|
||||
return texRT;
|
||||
return views;
|
||||
}
|
||||
|
||||
sk_sp<GrVkTextureRenderTarget>
|
||||
@ -215,21 +183,30 @@ GrVkTextureRenderTarget::MakeNewTextureRenderTarget(GrVkGpu* gpu,
|
||||
}
|
||||
sk_sp<GrVkImageLayout> layout(new GrVkImageLayout(info.fImageLayout));
|
||||
|
||||
sk_sp<GrVkTextureRenderTarget> trt = Make(gpu, desc, info, std::move(layout), mipMapsStatus,
|
||||
budgeted, GrBackendObjectOwnership::kOwned, false);
|
||||
if (!trt) {
|
||||
Views views = create_views(gpu, desc, info);
|
||||
if (!views.colorAttachmentView) {
|
||||
GrVkImage::DestroyImageInfo(gpu, &info);
|
||||
return nullptr;
|
||||
}
|
||||
if (desc.fSampleCnt > 1) {
|
||||
return sk_sp<GrVkTextureRenderTarget>(new GrVkTextureRenderTarget(
|
||||
gpu, budgeted, desc, info, std::move(layout), views.imageView, views.msInfo,
|
||||
std::move(views.msLayout), views.colorAttachmentView, views.resolveAttachmentView,
|
||||
mipMapsStatus));
|
||||
} else {
|
||||
return sk_sp<GrVkTextureRenderTarget>(new GrVkTextureRenderTarget(
|
||||
gpu, budgeted, desc, info, std::move(layout), views.imageView,
|
||||
views.colorAttachmentView, mipMapsStatus));
|
||||
}
|
||||
|
||||
return trt;
|
||||
}
|
||||
|
||||
sk_sp<GrVkTextureRenderTarget>
|
||||
GrVkTextureRenderTarget::MakeWrappedTextureRenderTarget(GrVkGpu* gpu,
|
||||
const GrSurfaceDesc& desc,
|
||||
GrWrapOwnership wrapOwnership,
|
||||
const GrVkImageInfo& info,
|
||||
sk_sp<GrVkImageLayout> layout) {
|
||||
sk_sp<GrVkTextureRenderTarget> GrVkTextureRenderTarget::MakeWrappedTextureRenderTarget(
|
||||
GrVkGpu* gpu,
|
||||
const GrSurfaceDesc& desc,
|
||||
GrWrapOwnership wrapOwnership,
|
||||
GrWrapCacheable cacheable,
|
||||
const GrVkImageInfo& info,
|
||||
sk_sp<GrVkImageLayout> layout) {
|
||||
// Wrapped textures require both image and allocation (because they can be mapped)
|
||||
SkASSERT(VK_NULL_HANDLE != info.fImage && VK_NULL_HANDLE != info.fAlloc.fMemory);
|
||||
|
||||
@ -238,43 +215,20 @@ GrVkTextureRenderTarget::MakeWrappedTextureRenderTarget(GrVkGpu* gpu,
|
||||
|
||||
GrBackendObjectOwnership ownership = kBorrow_GrWrapOwnership == wrapOwnership
|
||||
? GrBackendObjectOwnership::kBorrowed : GrBackendObjectOwnership::kOwned;
|
||||
|
||||
return Make(gpu, desc, info, std::move(layout), mipMapsStatus, SkBudgeted::kNo, ownership,
|
||||
true);
|
||||
}
|
||||
|
||||
bool GrVkTextureRenderTarget::updateForMipmap(GrVkGpu* gpu, const GrVkImageInfo& newInfo) {
|
||||
VkFormat pixelFormat;
|
||||
GrPixelConfigToVkFormat(this->config(), &pixelFormat);
|
||||
if (this->numStencilSamples() > 1) {
|
||||
const GrVkImageView* resolveAttachmentView =
|
||||
GrVkImageView::Create(gpu,
|
||||
newInfo.fImage,
|
||||
pixelFormat,
|
||||
GrVkImageView::kColor_Type,
|
||||
newInfo.fLevelCount,
|
||||
GrVkYcbcrConversionInfo());
|
||||
if (!resolveAttachmentView) {
|
||||
return false;
|
||||
}
|
||||
fResolveAttachmentView->unref(gpu);
|
||||
fResolveAttachmentView = resolveAttachmentView;
|
||||
} else {
|
||||
const GrVkImageView* colorAttachmentView = GrVkImageView::Create(gpu,
|
||||
newInfo.fImage,
|
||||
pixelFormat,
|
||||
GrVkImageView::kColor_Type,
|
||||
1,
|
||||
GrVkYcbcrConversionInfo());
|
||||
if (!colorAttachmentView) {
|
||||
return false;
|
||||
}
|
||||
fColorAttachmentView->unref(gpu);
|
||||
fColorAttachmentView = colorAttachmentView;
|
||||
Views views = create_views(gpu, desc, info);
|
||||
if (!views.colorAttachmentView) {
|
||||
return nullptr;
|
||||
}
|
||||
if (desc.fSampleCnt > 1) {
|
||||
return sk_sp<GrVkTextureRenderTarget>(new GrVkTextureRenderTarget(
|
||||
gpu, desc, info, std::move(layout), views.imageView, views.msInfo,
|
||||
std::move(views.msLayout), views.colorAttachmentView, views.resolveAttachmentView,
|
||||
mipMapsStatus, ownership, cacheable));
|
||||
} else {
|
||||
return sk_sp<GrVkTextureRenderTarget>(new GrVkTextureRenderTarget(
|
||||
gpu, desc, info, std::move(layout), views.imageView, views.colorAttachmentView,
|
||||
mipMapsStatus, ownership, cacheable));
|
||||
}
|
||||
|
||||
this->createFramebuffer(gpu);
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t GrVkTextureRenderTarget::onGpuMemorySize() const {
|
||||
|
@ -34,11 +34,10 @@ public:
|
||||
static sk_sp<GrVkTextureRenderTarget> MakeWrappedTextureRenderTarget(GrVkGpu*,
|
||||
const GrSurfaceDesc&,
|
||||
GrWrapOwnership,
|
||||
GrWrapCacheable,
|
||||
const GrVkImageInfo&,
|
||||
sk_sp<GrVkImageLayout>);
|
||||
|
||||
bool updateForMipmap(GrVkGpu* gpu, const GrVkImageInfo& newInfo);
|
||||
|
||||
GrBackendFormat backendFormat() const override { return this->getBackendFormat(); }
|
||||
|
||||
protected:
|
||||
@ -53,6 +52,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
// MSAA, not-wrapped
|
||||
GrVkTextureRenderTarget(GrVkGpu* gpu,
|
||||
SkBudgeted budgeted,
|
||||
const GrSurfaceDesc& desc,
|
||||
@ -63,9 +63,9 @@ private:
|
||||
sk_sp<GrVkImageLayout> msaaLayout,
|
||||
const GrVkImageView* colorAttachmentView,
|
||||
const GrVkImageView* resolveAttachmentView,
|
||||
GrMipMapsStatus,
|
||||
GrBackendObjectOwnership);
|
||||
GrMipMapsStatus);
|
||||
|
||||
// non-MSAA, not-wrapped
|
||||
GrVkTextureRenderTarget(GrVkGpu* gpu,
|
||||
SkBudgeted budgeted,
|
||||
const GrSurfaceDesc& desc,
|
||||
@ -73,9 +73,9 @@ private:
|
||||
sk_sp<GrVkImageLayout> layout,
|
||||
const GrVkImageView* texView,
|
||||
const GrVkImageView* colorAttachmentView,
|
||||
GrMipMapsStatus,
|
||||
GrBackendObjectOwnership);
|
||||
GrMipMapsStatus);
|
||||
|
||||
// MSAA, wrapped
|
||||
GrVkTextureRenderTarget(GrVkGpu* gpu,
|
||||
const GrSurfaceDesc& desc,
|
||||
const GrVkImageInfo& info,
|
||||
@ -86,8 +86,10 @@ private:
|
||||
const GrVkImageView* colorAttachmentView,
|
||||
const GrVkImageView* resolveAttachmentView,
|
||||
GrMipMapsStatus,
|
||||
GrBackendObjectOwnership);
|
||||
GrBackendObjectOwnership,
|
||||
GrWrapCacheable);
|
||||
|
||||
// non-MSAA, wrapped
|
||||
GrVkTextureRenderTarget(GrVkGpu* gpu,
|
||||
const GrSurfaceDesc& desc,
|
||||
const GrVkImageInfo& info,
|
||||
@ -95,16 +97,8 @@ private:
|
||||
const GrVkImageView* texView,
|
||||
const GrVkImageView* colorAttachmentView,
|
||||
GrMipMapsStatus,
|
||||
GrBackendObjectOwnership);
|
||||
|
||||
static sk_sp<GrVkTextureRenderTarget> Make(GrVkGpu*,
|
||||
const GrSurfaceDesc&,
|
||||
const GrVkImageInfo&,
|
||||
sk_sp<GrVkImageLayout>,
|
||||
GrMipMapsStatus,
|
||||
SkBudgeted budgeted,
|
||||
GrBackendObjectOwnership,
|
||||
bool isWrapped);
|
||||
GrBackendObjectOwnership,
|
||||
GrWrapCacheable);
|
||||
|
||||
// GrGLRenderTarget accounts for the texture's memory and any MSAA renderbuffer's memory.
|
||||
size_t onGpuMemorySize() const override;
|
||||
|
@ -113,8 +113,9 @@ static sk_sp<SkImage> new_wrapped_texture_common(GrContext* ctx,
|
||||
}
|
||||
|
||||
GrProxyProvider* proxyProvider = ctx->contextPriv().proxyProvider();
|
||||
sk_sp<GrTextureProxy> proxy = proxyProvider->wrapBackendTexture(
|
||||
backendTex, origin, ownership, kRead_GrIOType, releaseProc, releaseCtx);
|
||||
sk_sp<GrTextureProxy> proxy =
|
||||
proxyProvider->wrapBackendTexture(backendTex, origin, ownership, GrWrapCacheable::kNo,
|
||||
kRead_GrIOType, releaseProc, releaseCtx);
|
||||
if (!proxy) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -292,9 +292,9 @@ bool SkImage_GpuBase::MakeTempTextureProxies(GrContext* ctx, const GrBackendText
|
||||
}
|
||||
SkASSERT(yuvaTexturesCopy[textureIndex].isValid());
|
||||
|
||||
tempTextureProxies[textureIndex] =
|
||||
proxyProvider->wrapBackendTexture(yuvaTexturesCopy[textureIndex], imageOrigin,
|
||||
kBorrow_GrWrapOwnership, kRead_GrIOType);
|
||||
tempTextureProxies[textureIndex] = proxyProvider->wrapBackendTexture(
|
||||
yuvaTexturesCopy[textureIndex], imageOrigin, kBorrow_GrWrapOwnership,
|
||||
GrWrapCacheable::kNo, kRead_GrIOType);
|
||||
if (!tempTextureProxies[textureIndex]) {
|
||||
return false;
|
||||
}
|
||||
@ -460,7 +460,7 @@ sk_sp<GrTextureProxy> SkImage_GpuBase::MakePromiseImageLazyProxy(
|
||||
}
|
||||
|
||||
auto tex = resourceProvider->wrapBackendTexture(backendTexture, kBorrow_GrWrapOwnership,
|
||||
kRead_GrIOType);
|
||||
GrWrapCacheable::kYes, kRead_GrIOType);
|
||||
if (!tex) {
|
||||
// Even though we failed to wrap the backend texture, we must call the release
|
||||
// proc to keep our contract of always calling Fulfill and Release in pairs.
|
||||
|
@ -997,7 +997,8 @@ DEF_GPUTEST(PorterDuffNoDualSourceBlending, reporter, options) {
|
||||
GrXferProcessor::DstProxy fakeDstProxy;
|
||||
{
|
||||
sk_sp<GrTextureProxy> proxy = proxyProvider->wrapBackendTexture(
|
||||
backendTex, kTopLeft_GrSurfaceOrigin, kBorrow_GrWrapOwnership, kRead_GrIOType);
|
||||
backendTex, kTopLeft_GrSurfaceOrigin, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo,
|
||||
kRead_GrIOType);
|
||||
fakeDstProxy.setProxy(std::move(proxy));
|
||||
}
|
||||
|
||||
|
@ -53,8 +53,8 @@ DEF_GPUTEST_FOR_NULLGL_CONTEXT(GrSurface, reporter, ctxInfo) {
|
||||
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(
|
||||
nullptr, 256, 256, GrColorType::kRGBA_8888, false, GrMipMapped::kNo);
|
||||
|
||||
sk_sp<GrSurface> texRT2 =
|
||||
resourceProvider->wrapRenderableBackendTexture(backendTex, 1, kBorrow_GrWrapOwnership);
|
||||
sk_sp<GrSurface> texRT2 = resourceProvider->wrapRenderableBackendTexture(
|
||||
backendTex, 1, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo);
|
||||
|
||||
REPORTER_ASSERT(reporter, texRT2.get() == texRT2->asRenderTarget());
|
||||
REPORTER_ASSERT(reporter, texRT2.get() == texRT2->asTexture());
|
||||
@ -279,7 +279,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadOnlyTexture, reporter, context_info) {
|
||||
auto backendTex = context->contextPriv().getGpu()->createTestingOnlyBackendTexture(
|
||||
pixels.addr(), kSize, kSize, kRGBA_8888_SkColorType, true, GrMipMapped::kNo);
|
||||
auto proxy = proxyProvider->wrapBackendTexture(backendTex, kTopLeft_GrSurfaceOrigin,
|
||||
kBorrow_GrWrapOwnership, ioType);
|
||||
kBorrow_GrWrapOwnership,
|
||||
GrWrapCacheable::kNo, ioType);
|
||||
auto surfContext = context->contextPriv().makeWrappedSurfaceContext(proxy);
|
||||
|
||||
// Read pixels should work with a read-only texture.
|
||||
@ -323,7 +324,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadOnlyTexture, reporter, context_info) {
|
||||
backendTex = context->contextPriv().getGpu()->createTestingOnlyBackendTexture(
|
||||
nullptr, kSize, kSize, kRGBA_8888_SkColorType, true, GrMipMapped::kYes);
|
||||
proxy = proxyProvider->wrapBackendTexture(backendTex, kTopLeft_GrSurfaceOrigin,
|
||||
kBorrow_GrWrapOwnership, ioType);
|
||||
kBorrow_GrWrapOwnership, GrWrapCacheable::kNo,
|
||||
ioType);
|
||||
context->flush();
|
||||
proxy->peekTexture()->texturePriv().markMipMapsDirty(); // avoids assert in GrGpu.
|
||||
auto regenResult =
|
||||
@ -363,7 +365,7 @@ DEF_GPUTEST(TextureIdleProcTest, reporter, options) {
|
||||
auto backendTexture = context->contextPriv().getGpu()->createTestingOnlyBackendTexture(
|
||||
nullptr, kS, kS, GrColorType::kRGBA_8888, false, GrMipMapped::kNo);
|
||||
auto texture = context->contextPriv().resourceProvider()->wrapBackendTexture(
|
||||
backendTexture, kBorrow_GrWrapOwnership, kRW_GrIOType);
|
||||
backendTexture, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, kRW_GrIOType);
|
||||
installBackendTextureReleaseProc(texture.get());
|
||||
return texture;
|
||||
};
|
||||
@ -372,7 +374,7 @@ DEF_GPUTEST(TextureIdleProcTest, reporter, options) {
|
||||
auto backendTexture = context->contextPriv().getGpu()->createTestingOnlyBackendTexture(
|
||||
nullptr, kS, kS, GrColorType::kRGBA_8888, true, GrMipMapped::kNo);
|
||||
auto texture = context->contextPriv().resourceProvider()->wrapRenderableBackendTexture(
|
||||
backendTexture, 1, kBorrow_GrWrapOwnership);
|
||||
backendTexture, 1, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo);
|
||||
installBackendTextureReleaseProc(texture.get());
|
||||
return texture;
|
||||
};
|
||||
|
@ -47,11 +47,11 @@ void testing_only_texture_test(skiatest::Reporter* reporter, GrContext* context,
|
||||
|
||||
sk_sp<GrTexture> wrappedTex;
|
||||
if (renderTarget) {
|
||||
wrappedTex = gpu->wrapRenderableBackendTexture(backendTex, 1,
|
||||
GrWrapOwnership::kAdopt_GrWrapOwnership);
|
||||
wrappedTex = gpu->wrapRenderableBackendTexture(
|
||||
backendTex, 1, GrWrapOwnership::kAdopt_GrWrapOwnership, GrWrapCacheable::kNo);
|
||||
} else {
|
||||
wrappedTex = gpu->wrapBackendTexture(backendTex, GrWrapOwnership::kAdopt_GrWrapOwnership,
|
||||
GrWrapCacheable::kYes, kRead_GrIOType);
|
||||
GrWrapCacheable::kNo, kRead_GrIOType);
|
||||
}
|
||||
REPORTER_ASSERT(reporter, wrappedTex);
|
||||
|
||||
|
@ -468,7 +468,7 @@ DEF_GPUTEST(LazyProxyDeinstantiateTest, reporter, /* options */) {
|
||||
|
||||
sk_sp<GrTexture> texture =
|
||||
rp->wrapBackendTexture(backendTex, kBorrow_GrWrapOwnership,
|
||||
kRead_GrIOType, GrWrapCacheable::kYes);
|
||||
GrWrapCacheable::kNo, kRead_GrIOType);
|
||||
if (!texture) {
|
||||
return sk_sp<GrTexture>();
|
||||
}
|
||||
|
@ -297,7 +297,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
|
||||
true, GrMipMapped::kNo);
|
||||
|
||||
sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapRenderableBackendTexture(
|
||||
backendTex, origin, supportedNumSamples);
|
||||
backendTex, origin, supportedNumSamples, kBorrow_GrWrapOwnership,
|
||||
GrWrapCacheable::kNo);
|
||||
if (!sProxy) {
|
||||
gpu->deleteTestingOnlyBackendTexture(backendTex);
|
||||
continue; // This can fail on Mesa
|
||||
@ -323,7 +324,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
|
||||
false, GrMipMapped::kNo);
|
||||
|
||||
sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapBackendTexture(
|
||||
backendTex, origin, kBorrow_GrWrapOwnership, kRead_GrIOType);
|
||||
backendTex, origin, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo,
|
||||
kRead_GrIOType);
|
||||
if (!sProxy) {
|
||||
gpu->deleteTestingOnlyBackendTexture(backendTex);
|
||||
continue;
|
||||
|
@ -136,7 +136,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(RectangleTexture, reporter, ctxInfo) {
|
||||
}
|
||||
|
||||
sk_sp<GrTextureProxy> rectProxy = proxyProvider->wrapBackendTexture(
|
||||
rectangleTex, origin, kBorrow_GrWrapOwnership, kRW_GrIOType);
|
||||
rectangleTex, origin, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, kRW_GrIOType);
|
||||
|
||||
if (!rectProxy) {
|
||||
ERRORF(reporter, "Error creating proxy for rectangle texture.");
|
||||
|
@ -70,7 +70,7 @@ static GrSurfaceProxy* make_backend(GrContext* context, const ProxyParams& p,
|
||||
}
|
||||
|
||||
auto tmp = proxyProvider->wrapBackendTexture(*backendTex, p.fOrigin, kBorrow_GrWrapOwnership,
|
||||
kRead_GrIOType);
|
||||
GrWrapCacheable::kNo, kRead_GrIOType);
|
||||
if (!tmp) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -223,10 +223,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheWrappedResources, reporter, ctxI
|
||||
context->resetContext();
|
||||
|
||||
sk_sp<GrTexture> borrowed(resourceProvider->wrapBackendTexture(
|
||||
backendTextures[0], kBorrow_GrWrapOwnership, kRead_GrIOType));
|
||||
backendTextures[0], kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, kRead_GrIOType));
|
||||
|
||||
sk_sp<GrTexture> adopted(resourceProvider->wrapBackendTexture(
|
||||
backendTextures[1], kAdopt_GrWrapOwnership, kRead_GrIOType));
|
||||
backendTextures[1], kAdopt_GrWrapOwnership, GrWrapCacheable::kNo, kRead_GrIOType));
|
||||
|
||||
REPORTER_ASSERT(reporter, borrowed != nullptr && adopted != nullptr);
|
||||
if (!borrowed || !adopted) {
|
||||
@ -277,8 +277,9 @@ public:
|
||||
SimulatedProperty property, size_t size = kDefaultSize) {
|
||||
return new TestResource(gpu, budgeted, property, kScratchConstructor, size);
|
||||
}
|
||||
static TestResource* CreateWrapped(GrGpu* gpu, size_t size = kDefaultSize) {
|
||||
return new TestResource(gpu, size);
|
||||
static TestResource* CreateWrapped(GrGpu* gpu, GrWrapCacheable cacheable,
|
||||
size_t size = kDefaultSize) {
|
||||
return new TestResource(gpu, cacheable, size);
|
||||
}
|
||||
|
||||
~TestResource() override {
|
||||
@ -317,14 +318,14 @@ private:
|
||||
}
|
||||
|
||||
// Constructor for simulating resources that wrap backend objects.
|
||||
TestResource(GrGpu* gpu, size_t size)
|
||||
: INHERITED(gpu)
|
||||
, fToDelete(nullptr)
|
||||
, fSize(size)
|
||||
, fProperty(kA_SimulatedProperty)
|
||||
, fIsScratch(false) {
|
||||
TestResource(GrGpu* gpu, GrWrapCacheable cacheable, size_t size)
|
||||
: INHERITED(gpu)
|
||||
, fToDelete(nullptr)
|
||||
, fSize(size)
|
||||
, fProperty(kA_SimulatedProperty)
|
||||
, fIsScratch(false) {
|
||||
++fNumAlive;
|
||||
this->registerWithCacheWrapped();
|
||||
this->registerWithCacheWrapped(cacheable);
|
||||
}
|
||||
|
||||
void computeScratchKey(GrScratchKey* key) const override {
|
||||
@ -501,24 +502,33 @@ static void test_budgeting(skiatest::Reporter* reporter) {
|
||||
10);
|
||||
TestResource* unique = new TestResource(gpu, SkBudgeted::kYes, 11);
|
||||
unique->resourcePriv().setUniqueKey(uniqueKey);
|
||||
TestResource* wrapped = TestResource::CreateWrapped(gpu, 12);
|
||||
TestResource* unbudgeted = new TestResource(gpu, SkBudgeted::kNo, 13);
|
||||
TestResource* wrappedCacheable = TestResource::CreateWrapped(gpu, GrWrapCacheable::kYes, 12);
|
||||
TestResource* wrappedUncacheable = TestResource::CreateWrapped(gpu, GrWrapCacheable::kNo, 13);
|
||||
TestResource* unbudgeted = new TestResource(gpu, SkBudgeted::kNo, 14);
|
||||
|
||||
// Make sure we can add a unique key to the wrapped resource
|
||||
// Make sure we can add a unique key to the wrapped resources
|
||||
GrUniqueKey uniqueKey2;
|
||||
make_unique_key<0>(&uniqueKey2, 1);
|
||||
wrapped->resourcePriv().setUniqueKey(uniqueKey2);
|
||||
GrGpuResource* wrappedViaKey = cache->findAndRefUniqueResource(uniqueKey2);
|
||||
REPORTER_ASSERT(reporter, wrappedViaKey != nullptr);
|
||||
GrUniqueKey uniqueKey3;
|
||||
make_unique_key<0>(&uniqueKey3, 2);
|
||||
wrappedCacheable->resourcePriv().setUniqueKey(uniqueKey2);
|
||||
wrappedUncacheable->resourcePriv().setUniqueKey(uniqueKey3);
|
||||
GrGpuResource* wrappedCacheableViaKey = cache->findAndRefUniqueResource(uniqueKey2);
|
||||
REPORTER_ASSERT(reporter, wrappedCacheableViaKey);
|
||||
GrGpuResource* wrappedUncacheableViaKey = cache->findAndRefUniqueResource(uniqueKey3);
|
||||
REPORTER_ASSERT(reporter, wrappedUncacheableViaKey);
|
||||
|
||||
// Remove the extra ref we just added.
|
||||
wrappedViaKey->unref();
|
||||
// Remove the extra refs we just added.
|
||||
SkSafeUnref(wrappedCacheableViaKey);
|
||||
SkSafeUnref(wrappedUncacheableViaKey);
|
||||
|
||||
// Make sure sizes are as we expect
|
||||
REPORTER_ASSERT(reporter, 4 == cache->getResourceCount());
|
||||
REPORTER_ASSERT(reporter, 5 == cache->getResourceCount());
|
||||
REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + unique->gpuMemorySize() +
|
||||
wrapped->gpuMemorySize() + unbudgeted->gpuMemorySize() ==
|
||||
cache->getResourceBytes());
|
||||
wrappedCacheable->gpuMemorySize() +
|
||||
wrappedUncacheable->gpuMemorySize() +
|
||||
unbudgeted->gpuMemorySize() ==
|
||||
cache->getResourceBytes());
|
||||
REPORTER_ASSERT(reporter, 2 == cache->getBudgetedResourceCount());
|
||||
REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + unique->gpuMemorySize() ==
|
||||
cache->getBudgetedResourceBytes());
|
||||
@ -526,31 +536,39 @@ static void test_budgeting(skiatest::Reporter* reporter) {
|
||||
|
||||
// Our refs mean that the resources are non purgeable.
|
||||
cache->purgeAllUnlocked();
|
||||
REPORTER_ASSERT(reporter, 4 == cache->getResourceCount());
|
||||
REPORTER_ASSERT(reporter, 5 == cache->getResourceCount());
|
||||
REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + unique->gpuMemorySize() +
|
||||
wrapped->gpuMemorySize() + unbudgeted->gpuMemorySize() ==
|
||||
cache->getResourceBytes());
|
||||
wrappedCacheable->gpuMemorySize() +
|
||||
wrappedUncacheable->gpuMemorySize() +
|
||||
unbudgeted->gpuMemorySize() ==
|
||||
cache->getResourceBytes());
|
||||
REPORTER_ASSERT(reporter, 2 == cache->getBudgetedResourceCount());
|
||||
REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + unique->gpuMemorySize() ==
|
||||
cache->getBudgetedResourceBytes());
|
||||
REPORTER_ASSERT(reporter, 0 == cache->getPurgeableBytes());
|
||||
|
||||
// Unreffing the wrapped resource with a unique key shouldn't free it right away.
|
||||
wrapped->unref();
|
||||
// Unreffing the cacheable wrapped resource with a unique key shouldn't free it right away.
|
||||
// However, unreffing the uncacheable wrapped resource should free it.
|
||||
wrappedCacheable->unref();
|
||||
wrappedUncacheable->unref();
|
||||
REPORTER_ASSERT(reporter, 4 == cache->getResourceCount());
|
||||
REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + unique->gpuMemorySize() +
|
||||
wrapped->gpuMemorySize() + unbudgeted->gpuMemorySize() ==
|
||||
cache->getResourceBytes());
|
||||
wrappedCacheable->gpuMemorySize() +
|
||||
unbudgeted->gpuMemorySize() ==
|
||||
cache->getResourceBytes());
|
||||
REPORTER_ASSERT(reporter, 12 == cache->getPurgeableBytes());
|
||||
|
||||
// Now try freeing the budgeted resources first
|
||||
wrapped = TestResource::CreateWrapped(gpu);
|
||||
wrappedCacheable = TestResource::CreateWrapped(gpu, GrWrapCacheable::kYes);
|
||||
wrappedUncacheable = TestResource::CreateWrapped(gpu, GrWrapCacheable::kNo);
|
||||
unique->unref();
|
||||
REPORTER_ASSERT(reporter, 23 == cache->getPurgeableBytes());
|
||||
cache->purgeAllUnlocked();
|
||||
REPORTER_ASSERT(reporter, 3 == cache->getResourceCount());
|
||||
REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + wrapped->gpuMemorySize() +
|
||||
unbudgeted->gpuMemorySize() == cache->getResourceBytes());
|
||||
REPORTER_ASSERT(reporter, 4 == cache->getResourceCount());
|
||||
REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + wrappedCacheable->gpuMemorySize() +
|
||||
wrappedUncacheable->gpuMemorySize() +
|
||||
unbudgeted->gpuMemorySize() ==
|
||||
cache->getResourceBytes());
|
||||
REPORTER_ASSERT(reporter, 1 == cache->getBudgetedResourceCount());
|
||||
REPORTER_ASSERT(reporter, scratch->gpuMemorySize() == cache->getBudgetedResourceBytes());
|
||||
REPORTER_ASSERT(reporter, 0 == cache->getPurgeableBytes());
|
||||
@ -558,15 +576,17 @@ static void test_budgeting(skiatest::Reporter* reporter) {
|
||||
scratch->unref();
|
||||
REPORTER_ASSERT(reporter, 10 == cache->getPurgeableBytes());
|
||||
cache->purgeAllUnlocked();
|
||||
REPORTER_ASSERT(reporter, 2 == cache->getResourceCount());
|
||||
REPORTER_ASSERT(reporter, unbudgeted->gpuMemorySize() + wrapped->gpuMemorySize() ==
|
||||
cache->getResourceBytes());
|
||||
REPORTER_ASSERT(reporter, 3 == cache->getResourceCount());
|
||||
REPORTER_ASSERT(reporter, unbudgeted->gpuMemorySize() + wrappedCacheable->gpuMemorySize() +
|
||||
wrappedUncacheable->gpuMemorySize() ==
|
||||
cache->getResourceBytes());
|
||||
REPORTER_ASSERT(reporter, 0 == cache->getBudgetedResourceCount());
|
||||
REPORTER_ASSERT(reporter, 0 == cache->getBudgetedResourceBytes());
|
||||
REPORTER_ASSERT(reporter, 0 == cache->getPurgeableBytes());
|
||||
|
||||
// Unreffing the wrapped resource (with no unique key) should free it right away.
|
||||
wrapped->unref();
|
||||
// Unreffing the wrapped resources (with no unique key) should free them right away.
|
||||
wrappedUncacheable->unref();
|
||||
wrappedCacheable->unref();
|
||||
REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
|
||||
REPORTER_ASSERT(reporter, unbudgeted->gpuMemorySize() == cache->getResourceBytes());
|
||||
REPORTER_ASSERT(reporter, 0 == cache->getBudgetedResourceCount());
|
||||
@ -630,7 +650,7 @@ static void test_unbudgeted(skiatest::Reporter* reporter) {
|
||||
REPORTER_ASSERT(reporter, 21 == cache->getBudgetedResourceBytes());
|
||||
REPORTER_ASSERT(reporter, 21 == cache->getPurgeableBytes());
|
||||
|
||||
wrapped = TestResource::CreateWrapped(gpu, large);
|
||||
wrapped = TestResource::CreateWrapped(gpu, GrWrapCacheable::kYes, large);
|
||||
REPORTER_ASSERT(reporter, 3 == cache->getResourceCount());
|
||||
REPORTER_ASSERT(reporter, 21 + large == cache->getResourceBytes());
|
||||
REPORTER_ASSERT(reporter, 2 == cache->getBudgetedResourceCount());
|
||||
@ -670,7 +690,7 @@ void test_unbudgeted_to_scratch(skiatest::Reporter* reporter);
|
||||
// Since this resource is unbudgeted, it should not be reachable as scratch.
|
||||
REPORTER_ASSERT(reporter, resource->resourcePriv().getScratchKey() == key);
|
||||
REPORTER_ASSERT(reporter, !resource->cacheAccess().isScratch());
|
||||
REPORTER_ASSERT(reporter, GrBudgetedType::kUnbudgetedCacheable ==
|
||||
REPORTER_ASSERT(reporter, GrBudgetedType::kUnbudgetedUncacheable ==
|
||||
resource->resourcePriv().budgetedType());
|
||||
REPORTER_ASSERT(reporter, nullptr == cache->findAndRefScratchResource(key, TestResource::kDefaultSize, GrResourceCache::ScratchFlags::kNone));
|
||||
REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
|
||||
@ -1512,28 +1532,41 @@ static void test_free_resource_messages(skiatest::Reporter* reporter) {
|
||||
GrResourceCache* cache = mock.cache();
|
||||
GrGpu* gpu = context->contextPriv().getGpu();
|
||||
|
||||
TestResource* wrapped1 = TestResource::CreateWrapped(gpu, 12);
|
||||
TestResource* wrapped1 = TestResource::CreateWrapped(gpu, GrWrapCacheable::kYes);
|
||||
cache->insertCrossContextGpuResource(wrapped1);
|
||||
|
||||
REPORTER_ASSERT(reporter, 1 == TestResource::NumAlive());
|
||||
|
||||
TestResource* wrapped2 = TestResource::CreateWrapped(gpu, 12);
|
||||
TestResource* wrapped2 = TestResource::CreateWrapped(gpu, GrWrapCacheable::kYes);
|
||||
cache->insertCrossContextGpuResource(wrapped2);
|
||||
|
||||
REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
|
||||
// An uncacheable cross-context should not be purged as soon as we drop our ref. This
|
||||
// is because inserting it as a cross-context resource actually holds a ref until the
|
||||
// message is received.
|
||||
TestResource* wrapped3 = TestResource::CreateWrapped(gpu, GrWrapCacheable::kNo);
|
||||
cache->insertCrossContextGpuResource(wrapped3);
|
||||
|
||||
REPORTER_ASSERT(reporter, 3 == TestResource::NumAlive());
|
||||
|
||||
// Have only ref waiting on message.
|
||||
wrapped1->unref();
|
||||
wrapped2->unref();
|
||||
wrapped3->unref();
|
||||
|
||||
REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
|
||||
REPORTER_ASSERT(reporter, 3 == TestResource::NumAlive());
|
||||
|
||||
// This should free nothing since no messages were sent.
|
||||
cache->purgeAsNeeded();
|
||||
|
||||
// Send message to free the first resource
|
||||
GrGpuResourceFreedMessage msg { wrapped1, context->uniqueID() };
|
||||
SkMessageBus<GrGpuResourceFreedMessage>::Post(msg);
|
||||
GrGpuResourceFreedMessage msg1{wrapped1, context->uniqueID()};
|
||||
SkMessageBus<GrGpuResourceFreedMessage>::Post(msg1);
|
||||
cache->purgeAsNeeded();
|
||||
|
||||
REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
|
||||
|
||||
GrGpuResourceFreedMessage msg2{wrapped3, context->uniqueID()};
|
||||
SkMessageBus<GrGpuResourceFreedMessage>::Post(msg2);
|
||||
cache->purgeAsNeeded();
|
||||
|
||||
REPORTER_ASSERT(reporter, 1 == TestResource::NumAlive());
|
||||
|
@ -113,7 +113,8 @@ static sk_sp<GrTextureProxy> create_wrapped_backend(GrContext* context, SkBackin
|
||||
backendTex.setPixelConfig(desc.fConfig);
|
||||
|
||||
return proxyProvider->wrapBackendTexture(backendTex, kBottomLeft_GrSurfaceOrigin,
|
||||
kBorrow_GrWrapOwnership, kRead_GrIOType);
|
||||
kBorrow_GrWrapOwnership, GrWrapCacheable::kYes,
|
||||
kRead_GrIOType);
|
||||
}
|
||||
|
||||
|
||||
|
@ -128,7 +128,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SkTraceMemoryDump_unownedGLTexture, report
|
||||
idDesc.fOwnership = GrBackendObjectOwnership::kBorrowed;
|
||||
|
||||
auto texture = GrGLTexture::MakeWrapped(gpu, desc, GrMipMapsStatus::kNotAllocated, idDesc,
|
||||
GrWrapCacheable::kYes, kRead_GrIOType);
|
||||
GrWrapCacheable::kNo, kRead_GrIOType);
|
||||
|
||||
ValidateMemoryDumps(reporter, context, texture->gpuMemorySize(), false /* isOwned */);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) {
|
||||
SkAssertResult(origBackendTex.getVkImageInfo(&imageInfo));
|
||||
|
||||
sk_sp<GrTexture> tex = gpu->wrapBackendTexture(origBackendTex, kBorrow_GrWrapOwnership,
|
||||
GrWrapCacheable::kYes, kRead_GrIOType);
|
||||
GrWrapCacheable::kNo, kRead_GrIOType);
|
||||
REPORTER_ASSERT(reporter, tex);
|
||||
|
||||
// image is null
|
||||
@ -52,10 +52,10 @@ void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) {
|
||||
backendCopy.fImage = VK_NULL_HANDLE;
|
||||
GrBackendTexture backendTex = GrBackendTexture(kW, kH, backendCopy);
|
||||
backendTex.setPixelConfig(kPixelConfig);
|
||||
tex = gpu->wrapBackendTexture(backendTex, kBorrow_GrWrapOwnership, GrWrapCacheable::kYes,
|
||||
tex = gpu->wrapBackendTexture(backendTex, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo,
|
||||
kRead_GrIOType);
|
||||
REPORTER_ASSERT(reporter, !tex);
|
||||
tex = gpu->wrapBackendTexture(backendTex, kAdopt_GrWrapOwnership, GrWrapCacheable::kYes,
|
||||
tex = gpu->wrapBackendTexture(backendTex, kAdopt_GrWrapOwnership, GrWrapCacheable::kNo,
|
||||
kRead_GrIOType);
|
||||
REPORTER_ASSERT(reporter, !tex);
|
||||
}
|
||||
@ -66,10 +66,10 @@ void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) {
|
||||
backendCopy.fAlloc = GrVkAlloc();
|
||||
GrBackendTexture backendTex = GrBackendTexture(kW, kH, backendCopy);
|
||||
backendTex.setPixelConfig(kPixelConfig);
|
||||
tex = gpu->wrapBackendTexture(backendTex, kBorrow_GrWrapOwnership, GrWrapCacheable::kYes,
|
||||
tex = gpu->wrapBackendTexture(backendTex, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo,
|
||||
kRead_GrIOType);
|
||||
REPORTER_ASSERT(reporter, !tex);
|
||||
tex = gpu->wrapBackendTexture(backendTex, kAdopt_GrWrapOwnership, GrWrapCacheable::kYes,
|
||||
tex = gpu->wrapBackendTexture(backendTex, kAdopt_GrWrapOwnership, GrWrapCacheable::kNo,
|
||||
kRead_GrIOType);
|
||||
REPORTER_ASSERT(reporter, !tex);
|
||||
}
|
||||
@ -79,7 +79,7 @@ void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) {
|
||||
GrVkImageInfo backendCopy = imageInfo;
|
||||
GrBackendTexture backendTex = GrBackendTexture(kW, kH, backendCopy);
|
||||
backendTex.setPixelConfig(kPixelConfig);
|
||||
tex = gpu->wrapBackendTexture(backendTex, kAdopt_GrWrapOwnership, GrWrapCacheable::kYes,
|
||||
tex = gpu->wrapBackendTexture(backendTex, kAdopt_GrWrapOwnership, GrWrapCacheable::kNo,
|
||||
kRead_GrIOType);
|
||||
|
||||
REPORTER_ASSERT(reporter, tex);
|
||||
@ -137,8 +137,8 @@ void wrap_trt_test(skiatest::Reporter* reporter, GrContext* context) {
|
||||
GrVkImageInfo imageInfo;
|
||||
SkAssertResult(origBackendTex.getVkImageInfo(&imageInfo));
|
||||
|
||||
sk_sp<GrTexture> tex =
|
||||
gpu->wrapRenderableBackendTexture(origBackendTex, 1, kBorrow_GrWrapOwnership);
|
||||
sk_sp<GrTexture> tex = gpu->wrapRenderableBackendTexture(
|
||||
origBackendTex, 1, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo);
|
||||
REPORTER_ASSERT(reporter, tex);
|
||||
|
||||
// image is null
|
||||
@ -147,9 +147,11 @@ void wrap_trt_test(skiatest::Reporter* reporter, GrContext* context) {
|
||||
backendCopy.fImage = VK_NULL_HANDLE;
|
||||
GrBackendTexture backendTex = GrBackendTexture(kW, kH, backendCopy);
|
||||
backendTex.setPixelConfig(kPixelConfig);
|
||||
tex = gpu->wrapRenderableBackendTexture(backendTex, 1, kBorrow_GrWrapOwnership);
|
||||
tex = gpu->wrapRenderableBackendTexture(backendTex, 1, kBorrow_GrWrapOwnership,
|
||||
GrWrapCacheable::kNo);
|
||||
REPORTER_ASSERT(reporter, !tex);
|
||||
tex = gpu->wrapRenderableBackendTexture(backendTex, 1, kAdopt_GrWrapOwnership);
|
||||
tex = gpu->wrapRenderableBackendTexture(backendTex, 1, kAdopt_GrWrapOwnership,
|
||||
GrWrapCacheable::kNo);
|
||||
REPORTER_ASSERT(reporter, !tex);
|
||||
}
|
||||
|
||||
@ -159,9 +161,11 @@ void wrap_trt_test(skiatest::Reporter* reporter, GrContext* context) {
|
||||
backendCopy.fAlloc = GrVkAlloc();
|
||||
GrBackendTexture backendTex = GrBackendTexture(kW, kH, backendCopy);
|
||||
backendTex.setPixelConfig(kPixelConfig);
|
||||
tex = gpu->wrapRenderableBackendTexture(backendTex, 1, kBorrow_GrWrapOwnership);
|
||||
tex = gpu->wrapRenderableBackendTexture(backendTex, 1, kBorrow_GrWrapOwnership,
|
||||
GrWrapCacheable::kNo);
|
||||
REPORTER_ASSERT(reporter, !tex);
|
||||
tex = gpu->wrapRenderableBackendTexture(backendTex, 1, kAdopt_GrWrapOwnership);
|
||||
tex = gpu->wrapRenderableBackendTexture(backendTex, 1, kAdopt_GrWrapOwnership,
|
||||
GrWrapCacheable::kNo);
|
||||
REPORTER_ASSERT(reporter, !tex);
|
||||
}
|
||||
|
||||
@ -170,7 +174,8 @@ void wrap_trt_test(skiatest::Reporter* reporter, GrContext* context) {
|
||||
GrVkImageInfo backendCopy = imageInfo;
|
||||
GrBackendTexture backendTex = GrBackendTexture(kW, kH, backendCopy);
|
||||
backendTex.setPixelConfig(kPixelConfig);
|
||||
tex = gpu->wrapRenderableBackendTexture(backendTex, 1, kAdopt_GrWrapOwnership);
|
||||
tex = gpu->wrapRenderableBackendTexture(backendTex, 1, kAdopt_GrWrapOwnership,
|
||||
GrWrapCacheable::kNo);
|
||||
REPORTER_ASSERT(reporter, tex);
|
||||
}
|
||||
}
|
||||
|
@ -33,10 +33,10 @@ sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrContext* context, bool isRT, in
|
||||
// Adopt ownership so our caller doesn't have to worry about deleting the backend texture.
|
||||
if (isRT) {
|
||||
proxy = context->contextPriv().proxyProvider()->wrapRenderableBackendTexture(
|
||||
backendTex, origin, 1, kAdopt_GrWrapOwnership);
|
||||
backendTex, origin, 1, kAdopt_GrWrapOwnership, GrWrapCacheable::kNo);
|
||||
} else {
|
||||
proxy = context->contextPriv().proxyProvider()->wrapBackendTexture(
|
||||
backendTex, origin, kAdopt_GrWrapOwnership, kRW_GrIOType);
|
||||
backendTex, origin, kAdopt_GrWrapOwnership, GrWrapCacheable::kNo, kRW_GrIOType);
|
||||
}
|
||||
|
||||
if (!proxy) {
|
||||
|
Loading…
Reference in New Issue
Block a user