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>
This commit is contained in:
parent
d27392f8a4
commit
d375dbf155
@ -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");
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user