Add more optional debugging printouts for resource allocation

Change-Id: I84e9d2cc8862d366fab3f9142fee5b8ed981bed7
Reviewed-on: https://skia-review.googlesource.com/143705
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2018-07-27 07:18:06 -04:00 committed by Skia Commit-Bot
parent 2739ab0986
commit da1be46e24
2 changed files with 33 additions and 0 deletions

View File

@ -18,6 +18,17 @@
#include "GrTextureProxy.h" #include "GrTextureProxy.h"
#include "GrUninstantiateProxyTracker.h" #include "GrUninstantiateProxyTracker.h"
#if GR_TRACK_INTERVAL_CREATION
uint32_t GrResourceAllocator::Interval::CreateUniqueID() {
static int32_t gUniqueID = SK_InvalidUniqueID;
uint32_t id;
do {
id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1);
} while (id == SK_InvalidUniqueID);
return id;
}
#endif
void GrResourceAllocator::Interval::assign(sk_sp<GrSurface> s) { void GrResourceAllocator::Interval::assign(sk_sp<GrSurface> s) {
SkASSERT(!fAssignedSurface); SkASSERT(!fAssignedSurface);
fAssignedSurface = s; fAssignedSurface = s;

View File

@ -22,6 +22,9 @@ class GrUninstantiateProxyTracker;
// Print out explicit allocation information // Print out explicit allocation information
#define GR_ALLOCATION_SPEW 0 #define GR_ALLOCATION_SPEW 0
// Print out information about interval creation
#define GR_TRACK_INTERVAL_CREATION 0
/* /*
* The ResourceAllocator explicitly distributes GPU resources at flush time. It operates by * The ResourceAllocator explicitly distributes GPU resources at flush time. It operates by
* being given the usage intervals of the various proxies. It keeps these intervals in a singly * being given the usage intervals of the various proxies. It keeps these intervals in a singly
@ -112,6 +115,11 @@ private:
, fEnd(end) , fEnd(end)
, fNext(nullptr) { , fNext(nullptr) {
SkASSERT(proxy); SkASSERT(proxy);
#if GR_TRACK_INTERVAL_CREATION
fUniqueID = CreateUniqueID();
SkDebugf("New intvl %d: proxyID: %d [ %d, %d ]\n",
fUniqueID, proxy->uniqueID().asUInt(), start, end);
#endif
} }
void resetTo(GrSurfaceProxy* proxy, unsigned int start, unsigned int end) { void resetTo(GrSurfaceProxy* proxy, unsigned int start, unsigned int end) {
@ -122,6 +130,11 @@ private:
fStart = start; fStart = start;
fEnd = end; fEnd = end;
fNext = nullptr; fNext = nullptr;
#if GR_TRACK_INTERVAL_CREATION
fUniqueID = CreateUniqueID();
SkDebugf("New intvl %d: proxyID: %d [ %d, %d ]\n",
fUniqueID, proxy->uniqueID().asUInt(), start, end);
#endif
} }
~Interval() { ~Interval() {
@ -140,6 +153,9 @@ private:
void extendEnd(unsigned int newEnd) { void extendEnd(unsigned int newEnd) {
if (newEnd > fEnd) { if (newEnd > fEnd) {
fEnd = newEnd; fEnd = newEnd;
#if GR_TRACK_INTERVAL_CREATION
SkDebugf("intvl %d: extending from %d to %d\n", fUniqueID, fEnd, newEnd);
#endif
} }
} }
@ -160,6 +176,12 @@ private:
unsigned int fStart; unsigned int fStart;
unsigned int fEnd; unsigned int fEnd;
Interval* fNext; Interval* fNext;
#if GR_TRACK_INTERVAL_CREATION
uint32_t fUniqueID;
uint32_t CreateUniqueID();
#endif
}; };
class IntervalList { class IntervalList {