Depsgraph: Reduce number of depsgraph_legacy usages outside of depsgraph
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 20 Oct 2017 15:01:35 +0000 (17:01 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 20 Oct 2017 15:01:35 +0000 (17:01 +0200)
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/displist.c
source/blender/depsgraph/intern/depsgraph_eval.cc
source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
source/blender/modifiers/intern/MOD_subsurf.c

index 18db368ee2b2c9594e1725346acd738e7c35043f..f5da88f57f3f356c293115f581deeb768654ea76 100644 (file)
@@ -2611,7 +2611,8 @@ static void editbmesh_calc_modifiers(
  * we'll be using GPU backend of OpenSubdiv. This is so
  * playback performance is kept as high as possible.
  */
-static bool calc_modifiers_skip_orco(Scene *scene,
+static bool calc_modifiers_skip_orco(const EvaluationContext *eval_ctx,
+                                     Scene *scene,
                                      Object *ob,
                                      bool use_render_params)
 {
@@ -2627,8 +2628,7 @@ static bool calc_modifiers_skip_orco(Scene *scene,
                else if ((ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) != 0) {
                        return false;
                }
-               /* TODO(sergey): How do we get depsgraph here? */
-               else if ((DEG_get_eval_flags_for_id(scene->depsgraph_legacy, &ob->id) & DAG_EVAL_NEED_CPU) != 0) {
+               else if ((DEG_get_eval_flags_for_id(eval_ctx->depsgraph, &ob->id) & DAG_EVAL_NEED_CPU) != 0) {
                        return false;
                }
                SubsurfModifierData *smd = (SubsurfModifierData *)last_md;
@@ -2649,7 +2649,7 @@ static void mesh_build_data(
        BKE_object_sculpt_modifiers_changed(ob);
 
 #ifdef WITH_OPENSUBDIV
-       if (calc_modifiers_skip_orco(scene, ob, false)) {
+       if (calc_modifiers_skip_orco(eval_ctx, scene, ob, false)) {
                dataMask &= ~(CD_MASK_ORCO | CD_MASK_PREVIEW_MCOL);
        }
 #endif
@@ -2686,7 +2686,7 @@ static void editbmesh_build_data(
        BKE_editmesh_free_derivedmesh(em);
 
 #ifdef WITH_OPENSUBDIV
-       if (calc_modifiers_skip_orco(scene, obedit, false)) {
+       if (calc_modifiers_skip_orco(eval_ctx, scene, obedit, false)) {
                dataMask &= ~(CD_MASK_ORCO | CD_MASK_PREVIEW_MCOL);
        }
 #endif
index 8316d68b35c749030f1f30f0add42414999eb110..15a520fe8ceee61973d107a0a56e971f8b23f113 100644 (file)
@@ -1745,9 +1745,8 @@ static void do_makeDispListCurveTypes(
                }
 
                if (!for_orco) {
-                       /* TODO(sergey): How do we get depsgraph here? */
                        if ((cu->flag & CU_PATH) ||
-                           DEG_get_eval_flags_for_id(scene->depsgraph_legacy, &ob->id) & DAG_EVAL_NEED_CURVE_PATH)
+                           DEG_get_eval_flags_for_id(eval_ctx->depsgraph, &ob->id) & DAG_EVAL_NEED_CURVE_PATH)
                        {
                                calc_curvepath(ob, &nubase);
                        }
index 9235069f531f763ea63df2a5c9c6f5d50ebac1f1..03c2f0742fc7f64bee22382d4d9addffed9c4c93 100644 (file)
@@ -37,6 +37,8 @@
 
 extern "C" {
 #include "BKE_scene.h"
+
+#include "DNA_scene_types.h"
 } /* extern "C" */
 
 #include "DEG_depsgraph.h"
@@ -83,6 +85,8 @@ void DEG_evaluation_context_init_from_scene(EvaluationContext *eval_ctx,
                                             eEvaluationMode mode)
 {
        DEG_evaluation_context_init(eval_ctx, mode);
+       /* TODO(sergey): Use proper depsgraph here. */
+       eval_ctx->depsgraph = scene->depsgraph_legacy;
        eval_ctx->scene_layer = scene_layer;
        eval_ctx->engine = engine;
        eval_ctx->ctime = BKE_scene_frame_get(scene);
index 6ab855ac6afcc006ed316dfec573bb1acbd1f105..d864e0af3be5d651215e9e6f2ba19e89c6d21f5a 100644 (file)
@@ -953,6 +953,7 @@ Render *BlenderStrokeRenderer::RenderScene(Render * /*re*/, bool render)
 
        Render *freestyle_render = RE_NewSceneRender(freestyle_scene);
        DEG_scene_relations_update(freestyle_bmain, freestyle_scene);
+       /* Need to get proper depsgraph. */
        freestyle_render->depsgraph = freestyle_scene->depsgraph_legacy;
 
        RE_RenderFreestyleStrokes(freestyle_render, freestyle_bmain, freestyle_scene,
index 6a07f842cf32711db06f32d3a9dc1f56107b13b3..13eef35a198ad2f6ee4c84beea0b4fdff2e1c6e8 100644 (file)
@@ -98,7 +98,7 @@ static bool isDisabled(ModifierData *md, int useRenderParams)
        return get_render_subsurf_level(&md->scene->r, levels, useRenderParams != 0) == 0;
 }
 
-static DerivedMesh *applyModifier(ModifierData *md, const EvaluationContext *UNUSED(eval_ctx),
+static DerivedMesh *applyModifier(ModifierData *md, const EvaluationContext *eval_ctx,
                                   Object *ob, DerivedMesh *derivedData,
                                   ModifierApplyFlag flag)
 {
@@ -135,8 +135,7 @@ static DerivedMesh *applyModifier(ModifierData *md, const EvaluationContext *UNU
                else if ((ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) != 0) {
                        modifier_setError(md, "OpenSubdiv is not supported in paint modes");
                }
-               /* TODO(sergey): How do we get depsgraph here? */
-               else if ((DEG_get_eval_flags_for_id(md->scene->depsgraph_legacy, &ob->id) & DAG_EVAL_NEED_CPU) == 0) {
+               else if ((DEG_get_eval_flags_for_id(eval_ctx->depsgraph, &ob->id) & DAG_EVAL_NEED_CPU) == 0) {
                        subsurf_flags |= SUBSURF_USE_GPU_BACKEND;
                        do_cddm_convert = false;
                }