Sculpt: Add timing information for BMesh PBVH
The goal is to make it possible to have more or less reliable way to perform performance comparisons of changes in algorithms used in dynamic topology. This change allows to run Blender with the following arguments: blender --log "sculpt.detail,pbvh.bmesh" --log-level 2 and see timing of dynamic topology flood-fill operation, as well as individual timings of edge subdivision/collapsing. Pull Request: https://projects.blender.org/blender/blender/pulls/114099
This commit is contained in:
parent
15692501b2
commit
92a19747f0
|
@ -25,6 +25,12 @@
|
|||
#include "bmesh.h"
|
||||
#include "pbvh_intern.hh"
|
||||
|
||||
#include "PIL_time.h"
|
||||
|
||||
#include "CLG_log.h"
|
||||
|
||||
static CLG_LogRef LOG = {"pbvh.bmesh"};
|
||||
|
||||
using blender::Array;
|
||||
using blender::IndexRange;
|
||||
using blender::Span;
|
||||
|
@ -1134,6 +1140,8 @@ static void pbvh_bmesh_split_edge(EdgeQueueContext *eq_ctx, PBVH *pbvh, BMEdge *
|
|||
|
||||
static bool pbvh_bmesh_subdivide_long_edges(EdgeQueueContext *eq_ctx, PBVH *pbvh)
|
||||
{
|
||||
const double start_time = PIL_check_seconds_timer();
|
||||
|
||||
bool any_subdivided = false;
|
||||
|
||||
while (!BLI_heapsimple_is_empty(eq_ctx->q->heap)) {
|
||||
|
@ -1174,6 +1182,9 @@ static bool pbvh_bmesh_subdivide_long_edges(EdgeQueueContext *eq_ctx, PBVH *pbvh
|
|||
pbvh_bmesh_edge_tag_verify(pbvh);
|
||||
#endif
|
||||
|
||||
CLOG_INFO(
|
||||
&LOG, 2, "Long edge subdivision took %f seconds.", PIL_check_seconds_timer() - start_time);
|
||||
|
||||
return any_subdivided;
|
||||
}
|
||||
|
||||
|
@ -1312,6 +1323,8 @@ static void pbvh_bmesh_collapse_edge(
|
|||
|
||||
static bool pbvh_bmesh_collapse_short_edges(EdgeQueueContext *eq_ctx, PBVH *pbvh)
|
||||
{
|
||||
const double start_time = PIL_check_seconds_timer();
|
||||
|
||||
const float min_len_squared = pbvh->bm_min_edge_len * pbvh->bm_min_edge_len;
|
||||
bool any_collapsed = false;
|
||||
/* Deleted verts point to vertices they were merged into, or nullptr when removed. */
|
||||
|
@ -1360,6 +1373,9 @@ static bool pbvh_bmesh_collapse_short_edges(EdgeQueueContext *eq_ctx, PBVH *pbvh
|
|||
|
||||
BLI_ghash_free(deleted_verts, nullptr, nullptr);
|
||||
|
||||
CLOG_INFO(
|
||||
&LOG, 2, "Short edge collapse took %f seconds.", PIL_check_seconds_timer() - start_time);
|
||||
|
||||
return any_collapsed;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,9 +39,15 @@
|
|||
#include "RNA_access.hh"
|
||||
#include "RNA_define.hh"
|
||||
|
||||
#include "PIL_time.h"
|
||||
|
||||
#include "CLG_log.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
|
||||
static CLG_LogRef LOG = {"sculpt.detail"};
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Internal Utilities
|
||||
* \{ */
|
||||
|
@ -109,6 +115,8 @@ static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *op)
|
|||
SCULPT_undo_push_begin(ob, op);
|
||||
SCULPT_undo_push_node(ob, nullptr, SCULPT_UNDO_COORDS);
|
||||
|
||||
const double start_time = PIL_check_seconds_timer();
|
||||
|
||||
while (BKE_pbvh_bmesh_update_topology(
|
||||
ss->pbvh, PBVH_Collapse | PBVH_Subdivide, center, nullptr, size, false, false))
|
||||
{
|
||||
|
@ -117,6 +125,8 @@ static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *op)
|
|||
}
|
||||
}
|
||||
|
||||
CLOG_INFO(&LOG, 2, "Detail flood fill took %f seconds.", PIL_check_seconds_timer() - start_time);
|
||||
|
||||
SCULPT_undo_push_end(ob);
|
||||
|
||||
/* Force rebuild of PBVH for better BB placement. */
|
||||
|
|
Loading…
Reference in New Issue