[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59690] branches/soc-2013-depsgraph_mt/ source/blender: Pass EvaluationContext to object update routines

Sergey Sharybin sergey.vfx at gmail.com
Sat Aug 31 13:01:51 CEST 2013


Revision: 59690
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59690
Author:   nazgul
Date:     2013-08-31 11:01:50 +0000 (Sat, 31 Aug 2013)
Log Message:
-----------
Pass EvaluationContext to object update routines

Main purpose of this change is to get rid of legacy
G.is_rendering check to distinguish whether update
happens for viewport or for render purposes.

Currently EvaluationContext structure only contains
single field, which indicates whether update happens
for viewport or render, but in the future it might
be extended by all the stuff needed for duplis and
friends.

This commit also gets rid of derived mesh creation
fro modifier stack for operand objects (like second
operand for boolean). This was only confusing and
violated threaded update actually. Now modifier stack
assumes all the dependencies are met and derived
meshes for operand objects might be just used.

This requires some changes to renderer as well,
so now there's also a derivedRender stored in object
structure. It also solves old TODO when boolean
will use preview setting for it's operand subsurf
level.

There's still the whole bunch of TODOs:
- Duplis might have some regressions when rendering.

- External render engines are to be take care about
  (there might be some regressions for them as well,
  because they're for sure not aware of derivedRender).

- Viewport required DAG_on_visible_update when changing
  current screen to keep all DMs up-to-date. The same
  happens when changing the scene, so perhaps this is
  correct thing to have anyway.

- Render database is doing some tricks to make sure
  derivedRender for invisible objects but which are
  needed for other objects are properly calculated.

  It uses some recursion and might end up with some
  crashes if having dependency cycles.

  This is to be changed to non-recursive algorithm
  which would be aware of cycles as well. API might
  have some cleanup as well.

- Ideally, derivedRender shall be calculated in threads
  (same as what's happening in scene evaluation).

- Currently only meshes are being changed. Other types
  of objects are not expected to change any behavior.

Modified Paths:
--------------
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_DerivedMesh.h
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_anim.h
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_depsgraph.h
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_group.h
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_object.h
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_scene.h
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/DerivedMesh.c
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/anim.c
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/depsgraph.c
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/dynamicpaint.c
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/group.c
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/object.c
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/pointcache.c
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/scene.c
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/sequencer.c
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/shrinkwrap.c
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/smoke.c
    branches/soc-2013-depsgraph_mt/source/blender/blenloader/intern/readfile.c
    branches/soc-2013-depsgraph_mt/source/blender/collada/AnimationExporter.cpp
    branches/soc-2013-depsgraph_mt/source/blender/editors/mesh/editmesh_extrude.c
    branches/soc-2013-depsgraph_mt/source/blender/editors/mesh/editmesh_utils.c
    branches/soc-2013-depsgraph_mt/source/blender/editors/object/object_add.c
    branches/soc-2013-depsgraph_mt/source/blender/editors/render/render_internal.c
    branches/soc-2013-depsgraph_mt/source/blender/editors/render/render_opengl.c
    branches/soc-2013-depsgraph_mt/source/blender/editors/screen/screen_edit.c
    branches/soc-2013-depsgraph_mt/source/blender/editors/sound/sound_ops.c
    branches/soc-2013-depsgraph_mt/source/blender/editors/space_view3d/view3d_draw.c
    branches/soc-2013-depsgraph_mt/source/blender/editors/space_view3d/view3d_view.c
    branches/soc-2013-depsgraph_mt/source/blender/editors/transform/transform_conversions.c
    branches/soc-2013-depsgraph_mt/source/blender/editors/transform/transform_snap.c
    branches/soc-2013-depsgraph_mt/source/blender/gpu/intern/gpu_material.c
    branches/soc-2013-depsgraph_mt/source/blender/makesdna/DNA_object_types.h
    branches/soc-2013-depsgraph_mt/source/blender/makesrna/intern/rna_object_api.c
    branches/soc-2013-depsgraph_mt/source/blender/makesrna/intern/rna_scene_api.c
    branches/soc-2013-depsgraph_mt/source/blender/modifiers/intern/MOD_array.c
    branches/soc-2013-depsgraph_mt/source/blender/modifiers/intern/MOD_boolean.c
    branches/soc-2013-depsgraph_mt/source/blender/modifiers/intern/MOD_util.c
    branches/soc-2013-depsgraph_mt/source/blender/modifiers/intern/MOD_util.h
    branches/soc-2013-depsgraph_mt/source/blender/render/intern/source/convertblender.c
    branches/soc-2013-depsgraph_mt/source/blender/render/intern/source/external_engine.c
    branches/soc-2013-depsgraph_mt/source/blender/render/intern/source/pipeline.c
    branches/soc-2013-depsgraph_mt/source/blender/windowmanager/intern/wm_event_system.c
    branches/soc-2013-depsgraph_mt/source/blender/windowmanager/intern/wm_operators.c

Modified: branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_DerivedMesh.h
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_DerivedMesh.h	2013-08-31 08:18:08 UTC (rev 59689)
+++ branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_DerivedMesh.h	2013-08-31 11:01:50 UTC (rev 59690)
@@ -640,6 +640,8 @@
 DerivedMesh *mesh_create_derived_for_modifier(struct Scene *scene, struct Object *ob,
                                               struct ModifierData *md, int build_shapekey_layers);
 
+DerivedMesh *mesh_get_derived_render(struct Scene *scene, struct Object *ob,
+                                     CustomDataMask dataMask);
 DerivedMesh *mesh_create_derived_render(struct Scene *scene, struct Object *ob,
                                         CustomDataMask dataMask);
 
@@ -674,6 +676,7 @@
 int editbmesh_modifier_is_enabled(struct Scene *scene, struct ModifierData *md, DerivedMesh *dm);
 void makeDerivedMesh(struct Scene *scene, struct Object *ob, struct BMEditMesh *em, 
                      CustomDataMask dataMask, int build_shapekey_layers);
+void makeDerivedMeshRender(struct Scene *scene, struct Object *ob, CustomDataMask dataMask);
 
 /** returns an array of deform matrices for crazyspace correction, and the
  * number of modifiers left */

Modified: branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_anim.h
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_anim.h	2013-08-31 08:18:08 UTC (rev 59689)
+++ branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_anim.h	2013-08-31 11:01:50 UTC (rev 59690)
@@ -32,6 +32,7 @@
  *  \author nzc
  *  \since March 2001
  */
+struct EvaluationContext;
 struct Path;
 struct Object;
 struct PartEff;
@@ -65,8 +66,9 @@
 /* ---------------------------------------------------- */
 /* Dupli-Geometry */
 
-struct ListBase *object_duplilist_ex(struct Scene *sce, struct Object *ob, bool update, bool for_render);
-struct ListBase *object_duplilist(struct Scene *sce, struct Object *ob, bool for_render);
+struct ListBase *object_duplilist_ex(struct EvaluationContext *evaluation_context, struct Scene *sce, struct Object *ob, bool update);
+struct ListBase *object_duplilist(struct EvaluationContext *evaluation_context, struct Scene *sce, struct Object *ob);
+struct ListBase *object_duplilist_viewport(struct Scene *scene, struct Object *object);
 void free_object_duplilist(struct ListBase *lb);
 int count_duplilist(struct Object *ob);
 

Modified: branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_depsgraph.h
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_depsgraph.h	2013-08-31 08:18:08 UTC (rev 59689)
+++ branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_depsgraph.h	2013-08-31 11:01:50 UTC (rev 59690)
@@ -130,10 +130,6 @@
                                             void (*func)(void *node, void *user_data),
                                             void *user_data);
 
-struct Object *DAG_threaded_update_get_node_object(void *node_v);
-
-const char *DAG_threaded_update_get_node_name(void *node_v);
-
 void DAG_threaded_update_handle_node_updated(void *node_v,
                                              void (*func)(void *node, void *user_data),
                                              void *user_data);
@@ -142,6 +138,17 @@
 
 void DAG_print_dependencies(struct Main *bmain, struct Scene *scene, struct Object *ob);
 
+/* Tagging and querying */
+void DAG_tag_clear_nodes(struct Scene *scene);
+void DAG_tag_condition_nodes(struct Scene *scene, bool (*condition) (void *node_v, void *user_data),
+                             void *user_data);
+void DAG_tag_flush_nodes(struct Scene *scene);
+void DAG_foreach_tagged_nodes(struct Scene *scene, void (*callback) (void *node_v, void *user_data),
+                              void *user_data);
+
+struct Object *DAG_get_node_object(void *node_v);
+const char *DAG_get_node_name(void *node_v);
+
 #ifdef __cplusplus
 }
 #endif

Modified: branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_group.h
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_group.h	2013-08-31 08:18:08 UTC (rev 59689)
+++ branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_group.h	2013-08-31 11:01:50 UTC (rev 59690)
@@ -34,6 +34,7 @@
  */
 
 struct Base;
+struct EvaluationContext;
 struct Group;
 struct GroupObject;
 struct Main;
@@ -52,6 +53,6 @@
 bool          BKE_group_is_animated(struct Group *group, struct Object *parent);
 
 void          BKE_group_tag_recalc(struct Group *group);
-void          BKE_group_handle_recalc_and_update(struct Scene *scene, struct Object *parent, struct Group *group);
+void          BKE_group_handle_recalc_and_update(struct EvaluationContext *evaluation_context, struct Scene *scene, struct Object *parent, struct Group *group);
 
 #endif  /* __BKE_GROUP_H__ */

Modified: branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_object.h
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_object.h	2013-08-31 08:18:08 UTC (rev 59689)
+++ branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_object.h	2013-08-31 11:01:50 UTC (rev 59690)
@@ -34,6 +34,7 @@
 #endif
 
 struct Base;
+struct EvaluationContext;
 struct Scene;
 struct Object;
 struct Camera;
@@ -65,6 +66,7 @@
 
 void BKE_object_free(struct Object *ob);
 void BKE_object_free_derived_caches(struct Object *ob);
+void BKE_object_free_derivedRender_caches(struct Object *ob);
 
 bool BKE_object_support_modifier_type_check(struct Object *ob, int modifier_type);
 
@@ -150,8 +152,9 @@
                                       const ObjectTfmProtectedChannels *obtfm,
                                       const short protectflag);
 
-void BKE_object_handle_update(struct Scene *scene, struct Object *ob);
-void BKE_object_handle_update_ex(struct Scene *scene, struct Object *ob,
+void BKE_object_handle_update(struct EvaluationContext *evaluation_context, struct Scene *scene, struct Object *ob);
+void BKE_object_handle_update_ex(struct EvaluationContext *evaluation_context,
+                                 struct Scene *scene, struct Object *ob,
                                  struct RigidBodyWorld *rbw);
 void BKE_object_sculpt_modifiers_changed(struct Object *ob);
 

Modified: branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_scene.h
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_scene.h	2013-08-31 08:18:08 UTC (rev 59689)
+++ branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_scene.h	2013-08-31 11:01:50 UTC (rev 59690)
@@ -39,6 +39,7 @@
 
 struct AviCodecData;
 struct Base;
+struct EvaluationContext;
 struct bglMats;
 struct Main;
 struct Object;
@@ -111,12 +112,23 @@
 float BKE_scene_frame_get_from_ctime(struct Scene *scene, const float frame);
 void  BKE_scene_frame_set(struct Scene *scene, double cfra);
 
-void BKE_scene_update_tagged_ex(struct Main *bmain, struct Scene *scene, bool use_threads);
-void BKE_scene_update_tagged(struct Main *bmain, struct Scene *sce);
+/* **  Scene evaluation ** */
 
-void BKE_scene_update_for_newframe_ex(struct Main *bmain, struct Scene *sce, unsigned int lay, bool use_threads);
-void BKE_scene_update_for_newframe(struct Main *bmain, struct Scene *sce, unsigned int lay);
+/* TODO(sergey): Find a better place for this. */
+typedef struct EvaluationContext {
+	bool for_render;  /* Set to true if evaluation shall be performed for render purposes,
+	                     keep at false if update shall happen for the viewport. */
+} EvaluationContext;
 
+void BKE_scene_update_tagged_ex(struct EvaluationContext *evaluation_context, struct Main *bmain, struct Scene *scene, bool use_threads);
+void BKE_scene_update_tagged(struct EvaluationContext *evaluation_context, struct Main *bmain, struct Scene *sce);
+
+void BKE_scene_update_for_newframe_ex(struct EvaluationContext *evaluation_context, struct Main *bmain, struct Scene *sce, unsigned int lay, bool use_threads);
+void BKE_scene_update_for_newframe(struct EvaluationContext *evaluation_context, struct Main *bmain, struct Scene *sce, unsigned int lay);
+
+void BKE_scene_update_for_newframe_viewport(struct Main *bmain, struct Scene *sce, unsigned int lay);
+void BKE_scene_update_for_newframe_render(struct Main *bmain, struct Scene *sce, unsigned int lay);
+
 struct SceneRenderLayer *BKE_scene_add_render_layer(struct Scene *sce, const char *name);
 int BKE_scene_remove_render_layer(struct Main *main, struct Scene *scene, struct SceneRenderLayer *srl);
 

Modified: branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/DerivedMesh.c	2013-08-31 08:18:08 UTC (rev 59689)
+++ branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/DerivedMesh.c	2013-08-31 11:01:50 UTC (rev 59690)
@@ -2305,6 +2305,20 @@
 	}
 }
 
+void makeDerivedMeshRender(Scene *scene, Object *ob, CustomDataMask dataMask)
+{
+	if (ob->derivedRender) {
+		ob->derivedRender->needsFree = 1;
+		ob->derivedRender->release(ob->derivedRender);
+	}
+
+	mesh_calc_modifiers(scene, ob, NULL, NULL, &ob->derivedRender, 1, 1, 0, dataMask, -1, 0, 0);
+
+	ob->derivedRender->needsFree = 0;
+
+	BLI_assert(!(ob->derivedRender->dirty & DM_DIRTY_NORMALS));
+}
+
 /***/
 
 DerivedMesh *mesh_get_derived_final(Scene *scene, Object *ob, CustomDataMask dataMask)
@@ -2334,13 +2348,24 @@
 	return ob->derivedDeform;
 }
 
+DerivedMesh *mesh_get_derived_render(Scene *scene, Object *ob, CustomDataMask dataMask)
+{
+	/* TODO(sergey): Add data mask check here. */
+	if (!ob->derivedRender) {
+		makeDerivedMeshRender(scene, ob, dataMask);
+	}
+
+	return ob->derivedRender;
+}
+
 DerivedMesh *mesh_create_derived_render(Scene *scene, Object *ob, CustomDataMask dataMask)
 {
-	DerivedMesh *final;
-	
-	mesh_calc_modifiers(scene, ob, NULL, NULL, &final, 1, 1, 0, dataMask, -1, 0, 0);
+	/* TODO(sergey): Add data mask check here. */
+	if (!ob->derivedRender) {

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list