diff options
author | Robert Phillips <robertphillips@google.com> | 2017-09-14 12:45:25 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-09-14 18:42:51 +0000 |
commit | d375dbf1557de71ce8e348e6002463f076cc3967 (patch) | |
tree | 7987175183702bb5e8839c272bc4fca37932af02 /src | |
parent | d27392f8a43c5efe2fdb40387aa5c03e611dbea4 (diff) |
Land scaffolding for explicit MDB resource allocation
Change-Id: I1cb30b50068e99181788181683e82e2421d0038a
Reviewed-on: https://skia-review.googlesource.com/46701
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrDrawingManager.cpp | 10 | ||||
-rw-r--r-- | src/gpu/GrOpList.h | 6 | ||||
-rw-r--r-- | src/gpu/GrRenderTargetOpList.cpp | 20 | ||||
-rw-r--r-- | src/gpu/GrRenderTargetOpList.h | 2 | ||||
-rw-r--r-- | src/gpu/GrResourceAllocator.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrResourceAllocator.h | 2 | ||||
-rw-r--r-- | src/gpu/GrTextureOpList.cpp | 20 | ||||
-rw-r--r-- | src/gpu/GrTextureOpList.h | 2 |
8 files changed, 61 insertions, 3 deletions
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp index 8d9e238f95..84a48b441f 100644 --- a/src/gpu/GrDrawingManager.cpp +++ b/src/gpu/GrDrawingManager.cpp @@ -15,6 +15,7 @@ #include "GrRenderTargetContext.h" #include "GrPathRenderingRenderTargetContext.h" #include "GrRenderTargetProxy.h" +#include "GrResourceAllocator.h" #include "GrResourceProvider.h" #include "GrSoftwarePathRenderer.h" #include "GrSurfaceProxyPriv.h" @@ -168,6 +169,15 @@ GrSemaphoresSubmitted GrDrawingManager::internalFlush(GrSurfaceProxy*, } #endif +#ifdef MDB_ALLOC_RESOURCES + GrResourceAllocator alloc(fContext->resourceProvider()); + for (int i = 0; i < fOpLists.count(); ++i) { + fOpLists[i]->gatherProxyIntervals(&alloc); + } + + alloc.assign(); +#endif + for (int i = 0; i < fOpLists.count(); ++i) { if (!fOpLists[i]->instantiate(fContext->resourceProvider())) { SkDebugf("OpList failed to instantiate.\n"); diff --git a/src/gpu/GrOpList.h b/src/gpu/GrOpList.h index c801f96375..71a4b4c264 100644 --- a/src/gpu/GrOpList.h +++ b/src/gpu/GrOpList.h @@ -25,6 +25,7 @@ class GrCaps; class GrOpFlushState; class GrPrepareCallback; class GrRenderTargetOpList; +class GrResourceAllocator; class GrResourceProvider; class GrSurfaceProxy; class GrTextureProxy; @@ -113,7 +114,10 @@ protected: GrLoadOp fStencilLoadOp = GrLoadOp::kLoad; private: - friend class GrDrawingManager; // for resetFlag & TopoSortTraits + friend class GrDrawingManager; // for resetFlag, TopoSortTraits & gatherProxyIntervals + + // Feed proxy usage intervals to the GrResourceAllocator class + virtual void gatherProxyIntervals(GrResourceAllocator*) const = 0; static uint32_t CreateUniqueID(); diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp index a53a84ca5f..15cb4f16c6 100644 --- a/src/gpu/GrRenderTargetOpList.cpp +++ b/src/gpu/GrRenderTargetOpList.cpp @@ -12,6 +12,7 @@ #include "GrGpuCommandBuffer.h" #include "GrRect.h" #include "GrRenderTargetContext.h" +#include "GrResourceAllocator.h" #include "instanced/InstancedRendering.h" #include "ops/GrClearOp.h" #include "ops/GrCopySurfaceOp.h" @@ -252,6 +253,25 @@ bool GrRenderTargetOpList::copySurface(const GrCaps& caps, return true; } +void GrRenderTargetOpList::gatherProxyIntervals(GrResourceAllocator* alloc) const { + unsigned int cur = alloc->numOps(); + + // Add the interval for all the writes to this opList's target + alloc->addInterval(fTarget.get(), cur, cur+fRecordedOps.count()-1); + + auto gather = [ alloc ] (GrSurfaceProxy* p) { + alloc->addInterval(p); + }; + for (int i = 0; i < fRecordedOps.count(); ++i) { + SkASSERT(alloc->curOp() == cur+i); + + const GrOp* op = fRecordedOps[i].fOp.get(); // only diff from the GrTextureOpList version + op->visitProxies(gather); + + alloc->incOps(); + } +} + static inline bool can_reorder(const SkRect& a, const SkRect& b) { return !GrRectsOverlap(a, b); } bool GrRenderTargetOpList::combineIfPossible(const RecordedOp& a, GrOp* b, diff --git a/src/gpu/GrRenderTargetOpList.h b/src/gpu/GrRenderTargetOpList.h index 55fc904839..cf513b7e4d 100644 --- a/src/gpu/GrRenderTargetOpList.h +++ b/src/gpu/GrRenderTargetOpList.h @@ -141,6 +141,8 @@ private: GrAppliedClip* fAppliedClip; }; + void gatherProxyIntervals(GrResourceAllocator*) const override; + void recordOp(std::unique_ptr<GrOp>, const GrCaps& caps, GrAppliedClip* = nullptr, const DstProxy* = nullptr); diff --git a/src/gpu/GrResourceAllocator.cpp b/src/gpu/GrResourceAllocator.cpp index e5d6dbf360..ba62854a3a 100644 --- a/src/gpu/GrResourceAllocator.cpp +++ b/src/gpu/GrResourceAllocator.cpp @@ -88,7 +88,7 @@ void GrResourceAllocator::freeUpSurface(GrSurface* surface) { // First try to reuse one of the recently allocated/used GrSurfaces in the free pool. // If we can't find a useable one, create a new one. // TODO: handle being overbudget -sk_sp<GrSurface> GrResourceAllocator::findSurfaceFor(GrSurfaceProxy* proxy) { +sk_sp<GrSurface> GrResourceAllocator::findSurfaceFor(const GrSurfaceProxy* proxy) { // First look in the free pool GrScratchKey key; diff --git a/src/gpu/GrResourceAllocator.h b/src/gpu/GrResourceAllocator.h index bd0c690a58..966359c85e 100644 --- a/src/gpu/GrResourceAllocator.h +++ b/src/gpu/GrResourceAllocator.h @@ -62,7 +62,7 @@ private: // These two methods wrap the interactions with the free pool void freeUpSurface(GrSurface* surface); - sk_sp<GrSurface> findSurfaceFor(GrSurfaceProxy* proxy); + sk_sp<GrSurface> findSurfaceFor(const GrSurfaceProxy* proxy); struct FreePoolTraits { static const GrScratchKey& GetKey(const GrSurface& s) { diff --git a/src/gpu/GrTextureOpList.cpp b/src/gpu/GrTextureOpList.cpp index e5fbb20bf2..97371d598f 100644 --- a/src/gpu/GrTextureOpList.cpp +++ b/src/gpu/GrTextureOpList.cpp @@ -9,6 +9,7 @@ #include "GrAuditTrail.h" #include "GrGpu.h" +#include "GrResourceAllocator.h" #include "GrTextureProxy.h" #include "SkStringUtils.h" #include "ops/GrCopySurfaceOp.h" @@ -108,6 +109,25 @@ bool GrTextureOpList::copySurface(const GrCaps& caps, return true; } +void GrTextureOpList::gatherProxyIntervals(GrResourceAllocator* alloc) const { + unsigned int cur = alloc->numOps(); + + // Add the interval for all the writes to this opList's target + alloc->addInterval(fTarget.get(), cur, cur+fRecordedOps.count()-1); + + auto gather = [ alloc ] (GrSurfaceProxy* p) { + alloc->addInterval(p); + }; + for (int i = 0; i < fRecordedOps.count(); ++i) { + SkASSERT(alloc->curOp() == cur+i); + + const GrOp* op = fRecordedOps[i].get(); // only diff from the GrRenderTargetOpList version + op->visitProxies(gather); + + alloc->incOps(); + } +} + void GrTextureOpList::recordOp(std::unique_ptr<GrOp> op) { SkASSERT(fTarget.get()); // A closed GrOpList should never receive new/more ops diff --git a/src/gpu/GrTextureOpList.h b/src/gpu/GrTextureOpList.h index 5f1e331051..0d00c9479a 100644 --- a/src/gpu/GrTextureOpList.h +++ b/src/gpu/GrTextureOpList.h @@ -64,6 +64,8 @@ public: SkDEBUGCODE(int numOps() const override { return fRecordedOps.count(); }) private: + void gatherProxyIntervals(GrResourceAllocator*) const override; + void recordOp(std::unique_ptr<GrOp>); SkSTArray<2, std::unique_ptr<GrOp>, true> fRecordedOps; |