[Bf-blender-cvs] [7329f11] temp_custom_loop_normals: More optimization: Allocate all LinkNode need for loops in one step, instead of doing one alloc per loop.
Bastien Montagne
noreply at git.blender.org
Thu Aug 7 20:27:02 CEST 2014
Commit: 7329f1141038936a4f12df0e54f256273a9edbee
Author: Bastien Montagne
Date: Thu Aug 7 20:23:18 2014 +0200
Branches: temp_custom_loop_normals
https://developer.blender.org/rB7329f1141038936a4f12df0e54f256273a9edbee
More optimization: Allocate all LinkNode need for loops in one step, instead of doing one alloc per loop.
This allocate a bit more memory than needed (since we won't use linknodes of 'sharp' loops),
but avoids calling BLI_linklist_prepend_memarena() once per 'smooth' loop.
Note: gave much less benefits than expected, in the end - guess memarena allocation is *really* fast!
===================================================================
M source/blender/blenkernel/BKE_mesh.h
M source/blender/blenkernel/intern/mesh_evaluate.c
M source/blender/modifiers/intern/MOD_setsplitnormal.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index 73751b2..f98703a 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -197,6 +197,7 @@ typedef struct MLoopNorSpace {
} MLoopNorSpace;
typedef struct MLoopsNorSpaces {
MLoopNorSpace **lspaces;
+ LinkNode *loops_pool; /* Allocated once, avoids to call BLI_linklist_prepend_arena() for each loop! */
MemArena *mem;
} MLoopsNorSpaces;
void BKE_init_loops_normal_spaces(MLoopsNorSpaces *lnors_spaces, const int numLoops);
diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c
index 82a4e84..396ed2b 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.c
+++ b/source/blender/blenkernel/intern/mesh_evaluate.c
@@ -321,12 +321,14 @@ void BKE_init_loops_normal_spaces(MLoopsNorSpaces *lnors_spaces, const int numLo
{
MemArena *mem = lnors_spaces->mem = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
lnors_spaces->lspaces = BLI_memarena_calloc(mem, sizeof(MLoopNorSpace *) * (size_t)numLoops);
+ lnors_spaces->loops_pool = BLI_memarena_alloc(mem, sizeof(LinkNode) * (size_t)numLoops);
}
void BKE_free_loops_normal_spaces(MLoopsNorSpaces *lnors_spaces)
{
BLI_memarena_free(lnors_spaces->mem);
lnors_spaces->lspaces = NULL;
+ lnors_spaces->loops_pool = NULL;
lnors_spaces->mem = NULL;
}
@@ -397,11 +399,11 @@ void BKE_lnor_space_define(MLoopNorSpace *lnor_space, const float lnor[3],
}
void BKE_lnor_space_add_loop(MLoopsNorSpaces *lnors_spaces, MLoopNorSpace *lnor_space, const int ml_index,
- const bool add_to_list)
+ const bool do_add_loop)
{
lnors_spaces->lspaces[ml_index] = lnor_space;
- if (add_to_list) {
- BLI_linklist_prepend_arena(&lnor_space->loops, SET_INT_IN_POINTER(ml_index), lnors_spaces->mem);
+ if (do_add_loop) {
+ BLI_linklist_prepend_nlink(&lnor_space->loops, SET_INT_IN_POINTER(ml_index), &lnors_spaces->loops_pool[ml_index]);
}
}
diff --git a/source/blender/modifiers/intern/MOD_setsplitnormal.c b/source/blender/modifiers/intern/MOD_setsplitnormal.c
index d5974cd..f93fa44 100644
--- a/source/blender/modifiers/intern/MOD_setsplitnormal.c
+++ b/source/blender/modifiers/intern/MOD_setsplitnormal.c
@@ -200,7 +200,7 @@ static float vertex_weight(MDeformVert *dvert, const int index, const int defgrp
static void setSplitNormalModifier_do(SetSplitNormalModifierData *smd, Object *ob, DerivedMesh *dm)
{
- float (*clnors)[2];
+ short (*clnors)[2];
const int num_verts = dm->getNumVerts(dm);
const int num_edges = dm->getNumEdges(dm);
const int num_loops = dm->getNumLoops(dm);
More information about the Bf-blender-cvs
mailing list