From 4c6e07230f76c21e67f0d5ef15464ca7d55c404a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cle=CC=81ment=20Foucault?= Date: Mon, 24 Oct 2022 16:25:04 +0200 Subject: Pencil: Fix regression (part2) with stroke buffer introduced in rB0ee9282b5c51 `vert_len` was being shadowed and index_min & max wasn't correctly set. --- source/blender/draw/engines/gpencil/gpencil_engine.c | 3 --- source/blender/draw/intern/draw_cache_impl_gpencil.cc | 7 +++++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c index 525d166dba6..78e658d35eb 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.c +++ b/source/blender/draw/engines/gpencil/gpencil_engine.c @@ -526,9 +526,6 @@ static void gpencil_stroke_cache_populate(bGPDlayer *gpl, if (show_fill) { int vfirst = gps->runtime.fill_start * 3; int vcount = gps->tot_triangles * 3; - if (do_sbuffer) { - printf("draw_fill vfirst %d vcount %d\n", vfirst, vcount); - } gpencil_drawcall_add(iter, geom, vfirst, vcount); } diff --git a/source/blender/draw/intern/draw_cache_impl_gpencil.cc b/source/blender/draw/intern/draw_cache_impl_gpencil.cc index 33cd62bd33f..b46a4907da8 100644 --- a/source/blender/draw/intern/draw_cache_impl_gpencil.cc +++ b/source/blender/draw/intern/draw_cache_impl_gpencil.cc @@ -619,10 +619,10 @@ static void gpencil_sbuffer_stroke_ensure(bGPdata *gpd, bool do_fill) /* Calc uv data along the stroke. */ BKE_gpencil_stroke_uv_update(gps); - int vert_len = gps->tot_triangles + (gps->totpoints + gpencil_stroke_is_cyclic(gps)) * 2; + int tri_len = gps->tot_triangles + (gps->totpoints + gpencil_stroke_is_cyclic(gps)) * 2; /* Create IBO. */ GPUIndexBufBuilder ibo_builder; - GPU_indexbuf_init(&ibo_builder, GPU_PRIM_TRIS, vert_len, 0xFFFFFFFFu); + GPU_indexbuf_init(&ibo_builder, GPU_PRIM_TRIS, tri_len, 0xFFFFFFFFu); /* Create VBO. */ GPUUsageType vbo_flag = GPU_USAGE_STATIC | GPU_USAGE_FLAG_BUFFER_TEXTURE_ONLY; GPUVertFormat *format = gpencil_stroke_format(); @@ -652,6 +652,9 @@ static void gpencil_sbuffer_stroke_ensure(bGPdata *gpd, bool do_fill) /* HACK since we didn't use the builder API to avoid another malloc and copy, * we need to set the number of indices manually. */ ibo_builder.index_len = gps->tot_triangles * 3; + ibo_builder.index_min = 0; + /* For this case, do not allow index compaction to avoid yet another preprocessing step. */ + ibo_builder.index_max = 0xFFFFFFFFu - 1u; gps->runtime.stroke_start = gps->tot_triangles; -- cgit v1.2.3