Bypass interval tracking and assignment of read-only texures in GrResourceAllocator.

Bug: skia:8509

Change-Id: Idecf3a5335945c9ff21f27cd3f7887125214d02d
Reviewed-on: https://skia-review.googlesource.com/c/174592
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Brian Salomon 2018-12-05 15:09:19 -05:00 committed by Skia Commit-Bot
parent 796693af3c
commit 1b04794234
2 changed files with 44 additions and 31 deletions

View File

@ -367,7 +367,8 @@ public:
/**
* The pixel values of this proxy's surface cannot be modified (e.g. doesn't support write
* pixels or MIP map level regen),
* pixels or MIP map level regen). Read-only proxies also bypass interval tracking and
* assignment in GrResourceAllocator.
*/
bool readOnly() const { return fSurfaceFlags & GrInternalSurfaceFlags::kReadOnly; }

View File

@ -60,16 +60,26 @@ void GrResourceAllocator::addInterval(GrSurfaceProxy* proxy, unsigned int start,
SkASSERT(start <= end);
SkASSERT(!fAssigned); // We shouldn't be adding any intervals after (or during) assignment
// If a proxy is read only it must refer to a texture with specific content that cannot be
// recycled. We don't need to assign a texture to it and no other proxy can be instantiated
// with the same texture.
if (proxy->readOnly()) {
// Since we aren't going to add an interval we won't revisit this proxy in assign(). So it
// must already be instantiated or it must be a lazy proxy that we will instantiate below.
SkASSERT(proxy->isInstantiated() ||
GrSurfaceProxy::LazyState::kNot != proxy->lazyInstantiationState());
} else {
if (Interval* intvl = fIntvlHash.find(proxy->uniqueID().asUInt())) {
// Revise the interval for an existing use
#ifdef SK_DEBUG
if (0 == start && 0 == end) {
// This interval is for the initial upload to a deferred proxy. Due to the vagaries
// of how deferred proxies are collected they can appear as uploads multiple times in a
// single opLists' list and as uploads in several opLists.
// of how deferred proxies are collected they can appear as uploads multiple times
// in a single opLists' list and as uploads in several opLists.
SkASSERT(0 == intvl->start());
} else if (isDirectDstRead) {
// Direct reads from the render target itself should occur w/in the existing interval
// Direct reads from the render target itself should occur w/in the existing
// interval
SkASSERT(intvl->start() <= start && intvl->end() >= end);
} else {
SkASSERT(intvl->end() <= start && intvl->end() <= end);
@ -78,7 +88,6 @@ void GrResourceAllocator::addInterval(GrSurfaceProxy* proxy, unsigned int start,
intvl->extendEnd(end);
return;
}
Interval* newIntvl;
if (fFreeIntervalList) {
newIntvl = fFreeIntervalList;
@ -91,8 +100,11 @@ void GrResourceAllocator::addInterval(GrSurfaceProxy* proxy, unsigned int start,
fIntvlList.insertByIncreasingStart(newIntvl);
fIntvlHash.add(newIntvl);
}
if (!fResourceProvider->explicitlyAllocateGPUResources()) {
// Because readOnly proxies do not get a usage interval we must instantiate them here (since it
// won't occur in GrResourceAllocator::assign)
if (proxy->readOnly() || !fResourceProvider->explicitlyAllocateGPUResources()) {
// FIXME: remove this once we can do the lazy instantiation from assign instead.
if (GrSurfaceProxy::LazyState::kNot != proxy->lazyInstantiationState()) {
if (proxy->priv().doLazyInstantiation(fResourceProvider)) {