]> O.S.I.I.S - jp/vkvg.git/commitdiff
check vbo size once during poly fill
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Fri, 14 Jan 2022 06:25:35 +0000 (07:25 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Fri, 14 Jan 2022 06:25:35 +0000 (07:25 +0100)
src/vkvg_context_internal.c

index 15e2c359d90bc8fd0f757162e30086a2d4e371dd..658e65761cc1845dc7d06cc3adfa14aac15ac604 100644 (file)
@@ -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);