Add more timing hooks for boolean.

This commit is contained in:
Howard Trickey 2020-12-05 07:48:41 -05:00
parent 887a602448
commit 8982a315b7
3 changed files with 54 additions and 2 deletions

View File

@ -2178,8 +2178,8 @@ static void calc_overlap_itts_range_func(void *__restrict userdata,
}
/**
* Fill in itt_map with the vector of ITT_values that result from intersecting the triangles in ov.
* Use a canonical order for triangles: (a,b) where a < b.
* Fill in itt_map with the vector of ITT_values that result from intersecting the triangles in
* ov. Use a canonical order for triangles: (a,b) where a < b.
*/
static void calc_overlap_itts(Map<std::pair<int, int>, ITT_value> &itt_map,
const IMesh &tm,

View File

@ -30,6 +30,10 @@
#include "bmesh_boolean.h"
#include "bmesh_edgesplit.h"
#include "PIL_time.h"
// #define PERF_DEBUG
namespace blender::meshintersect {
#ifdef WITH_GMP
@ -354,7 +358,14 @@ static bool bmesh_boolean(BMesh *bm,
{
IMeshArena arena;
IMesh m_triangulated;
# ifdef PERF_DEBUG
double start_time = PIL_check_seconds_timer();
# endif
IMesh m_in = mesh_from_bm(bm, looptris, looptris_tot, &m_triangulated, &arena);
# ifdef PERF_DEBUG
double mesh_time = PIL_check_seconds_timer();
std::cout << "bmesh_boolean, imesh_from_bm done, time = " << mesh_time - start_time << "\n";
# endif
std::function<int(int)> shape_fn;
if (use_self && boolean_mode == BoolOpType::None) {
/* Unary knife operation. Want every face where test_fn doesn't return -1. */
@ -379,7 +390,16 @@ static bool bmesh_boolean(BMesh *bm,
}
IMesh m_out = boolean_mesh(
m_in, boolean_mode, nshapes, shape_fn, use_self, &m_triangulated, &arena);
# ifdef PERF_DEBUG
double boolean_time = PIL_check_seconds_timer();
std::cout << "boolean done, time = " << boolean_time - mesh_time << "\n";
# endif
bool any_change = apply_mesh_output_to_bmesh(bm, m_out, keep_hidden);
# ifdef PERF_DEBUG
double apply_mesh_time = PIL_check_seconds_timer();
std::cout << "applied boolean output to bmesh, time = " << apply_mesh_time - boolean_time
<< "\n";
# endif
if (use_separate_all) {
/* We are supposed to separate all faces that are incident on intersection edges. */
BM_mesh_edgesplit(bm, false, true, false);

View File

@ -630,7 +630,15 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
Object *operand_ob = bmd->object;
#ifdef DEBUG_TIME
TIMEIT_BLOCK_INIT(operand_get_evaluated_mesh);
TIMEIT_BLOCK_START(operand_get_evaluated_mesh);
#endif
mesh_operand_ob = BKE_modifier_get_evaluated_mesh_from_evaluated_object(operand_ob, false);
#ifdef DEBUG_TIME
TIMEIT_BLOCK_END(operand_get_evaluated_mesh);
TIMEIT_BLOCK_STATS(operand_get_evaluated_mesh);
#endif
if (mesh_operand_ob) {
/* XXX This is utterly non-optimal, we may go from a bmesh to a mesh back to a bmesh!
@ -642,11 +650,35 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
result = get_quick_mesh(object, mesh, operand_ob, mesh_operand_ob, bmd->operation);
if (result == NULL) {
#ifdef DEBUG_TIME
TIMEIT_BLOCK_INIT(object_BMD_mesh_bm_create);
TIMEIT_BLOCK_START(object_BMD_mesh_bm_create);
#endif
bm = BMD_mesh_bm_create(mesh, object, mesh_operand_ob, operand_ob, &is_flip);
#ifdef DEBUG_TIME
TIMEIT_BLOCK_END(object_BMD_mesh_bm_create);
TIMEIT_BLOCK_STATS(object_BMD_mesh_bm_create);
#endif
#ifdef DEBUG_TIME
TIMEIT_BLOCK_INIT(BMD_mesh_intersection);
TIMEIT_BLOCK_START(BMD_mesh_intersection);
#endif
BMD_mesh_intersection(bm, md, ctx, mesh_operand_ob, object, operand_ob, is_flip);
#ifdef DEBUG_TIME
TIMEIT_BLOCK_END(BMD_mesh_intersection);
TIMEIT_BLOCK_STATS(BMD_mesh_intersection);
#endif
#ifdef DEBUG_TIME
TIMEIT_BLOCK_INIT(BKE_mesh_from_bmesh_for_eval_nomain);
TIMEIT_BLOCK_START(BKE_mesh_from_bmesh_for_eval_nomain);
#endif
result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL, mesh);
#ifdef DEBUG_TIME
TIMEIT_BLOCK_END(BKE_mesh_from_bmesh_for_eval_nomain);
TIMEIT_BLOCK_STATS(BKE_mesh_from_bmesh_for_eval_nomain);
#endif
BM_mesh_free(bm);
result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
}