Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2019-04-26 15:02:58 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-04-26 16:33:49 +0300
commit50d75cd528b904760426ff9bcc31a3794e995edb (patch)
treeca5bdc2ce24bc944dc02951e74bd7e2e80d7990a /source/blender/draw/modes/pose_mode.c
parent03d482d212945eb46144524ccb8824d6889e8039 (diff)
Fix T62880 Severe FPS drop with multiple bone shapes
Fix instancing batches not being reused by custom bone shapes. Drawing thoses is now faster than 2.79 (40fps instead of 30fps)
Diffstat (limited to 'source/blender/draw/modes/pose_mode.c')
-rw-r--r--source/blender/draw/modes/pose_mode.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/source/blender/draw/modes/pose_mode.c b/source/blender/draw/modes/pose_mode.c
index 5e3353414f5..a37901a1fa9 100644
--- a/source/blender/draw/modes/pose_mode.c
+++ b/source/blender/draw/modes/pose_mode.c
@@ -72,6 +72,7 @@ typedef struct POSE_Data {
typedef struct POSE_PrivateData {
DRWShadingGroup *bone_selection_shgrp;
DRWShadingGroup *bone_selection_invert_shgrp;
+ GHash *custom_shapes[2];
float blend_color[4];
float blend_color_invert[4];
bool transparent_bones;
@@ -139,6 +140,8 @@ static void POSE_cache_init(void *vedata)
state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL |
DRW_STATE_BLEND | DRW_STATE_WIRE;
psl->relationship[i] = DRW_pass_create("Bone Relationship Pass", state);
+
+ ppd->custom_shapes[i] = BLI_ghash_ptr_new(__func__);
}
{
@@ -213,6 +216,7 @@ static void POSE_cache_populate(void *vedata, Object *ob)
.bone_envelope = psl->bone_envelope[ghost],
.bone_axes = psl->bone_axes,
.relationship_lines = psl->relationship[ghost],
+ .custom_shapes = ppd->custom_shapes[transp],
};
DRW_shgroup_armature_pose(ob, passes, transp);
}
@@ -231,6 +235,16 @@ static void POSE_cache_populate(void *vedata, Object *ob)
}
}
+static void POSE_cache_finish(void *vedata)
+{
+ POSE_PrivateData *ppd = ((POSE_Data *)vedata)->stl->g_data;
+
+ /* TODO(fclem): Do not free it for each frame but reuse it. Avoiding alloc cost. */
+ for (int i = 0; i < 2; i++) {
+ BLI_ghash_free(ppd->custom_shapes[i], NULL, NULL);
+ }
+}
+
/**
* Return true if armature should be handled by the pose mode engine.
*/
@@ -323,7 +337,7 @@ DrawEngineType draw_engine_pose_type = {
&POSE_engine_free,
&POSE_cache_init,
&POSE_cache_populate,
- NULL,
+ &POSE_cache_finish,
NULL,
&POSE_draw_scene,
NULL,