From f6fc863acd7c24874026202d4c2aec50c60b40d2 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 27 Sep 2019 22:42:57 +0200 Subject: Sculpt: multithread GPU draw buffer filling for workbench This improves performance of some sculpt tools, particularly those that modify many vertices like filter and mask tools, or use brushes with large radius. For mask expand it can make updates up to 2x faster on heavy meshes, but for most tools it's more on the order of 1-1.1x. There are bigger bottlenecks to solve, like normal updates. Ref T70295 Differential Revision: https://developer.blender.org/D5926 --- source/blender/draw/intern/draw_manager_data.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'source/blender/draw/intern') diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index 78353a58e33..e978ae44bcd 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -834,14 +834,14 @@ static float sculpt_debug_colors[9][4] = { static void sculpt_draw_cb(DRWSculptCallbackData *scd, GPU_PBVH_Buffers *buffers) { - GPUBatch *geom = GPU_pbvh_buffers_batch_get(buffers, scd->fast_mode, scd->use_wire); - short index = 0; - /* Meh... use_mask is a bit misleading here. */ if (scd->use_mask && !GPU_pbvh_buffers_has_mask(buffers)) { return; } + GPUBatch *geom = GPU_pbvh_buffers_batch_get(buffers, scd->fast_mode, scd->use_wire); + short index = 0; + if (scd->use_mats) { index = GPU_pbvh_buffers_material_index_get(buffers); } @@ -906,25 +906,28 @@ static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd, bool use_vcol) return; } + const DRWContextState *drwctx = DRW_context_state_get(); + RegionView3D *rv3d = drwctx->rv3d; + + /* Frustum planes to show only visible PBVH nodes. */ float planes[6][4]; drw_sculpt_get_frustum_planes(scd->ob, planes); PBVHFrustumPlanes frustum = {.planes = planes, .num_planes = 6}; + /* Fast mode to show low poly multires while navigating. */ scd->fast_mode = false; - - const DRWContextState *drwctx = DRW_context_state_get(); if (drwctx->evil_C != NULL) { Paint *p = BKE_paint_get_active_from_context(drwctx->evil_C); if (p && (p->flags & PAINT_FAST_NAVIGATE)) { - scd->fast_mode = (drwctx->rv3d->rflag & RV3D_NAVIGATING) != 0; + scd->fast_mode = rv3d && (rv3d->rflag & RV3D_NAVIGATING); } } Mesh *mesh = scd->ob->data; BKE_pbvh_update_normals(pbvh, mesh->runtime.subdiv_ccg); - BKE_pbvh_update_draw_buffers(pbvh, use_vcol); - BKE_pbvh_draw_cb(pbvh, &frustum, (void (*)(void *, GPU_PBVH_Buffers *))sculpt_draw_cb, scd); + BKE_pbvh_draw_cb( + pbvh, use_vcol, &frustum, (void (*)(void *, GPU_PBVH_Buffers *))sculpt_draw_cb, scd); if (SCULPT_DEBUG_BUFFERS) { int debug_node_nr = 0; -- cgit v1.2.3