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/object_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/object_mode.c')
-rw-r--r--source/blender/draw/modes/object_mode.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index 7d42f59fea0..f7694f4a6f6 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -53,6 +53,8 @@
#include "BKE_particle.h"
#include "BKE_tracking.h"
+#include "BLI_ghash.h"
+
#include "ED_view3d.h"
#include "GPU_batch.h"
@@ -273,6 +275,8 @@ typedef struct OBJECT_PrivateData {
OBJECT_ShadingGroupList sgl;
OBJECT_ShadingGroupList sgl_ghost;
+ GHash *custom_shapes;
+
/* Outlines */
DRWShadingGroup *outlines_active;
DRWShadingGroup *outlines_select;
@@ -1040,6 +1044,8 @@ static void OBJECT_cache_init(void *vedata)
g_data->xray_enabled_and_not_wire = g_data->xray_enabled &&
draw_ctx->v3d->shading.type > OB_WIRE;
+ g_data->custom_shapes = BLI_ghash_ptr_new(__func__);
+
{
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL |
DRW_STATE_WIRE;
@@ -3288,6 +3294,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
.bone_envelope = sgl->bone_envelope,
.bone_axes = sgl->bone_axes,
.relationship_lines = NULL, /* Don't draw relationship lines */
+ .custom_shapes = stl->g_data->custom_shapes,
};
DRW_shgroup_armature_object(ob, view_layer, passes, is_wire);
}
@@ -3395,6 +3402,11 @@ static void OBJECT_cache_finish(void *vedata)
DRW_pass_sort_shgroup_z(stl->g_data->sgl.image_empties);
DRW_pass_sort_shgroup_z(stl->g_data->sgl_ghost.image_empties);
+
+ if (stl->g_data->custom_shapes) {
+ /* TODO(fclem): Do not free it for each frame but reuse it. Avoiding alloc cost. */
+ BLI_ghash_free(stl->g_data->custom_shapes, NULL, NULL);
+ }
}
static void OBJECT_draw_scene(void *vedata)