[Bf-blender-cvs] [49e9d105f0e] tmp-worbench-rewrite2-optimizations: Experimental bbox cache
Miguel Pozo
noreply at git.blender.org
Tue Jan 17 16:15:31 CET 2023
Commit: 49e9d105f0e9d97fe2ff76ae6e4da04d94740a7b
Author: Miguel Pozo
Date: Wed Jan 11 17:19:45 2023 +0100
Branches: tmp-worbench-rewrite2-optimizations
https://developer.blender.org/rB49e9d105f0e9d97fe2ff76ae6e4da04d94740a7b
Experimental bbox cache
===================================================================
M source/blender/draw/intern/draw_manager_data.cc
M source/blender/draw/intern/draw_resource.hh
===================================================================
diff --git a/source/blender/draw/intern/draw_manager_data.cc b/source/blender/draw/intern/draw_manager_data.cc
index 5b4e0792577..01cdf785a05 100644
--- a/source/blender/draw/intern/draw_manager_data.cc
+++ b/source/blender/draw/intern/draw_manager_data.cc
@@ -719,8 +719,18 @@ static void drw_call_obinfos_init(DRWObjectInfos *ob_infos, Object *ob)
static void drw_call_culling_init(DRWCullingState *cull, Object *ob)
{
- const BoundBox *bbox;
- if (ob != nullptr && (bbox = BKE_object_boundbox_get(ob))) {
+ /* WORKAROUND (Experimental):
+ * Store the last retrieved bbox so each object instance doesn't have to malloc a new one */
+ static const BoundBox *bbox_cache = nullptr;
+ static const void *object_data_cache = nullptr;
+
+ if (ob != nullptr && ob->data != object_data_cache) {
+ // object_data_cache = ob->data;
+ bbox_cache = BKE_object_boundbox_get(ob);
+ }
+ const BoundBox *bbox = bbox_cache;
+
+ if (ob != nullptr && bbox != nullptr) {
float corner[3];
/* Get BoundSphere center and radius from the BoundBox. */
mid_v3_v3v3(cull->bsphere.center, bbox->vec[0], bbox->vec[6]);
diff --git a/source/blender/draw/intern/draw_resource.hh b/source/blender/draw/intern/draw_resource.hh
index a2de084b900..d1a6b2a5468 100644
--- a/source/blender/draw/intern/draw_resource.hh
+++ b/source/blender/draw/intern/draw_resource.hh
@@ -151,7 +151,17 @@ inline void ObjectBounds::sync()
inline void ObjectBounds::sync(Object &ob)
{
- const BoundBox *bbox = BKE_object_boundbox_get(&ob);
+ /* WORKAROUND (Experimental):
+ * Store the last retrieved bbox so each object instance doesn't have to malloc a new one */
+ static const BoundBox *bbox_cache = nullptr;
+ static const void *object_data_cache = nullptr;
+
+ if (ob.data != object_data_cache) {
+ // object_data_cache = ob.data;
+ bbox_cache = BKE_object_boundbox_get(&ob);
+ }
+
+ const BoundBox *bbox = bbox_cache;
if (bbox == nullptr) {
bounding_sphere.w = -1.0f; /* Disable test. */
return;
More information about the Bf-blender-cvs
mailing list