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:
authorJacques Lucke <mail@jlucke.com>2019-04-17 19:09:33 +0300
committerJacques Lucke <mail@jlucke.com>2019-04-17 19:09:33 +0300
commit81ce3801bf0a876b73b73817ca1a61b4e81b214d (patch)
treed9f749b8d494c68903b3f591434522c119177f7e /source/blender/blenkernel/BKE_fcurve.h
parent5f5a22970b4f7b3c42f73cf1f5a5dac4f32a14b0 (diff)
Animation: Refactor storage usage during fcurve modifier evaluation
Previously, when a fcurve modifier used storage, many heap allocations were done. This caused major slowdowns as described in T63656. Furthermore, the storage usage was a special case only used by the Cycles modifier. This refactor makes storage usage the "normal" case. That reduces the overall complexity. The storage is stack allocated now. The framerate on the provided test scene went up from ~5 fps to ~16 fps. Reviewers: angavrilov Differential Revision: https://developer.blender.org/D4701
Diffstat (limited to 'source/blender/blenkernel/BKE_fcurve.h')
-rw-r--r--source/blender/blenkernel/BKE_fcurve.h43
1 files changed, 14 insertions, 29 deletions
diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h
index 52a4d00b117..5e45faf1d0b 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -115,8 +115,6 @@ float evaluate_driver(struct PathResolvedRNA *anim_rna,
/* ************** F-Curve Modifiers *************** */
-typedef struct GHash FModifierStackStorage;
-
/* F-Curve Modifier Type-Info (fmi):
* This struct provides function pointers for runtime, so that functions can be
* written more generally (with fewer/no special exceptions for various modifiers).
@@ -136,6 +134,7 @@ typedef struct FModifierTypeInfo {
short requires; /* eFMI_Requirement_Flags */
char name[64]; /* name of modifier in interface */
char structName[64]; /* name of struct for SDNA */
+ uint storage_size; /* size of buffer that can be reused between time and value evaluation */
/* data management function pointers - special handling */
/* free any data that is allocated separately (optional) */
@@ -149,27 +148,11 @@ typedef struct FModifierTypeInfo {
/* evaluation */
/* evaluate time that the modifier requires the F-Curve to be evaluated at */
- float (*evaluate_modifier_time)(struct FCurve *fcu,
- struct FModifier *fcm,
- float cvalue,
- float evaltime);
+ float (*evaluate_modifier_time)(
+ struct FCurve *fcu, struct FModifier *fcm, float cvalue, float evaltime, void *storage);
/* evaluate the modifier for the given time and 'accumulated' value */
- void (*evaluate_modifier)(struct FCurve *fcu,
- struct FModifier *fcm,
- float *cvalue,
- float evaltime);
-
- /* Same as above but for modifiers which requires storage */
- float (*evaluate_modifier_time_storage)(FModifierStackStorage *storage,
- struct FCurve *fcu,
- struct FModifier *fcm,
- float cvalue,
- float evaltime);
- void (*evaluate_modifier_storage)(FModifierStackStorage *storage,
- struct FCurve *fcu,
- struct FModifier *fcm,
- float *cvalue,
- float evaltime);
+ void (*evaluate_modifier)(
+ struct FCurve *fcu, struct FModifier *fcm, float *cvalue, float evaltime, void *storage);
} FModifierTypeInfo;
/* Values which describe the behavior of a FModifier Type */
@@ -194,9 +177,6 @@ typedef enum eFMI_Requirement_Flags {
FMI_REQUIRES_NOTHING = (1 << 1),
/* refer to modifier instance */
FMI_REQUIRES_RUNTIME_CHECK = (1 << 2),
-
- /* Requires to store data shared between time and valua evaluation */
- FMI_REQUIRES_STORAGE = (1 << 3),
} eFMI_Requirement_Flags;
/* Function Prototypes for FModifierTypeInfo's */
@@ -216,14 +196,19 @@ void set_active_fmodifier(ListBase *modifiers, struct FModifier *fcm);
bool list_has_suitable_fmodifier(ListBase *modifiers, int mtype, short acttype);
-FModifierStackStorage *evaluate_fmodifiers_storage_new(ListBase *modifiers);
-void evaluate_fmodifiers_storage_free(FModifierStackStorage *storage);
-float evaluate_time_fmodifiers(FModifierStackStorage *storage,
+typedef struct FModifiersStackStorage {
+ uint modifier_count;
+ uint size_per_modifier;
+ void *buffer;
+} FModifiersStackStorage;
+
+uint evaluate_fmodifiers_storage_size_per_modifier(ListBase *modifiers);
+float evaluate_time_fmodifiers(FModifiersStackStorage *storage,
ListBase *modifiers,
struct FCurve *fcu,
float cvalue,
float evaltime);
-void evaluate_value_fmodifiers(FModifierStackStorage *storage,
+void evaluate_value_fmodifiers(FModifiersStackStorage *storage,
ListBase *modifiers,
struct FCurve *fcu,
float *cvalue,