Isolate GrBufferAllocPools inside GrBatchTarget
This CL refactors the location of the GrBufferAllocPools so they reside entirely inside the GrBatchTarget. This is in preparation for making them use scratch resources. Review URL: https://codereview.chromium.org/1131553002
This commit is contained in:
parent
0acd0d33fd
commit
e40d397259
@ -13,7 +13,6 @@
|
||||
#if SK_SUPPORT_GPU
|
||||
|
||||
#include "GrBatchTarget.h"
|
||||
#include "GrBufferAllocPool.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrPathUtils.h"
|
||||
#include "GrTest.h"
|
||||
|
@ -13,7 +13,6 @@
|
||||
#if SK_SUPPORT_GPU
|
||||
|
||||
#include "GrBatchTarget.h"
|
||||
#include "GrBufferAllocPool.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrDefaultGeoProcFactory.h"
|
||||
#include "GrPathUtils.h"
|
||||
|
@ -25,7 +25,6 @@ class GrFragmentProcessor;
|
||||
class GrGpu;
|
||||
class GrGpuTraceMarker;
|
||||
class GrIndexBuffer;
|
||||
class GrIndexBufferAllocPool;
|
||||
class GrLayerCache;
|
||||
class GrOvalRenderer;
|
||||
class GrPath;
|
||||
@ -39,7 +38,6 @@ class GrTextBlobCache;
|
||||
class GrTextContext;
|
||||
class GrTextureParams;
|
||||
class GrVertexBuffer;
|
||||
class GrVertexBufferAllocPool;
|
||||
class GrStrokeInfo;
|
||||
class GrSoftwarePathRenderer;
|
||||
class SkGpuDevice;
|
||||
@ -596,8 +594,6 @@ private:
|
||||
GrPathRendererChain* fPathRendererChain;
|
||||
GrSoftwarePathRenderer* fSoftwarePathRenderer;
|
||||
|
||||
GrVertexBufferAllocPool* fDrawBufferVBAllocPool;
|
||||
GrIndexBufferAllocPool* fDrawBufferIBAllocPool;
|
||||
GrDrawTarget* fDrawBuffer;
|
||||
|
||||
// Set by OverbudgetCB() to request that GrContext flush before exiting a draw.
|
||||
@ -626,8 +622,6 @@ private:
|
||||
void initMockContext();
|
||||
void initCommon();
|
||||
|
||||
void setupDrawBuffer();
|
||||
|
||||
class AutoCheckFlush;
|
||||
// Sets the paint and returns the target to draw into.
|
||||
GrDrawTarget* prepareToDraw(GrPipelineBuilder*,
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include "GrBatch.h"
|
||||
#include "GrBatchTarget.h"
|
||||
#include "GrBufferAllocPool.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrDrawTargetCaps.h"
|
||||
#include "GrGeometryProcessor.h"
|
||||
@ -795,11 +794,8 @@ public:
|
||||
int firstVertex;
|
||||
|
||||
size_t vertexStride = quadProcessor->getVertexStride();
|
||||
void *vertices = batchTarget->vertexPool()->makeSpace(vertexStride,
|
||||
vertexCount,
|
||||
&vertexBuffer,
|
||||
&firstVertex);
|
||||
|
||||
void *vertices = batchTarget->makeVertSpace(vertexStride, vertexCount,
|
||||
&vertexBuffer, &firstVertex);
|
||||
if (!vertices) {
|
||||
SkDebugf("Could not allocate vertices\n");
|
||||
return;
|
||||
@ -808,17 +804,13 @@ public:
|
||||
const GrIndexBuffer* indexBuffer;
|
||||
int firstIndex;
|
||||
|
||||
void *indices = batchTarget->indexPool()->makeSpace(indexCount,
|
||||
&indexBuffer,
|
||||
&firstIndex);
|
||||
|
||||
if (!indices) {
|
||||
uint16_t *idxs = batchTarget->makeIndexSpace(indexCount, &indexBuffer, &firstIndex);
|
||||
if (!idxs) {
|
||||
SkDebugf("Could not allocate indices\n");
|
||||
return;
|
||||
}
|
||||
|
||||
QuadVertex* verts = reinterpret_cast<QuadVertex*>(vertices);
|
||||
uint16_t* idxs = reinterpret_cast<uint16_t*>(indices);
|
||||
|
||||
SkSTArray<kPreallocDrawCnt, Draw, true> draws;
|
||||
create_vertices(segments, fanPt, &draws, verts, idxs);
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include "GrBatch.h"
|
||||
#include "GrBatchTarget.h"
|
||||
#include "GrBufferAllocPool.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrPipelineBuilder.h"
|
||||
#include "GrResourceProvider.h"
|
||||
@ -209,10 +208,10 @@ public:
|
||||
SkASSERT(vertexStride == 2 * sizeof(SkPoint));
|
||||
|
||||
const GrVertexBuffer* vertexBuffer;
|
||||
void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride,
|
||||
kVerticesPerQuad * instanceCount,
|
||||
&vertexBuffer,
|
||||
&flushInfo.fVertexOffset);
|
||||
void* vertices = batchTarget->makeVertSpace(vertexStride,
|
||||
kVerticesPerQuad * instanceCount,
|
||||
&vertexBuffer,
|
||||
&flushInfo.fVertexOffset);
|
||||
flushInfo.fVertexBuffer.reset(SkRef(vertexBuffer));
|
||||
flushInfo.fIndexBuffer.reset(batchTarget->resourceProvider()->refQuadIndexBuffer());
|
||||
if (!vertices || !flushInfo.fIndexBuffer) {
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "GrBatch.h"
|
||||
#include "GrBatchTarget.h"
|
||||
#include "GrBatchTest.h"
|
||||
#include "GrBufferAllocPool.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrDefaultGeoProcFactory.h"
|
||||
#include "GrDrawTargetCaps.h"
|
||||
@ -870,10 +869,8 @@ void AAHairlineBatch::generateGeometry(GrBatchTarget* batchTarget, const GrPipel
|
||||
|
||||
size_t vertexStride = lineGP->getVertexStride();
|
||||
int vertexCount = kLineSegNumVertices * lineCount;
|
||||
void *vertices = batchTarget->vertexPool()->makeSpace(vertexStride,
|
||||
vertexCount,
|
||||
&vertexBuffer,
|
||||
&firstVertex);
|
||||
void *vertices = batchTarget->makeVertSpace(vertexStride, vertexCount,
|
||||
&vertexBuffer, &firstVertex);
|
||||
|
||||
if (!vertices || !linesIndexBuffer) {
|
||||
SkDebugf("Could not allocate vertices\n");
|
||||
@ -908,10 +905,8 @@ void AAHairlineBatch::generateGeometry(GrBatchTarget* batchTarget, const GrPipel
|
||||
|
||||
size_t vertexStride = sizeof(BezierVertex);
|
||||
int vertexCount = kQuadNumVertices * quadCount + kQuadNumVertices * conicCount;
|
||||
void *vertices = batchTarget->vertexPool()->makeSpace(vertexStride,
|
||||
vertexCount,
|
||||
&vertexBuffer,
|
||||
&firstVertex);
|
||||
void *vertices = batchTarget->makeVertSpace(vertexStride, vertexCount,
|
||||
&vertexBuffer, &firstVertex);
|
||||
|
||||
if (!vertices || !quadsIndexBuffer) {
|
||||
SkDebugf("Could not allocate vertices\n");
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "GrBatch.h"
|
||||
#include "GrBatchTarget.h"
|
||||
#include "GrBatchTest.h"
|
||||
#include "GrBufferAllocPool.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrDefaultGeoProcFactory.h"
|
||||
#include "GrGeometryProcessor.h"
|
||||
|
@ -1526,10 +1526,10 @@ public:
|
||||
int instanceCount = fInstanceCount;
|
||||
const GrVertexBuffer* vertexBuffer;
|
||||
|
||||
void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride,
|
||||
glyphCount * kVerticesPerGlyph,
|
||||
&vertexBuffer,
|
||||
&flushInfo.fVertexOffset);
|
||||
void* vertices = batchTarget->makeVertSpace(vertexStride,
|
||||
glyphCount * kVerticesPerGlyph,
|
||||
&vertexBuffer,
|
||||
&flushInfo.fVertexOffset);
|
||||
flushInfo.fVertexBuffer.reset(SkRef(vertexBuffer));
|
||||
flushInfo.fIndexBuffer.reset(batchTarget->resourceProvider()->refQuadIndexBuffer());
|
||||
if (!vertices || !flushInfo.fVertexBuffer) {
|
||||
|
@ -58,8 +58,8 @@ void* GrBatch::InstancedHelper::init(GrBatchTarget* batchTarget, GrPrimitiveType
|
||||
const GrVertexBuffer* vertexBuffer;
|
||||
int firstVertex;
|
||||
int vertexCount = verticesPerInstance * instancesToDraw;
|
||||
void* vertices = batchTarget->vertexPool()->makeSpace(vertexStride, vertexCount, &vertexBuffer,
|
||||
&firstVertex);
|
||||
void* vertices = batchTarget->makeVertSpace(vertexStride, vertexCount,
|
||||
&vertexBuffer, &firstVertex);
|
||||
if (!vertices) {
|
||||
SkDebugf("Vertices could not be allocated for instanced rendering.");
|
||||
return NULL;
|
||||
|
@ -17,9 +17,7 @@
|
||||
#include "SkTypes.h"
|
||||
|
||||
class GrGpu;
|
||||
class GrIndexBufferAllocPool;
|
||||
class GrPipeline;
|
||||
class GrVertexBufferAllocPool;
|
||||
|
||||
struct GrInitInvariantOutput;
|
||||
|
||||
|
@ -10,18 +10,27 @@
|
||||
#include "GrBatchAtlas.h"
|
||||
#include "GrPipeline.h"
|
||||
|
||||
GrBatchTarget::GrBatchTarget(GrGpu* gpu,
|
||||
GrVertexBufferAllocPool* vpool,
|
||||
GrIndexBufferAllocPool* ipool)
|
||||
static const size_t DRAW_BUFFER_VBPOOL_BUFFER_SIZE = 1 << 15;
|
||||
static const int DRAW_BUFFER_VBPOOL_PREALLOC_BUFFERS = 4;
|
||||
|
||||
static const size_t DRAW_BUFFER_IBPOOL_BUFFER_SIZE = 1 << 11;
|
||||
static const int DRAW_BUFFER_IBPOOL_PREALLOC_BUFFERS = 4;
|
||||
|
||||
GrBatchTarget::GrBatchTarget(GrGpu* gpu)
|
||||
: fGpu(gpu)
|
||||
, fVertexPool(vpool)
|
||||
, fIndexPool(ipool)
|
||||
, fFlushBuffer(kFlushBufferInitialSizeInBytes)
|
||||
, fIter(fFlushBuffer)
|
||||
, fNumberOfDraws(0)
|
||||
, fCurrentToken(0)
|
||||
, fLastFlushedToken(0)
|
||||
, fInlineUpdatesIndex(0) {
|
||||
|
||||
fVertexPool.reset(SkNEW_ARGS(GrVertexBufferAllocPool, (fGpu,
|
||||
DRAW_BUFFER_VBPOOL_BUFFER_SIZE,
|
||||
DRAW_BUFFER_VBPOOL_PREALLOC_BUFFERS)));
|
||||
fIndexPool.reset(SkNEW_ARGS(GrIndexBufferAllocPool, (fGpu,
|
||||
DRAW_BUFFER_IBPOOL_BUFFER_SIZE,
|
||||
DRAW_BUFFER_IBPOOL_PREALLOC_BUFFERS)));
|
||||
}
|
||||
|
||||
void GrBatchTarget::flushNext(int n) {
|
||||
@ -53,3 +62,14 @@ void GrBatchTarget::flushNext(int n) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void* GrBatchTarget::makeVertSpace(size_t vertexSize, int vertexCount,
|
||||
const GrVertexBuffer** buffer, int* startVertex) {
|
||||
return fVertexPool->makeSpace(vertexSize, vertexCount, buffer, startVertex);
|
||||
}
|
||||
|
||||
uint16_t* GrBatchTarget::makeIndexSpace(int indexCount,
|
||||
const GrIndexBuffer** buffer, int* startIndex) {
|
||||
return reinterpret_cast<uint16_t*>(fIndexPool->makeSpace(indexCount, buffer, startIndex));
|
||||
}
|
||||
|
||||
|
@ -19,16 +19,10 @@
|
||||
* GrBatch instances use this object to allocate space for their geometry and to issue the draws
|
||||
* that render their batch.
|
||||
*/
|
||||
|
||||
class GrIndexBufferAllocPool;
|
||||
class GrVertexBufferAllocPool;
|
||||
|
||||
class GrBatchTarget : public SkNoncopyable {
|
||||
public:
|
||||
typedef GrBatchAtlas::BatchToken BatchToken;
|
||||
GrBatchTarget(GrGpu* gpu,
|
||||
GrVertexBufferAllocPool* vpool,
|
||||
GrIndexBufferAllocPool* ipool);
|
||||
GrBatchTarget(GrGpu* gpu);
|
||||
|
||||
void initDraw(const GrPrimitiveProcessor* primProc, const GrPipeline* pipeline) {
|
||||
GrNEW_APPEND_TO_RECORDER(fFlushBuffer, BufferedFlush, (primProc, pipeline));
|
||||
@ -94,6 +88,7 @@ public:
|
||||
void resetNumberOfDraws() { fNumberOfDraws = 0; }
|
||||
int numberOfDraws() const { return fNumberOfDraws; }
|
||||
void preFlush() {
|
||||
this->unmapVertexAndIndexBuffers();
|
||||
int updateCount = fAsapUploads.count();
|
||||
for (int i = 0; i < updateCount; i++) {
|
||||
fAsapUploads[i]->upload(TextureUploader(fGpu));
|
||||
@ -117,11 +112,13 @@ public:
|
||||
|
||||
const GrDrawTargetCaps& caps() const { return *fGpu->caps(); }
|
||||
|
||||
GrVertexBufferAllocPool* vertexPool() { return fVertexPool; }
|
||||
GrIndexBufferAllocPool* indexPool() { return fIndexPool; }
|
||||
|
||||
GrResourceProvider* resourceProvider() const { return fGpu->getContext()->resourceProvider(); }
|
||||
|
||||
void* makeVertSpace(size_t vertexSize, int vertexCount,
|
||||
const GrVertexBuffer** buffer, int* startVertex);
|
||||
uint16_t* makeIndexSpace(int indexCount,
|
||||
const GrIndexBuffer** buffer, int* startIndex);
|
||||
|
||||
// A helper for draws which overallocate and then return data to the pool
|
||||
void putBackIndices(size_t indices) { fIndexPool->putBack(indices * sizeof(uint16_t)); }
|
||||
|
||||
@ -129,10 +126,20 @@ public:
|
||||
fVertexPool->putBack(vertices * vertexStride);
|
||||
}
|
||||
|
||||
void reset() {
|
||||
fVertexPool->reset();
|
||||
fIndexPool->reset();
|
||||
}
|
||||
|
||||
private:
|
||||
void unmapVertexAndIndexBuffers() {
|
||||
fVertexPool->unmap();
|
||||
fIndexPool->unmap();
|
||||
}
|
||||
|
||||
GrGpu* fGpu;
|
||||
GrVertexBufferAllocPool* fVertexPool;
|
||||
GrIndexBufferAllocPool* fIndexPool;
|
||||
SkAutoTDelete<GrVertexBufferAllocPool> fVertexPool;
|
||||
SkAutoTDelete<GrIndexBufferAllocPool> fIndexPool;
|
||||
|
||||
typedef void* TBufferAlign; // This wouldn't be enough align if a command used long double.
|
||||
|
||||
|
@ -358,10 +358,10 @@ GrGeometryBuffer* GrBufferAllocPool::createBuffer(size_t size) {
|
||||
GrVertexBufferAllocPool::GrVertexBufferAllocPool(GrGpu* gpu,
|
||||
size_t bufferSize,
|
||||
int preallocBufferCnt)
|
||||
: GrBufferAllocPool(gpu,
|
||||
kVertex_BufferType,
|
||||
bufferSize,
|
||||
preallocBufferCnt) {
|
||||
: GrBufferAllocPool(gpu,
|
||||
kVertex_BufferType,
|
||||
bufferSize,
|
||||
preallocBufferCnt) {
|
||||
}
|
||||
|
||||
void* GrVertexBufferAllocPool::makeSpace(size_t vertexSize,
|
||||
@ -391,10 +391,10 @@ void* GrVertexBufferAllocPool::makeSpace(size_t vertexSize,
|
||||
GrIndexBufferAllocPool::GrIndexBufferAllocPool(GrGpu* gpu,
|
||||
size_t bufferSize,
|
||||
int preallocBufferCnt)
|
||||
: GrBufferAllocPool(gpu,
|
||||
kIndex_BufferType,
|
||||
bufferSize,
|
||||
preallocBufferCnt) {
|
||||
: GrBufferAllocPool(gpu,
|
||||
kIndex_BufferType,
|
||||
bufferSize,
|
||||
preallocBufferCnt) {
|
||||
}
|
||||
|
||||
void* GrIndexBufferAllocPool::makeSpace(int indexCount,
|
||||
|
@ -11,19 +11,13 @@
|
||||
#include "GrTargetCommands.h"
|
||||
|
||||
class GrInOrderDrawBuffer;
|
||||
class GrVertexBufferAllocPool;
|
||||
class GrIndexBufferAllocPool;
|
||||
|
||||
class GrCommandBuilder : ::SkNoncopyable {
|
||||
public:
|
||||
typedef GrTargetCommands::Cmd Cmd;
|
||||
typedef GrTargetCommands::State State;
|
||||
|
||||
GrCommandBuilder(GrGpu* gpu,
|
||||
GrVertexBufferAllocPool* vertexPool,
|
||||
GrIndexBufferAllocPool* indexPool)
|
||||
: fCommands(gpu, vertexPool, indexPool) {
|
||||
}
|
||||
GrCommandBuilder(GrGpu* gpu) : fCommands(gpu) { }
|
||||
|
||||
virtual ~GrCommandBuilder() {}
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "GrBatch.h"
|
||||
#include "GrBatchFontCache.h"
|
||||
#include "GrBatchTarget.h"
|
||||
#include "GrBufferAllocPool.h"
|
||||
#include "GrDefaultGeoProcFactory.h"
|
||||
#include "GrGpuResource.h"
|
||||
#include "GrGpuResourcePriv.h"
|
||||
@ -50,12 +49,6 @@
|
||||
#include "effects/GrDashingEffect.h"
|
||||
#include "effects/GrSingleTextureEffect.h"
|
||||
|
||||
static const size_t DRAW_BUFFER_VBPOOL_BUFFER_SIZE = 1 << 15;
|
||||
static const int DRAW_BUFFER_VBPOOL_PREALLOC_BUFFERS = 4;
|
||||
|
||||
static const size_t DRAW_BUFFER_IBPOOL_BUFFER_SIZE = 1 << 11;
|
||||
static const int DRAW_BUFFER_IBPOOL_PREALLOC_BUFFERS = 4;
|
||||
|
||||
#define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == this)
|
||||
#define RETURN_IF_ABANDONED if (!fDrawBuffer) { return; }
|
||||
#define RETURN_FALSE_IF_ABANDONED if (!fDrawBuffer) { return false; }
|
||||
@ -109,8 +102,6 @@ GrContext::GrContext(const Options& opts) : fOptions(opts), fUniqueID(next_id())
|
||||
fSoftwarePathRenderer = NULL;
|
||||
fBatchFontCache = NULL;
|
||||
fDrawBuffer = NULL;
|
||||
fDrawBufferVBAllocPool = NULL;
|
||||
fDrawBufferIBAllocPool = NULL;
|
||||
fFlushToReduceCacheSize = false;
|
||||
fAARectRenderer = NULL;
|
||||
fOvalRenderer = NULL;
|
||||
@ -140,7 +131,7 @@ void GrContext::initCommon() {
|
||||
|
||||
fDidTestPMConversions = false;
|
||||
|
||||
this->setupDrawBuffer();
|
||||
fDrawBuffer = SkNEW_ARGS(GrInOrderDrawBuffer, (this));
|
||||
|
||||
// GrBatchFontCache will eventually replace GrFontCache
|
||||
fBatchFontCache = SkNEW_ARGS(GrBatchFontCache, (this));
|
||||
@ -163,8 +154,6 @@ GrContext::~GrContext() {
|
||||
SkDELETE(fResourceCache);
|
||||
SkDELETE(fBatchFontCache);
|
||||
SkDELETE(fDrawBuffer);
|
||||
SkDELETE(fDrawBufferVBAllocPool);
|
||||
SkDELETE(fDrawBufferIBAllocPool);
|
||||
|
||||
fAARectRenderer->unref();
|
||||
fOvalRenderer->unref();
|
||||
@ -187,15 +176,9 @@ void GrContext::abandonContext() {
|
||||
SkSafeSetNull(fPathRendererChain);
|
||||
SkSafeSetNull(fSoftwarePathRenderer);
|
||||
|
||||
delete fDrawBuffer;
|
||||
SkDELETE(fDrawBuffer);
|
||||
fDrawBuffer = NULL;
|
||||
|
||||
delete fDrawBufferVBAllocPool;
|
||||
fDrawBufferVBAllocPool = NULL;
|
||||
|
||||
delete fDrawBufferIBAllocPool;
|
||||
fDrawBufferIBAllocPool = NULL;
|
||||
|
||||
fBatchFontCache->freeAll();
|
||||
fLayerCache->freeAll();
|
||||
fTextBlobCache->freeAll();
|
||||
@ -483,10 +466,8 @@ public:
|
||||
const GrVertexBuffer* vertexBuffer;
|
||||
int firstVertex;
|
||||
|
||||
void* verts = batchTarget->vertexPool()->makeSpace(vertexStride,
|
||||
vertexCount,
|
||||
&vertexBuffer,
|
||||
&firstVertex);
|
||||
void* verts = batchTarget->makeVertSpace(vertexStride, vertexCount,
|
||||
&vertexBuffer, &firstVertex);
|
||||
|
||||
if (!verts) {
|
||||
SkDebugf("Could not allocate vertices\n");
|
||||
@ -821,10 +802,8 @@ public:
|
||||
const GrVertexBuffer* vertexBuffer;
|
||||
int firstVertex;
|
||||
|
||||
void* verts = batchTarget->vertexPool()->makeSpace(vertexStride,
|
||||
this->vertexCount(),
|
||||
&vertexBuffer,
|
||||
&firstVertex);
|
||||
void* verts = batchTarget->makeVertSpace(vertexStride, this->vertexCount(),
|
||||
&vertexBuffer, &firstVertex);
|
||||
|
||||
if (!verts) {
|
||||
SkDebugf("Could not allocate vertices\n");
|
||||
@ -834,11 +813,9 @@ public:
|
||||
const GrIndexBuffer* indexBuffer = NULL;
|
||||
int firstIndex = 0;
|
||||
|
||||
void* indices = NULL;
|
||||
uint16_t* indices = NULL;
|
||||
if (this->hasIndices()) {
|
||||
indices = batchTarget->indexPool()->makeSpace(this->indexCount(),
|
||||
&indexBuffer,
|
||||
&firstIndex);
|
||||
indices = batchTarget->makeIndexSpace(this->indexCount(), &indexBuffer, &firstIndex);
|
||||
|
||||
if (!indices) {
|
||||
SkDebugf("Could not allocate indices\n");
|
||||
@ -854,7 +831,7 @@ public:
|
||||
// TODO we can actually cache this interleaved and then just memcopy
|
||||
if (this->hasIndices()) {
|
||||
for (int j = 0; j < args.fIndices.count(); ++j, ++indexOffset) {
|
||||
*((uint16_t*)indices + indexOffset) = args.fIndices[j] + vertexOffset;
|
||||
*(indices + indexOffset) = args.fIndices[j] + vertexOffset;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1813,25 +1790,6 @@ int GrContext::getRecommendedSampleCount(GrPixelConfig config,
|
||||
chosenSampleCount : 0;
|
||||
}
|
||||
|
||||
void GrContext::setupDrawBuffer() {
|
||||
SkASSERT(NULL == fDrawBuffer);
|
||||
SkASSERT(NULL == fDrawBufferVBAllocPool);
|
||||
SkASSERT(NULL == fDrawBufferIBAllocPool);
|
||||
|
||||
fDrawBufferVBAllocPool =
|
||||
SkNEW_ARGS(GrVertexBufferAllocPool, (fGpu,
|
||||
DRAW_BUFFER_VBPOOL_BUFFER_SIZE,
|
||||
DRAW_BUFFER_VBPOOL_PREALLOC_BUFFERS));
|
||||
fDrawBufferIBAllocPool =
|
||||
SkNEW_ARGS(GrIndexBufferAllocPool, (fGpu,
|
||||
DRAW_BUFFER_IBPOOL_BUFFER_SIZE,
|
||||
DRAW_BUFFER_IBPOOL_PREALLOC_BUFFERS));
|
||||
|
||||
fDrawBuffer = SkNEW_ARGS(GrInOrderDrawBuffer, (this,
|
||||
fDrawBufferVBAllocPool,
|
||||
fDrawBufferIBAllocPool));
|
||||
}
|
||||
|
||||
GrDrawTarget* GrContext::getTextTarget() {
|
||||
return this->prepareToDraw();
|
||||
}
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "GrBatch.h"
|
||||
#include "GrBatchTarget.h"
|
||||
#include "GrBatchTest.h"
|
||||
#include "GrBufferAllocPool.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrDefaultGeoProcFactory.h"
|
||||
#include "GrPathUtils.h"
|
||||
@ -320,10 +319,8 @@ public:
|
||||
const GrVertexBuffer* vertexBuffer;
|
||||
int firstVertex;
|
||||
|
||||
void* verts = batchTarget->vertexPool()->makeSpace(vertexStride,
|
||||
maxVertices,
|
||||
&vertexBuffer,
|
||||
&firstVertex);
|
||||
void* verts = batchTarget->makeVertSpace(vertexStride, maxVertices,
|
||||
&vertexBuffer, &firstVertex);
|
||||
|
||||
if (!verts) {
|
||||
SkDebugf("Could not allocate vertices\n");
|
||||
@ -335,9 +332,7 @@ public:
|
||||
|
||||
void* indices = NULL;
|
||||
if (isIndexed) {
|
||||
indices = batchTarget->indexPool()->makeSpace(maxIndices,
|
||||
&indexBuffer,
|
||||
&firstIndex);
|
||||
indices = batchTarget->makeIndexSpace(maxIndices, &indexBuffer, &firstIndex);
|
||||
|
||||
if (!indices) {
|
||||
SkDebugf("Could not allocate indices\n");
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "GrDrawTarget.h"
|
||||
|
||||
#include "GrBatch.h"
|
||||
#include "GrBufferAllocPool.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrDrawTargetCaps.h"
|
||||
#include "GrPath.h"
|
||||
@ -30,14 +29,10 @@
|
||||
#define DEBUG_INVAL_BUFFER 0xdeadcafe
|
||||
#define DEBUG_INVAL_START_IDX -1
|
||||
|
||||
GrDrawTarget::GrDrawTarget(GrContext* context,
|
||||
GrVertexBufferAllocPool* vpool,
|
||||
GrIndexBufferAllocPool* ipool)
|
||||
GrDrawTarget::GrDrawTarget(GrContext* context)
|
||||
: fContext(context)
|
||||
, fCaps(SkRef(context->getGpu()->caps()))
|
||||
, fGpuTraceMarkerCount(0)
|
||||
, fVertexPool(vpool)
|
||||
, fIndexPool(ipool)
|
||||
, fFlushing(false) {
|
||||
SkASSERT(context);
|
||||
}
|
||||
@ -113,13 +108,6 @@ bool GrDrawTarget::setupDstReadIfNecessary(const GrPipelineBuilder& pipelineBuil
|
||||
}
|
||||
}
|
||||
|
||||
void GrDrawTarget::reset() {
|
||||
fVertexPool->reset();
|
||||
fIndexPool->reset();
|
||||
|
||||
this->onReset();
|
||||
}
|
||||
|
||||
void GrDrawTarget::flush() {
|
||||
if (fFlushing) {
|
||||
return;
|
||||
|
@ -30,11 +30,9 @@
|
||||
|
||||
class GrClip;
|
||||
class GrDrawTargetCaps;
|
||||
class GrIndexBufferAllocPool;
|
||||
class GrPath;
|
||||
class GrPathRange;
|
||||
class GrPipeline;
|
||||
class GrVertexBufferAllocPool;
|
||||
|
||||
class GrDrawTarget : public SkRefCnt {
|
||||
public:
|
||||
@ -47,14 +45,14 @@ public:
|
||||
|
||||
// The context may not be fully constructed and should not be used during GrDrawTarget
|
||||
// construction.
|
||||
GrDrawTarget(GrContext* context, GrVertexBufferAllocPool*, GrIndexBufferAllocPool*);
|
||||
GrDrawTarget(GrContext* context);
|
||||
|
||||
virtual ~GrDrawTarget() {}
|
||||
|
||||
/**
|
||||
* Empties the draw buffer of any queued up draws.
|
||||
*/
|
||||
void reset();
|
||||
void reset() { this->onReset(); }
|
||||
|
||||
/**
|
||||
* This plays any queued up draws to its GrGpu target. It also resets this object (i.e. flushing
|
||||
@ -240,9 +238,6 @@ protected:
|
||||
return fContext->getGpu();
|
||||
}
|
||||
|
||||
GrVertexBufferAllocPool* getVertexAllocPool() { return fVertexPool; }
|
||||
GrIndexBufferAllocPool* getIndexAllocPool() { return fIndexPool; }
|
||||
|
||||
const GrTraceMarkerSet& getActiveTraceMarkers() { return fActiveTraceMarkers; }
|
||||
|
||||
// Makes a copy of the dst if it is necessary for the draw. Returns false if a copy is required
|
||||
@ -334,8 +329,6 @@ private:
|
||||
int fGpuTraceMarkerCount;
|
||||
GrTraceMarkerSet fActiveTraceMarkers;
|
||||
GrTraceMarkerSet fStoredTraceMarkers;
|
||||
GrVertexBufferAllocPool* fVertexPool;
|
||||
GrIndexBufferAllocPool* fIndexPool;
|
||||
bool fFlushing;
|
||||
|
||||
typedef SkRefCnt INHERITED;
|
||||
@ -346,10 +339,8 @@ private:
|
||||
*/
|
||||
class GrClipTarget : public GrDrawTarget {
|
||||
public:
|
||||
GrClipTarget(GrContext* context,
|
||||
GrVertexBufferAllocPool* vpool,
|
||||
GrIndexBufferAllocPool* ipool)
|
||||
: INHERITED(context, vpool, ipool) {
|
||||
GrClipTarget(GrContext* context)
|
||||
: INHERITED(context) {
|
||||
fClipMaskManager.setClipTarget(this);
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include "GrGpu.h"
|
||||
|
||||
#include "GrBufferAllocPool.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrDrawTargetCaps.h"
|
||||
#include "GrGpuResourcePriv.h"
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "SkPath.h"
|
||||
|
||||
class GrContext;
|
||||
class GrIndexBufferAllocPool;
|
||||
class GrPath;
|
||||
class GrPathRange;
|
||||
class GrPathRenderer;
|
||||
@ -22,7 +21,6 @@ class GrPathRendererChain;
|
||||
class GrPipeline;
|
||||
class GrPrimitiveProcessor;
|
||||
class GrStencilAttachment;
|
||||
class GrVertexBufferAllocPool;
|
||||
class GrVertices;
|
||||
|
||||
class GrGpu : public SkRefCnt {
|
||||
|
@ -15,11 +15,7 @@ public:
|
||||
typedef GrCommandBuilder::Cmd Cmd;
|
||||
typedef GrCommandBuilder::State State;
|
||||
|
||||
GrInOrderCommandBuilder(GrGpu* gpu,
|
||||
GrVertexBufferAllocPool* vertexPool,
|
||||
GrIndexBufferAllocPool* indexPool)
|
||||
: INHERITED(gpu, vertexPool, indexPool) {
|
||||
}
|
||||
GrInOrderCommandBuilder(GrGpu* gpu) : INHERITED(gpu) { }
|
||||
|
||||
Cmd* recordDrawBatch(State*, GrBatch*) override;
|
||||
Cmd* recordStencilPath(const GrPipelineBuilder&,
|
||||
|
@ -7,18 +7,13 @@
|
||||
|
||||
#include "GrInOrderDrawBuffer.h"
|
||||
|
||||
GrInOrderDrawBuffer::GrInOrderDrawBuffer(GrContext* context,
|
||||
GrVertexBufferAllocPool* vertexPool,
|
||||
GrIndexBufferAllocPool* indexPool)
|
||||
: INHERITED(context, vertexPool, indexPool)
|
||||
, fCommands(SkNEW_ARGS(GrInOrderCommandBuilder, (context->getGpu(), vertexPool, indexPool)))
|
||||
GrInOrderDrawBuffer::GrInOrderDrawBuffer(GrContext* context)
|
||||
: INHERITED(context)
|
||||
, fCommands(SkNEW_ARGS(GrInOrderCommandBuilder, (context->getGpu())))
|
||||
, fPathIndexBuffer(kPathIdxBufferMinReserve * sizeof(char)/4)
|
||||
, fPathTransformBuffer(kPathXformBufferMinReserve * sizeof(float)/4)
|
||||
, fPipelineBuffer(kPipelineBufferMinReserve)
|
||||
, fDrawID(0) {
|
||||
|
||||
SkASSERT(vertexPool);
|
||||
SkASSERT(indexPool);
|
||||
}
|
||||
|
||||
GrInOrderDrawBuffer::~GrInOrderDrawBuffer() {
|
||||
|
@ -29,14 +29,8 @@ public:
|
||||
* Creates a GrInOrderDrawBuffer
|
||||
*
|
||||
* @param context the context object that owns this draw buffer.
|
||||
* @param vertexPool pool where vertices for queued draws will be saved when
|
||||
* the vertex source is either reserved or array.
|
||||
* @param indexPool pool where indices for queued draws will be saved when
|
||||
* the index source is either reserved or array.
|
||||
*/
|
||||
GrInOrderDrawBuffer(GrContext* context,
|
||||
GrVertexBufferAllocPool* vertexPool,
|
||||
GrIndexBufferAllocPool* indexPool);
|
||||
GrInOrderDrawBuffer(GrContext* context);
|
||||
|
||||
~GrInOrderDrawBuffer() override;
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "GrBatch.h"
|
||||
#include "GrBatchTarget.h"
|
||||
#include "GrBatchTest.h"
|
||||
#include "GrBufferAllocPool.h"
|
||||
#include "GrDrawTarget.h"
|
||||
#include "GrGeometryProcessor.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
|
@ -66,10 +66,8 @@ private:
|
||||
SkAlignedSStorage<kMaxSize> fData;
|
||||
};
|
||||
|
||||
class GrIndexBufferAllocPool;
|
||||
class GrGLSLCaps;
|
||||
class GrGLPrimitiveProcessor;
|
||||
class GrVertexBufferAllocPool;
|
||||
|
||||
struct GrInitInvariantOutput;
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
void GrTargetCommands::reset() {
|
||||
fCmdBuffer.reset();
|
||||
fBatchTarget.reset();
|
||||
}
|
||||
|
||||
void GrTargetCommands::flush(GrInOrderDrawBuffer* iodb) {
|
||||
@ -31,8 +32,6 @@ void GrTargetCommands::flush(GrInOrderDrawBuffer* iodb) {
|
||||
}
|
||||
}
|
||||
|
||||
iodb->getVertexAllocPool()->unmap();
|
||||
iodb->getIndexAllocPool()->unmap();
|
||||
fBatchTarget.preFlush();
|
||||
|
||||
CmdBuffer::Iter iter(fCmdBuffer);
|
||||
|
@ -20,16 +20,13 @@
|
||||
#include "SkTypes.h"
|
||||
|
||||
class GrInOrderDrawBuffer;
|
||||
class GrVertexBufferAllocPool;
|
||||
class GrIndexBufferAllocPool;
|
||||
|
||||
|
||||
class GrTargetCommands : ::SkNoncopyable {
|
||||
public:
|
||||
GrTargetCommands(GrGpu* gpu,
|
||||
GrVertexBufferAllocPool* vertexPool,
|
||||
GrIndexBufferAllocPool* indexPool)
|
||||
GrTargetCommands(GrGpu* gpu)
|
||||
: fCmdBuffer(kCmdBufferInitialSizeInBytes)
|
||||
, fBatchTarget(gpu, vertexPool, indexPool) {
|
||||
, fBatchTarget(gpu) {
|
||||
}
|
||||
|
||||
class Cmd : ::SkNoncopyable {
|
||||
|
@ -1439,11 +1439,7 @@ public:
|
||||
size_t stride = gp->getVertexStride();
|
||||
const GrVertexBuffer* vertexBuffer;
|
||||
int firstVertex;
|
||||
void* verts = batchTarget->vertexPool()->makeSpace(stride,
|
||||
count,
|
||||
&vertexBuffer,
|
||||
&firstVertex);
|
||||
|
||||
void* verts = batchTarget->makeVertSpace(stride, count, &vertexBuffer, &firstVertex);
|
||||
if (!verts) {
|
||||
SkDebugf("Could not allocate vertices\n");
|
||||
return;
|
||||
|
@ -131,7 +131,6 @@ void GrResourceCache::changeTimestamp(uint32_t newTimestamp) { fTimestamp = newT
|
||||
// Code for the mock context. It's built on a mock GrGpu class that does nothing.
|
||||
////
|
||||
|
||||
#include "GrBufferAllocPool.h"
|
||||
#include "GrInOrderDrawBuffer.h"
|
||||
#include "GrGpu.h"
|
||||
|
||||
@ -266,10 +265,6 @@ void GrContext::initMockContext() {
|
||||
// these objects are required for any of tests that use this context. TODO: make stop allocating
|
||||
// resources in the buffer pools.
|
||||
SkDELETE(fDrawBuffer);
|
||||
SkDELETE(fDrawBufferVBAllocPool);
|
||||
SkDELETE(fDrawBufferIBAllocPool);
|
||||
|
||||
fDrawBuffer = NULL;
|
||||
fDrawBufferVBAllocPool = NULL;
|
||||
fDrawBufferIBAllocPool = NULL;
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "GrBatch.h"
|
||||
#include "GrBatchTarget.h"
|
||||
#include "GrBatchTest.h"
|
||||
#include "GrBufferAllocPool.h"
|
||||
#include "GrGeometryProcessor.h"
|
||||
#include "GrContext.h"
|
||||
#include "GrCoordTransform.h"
|
||||
|
Loading…
Reference in New Issue
Block a user