Handle null vertex buffers in Metal

When using instanced rendering, we sometimes bind a null vertex
buffer. Make sure not to crash during the deferred bind.

Change-Id: Ia0351222a220c2ac947de52e9d6eb76146dd64b1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408357
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
Brian Osman 2021-05-13 16:08:44 -04:00 committed by Skia Commit-Bot
parent 1a183bc90d
commit 3193a04b09

View File

@ -416,6 +416,10 @@ void GrMtlOpsRenderPass::setVertexBuffer(id<MTLRenderCommandEncoder> encoder,
const GrBuffer* buffer,
size_t vertexOffset,
size_t inputBufferIndex) {
if (!buffer) {
return;
}
constexpr static int kFirstBufferBindingIdx = GrMtlUniformHandler::kLastUniformBinding + 1;
int index = inputBufferIndex + kFirstBufferBindingIdx;
SkASSERT(index < 4);