Depsgraph: use more fine grained update tags for scenes

Ref D15710, this avoids unnecessary sequencer updates for some operations.
This commit is contained in:
Brecht Van Lommel 2022-08-23 15:20:21 +02:00
parent a87d3edb98
commit c32bb58e5b
7 changed files with 41 additions and 42 deletions

View File

@ -572,7 +572,7 @@ void BKE_view_layer_rename(Main *bmain, Scene *scene, ViewLayer *view_layer, con
}
/* Dependency graph uses view layer name based lookups. */
DEG_id_tag_update(&scene->id, 0);
DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
}
/* LayerCollection */

View File

@ -657,8 +657,7 @@ Object *ED_object_add_type_with_obdata(bContext *C,
WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene);
/* TODO(sergey): Use proper flag for tagging here. */
DEG_id_tag_update(&scene->id, 0);
DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
ED_outliner_select_sync_from_object_tag(C);

View File

@ -934,7 +934,7 @@ static int view_layer_add_exec(bContext *C, wmOperator *op)
WM_window_set_active_view_layer(win, view_layer_new);
}
DEG_id_tag_update(&scene->id, 0);
DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
DEG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene);
@ -1039,7 +1039,7 @@ static int view_layer_add_aov_exec(bContext *C, wmOperator *UNUSED(op))
ntreeCompositUpdateRLayers(scene->nodetree);
}
DEG_id_tag_update(&scene->id, 0);
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene);
@ -1091,7 +1091,7 @@ static int view_layer_remove_aov_exec(bContext *C, wmOperator *UNUSED(op))
ntreeCompositUpdateRLayers(scene->nodetree);
}
DEG_id_tag_update(&scene->id, 0);
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene);
@ -1143,7 +1143,7 @@ static int view_layer_add_lightgroup_exec(bContext *C, wmOperator *op)
ntreeCompositUpdateRLayers(scene->nodetree);
}
DEG_id_tag_update(&scene->id, 0);
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene);
@ -1193,7 +1193,7 @@ static int view_layer_remove_lightgroup_exec(bContext *C, wmOperator *UNUSED(op)
ntreeCompositUpdateRLayers(scene->nodetree);
}
DEG_id_tag_update(&scene->id, 0);
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene);
@ -1257,7 +1257,7 @@ static int view_layer_add_used_lightgroups_exec(bContext *C, wmOperator *UNUSED(
ntreeCompositUpdateRLayers(scene->nodetree);
}
DEG_id_tag_update(&scene->id, 0);
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene);
@ -1301,7 +1301,7 @@ static int view_layer_remove_unused_lightgroups_exec(bContext *C, wmOperator *UN
ntreeCompositUpdateRLayers(scene->nodetree);
}
DEG_id_tag_update(&scene->id, 0);
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene);
@ -1692,7 +1692,7 @@ static int freestyle_module_remove_exec(bContext *C, wmOperator *UNUSED(op))
BKE_freestyle_module_delete(&view_layer->freestyle_config, module);
DEG_id_tag_update(&scene->id, 0);
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
return OPERATOR_FINISHED;
@ -1722,7 +1722,7 @@ static int freestyle_module_move_exec(bContext *C, wmOperator *op)
int dir = RNA_enum_get(op->ptr, "direction");
if (BKE_freestyle_module_move(&view_layer->freestyle_config, module, dir)) {
DEG_id_tag_update(&scene->id, 0);
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
}
@ -1778,7 +1778,7 @@ static int freestyle_lineset_add_exec(bContext *C, wmOperator *UNUSED(op))
BKE_freestyle_lineset_add(bmain, &view_layer->freestyle_config, nullptr);
DEG_id_tag_update(&scene->id, 0);
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
return OPERATOR_FINISHED;
@ -1852,7 +1852,7 @@ static int freestyle_lineset_paste_exec(bContext *C, wmOperator *UNUSED(op))
FRS_paste_active_lineset(&view_layer->freestyle_config);
DEG_id_tag_update(&scene->id, 0);
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
return OPERATOR_FINISHED;
@ -1886,7 +1886,7 @@ static int freestyle_lineset_remove_exec(bContext *C, wmOperator *UNUSED(op))
FRS_delete_active_lineset(&view_layer->freestyle_config);
DEG_id_tag_update(&scene->id, 0);
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
return OPERATOR_FINISHED;
@ -1920,7 +1920,7 @@ static int freestyle_lineset_move_exec(bContext *C, wmOperator *op)
int dir = RNA_enum_get(op->ptr, "direction");
if (FRS_move_active_lineset(&view_layer->freestyle_config, dir)) {
DEG_id_tag_update(&scene->id, 0);
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
}

View File

@ -229,7 +229,7 @@ bool ED_scene_view_layer_delete(Main *bmain, Scene *scene, ViewLayer *layer, Rep
BKE_view_layer_free(layer);
DEG_id_tag_update(&scene->id, 0);
DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
DEG_relations_tag_update(bmain);
WM_main_add_notifier(NC_SCENE | ND_LAYER | NA_REMOVED, scene);

View File

@ -697,7 +697,7 @@ static int drop_world_exec(bContext *C, wmOperator *op)
id_us_plus(&world->id);
scene->world = world;
DEG_id_tag_update(&scene->id, 0);
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_SCENE | ND_WORLD, scene);

View File

@ -355,7 +355,7 @@ void rna_FreestyleSettings_module_remove(struct ID *id,
void rna_Scene_use_view_map_cache_update(struct Main *bmain,
struct Scene *scene,
struct PointerRNA *ptr);
void rna_Scene_glsl_update(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr);
void rna_Scene_render_update(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr);
void rna_Scene_freestyle_update(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr);
void rna_ViewLayer_name_set(struct PointerRNA *ptr, const char *value);
void rna_ViewLayer_material_override_update(struct Main *bmain,

View File

@ -853,12 +853,12 @@ void rna_Scene_set_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
Scene *scene = (Scene *)ptr->owner_id;
DEG_relations_tag_update(bmain);
DEG_id_tag_update_ex(bmain, &scene->id, 0);
DEG_id_tag_update_ex(bmain, &scene->id, ID_RECALC_BASE_FLAGS);
if (scene->set != NULL) {
/* Objects which are pulled into main scene's depsgraph needs to have
* their base flags updated.
*/
DEG_id_tag_update_ex(bmain, &scene->set->id, 0);
DEG_id_tag_update_ex(bmain, &scene->set->id, ID_RECALC_BASE_FLAGS);
}
}
@ -1680,18 +1680,18 @@ static bool rna_RenderSettings_use_spherical_stereo_get(PointerRNA *ptr)
return BKE_scene_use_spherical_stereo(scene);
}
void rna_Scene_glsl_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
void rna_Scene_render_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
Scene *scene = (Scene *)ptr->owner_id;
DEG_id_tag_update(&scene->id, 0);
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
}
static void rna_Scene_world_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
Scene *screen = (Scene *)ptr->owner_id;
rna_Scene_glsl_update(bmain, scene, ptr);
rna_Scene_render_update(bmain, scene, ptr);
WM_main_add_notifier(NC_WORLD | ND_WORLD, &screen->id);
DEG_relations_tag_update(bmain);
}
@ -1707,21 +1707,21 @@ static void rna_Scene_mesh_quality_update(Main *bmain, Scene *UNUSED(scene), Poi
}
FOREACH_SCENE_OBJECT_END;
rna_Scene_glsl_update(bmain, scene, ptr);
rna_Scene_render_update(bmain, scene, ptr);
}
void rna_Scene_freestyle_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
Scene *scene = (Scene *)ptr->owner_id;
DEG_id_tag_update(&scene->id, 0);
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
}
void rna_Scene_use_freestyle_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
Scene *scene = (Scene *)ptr->owner_id;
DEG_id_tag_update(&scene->id, 0);
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
if (scene->nodetree) {
ntreeCompositUpdateRLayers(scene->nodetree);
@ -1761,7 +1761,7 @@ static void rna_SceneRenderView_name_set(PointerRNA *ptr, const char *value)
void rna_ViewLayer_material_override_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
Scene *scene = (Scene *)ptr->owner_id;
rna_Scene_glsl_update(bmain, scene, ptr);
rna_Scene_render_update(bmain, scene, ptr);
DEG_relations_tag_update(bmain);
}
@ -1798,7 +1798,7 @@ void rna_ViewLayer_pass_update(Main *bmain, Scene *activescene, PointerRNA *ptr)
}
}
rna_Scene_glsl_update(bmain, activescene, ptr);
rna_Scene_render_update(bmain, activescene, ptr);
}
static char *rna_ViewLayerEEVEE_path(const PointerRNA *ptr)
@ -1955,7 +1955,7 @@ static void rna_Scene_use_simplify_update(Main *bmain, Scene *UNUSED(scene), Poi
WM_main_add_notifier(NC_GEOM | ND_DATA, NULL);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL);
DEG_id_tag_update(&sce->id, 0);
DEG_id_tag_update(&sce->id, ID_RECALC_COPY_ON_WRITE);
}
static void rna_Scene_simplify_update(Main *bmain, Scene *scene, PointerRNA *ptr)
@ -2308,7 +2308,7 @@ FreestyleLineSet *rna_FreestyleSettings_lineset_add(ID *id,
Scene *scene = (Scene *)id;
FreestyleLineSet *lineset = BKE_freestyle_lineset_add(bmain, (FreestyleConfig *)config, name);
DEG_id_tag_update(&scene->id, 0);
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
WM_main_add_notifier(NC_SCENE | ND_RENDER_OPTIONS, NULL);
return lineset;
@ -2329,7 +2329,7 @@ void rna_FreestyleSettings_lineset_remove(ID *id,
RNA_POINTER_INVALIDATE(lineset_ptr);
DEG_id_tag_update(&scene->id, 0);
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
WM_main_add_notifier(NC_SCENE | ND_RENDER_OPTIONS, NULL);
}
@ -2366,7 +2366,7 @@ FreestyleModuleConfig *rna_FreestyleSettings_module_add(ID *id, FreestyleSetting
Scene *scene = (Scene *)id;
FreestyleModuleConfig *module = BKE_freestyle_module_add((FreestyleConfig *)config);
DEG_id_tag_update(&scene->id, 0);
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
WM_main_add_notifier(NC_SCENE | ND_RENDER_OPTIONS, NULL);
return module;
@ -2395,7 +2395,7 @@ void rna_FreestyleSettings_module_remove(ID *id,
RNA_POINTER_INVALIDATE(module_ptr);
DEG_id_tag_update(&scene->id, 0);
DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE);
WM_main_add_notifier(NC_SCENE | ND_RENDER_OPTIONS, NULL);
}
@ -2426,7 +2426,7 @@ static ViewLayer *rna_ViewLayer_new(ID *id, Scene *UNUSED(sce), Main *bmain, con
Scene *scene = (Scene *)id;
ViewLayer *view_layer = BKE_view_layer_add(scene, name, NULL, VIEWLAYER_ADD_NEW);
DEG_id_tag_update(&scene->id, 0);
DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
DEG_relations_tag_update(bmain);
WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
@ -4467,7 +4467,7 @@ void rna_def_view_layer_common(BlenderRNA *brna, StructRNA *srna, const bool sce
RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_SKY);
RNA_def_property_ui_text(prop, "Sky", "Render Sky in this Layer");
if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_render_update");
}
else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@ -4477,7 +4477,7 @@ void rna_def_view_layer_common(BlenderRNA *brna, StructRNA *srna, const bool sce
RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_AO);
RNA_def_property_ui_text(prop, "Ambient Occlusion", "Render Ambient Occlusion in this Layer");
if (scene) {
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_render_update");
}
else {
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@ -6354,7 +6354,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
prop,
"Transparent",
"World background is transparent, for compositing the render over another background");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_render_update");
prop = RNA_def_property(srna, "use_freestyle", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@ -6385,14 +6385,14 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "mode", R_MBLUR);
RNA_def_property_ui_text(prop, "Motion Blur", "Use multi-sampled 3D scene motion blur");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_render_update");
prop = RNA_def_property(srna, "motion_blur_shutter", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "blurfac");
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.01f, 1.0f, 1, 2);
RNA_def_property_ui_text(prop, "Shutter", "Time taken in frames between shutter open and close");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_render_update");
prop = RNA_def_property(srna, "motion_blur_shutter_curve", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "mblur_shutter_curve");
@ -6404,13 +6404,13 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
prop = RNA_def_property(srna, "hair_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, hair_shape_type_items);
RNA_def_property_ui_text(prop, "Curves Shape Type", "Curves shape type");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_render_update");
prop = RNA_def_property(srna, "hair_subdiv", PROP_INT, PROP_NONE);
RNA_def_property_range(prop, 0, 3);
RNA_def_property_ui_text(
prop, "Additional Subdivision", "Additional subdivision along the curves");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update");
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_render_update");
/* Performance */
prop = RNA_def_property(srna, "use_high_quality_normals", PROP_BOOLEAN, PROP_NONE);