aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrBufferAllocPool.h
diff options
context:
space:
mode:
authorGravatar cdalton <cdalton@nvidia.com>2016-03-25 12:15:03 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-25 12:15:03 -0700
commit397536cabe12a9936659870dd220c869789424ba (patch)
tree0012d79d6f21884a38b7cfe8ecb016a28bc34b70 /src/gpu/GrBufferAllocPool.h
parentdd26a3ba0acdccdbd2f04b9020fdce59e1ed7609 (diff)
Consolidate GPU buffer implementations
Consolidates all the different buffer implementations into a single GrBuffer class. This will allow us to add new buffer types, use DSA in OpenGL, track buffer bindings by unique ID, cache buffers without respect to the type of data they have been used for previously, etc. This change is strictly a refactor; it introduces no change in functionality. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1825393002 Committed: https://skia.googlesource.com/skia/+/8b1bff29675afd25843439eade634a57f68fe16f Review URL: https://codereview.chromium.org/1825393002
Diffstat (limited to 'src/gpu/GrBufferAllocPool.h')
-rw-r--r--src/gpu/GrBufferAllocPool.h35
1 files changed, 11 insertions, 24 deletions
diff --git a/src/gpu/GrBufferAllocPool.h b/src/gpu/GrBufferAllocPool.h
index a3d8e45364..071b00b064 100644
--- a/src/gpu/GrBufferAllocPool.h
+++ b/src/gpu/GrBufferAllocPool.h
@@ -11,8 +11,9 @@
#include "SkTArray.h"
#include "SkTDArray.h"
#include "SkTypes.h"
+#include "GrTypesPriv.h"
-class GrGeometryBuffer;
+class GrBuffer;
class GrGpu;
/**
@@ -47,16 +48,6 @@ public:
protected:
/**
- * Used to determine what type of buffers to create. We could make the
- * createBuffer a virtual except that we want to use it in the cons for
- * pre-allocated buffers.
- */
- enum BufferType {
- kVertex_BufferType,
- kIndex_BufferType,
- };
-
- /**
* Constructor
*
* @param gpu The GrGpu used to create the buffers.
@@ -66,7 +57,7 @@ protected:
* reasonable minimum.
*/
GrBufferAllocPool(GrGpu* gpu,
- BufferType bufferType,
+ GrBufferType bufferType,
size_t bufferSize = 0);
virtual ~GrBufferAllocPool();
@@ -92,15 +83,15 @@ protected:
*/
void* makeSpace(size_t size,
size_t alignment,
- const GrGeometryBuffer** buffer,
+ const GrBuffer** buffer,
size_t* offset);
- GrGeometryBuffer* getBuffer(size_t size);
+ GrBuffer* getBuffer(size_t size);
private:
struct BufferBlock {
- size_t fBytesFree;
- GrGeometryBuffer* fBuffer;
+ size_t fBytesFree;
+ GrBuffer* fBuffer;
};
bool createBlock(size_t requestSize);
@@ -115,16 +106,14 @@ private:
GrGpu* fGpu;
size_t fMinBlockSize;
- BufferType fBufferType;
+ GrBufferType fBufferType;
SkTArray<BufferBlock> fBlocks;
void* fCpuData;
void* fBufferPtr;
- size_t fGeometryBufferMapThreshold;
+ size_t fBufferMapThreshold;
};
-class GrVertexBuffer;
-
/**
* A GrBufferAllocPool of vertex buffers
*/
@@ -160,15 +149,13 @@ public:
*/
void* makeSpace(size_t vertexSize,
int vertexCount,
- const GrVertexBuffer** buffer,
+ const GrBuffer** buffer,
int* startVertex);
private:
typedef GrBufferAllocPool INHERITED;
};
-class GrIndexBuffer;
-
/**
* A GrBufferAllocPool of index buffers
*/
@@ -200,7 +187,7 @@ public:
* @return pointer to first index.
*/
void* makeSpace(int indexCount,
- const GrIndexBuffer** buffer,
+ const GrBuffer** buffer,
int* startIndex);
private: