aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrBufferAllocPool.h
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2015-06-23 12:36:12 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-06-23 12:36:12 -0700
commitb607767703ff7898611cf88c1218d5d69535e984 (patch)
tree35b366932bc31df7a6a468261b704e1368bbdfb2 /src/gpu/GrBufferAllocPool.h
parente582a5a89102dde5c5bda4654cb07eca1da8efcd (diff)
Revert of Refactor GrBufferAllocPools to use resource cache (patchset #15 id:280001 of https://codereview.chromium.org/1139753002/)
Reason for revert: Will reland after Chromium branch Original issue's description: > Refactor GrBufferAllocPools to use resource cache > > Committed: https://skia.googlesource.com/skia/+/e935f1a0e2351373c33600b8388492ce1218014a TBR=bsalomon@google.com,joshualitt@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review URL: https://codereview.chromium.org/1204773003
Diffstat (limited to 'src/gpu/GrBufferAllocPool.h')
-rw-r--r--src/gpu/GrBufferAllocPool.h32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/gpu/GrBufferAllocPool.h b/src/gpu/GrBufferAllocPool.h
index bbcb8a5d7c..cd5d1971da 100644
--- a/src/gpu/GrBufferAllocPool.h
+++ b/src/gpu/GrBufferAllocPool.h
@@ -64,12 +64,16 @@ protected:
* @param bufferSize The minimum size of created buffers.
* This value will be clamped to some
* reasonable minimum.
+ * @param preallocBufferCnt The pool will allocate this number of
+ * buffers at bufferSize and keep them until it
+ * is destroyed.
*/
GrBufferAllocPool(GrGpu* gpu,
BufferType bufferType,
- size_t bufferSize = 0);
+ size_t bufferSize = 0,
+ int preallocBufferCnt = 0);
- virtual ~GrBufferAllocPool();
+ virtual ~GrBufferAllocPool();
/**
* Returns a block of memory to hold data. A buffer designated to hold the
@@ -95,7 +99,7 @@ protected:
const GrGeometryBuffer** buffer,
size_t* offset);
- GrGeometryBuffer* getBuffer(size_t size);
+ GrGeometryBuffer* createBuffer(size_t size);
private:
struct BufferBlock {
@@ -105,7 +109,6 @@ private:
bool createBlock(size_t requestSize);
void destroyBlock();
- void deleteBlocks();
void flushCpuData(const BufferBlock& block, size_t flushSize);
#ifdef SK_DEBUG
void validate(bool unusedBlockAllowed = false) const;
@@ -114,10 +117,15 @@ private:
size_t fBytesInUse;
GrGpu* fGpu;
+ SkTDArray<GrGeometryBuffer*> fPreallocBuffers;
size_t fMinBlockSize;
BufferType fBufferType;
SkTArray<BufferBlock> fBlocks;
+ int fPreallocBuffersInUse;
+ // We attempt to cycle through the preallocated buffers rather than
+ // always starting from the first.
+ int fPreallocBufferStartIdx;
SkAutoMalloc fCpuData;
void* fBufferPtr;
size_t fGeometryBufferMapThreshold;
@@ -134,8 +142,13 @@ public:
* Constructor
*
* @param gpu The GrGpu used to create the vertex buffers.
+ * @param bufferSize The minimum size of created VBs. This value
+ * will be clamped to some reasonable minimum.
+ * @param preallocBufferCnt The pool will allocate this number of VBs at
+ * bufferSize and keep them until it is
+ * destroyed.
*/
- GrVertexBufferAllocPool(GrGpu* gpu);
+ GrVertexBufferAllocPool(GrGpu* gpu, size_t bufferSize = 0, int preallocBufferCnt = 0);
/**
* Returns a block of memory to hold vertices. A buffer designated to hold
@@ -178,8 +191,15 @@ public:
* Constructor
*
* @param gpu The GrGpu used to create the index buffers.
+ * @param bufferSize The minimum size of created IBs. This value
+ * will be clamped to some reasonable minimum.
+ * @param preallocBufferCnt The pool will allocate this number of VBs at
+ * bufferSize and keep them until it is
+ * destroyed.
*/
- GrIndexBufferAllocPool(GrGpu* gpu);
+ GrIndexBufferAllocPool(GrGpu* gpu,
+ size_t bufferSize = 0,
+ int preallocBufferCnt = 0);
/**
* Returns a block of memory to hold indices. A buffer designated to hold