Minimize renderstate changes and vertex buffer rebinding.
We were resetting the vertex buffer state after every draw, even if
the vertex buffer hasn't changed. This addresses that. It also sets
certain renderstate at renderencoder creation -- again, rather than
at every draw.
Bug: skia:8243
Change-Id: I053e150c289c14b60385f555a8b4b771a131ea06
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/221336
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
diff --git a/src/gpu/mtl/GrMtlGpuCommandBuffer.h b/src/gpu/mtl/GrMtlGpuCommandBuffer.h
index 5ab40b2..7e820e3 100644
--- a/src/gpu/mtl/GrMtlGpuCommandBuffer.h
+++ b/src/gpu/mtl/GrMtlGpuCommandBuffer.h
@@ -61,6 +61,8 @@
void insertEventMarker(const char* msg) override {}
+ void initRenderState(id<MTLRenderCommandEncoder>);
+
void inlineUpload(GrOpFlushState* state, GrDeferredTextureUploadFn& upload) override {
// TODO: this could be more efficient
state->doUpload(upload);
@@ -134,7 +136,10 @@
size_t fCurrentVertexStride;
static constexpr size_t kNumBindings = GrMtlUniformHandler::kLastUniformBinding + 3;
- id<MTLBuffer> fBufferBindings[kNumBindings];
+ struct {
+ id<MTLBuffer> fBuffer;
+ size_t fOffset;
+ } fBufferBindings[kNumBindings];
typedef GrGpuRTCommandBuffer INHERITED;
};