[Bf-blender-cvs] [6c056f9ae2d] master: GP: Reduce memory reallocation in multiedit mode

Antonioya noreply at git.blender.org
Fri Jan 11 16:58:51 CET 2019


Commit: 6c056f9ae2d7898fe577d71a20daf4984838a577
Author: Antonioya
Date:   Fri Jan 11 16:58:18 2019 +0100
Branches: master
https://developer.blender.org/rB6c056f9ae2d7898fe577d71a20daf4984838a577

GP: Reduce memory reallocation in multiedit mode

There was a problem counting the number of points for edit points and lines. Now the total size is used allocating the VBO size and not the stroke size.

===================================================================

M	source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M	source/blender/draw/engines/gpencil/gpencil_draw_utils.c

===================================================================

diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index d5927ebca9a..beb9f3ee847 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -540,7 +540,7 @@ void DRW_gpencil_get_edit_geom(struct GpencilBatchCacheElem *be, bGPDstroke *gps
 		be->thickness_id = GPU_vertformat_attr_add(&be->format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
 
 		be->vbo = GPU_vertbuf_create_with_format(&be->format);
-		GPU_vertbuf_data_alloc(be->vbo, gps->totpoints);
+		GPU_vertbuf_data_alloc(be->vbo, be->tot_vertex);
 		be->vbo_len = 0;
 	}
 	gpencil_vbo_ensure_size(be, gps->totpoints);
@@ -619,7 +619,7 @@ void DRW_gpencil_get_edlin_geom(struct GpencilBatchCacheElem *be, bGPDstroke *gp
 		be->color_id = GPU_vertformat_attr_add(&be->format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
 
 		be->vbo = GPU_vertbuf_create_with_format(&be->format);
-		GPU_vertbuf_data_alloc(be->vbo, gps->totpoints);
+		GPU_vertbuf_data_alloc(be->vbo, be->tot_vertex);
 		be->vbo_len = 0;
 	}
 	gpencil_vbo_ensure_size(be, gps->totpoints);
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index 8bcd1e13fe1..bd0f6afd420 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -117,7 +117,7 @@ static void gpencil_calc_vertex(
 				cache_ob->tot_vertex += gps->totpoints + 3;
 				cache_ob->tot_triangles += gps->totpoints - 1;
 			}
-			if (!is_onion) {
+			if ((!is_multiedit) && (!is_onion)) {
 				break;
 			}
 		}
@@ -126,6 +126,8 @@ static void gpencil_calc_vertex(
 	cache->b_fill.tot_vertex = cache_ob->tot_triangles * 3;
 	cache->b_stroke.tot_vertex = cache_ob->tot_vertex;
 	cache->b_point.tot_vertex = cache_ob->tot_vertex;
+	cache->b_edit.tot_vertex = cache_ob->tot_vertex;
+	cache->b_edlin.tot_vertex = cache_ob->tot_vertex;
 
 	/* some modifiers can change the number of points */
 	int factor = 0;



More information about the Bf-blender-cvs mailing list