Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Unified Diff: src/gpu/batches/GrVertexBatch.cpp

Issue 1286043004: Make GrVertexBatch objects hold their own draws during GrDrawTarget flush (Closed) Base URL: https://skia.googlesource.com/skia.git@m
Patch Set: forward decl Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/batches/GrVertexBatch.h ('k') | src/gpu/effects/GrDashingEffect.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/batches/GrVertexBatch.cpp
diff --git a/src/gpu/batches/GrVertexBatch.cpp b/src/gpu/batches/GrVertexBatch.cpp
index e8004228183fedf4cfea953af2b4fd9ea3c79759..6081e2637176140c89acc2044b080d6311968ab9 100644
--- a/src/gpu/batches/GrVertexBatch.cpp
+++ b/src/gpu/batches/GrVertexBatch.cpp
@@ -6,24 +6,28 @@
*/
#include "GrVertexBatch.h"
-#include "GrBatchTarget.h"
+#include "GrBatchFlushState.h"
#include "GrResourceProvider.h"
-GrVertexBatch::GrVertexBatch() : fNumberOfDraws(0) {}
+GrVertexBatch::GrVertexBatch() : fDrawArrays(1) {}
-void* GrVertexBatch::InstancedHelper::init(GrBatchTarget* batchTarget, GrPrimitiveType primType,
- size_t vertexStride, const GrIndexBuffer* indexBuffer,
- int verticesPerInstance, int indicesPerInstance,
- int instancesToDraw) {
- SkASSERT(batchTarget);
+void GrVertexBatch::prepareDraws(GrBatchFlushState* state) {
+ Target target(state, this);
+ this->onPrepareDraws(&target);
+}
+
+void* GrVertexBatch::InstancedHelper::init(Target* target, GrPrimitiveType primType,
+ size_t vertexStride, const GrIndexBuffer* indexBuffer,
+ int verticesPerInstance, int indicesPerInstance,
+ int instancesToDraw) {
+ SkASSERT(target);
if (!indexBuffer) {
return NULL;
}
const GrVertexBuffer* vertexBuffer;
int firstVertex;
int vertexCount = verticesPerInstance * instancesToDraw;
- void* vertices = batchTarget->makeVertSpace(vertexStride, vertexCount,
- &vertexBuffer, &firstVertex);
+ void* vertices = target->makeVertexSpace(vertexStride, vertexCount, &vertexBuffer, &firstVertex);
if (!vertices) {
SkDebugf("Vertices could not be allocated for instanced rendering.");
return NULL;
@@ -38,14 +42,45 @@ void* GrVertexBatch::InstancedHelper::init(GrBatchTarget* batchTarget, GrPrimiti
return vertices;
}
-void* GrVertexBatch::QuadHelper::init(GrBatchTarget* batchTarget, size_t vertexStride,
+void GrVertexBatch::InstancedHelper::recordDraw(Target* target) {
+ SkASSERT(fVertices.instanceCount());
+ target->draw(fVertices);
+}
+
+void* GrVertexBatch::QuadHelper::init(Target* target, size_t vertexStride,
int quadsToDraw) {
SkAutoTUnref<const GrIndexBuffer> quadIndexBuffer(
- batchTarget->resourceProvider()->refQuadIndexBuffer());
+ target->resourceProvider()->refQuadIndexBuffer());
if (!quadIndexBuffer) {
SkDebugf("Could not get quad index buffer.");
return NULL;
}
- return this->INHERITED::init(batchTarget, kTriangles_GrPrimitiveType, vertexStride,
+ return this->INHERITED::init(target, kTriangles_GrPrimitiveType, vertexStride,
quadIndexBuffer, kVerticesPerQuad, kIndicesPerQuad, quadsToDraw);
}
+
+void GrVertexBatch::issueDraws(GrBatchFlushState* state) {
+ int uploadCnt = fInlineUploads.count();
+ int currUpload = 0;
+
+ // Iterate of all the drawArrays. Before issuing the draws in each array, perform any inline
+ // uploads.
+ for (SkTLList<DrawArray>::Iter da(fDrawArrays); da.get(); da.next()) {
+ state->advanceLastFlushedToken();
+ while (currUpload < uploadCnt &&
+ fInlineUploads[currUpload]->lastUploadToken() <= state->lastFlushedToken()) {
+ fInlineUploads[currUpload++]->upload(state->uploader());
+ }
+ const GrVertexBatch::DrawArray& drawArray = *da.get();
+ GrProgramDesc desc;
+ const GrPipeline* pipeline = this->pipeline();
+ const GrPrimitiveProcessor* primProc = drawArray.fPrimitiveProcessor.get();
+ state->gpu()->buildProgramDesc(&desc, *primProc, *pipeline, fBatchTracker);
+ GrGpu::DrawArgs args(primProc, pipeline, &desc, &fBatchTracker);
+
+ int drawCount = drawArray.fDraws.count();
+ for (int i = 0; i < drawCount; i++) {
+ state->gpu()->draw(args, drawArray.fDraws[i]);
+ }
+ }
+}
« no previous file with comments | « src/gpu/batches/GrVertexBatch.h ('k') | src/gpu/effects/GrDashingEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698