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

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

Issue 1806983002: Update how we send draws to gpu backend to reduce state setting. (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
Index: src/gpu/batches/GrVertexBatch.cpp
diff --git a/src/gpu/batches/GrVertexBatch.cpp b/src/gpu/batches/GrVertexBatch.cpp
index 5897fe95c47bcbfeb709b0fdd121e3ecade42380..be56100d7074962fd3ecf744a137be21981add43 100644
--- a/src/gpu/batches/GrVertexBatch.cpp
+++ b/src/gpu/batches/GrVertexBatch.cpp
@@ -16,7 +16,7 @@ void GrVertexBatch::onPrepare(GrBatchFlushState* state) {
this->onPrepareDraws(&target);
}
-void* GrVertexBatch::InstancedHelper::init(Target* target, GrPrimitiveType primType,
+void* GrVertexBatch::InstancedHelper::init(Target* target,
size_t vertexStride, const GrIndexBuffer* indexBuffer,
int verticesPerInstance, int indicesPerInstance,
int instancesToDraw) {
@@ -36,7 +36,7 @@ void* GrVertexBatch::InstancedHelper::init(Target* target, GrPrimitiveType primT
size_t ibSize = indexBuffer->gpuMemorySize();
int maxInstancesPerDraw = static_cast<int>(ibSize / (sizeof(uint16_t) * indicesPerInstance));
- fVertices.initInstanced(primType, vertexBuffer, indexBuffer,
+ fVertices.initInstanced(vertexBuffer, indexBuffer,
firstVertex, verticesPerInstance, indicesPerInstance, instancesToDraw,
maxInstancesPerDraw);
return vertices;
@@ -55,8 +55,8 @@ void* GrVertexBatch::QuadHelper::init(Target* target, size_t vertexStride,
SkDebugf("Could not get quad index buffer.");
return nullptr;
}
- return this->INHERITED::init(target, kTriangles_GrPrimitiveType, vertexStride,
- quadIndexBuffer, kVerticesPerQuad, kIndicesPerQuad, quadsToDraw);
+ return this->INHERITED::init(target, vertexStride, quadIndexBuffer, kVerticesPerQuad,
+ kIndicesPerQuad, quadsToDraw);
}
void GrVertexBatch::onDraw(GrBatchFlushState* state) {
@@ -72,15 +72,11 @@ void GrVertexBatch::onDraw(GrBatchFlushState* state) {
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);
- GrGpu::DrawArgs args(primProc, pipeline, &desc);
- int drawCount = drawArray.fDraws.count();
- for (int i = 0; i < drawCount; i++) {
- state->gpu()->draw(args, drawArray.fDraws[i]);
- }
+ state->gpu()->draw(*this->pipeline(),
+ *drawArray.fPrimitiveProcessor.get(),
+ drawArray.fPrimitiveType,
+ drawArray.fDraws.begin(),
+ drawArray.fDraws.count());
}
}

Powered by Google App Engine
This is Rietveld 408576698