aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/batches/GrVertexBatch.cpp
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2016-03-17 11:35:45 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-17 11:35:45 -0700
commit0e1853c89615d14d0d03c87c7e0c604e5285cc54 (patch)
treee0ffc4b77a62d396b548f6e45fc8b335d3e6ecc1 /src/gpu/batches/GrVertexBatch.cpp
parent852f15da7ceb53cfb49b9f728baa6dbc53b27694 (diff)
Update how we send draws to gpu backend to reduce state setting.
The main change here is that we pull primitive type off of the vertices, we set the gpu state on gpu once per pipeline/prim proc draw batch, and we create the ProgramDescriptor only for the Cache/ProgramBuilder. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1806983002 Review URL: https://codereview.chromium.org/1806983002
Diffstat (limited to 'src/gpu/batches/GrVertexBatch.cpp')
-rw-r--r--src/gpu/batches/GrVertexBatch.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/gpu/batches/GrVertexBatch.cpp b/src/gpu/batches/GrVertexBatch.cpp
index 5897fe95c4..17bcf8e3af 100644
--- a/src/gpu/batches/GrVertexBatch.cpp
+++ b/src/gpu/batches/GrVertexBatch.cpp
@@ -36,15 +36,15 @@ 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,
+ fMesh.initInstanced(primType, vertexBuffer, indexBuffer,
firstVertex, verticesPerInstance, indicesPerInstance, instancesToDraw,
maxInstancesPerDraw);
return vertices;
}
void GrVertexBatch::InstancedHelper::recordDraw(Target* target) {
- SkASSERT(fVertices.instanceCount());
- target->draw(fVertices);
+ SkASSERT(fMesh.instanceCount());
+ target->draw(fMesh);
}
void* GrVertexBatch::QuadHelper::init(Target* target, size_t vertexStride,
@@ -72,15 +72,10 @@ 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.fDraws.begin(),
+ drawArray.fDraws.count());
}
}