From 07f474135ebf5e9fa3508f11579b1fb9692f8f63 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Fri, 14 Jan 2022 07:25:35 +0100 Subject: [PATCH] check vbo size once during poly fill --- src/vkvg_context_internal.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/vkvg_context_internal.c b/src/vkvg_context_internal.c index 15e2c35..658e657 100644 --- a/src/vkvg_context_internal.c +++ b/src/vkvg_context_internal.c @@ -1535,10 +1535,17 @@ void _poly_fill (VkvgContext ctx){ if (pathPointCount > 2) { VKVG_IBO_INDEX_TYPE firstVertIdx = (VKVG_IBO_INDEX_TYPE)ctx->vertCount; + if (ctx->sizeVertices - ctx->vertCount < VKVG_ARRAY_THRESHOLD + pathPointCount) { + VKVG_IBO_INDEX_TYPE newSize = ctx->sizeVertices + pathPointCount; + VKVG_IBO_INDEX_TYPE modulo = pathPointCount % VKVG_VBO_SIZE; + if (modulo > 0) + newSize += VKVG_VBO_SIZE - modulo; + _resize_vertex_cache (ctx, newSize); + } + for (uint32_t i = 0; i < pathPointCount; i++) { v.pos = ctx->points [i+firstPtIdx]; ctx->vertexCache[ctx->vertCount++] = v; - _check_vertex_cache_size(ctx); } LOG(VKVG_LOG_INFO_PATH, "\tpoly fill: point count = %d; 1st vert = %d; vert count = %d\n", pathPointCount, firstVertIdx, ctx->vertCount - firstVertIdx); -- 2.47.3