Remove GrInternalSurfaceFlags::kNoPendingIO as it is no longer needed

Since explicit allocation is always enabled now, the resource allocator explicitly manages reuse of GrSurfaces and this flag isn't used/needed.

Change-Id: I5703bf4624e21f9aff9da76575f4ef757b1d2589
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/210140
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2019-04-24 14:09:10 -04:00 committed by Skia Commit-Bot
parent 2444c0e9aa
commit 10d172169f
23 changed files with 42 additions and 91 deletions

View File

@ -24,7 +24,7 @@ public:
const GrRenderTargetProxy* asRenderTargetProxy() const override { return this; }
// Actually instantiate the backing rendertarget, if necessary.
bool instantiate(GrResourceProvider*, bool dontForceNoPendingIO = false) override;
bool instantiate(GrResourceProvider*) override;
GrFSAAType fsaaType() const {
if (fSampleCnt <= 1) {

View File

@ -363,8 +363,7 @@ public:
return fUniqueID;
}
virtual bool instantiate(GrResourceProvider* resourceProvider,
bool dontForceNoPendingIO = false) = 0;
virtual bool instantiate(GrResourceProvider*) = 0;
void deinstantiate();
@ -504,8 +503,7 @@ protected:
void assign(sk_sp<GrSurface> surface);
sk_sp<GrSurface> createSurfaceImpl(GrResourceProvider*, int sampleCnt, bool needsStencil,
GrSurfaceDescFlags, GrMipMapped,
bool forceNoPendingIO) const;
GrSurfaceDescFlags, GrMipMapped) const;
// Once the size of a fully-lazy proxy is decided, and before it gets instantiated, the client
// can use this optional method to specify the proxy's size. (A proxy's size can be less than
@ -519,8 +517,7 @@ protected:
}
bool instantiateImpl(GrResourceProvider* resourceProvider, int sampleCnt, bool needsStencil,
GrSurfaceDescFlags descFlags, GrMipMapped, const GrUniqueKey*,
bool dontForceNoPendingIO);
GrSurfaceDescFlags descFlags, GrMipMapped, const GrUniqueKey*);
// In many cases these flags aren't actually known until the proxy has been instantiated.
// However, Ganesh frequently needs to change its behavior based on these settings. For

View File

@ -25,7 +25,7 @@ public:
const GrTextureProxy* asTextureProxy() const override { return this; }
// Actually instantiate the backing texture, if necessary
bool instantiate(GrResourceProvider*, bool dontForceNoPendingIO = false) override;
bool instantiate(GrResourceProvider*) override;
GrSamplerState::Filter highestFilterMode() const;

View File

@ -762,15 +762,10 @@ enum class GrInternalSurfaceFlags {
kNone = 0,
// Surface-level
kNoPendingIO = 1 << 0,
kSurfaceMask = kNoPendingIO,
// Texture-level
// Means the pixels in the texture are read-only. Cannot also be a GrRenderTarget[Proxy].
kReadOnly = 1 << 1,
kReadOnly = 1 << 0,
kTextureMask = kReadOnly,
@ -782,10 +777,10 @@ enum class GrInternalSurfaceFlags {
// this is disabled for FBO0
// but, otherwise, is enabled whenever MSAA is enabled and GrCaps reports mixed samples
// are supported
kMixedSampled = 1 << 2,
kMixedSampled = 1 << 1,
// This flag is for use with GL only. It tells us that the internal render target wraps FBO 0.
kGLRTFBOIDIs0 = 1 << 3,
kGLRTFBOIDIs0 = 1 << 2,
kRenderTargetMask = kMixedSampled | kGLRTFBOIDIs0,
};

View File

@ -498,8 +498,7 @@ sk_sp<GrTextureProxy> GrClipStackClip::createSoftwareClipMask(
// MDB TODO: We're going to fill this proxy with an ASAP upload (which is out of order wrt
// to ops), so it can't have any pending IO.
proxy = proxyProvider->createProxy(format, desc, kTopLeft_GrSurfaceOrigin,
SkBackingFit::kApprox, SkBudgeted::kYes,
GrInternalSurfaceFlags::kNoPendingIO);
SkBackingFit::kApprox, SkBudgeted::kYes);
auto uploader = skstd::make_unique<GrTDeferredProxyUploader<ClipMaskData>>(reducedClip);
GrTDeferredProxyUploader<ClipMaskData>* uploaderRaw = uploader.get();

View File

@ -531,7 +531,7 @@ bool GrDrawOpAtlas::createPages(GrProxyProvider* proxyProvider) {
for (uint32_t i = 0; i < this->maxPages(); ++i) {
fProxies[i] = proxyProvider->createProxy(fFormat, desc, kTopLeft_GrSurfaceOrigin,
SkBackingFit::kExact, SkBudgeted::kYes, GrInternalSurfaceFlags::kNoPendingIO);
SkBackingFit::kExact, SkBudgeted::kYes);
if (!fProxies[i]) {
return false;
}

View File

@ -65,7 +65,6 @@ sk_sp<GrTextureProxy> GrOnFlushResourceProvider::findOrCreateProxyByUniqueKey(
bool GrOnFlushResourceProvider::instatiateProxy(GrSurfaceProxy* proxy) {
SkASSERT(proxy->priv().ignoredByResourceAllocator());
SkASSERT(proxy->priv().requiresNoPendingIO());
// TODO: this class should probably just get a GrDirectContext
auto direct = fDrawingMgr->getContext()->priv().asDirectContext();

View File

@ -247,7 +247,6 @@ sk_sp<GrTextureProxy> GrProxyProvider::createTextureProxy(sk_sp<SkImage> srcImag
surfaceFlags |= GrInternalSurfaceFlags::kMixedSampled;
}
}
surfaceFlags |= GrInternalSurfaceFlags::kNoPendingIO;
GrSurfaceDesc desc;
desc.fWidth = srcImage->width();
@ -257,17 +256,13 @@ sk_sp<GrTextureProxy> GrProxyProvider::createTextureProxy(sk_sp<SkImage> srcImag
desc.fConfig = config;
sk_sp<GrTextureProxy> proxy = this->createLazyProxy(
[desc, budgeted, srcImage, fit, surfaceFlags](GrResourceProvider* resourceProvider) {
[desc, budgeted, srcImage, fit](GrResourceProvider* resourceProvider) {
SkPixmap pixMap;
SkAssertResult(srcImage->peekPixels(&pixMap));
GrMipLevel mipLevel = { pixMap.addr(), pixMap.rowBytes() };
auto resourceProviderFlags = GrResourceProvider::Flags::kNone;
if (surfaceFlags & GrInternalSurfaceFlags::kNoPendingIO) {
resourceProviderFlags |= GrResourceProvider::Flags::kNoPendingIO;
}
return LazyInstantiationResult(resourceProvider->createTexture(
desc, budgeted, fit, mipLevel, resourceProviderFlags));
desc, budgeted, fit, mipLevel, GrResourceProvider::Flags::kNoPendingIO));
},
format, desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo, surfaceFlags, fit, budgeted);
@ -753,7 +748,7 @@ sk_sp<GrTextureProxy> GrProxyProvider::MakeFullyLazyProxy(
LazyInstantiateCallback&& callback, const GrBackendFormat& format, Renderable renderable,
GrSurfaceOrigin origin, GrPixelConfig config, const GrCaps& caps, int sampleCnt) {
GrSurfaceDesc desc;
GrInternalSurfaceFlags surfaceFlags = GrInternalSurfaceFlags::kNoPendingIO;
GrInternalSurfaceFlags surfaceFlags = GrInternalSurfaceFlags::kNone;
if (Renderable::kYes == renderable) {
desc.fFlags = kRenderTarget_GrSurfaceFlag;
if (sampleCnt > 1 && caps.usesMixedSamples()) {

View File

@ -62,15 +62,14 @@ int GrRenderTargetProxy::maxWindowRectangles(const GrCaps& caps) const {
return this->glRTFBOIDIs0() ? 0 : caps.maxWindowRectangles();
}
bool GrRenderTargetProxy::instantiate(GrResourceProvider* resourceProvider,
bool dontForceNoPendingIO) {
bool GrRenderTargetProxy::instantiate(GrResourceProvider* resourceProvider) {
if (LazyState::kNot != this->lazyInstantiationState()) {
return false;
}
static constexpr GrSurfaceDescFlags kDescFlags = kRenderTarget_GrSurfaceFlag;
if (!this->instantiateImpl(resourceProvider, fSampleCnt, fNeedsStencil, kDescFlags,
GrMipMapped::kNo, nullptr, dontForceNoPendingIO)) {
GrMipMapped::kNo, nullptr)) {
return false;
}
SkASSERT(fTarget->asRenderTarget());
@ -82,7 +81,7 @@ sk_sp<GrSurface> GrRenderTargetProxy::createSurface(GrResourceProvider* resource
static constexpr GrSurfaceDescFlags kDescFlags = kRenderTarget_GrSurfaceFlag;
sk_sp<GrSurface> surface = this->createSurfaceImpl(resourceProvider, fSampleCnt, fNeedsStencil,
kDescFlags, GrMipMapped::kNo, true);
kDescFlags, GrMipMapped::kNo);
if (!surface) {
return nullptr;
}

View File

@ -298,8 +298,8 @@ sk_sp<GrSurface> GrResourceAllocator::findSurfaceFor(const GrSurfaceProxy* proxy
proxy->priv().computeScratchKey(&key);
auto filter = [&] (const GrSurface* s) {
return !proxy->priv().requiresNoPendingIO() || !s->surfacePriv().hasPendingIO();
auto filter = [] (const GrSurface* s) {
return true;
};
sk_sp<GrSurface> surface(fFreePool.findAndRemove(key, filter));
if (surface) {

View File

@ -107,18 +107,10 @@ sk_sp<GrTextureProxy> GrSWMaskHelper::toTextureProxy(GrRecordingContext* context
return nullptr;
}
// TODO: http://skbug.com/8422: Although this fixes http://skbug.com/8351, it seems like these
// should just participate in the normal allocation process and not need the pending IO flag.
auto surfaceFlags = GrInternalSurfaceFlags::kNone;
if (!context->priv().proxyProvider()->renderingDirectly()) {
// In DDL mode, this texture proxy will be instantiated at flush time, therfore it cannot
// have pending IO.
surfaceFlags |= GrInternalSurfaceFlags::kNoPendingIO;
}
auto clearFlag = kNone_GrSurfaceFlags;
if (context->priv().caps()->shouldInitializeTextures() && fit == SkBackingFit::kApprox) {
clearFlag = kPerformInitialClear_GrSurfaceFlag;
}
return context->priv().proxyProvider()->createTextureProxy(
std::move(img), clearFlag, 1, SkBudgeted::kYes, fit, surfaceFlags);
std::move(img), clearFlag, 1, SkBudgeted::kYes, fit);
}

View File

@ -187,10 +187,8 @@ static sk_sp<GrTextureProxy> make_deferred_mask_texture_proxy(GrRecordingContext
const GrBackendFormat format =
context->priv().caps()->getBackendFormatFromColorType(kAlpha_8_SkColorType);
// MDB TODO: We're going to fill this proxy with an ASAP upload (which is out of order wrt to
// ops), so it can't have any pending IO.
return proxyProvider->createProxy(format, desc, kTopLeft_GrSurfaceOrigin, fit, SkBudgeted::kYes,
GrInternalSurfaceFlags::kNoPendingIO);
return proxyProvider->createProxy(format, desc, kTopLeft_GrSurfaceOrigin, fit,
SkBudgeted::kYes);
}
namespace {

View File

@ -127,8 +127,7 @@ bool GrSurfaceProxyPriv::AttachStencilIfNeeded(GrResourceProvider* resourceProvi
sk_sp<GrSurface> GrSurfaceProxy::createSurfaceImpl(GrResourceProvider* resourceProvider,
int sampleCnt, bool needsStencil,
GrSurfaceDescFlags descFlags,
GrMipMapped mipMapped,
bool forceNoPendingIO) const {
GrMipMapped mipMapped) const {
SkASSERT(GrSurfaceProxy::LazyState::kNot == this->lazyInstantiationState());
SkASSERT(!fTarget);
GrSurfaceDesc desc;
@ -141,12 +140,9 @@ sk_sp<GrSurface> GrSurfaceProxy::createSurfaceImpl(GrResourceProvider* resourceP
desc.fConfig = fConfig;
desc.fSampleCnt = sampleCnt;
GrResourceProvider::Flags resourceProviderFlags = GrResourceProvider::Flags::kNone;
if ((fSurfaceFlags & GrInternalSurfaceFlags::kNoPendingIO) || forceNoPendingIO) {
// The explicit resource allocator requires that any resources it pulls out of the
// cache have no pending IO.
resourceProviderFlags = GrResourceProvider::Flags::kNoPendingIO;
}
// The explicit resource allocator requires that any resources it pulls out of the
// cache have no pending IO.
GrResourceProvider::Flags resourceProviderFlags = GrResourceProvider::Flags::kNoPendingIO;
sk_sp<GrSurface> surface;
if (GrMipMapped::kYes == mipMapped) {
@ -228,8 +224,7 @@ void GrSurfaceProxy::assign(sk_sp<GrSurface> surface) {
bool GrSurfaceProxy::instantiateImpl(GrResourceProvider* resourceProvider, int sampleCnt,
bool needsStencil, GrSurfaceDescFlags descFlags,
GrMipMapped mipMapped, const GrUniqueKey* uniqueKey,
bool dontForceNoPendingIO) {
GrMipMapped mipMapped, const GrUniqueKey* uniqueKey) {
SkASSERT(LazyState::kNot == this->lazyInstantiationState());
if (fTarget) {
if (uniqueKey && uniqueKey->isValid()) {
@ -239,7 +234,7 @@ bool GrSurfaceProxy::instantiateImpl(GrResourceProvider* resourceProvider, int s
}
sk_sp<GrSurface> surface = this->createSurfaceImpl(resourceProvider, sampleCnt, needsStencil,
descFlags, mipMapped, !dontForceNoPendingIO);
descFlags, mipMapped);
if (!surface) {
return false;
}
@ -499,11 +494,6 @@ bool GrSurfaceProxyPriv::doLazyInstantiation(GrResourceProvider* resourceProvide
void GrSurfaceProxy::validateSurface(const GrSurface* surface) {
SkASSERT(surface->config() == fConfig);
// Assert the flags are the same except for kNoPendingIO which is not passed onto the GrSurface.
GrInternalSurfaceFlags proxyFlags = fSurfaceFlags & ~GrInternalSurfaceFlags::kNoPendingIO;
GrInternalSurfaceFlags surfaceFlags = surface->surfacePriv().flags();
SkASSERT((proxyFlags & GrInternalSurfaceFlags::kSurfaceMask) ==
(surfaceFlags & GrInternalSurfaceFlags::kSurfaceMask));
this->onValidateSurface(surface);
}
#endif

View File

@ -36,10 +36,6 @@ public:
// Assign this proxy the provided GrSurface as its backing surface
void assign(sk_sp<GrSurface> surface) { fProxy->assign(std::move(surface)); }
bool requiresNoPendingIO() const {
return fProxy->fSurfaceFlags & GrInternalSurfaceFlags::kNoPendingIO;
}
// Don't abuse this call!!!!!!!
bool isExact() const { return SkBackingFit::kExact == fProxy->fFit; }

View File

@ -76,15 +76,13 @@ GrTextureProxy::~GrTextureProxy() {
}
}
bool GrTextureProxy::instantiate(GrResourceProvider* resourceProvider,
bool dontForceNoPendingIO) {
bool GrTextureProxy::instantiate(GrResourceProvider* resourceProvider) {
if (LazyState::kNot != this->lazyInstantiationState()) {
return false;
}
if (!this->instantiateImpl(resourceProvider, 1, /* needsStencil = */ false,
kNone_GrSurfaceFlags, fMipMapped,
fUniqueKey.isValid() ? &fUniqueKey : nullptr,
dontForceNoPendingIO)) {
fUniqueKey.isValid() ? &fUniqueKey : nullptr)) {
return false;
}
@ -97,7 +95,7 @@ sk_sp<GrSurface> GrTextureProxy::createSurface(GrResourceProvider* resourceProvi
sk_sp<GrSurface> surface = this->createSurfaceImpl(resourceProvider, 1,
/* needsStencil = */ false,
kNone_GrSurfaceFlags,
fMipMapped, true);
fMipMapped);
if (!surface) {
return nullptr;
}

View File

@ -75,8 +75,7 @@ size_t GrTextureRenderTargetProxy::onUninstantiatedGpuMemorySize() const {
!this->priv().isExact());
}
bool GrTextureRenderTargetProxy::instantiate(GrResourceProvider* resourceProvider,
bool dontForceNoPendingIO) {
bool GrTextureRenderTargetProxy::instantiate(GrResourceProvider* resourceProvider) {
if (LazyState::kNot != this->lazyInstantiationState()) {
return false;
}
@ -85,8 +84,7 @@ bool GrTextureRenderTargetProxy::instantiate(GrResourceProvider* resourceProvide
const GrUniqueKey& key = this->getUniqueKey();
if (!this->instantiateImpl(resourceProvider, this->numStencilSamples(), this->needsStencil(),
kDescFlags, this->mipMapped(), key.isValid() ? &key : nullptr,
dontForceNoPendingIO)) {
kDescFlags, this->mipMapped(), key.isValid() ? &key : nullptr)) {
return false;
}
if (key.isValid()) {
@ -105,7 +103,7 @@ sk_sp<GrSurface> GrTextureRenderTargetProxy::createSurface(
sk_sp<GrSurface> surface = this->createSurfaceImpl(resourceProvider, this->numStencilSamples(),
this->needsStencil(), kDescFlags,
this->mipMapped(), true);
this->mipMapped());
if (!surface) {
return nullptr;
}

View File

@ -40,7 +40,7 @@ private:
// Wrapped version
GrTextureRenderTargetProxy(sk_sp<GrSurface>, GrSurfaceOrigin);
bool instantiate(GrResourceProvider*, bool dontForceNoPendingIO = false) override;
bool instantiate(GrResourceProvider*) override;
sk_sp<GrSurface> createSurface(GrResourceProvider*) const override;
size_t onUninstantiatedGpuMemorySize() const override;

View File

@ -203,8 +203,7 @@ static sk_sp<GrTextureProxy> create_proxy(GrProxyProvider* proxyProvider) {
SkBitmap srcBM = create_bm();
sk_sp<SkImage> srcImage(SkImage::MakeFromBitmap(srcBM));
return proxyProvider->createTextureProxy(srcImage, kNone_GrSurfaceFlags, 1,
SkBudgeted::kYes, SkBackingFit::kExact,
GrInternalSurfaceFlags::kNoPendingIO);
SkBudgeted::kYes, SkBackingFit::kExact);
}
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageFilterCache_ImageBackedGPU, reporter, ctxInfo) {

View File

@ -173,7 +173,7 @@ DEF_GPUTEST(OpChainTest, reporter, /*ctxInfo*/) {
auto proxy = context->priv().proxyProvider()->createProxy(
format, desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo, SkBackingFit::kExact,
SkBudgeted::kNo, GrInternalSurfaceFlags::kNoPendingIO);
SkBudgeted::kNo, GrInternalSurfaceFlags::kNone);
SkASSERT(proxy);
proxy->instantiate(context->priv().resourceProvider());
int result[result_width()];

View File

@ -307,8 +307,7 @@ bool init_test_textures(GrResourceProvider* resourceProvider,
SkPixmap pixmap(ii, rgbaData.get(), ii.minRowBytes());
sk_sp<SkImage> img = SkImage::MakeRasterCopy(pixmap);
proxies[0] = proxyProvider->createTextureProxy(img, kNone_GrSurfaceFlags, 1,
SkBudgeted::kYes, SkBackingFit::kExact,
GrInternalSurfaceFlags::kNoPendingIO);
SkBudgeted::kYes, SkBackingFit::kExact);
proxies[0]->instantiate(resourceProvider);
}
@ -326,8 +325,7 @@ bool init_test_textures(GrResourceProvider* resourceProvider,
SkPixmap pixmap(ii, alphaData.get(), ii.minRowBytes());
sk_sp<SkImage> img = SkImage::MakeRasterCopy(pixmap);
proxies[1] = proxyProvider->createTextureProxy(img, kNone_GrSurfaceFlags, 1,
SkBudgeted::kYes, SkBackingFit::kExact,
GrInternalSurfaceFlags::kNoPendingIO);
SkBudgeted::kYes, SkBackingFit::kExact);
proxies[1]->instantiate(resourceProvider);
}

View File

@ -70,8 +70,7 @@ static sk_sp<GrTextureProxy> make_deferred(GrProxyProvider* proxyProvider, const
const GrBackendFormat format = caps->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
return proxyProvider->createProxy(format, desc, kBottomLeft_GrSurfaceOrigin,
SkBackingFit::kApprox, SkBudgeted::kYes,
GrInternalSurfaceFlags::kNoPendingIO);
SkBackingFit::kApprox, SkBudgeted::kYes);
}
static sk_sp<GrTextureProxy> make_wrapped(GrProxyProvider* proxyProvider, const GrCaps* caps) {

View File

@ -46,7 +46,7 @@ static sk_sp<GrTextureProxy> deferred_tex(skiatest::Reporter* reporter, GrContex
sk_sp<GrTextureProxy> proxy =
proxyProvider->createProxy(format, desc, kBottomLeft_GrSurfaceOrigin, fit,
SkBudgeted::kYes, GrInternalSurfaceFlags::kNoPendingIO);
SkBudgeted::kYes);
// Only budgeted & wrapped external proxies get to carry uniqueKeys
REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
return proxy;
@ -60,7 +60,7 @@ static sk_sp<GrTextureProxy> deferred_texRT(skiatest::Reporter* reporter, GrCont
sk_sp<GrTextureProxy> proxy =
proxyProvider->createProxy(format, desc, kBottomLeft_GrSurfaceOrigin, fit,
SkBudgeted::kYes, GrInternalSurfaceFlags::kNoPendingIO);
SkBudgeted::kYes);
// Only budgeted & wrapped external proxies get to carry uniqueKeys
REPORTER_ASSERT(reporter, !proxy->getUniqueKey().isValid());
return proxy;

View File

@ -532,8 +532,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WritePixelsPendingIO, reporter, ctxInfo) {
context->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
sk_sp<GrTextureProxy> temp = proxyProvider->createProxy(
format, desc, kTopLeft_GrSurfaceOrigin, SkBackingFit::kApprox, SkBudgeted::kYes,
GrInternalSurfaceFlags::kNoPendingIO);
format, desc, kTopLeft_GrSurfaceOrigin, SkBackingFit::kApprox, SkBudgeted::kYes);
temp->instantiate(context->priv().resourceProvider());
}