From 345b2bf22e42830a29354afc03daed41f850ec0d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Thu, 15 Jul 2021 07:43:32 +0200 Subject: [PATCH] =?utf8?q?check=20draw=20batch=20size=20between=20path=20?= =?utf8?q?=C3=A9missions=20to=20avoid=20ibo=20index=20out=20of=20bound?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/vkvg_context.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/src/vkvg_context.c b/src/vkvg_context.c index bca1164..00f3932 100644 --- a/src/vkvg_context.c +++ b/src/vkvg_context.c @@ -779,35 +779,16 @@ void vkvg_stroke_preserve (VkvgContext ctx) }else _draw_stoke_cap (ctx, hw, ctx->points[curPathPointIdx], vec2_line_norm(ctx->points[curPathPointIdx-1], ctx->points[curPathPointIdx]), false); - /*if (ctx->vertCount - ctx->curVertOffset > VKVG_IBO_MAX) { - _check_vao_size (ctx); - _ensure_renderpass_is_started(ctx); - - //split triangle emission into batch adressable by VKVG_IBO_MAX (index type) - VKVG_IBO_INDEX_TYPE indexMax = VKVG_IBO_MAX - VKVG_IBO_MAX % 3; - uint32_t vxTot = ctx->vertCount; - uint32_t idxTot = ctx->indCount; - ctx->indCount = ctx->curIndStart; - - - while (ctx->curVertOffset < vxTot) { - while (ctx->indexCache[ctx->indCount] < indexMax) - ctx->indCount++; - ctx->indCount -= ctx->indCount % 3; - uint32_t minInd = - uint32_t newVertOffset = ctx->indexCache[ctx->indCount-1]; - - _emit_draw (ctx); - } - - } */ - curPathPointIdx = firstPathPointIdx + pathPointCount; if (ptrSegment > 0) ptrPath += ptrSegment; else ptrPath++; + + //limit batch size here to 1/3 of the ibo index type ability + if (ctx->vertCount - ctx->curVertOffset > VKVG_IBO_MAX / 3) + _emit_draw_cmd_undrawn_vertices(ctx); } } -- 2.47.3