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

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

Issue 1835283002: Simplify GrDrawBatch uploads and token uage. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 4 years, 9 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 fc7a1e4fae227279592a62e69a02f5bd16e9c969..8a5dd6289bb30ad7427ea4b8ff5671ed3cfbb981 100644
--- a/src/gpu/batches/GrVertexBatch.cpp
+++ b/src/gpu/batches/GrVertexBatch.cpp
@@ -9,7 +9,10 @@
#include "GrBatchFlushState.h"
#include "GrResourceProvider.h"
-GrVertexBatch::GrVertexBatch(uint32_t classID) : INHERITED(classID) {}
+GrVertexBatch::GrVertexBatch(uint32_t classID)
+ : INHERITED(classID)
+ , fBaseDrawToken(GrBatchDrawToken::AlreadyFlushedToken()) {
+}
void GrVertexBatch::onPrepare(GrBatchFlushState* state) {
Target target(state, this);
@@ -42,9 +45,9 @@ void* GrVertexBatch::InstancedHelper::init(Target* target, GrPrimitiveType primT
return vertices;
}
-void GrVertexBatch::InstancedHelper::recordDraw(Target* target) {
+void GrVertexBatch::InstancedHelper::recordDraw(Target* target, const GrGeometryProcessor* gp) {
SkASSERT(fMesh.instanceCount());
- target->draw(fMesh);
+ target->draw(gp, fMesh);
}
void* GrVertexBatch::QuadHelper::init(Target* target, size_t vertexStride,
@@ -60,22 +63,50 @@ void* GrVertexBatch::QuadHelper::init(Target* target, size_t vertexStride,
}
void GrVertexBatch::onDraw(GrBatchFlushState* state) {
- int uploadCnt = fInlineUploads.count();
- int currUpload = 0;
+ int currUploadIdx = 0;
+ int currMeshIdx = 0;
+
+ SkASSERT(fQueuedDraws.empty() || fBaseDrawToken == state->nextTokenToFlush());
- // Iterate of all the drawArrays. Before issuing the draws in each array, perform any inline
- // uploads.
- for (DrawArrayList::Iter da(fDrawArrays); da.get(); da.next()) {
- state->advanceLastFlushedToken();
- while (currUpload < uploadCnt &&
- fInlineUploads[currUpload]->lastUploadToken() <= state->lastFlushedToken()) {
- fInlineUploads[currUpload++]->upload(state->uploader());
+ for (int currDrawIdx = 0; currDrawIdx < fQueuedDraws.count(); ++currDrawIdx) {
+ GrBatchDrawToken drawToken = state->nextTokenToFlush();
+ while (currUploadIdx < fInlineUploads.count() &&
+ fInlineUploads[currUploadIdx].fUploadBeforeToken == drawToken) {
+ state->doUpload(fInlineUploads[currUploadIdx++].fUpload);
}
- const GrVertexBatch::DrawArray& drawArray = *da.get();
+ const QueuedDraw &draw = fQueuedDraws[currDrawIdx];
+ state->gpu()->draw(*this->pipeline(), *draw.fGeometryProcessor.get(),
+ fMeshes.begin() + currMeshIdx, draw.fMeshCnt);
+ currMeshIdx += draw.fMeshCnt;
+ state->flushToken();
+ }
+ SkASSERT(currUploadIdx == fInlineUploads.count());
+ SkASSERT(currMeshIdx == fMeshes.count());
+ fQueuedDraws.reset();
+ fInlineUploads.reset();
+}
- state->gpu()->draw(*this->pipeline(),
- *drawArray.fPrimitiveProcessor.get(),
- drawArray.fDraws.begin(),
- drawArray.fDraws.count());
+//////////////////////////////////////////////////////////////////////////////
+
+void GrVertexBatch::Target::draw(const GrGeometryProcessor* gp, const GrMesh& mesh) {
+ GrVertexBatch* batch = this->vertexBatch();
+ batch->fMeshes.push_back(mesh);
+ if (!batch->fQueuedDraws.empty()) {
+ // If the last draw shares a geometry processor and there are no intervening uploads,
+ // add this mesh to it.
+ GrVertexBatch::QueuedDraw& lastDraw = this->vertexBatch()->fQueuedDraws.back();
+ if (lastDraw.fGeometryProcessor == gp &&
+ (batch->fInlineUploads.empty() ||
+ batch->fInlineUploads.back().fUploadBeforeToken != this->nextDrawToken())) {
+ ++lastDraw.fMeshCnt;
+ return;
+ }
+ }
+ GrVertexBatch::QueuedDraw& draw = this->vertexBatch()->fQueuedDraws.push_back();
+ GrBatchDrawToken token = this->state()->issueDrawToken();
+ draw.fGeometryProcessor.reset(gp);
+ draw.fMeshCnt = 1;
+ if (batch->fQueuedDraws.count() == 1) {
+ batch->fBaseDrawToken = token;
}
}
« 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