diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-09-27 23:42:57 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-09-29 16:28:15 +0300 |
commit | f6fc863acd7c24874026202d4c2aec50c60b40d2 (patch) | |
tree | 541dab504b4a4132869d4ba982c42aeca049f661 /source/blender/draw/intern/draw_manager_data.c | |
parent | c931a0057ffea26175a2dc111718e5f3590b00f8 (diff) |
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
Diffstat (limited to 'source/blender/draw/intern/draw_manager_data.c')
-rw-r--r-- | source/blender/draw/intern/draw_manager_data.c | 19 |
1 files changed, 11 insertions, 8 deletions
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; |