Depsgraph: Remove the "disable-copy-on-write" option completely

After discussion with Sergey and Dalai, we have decided to remove
this option completely. We're getting to the point where it is almost
impossible to really use 2.8 without COW, and keeping the old option
running ends up diverting dev resources away towards tracking down
and fixing problems with a parallel system that will be going away.
This commit is contained in:
Joshua Leung 2018-05-31 13:42:55 +02:00
parent 9b4e56c091
commit f56a9fbad5
14 changed files with 43 additions and 126 deletions

View File

@ -2934,9 +2934,6 @@ static bool calc_modifiers_skip_orco(Depsgraph *depsgraph,
static void mesh_finalize_eval(Object *object)
{
if (!DEG_depsgraph_use_copy_on_write()) {
return;
}
Mesh *mesh = (Mesh *)object->data;
Mesh *mesh_eval = object->runtime.mesh_eval;
/* Special Tweaks for cases when evaluated mesh came from

View File

@ -91,9 +91,6 @@ enum {
extern "C" {
#endif
bool DEG_depsgraph_use_copy_on_write(void);
void DEG_depsgraph_disable_copy_on_write(void);
/* ************************************************ */
/* Depsgraph API */

View File

@ -46,7 +46,6 @@ namespace DEG {
void deg_graph_build_finalize(Main *bmain, Depsgraph *graph)
{
const bool use_copy_on_write = DEG_depsgraph_use_copy_on_write();
/* Re-tag IDs for update if it was tagged before the relations
* update tag.
*/
@ -59,9 +58,7 @@ void deg_graph_build_finalize(Main *bmain, Depsgraph *graph)
/* TODO(sergey): This is not ideal at all, since this forces
* re-evaluaiton of the whole tree.
*/
if (use_copy_on_write) {
DEG_id_tag_update_ex(bmain, id_node->id_orig, DEG_TAG_COPY_ON_WRITE);
}
DEG_id_tag_update_ex(bmain, id_node->id_orig, DEG_TAG_COPY_ON_WRITE);
}
}

View File

@ -150,9 +150,6 @@ DepsgraphNodeBuilder::~DepsgraphNodeBuilder()
IDDepsNode *DepsgraphNodeBuilder::add_id_node(ID *id)
{
if (!DEG_depsgraph_use_copy_on_write()) {
return graph_->add_id_node(id);
}
IDDepsNode *id_node = NULL;
ID *id_cow = (ID *)BLI_ghash_lookup(cow_id_hash_, id);
if (id_cow != NULL) {
@ -324,22 +321,21 @@ ID *DepsgraphNodeBuilder::ensure_cow_id(ID *id_orig)
/* **** Build functions for entity nodes **** */
void DepsgraphNodeBuilder::begin_build() {
if (DEG_depsgraph_use_copy_on_write()) {
/* Store existing copy-on-write versions of datablock, so we can re-use
* them for new ID nodes.
*/
cow_id_hash_ = BLI_ghash_ptr_new("Depsgraph id hash");
foreach (IDDepsNode *id_node, graph_->id_nodes) {
if (deg_copy_on_write_is_expanded(id_node->id_cow)) {
if (id_node->id_orig == id_node->id_cow) {
continue;
}
BLI_ghash_insert(cow_id_hash_,
id_node->id_orig,
id_node->id_cow);
id_node->id_cow = NULL;
void DepsgraphNodeBuilder::begin_build()
{
/* Store existing copy-on-write versions of datablock, so we can re-use
* them for new ID nodes.
*/
cow_id_hash_ = BLI_ghash_ptr_new("Depsgraph id hash");
foreach (IDDepsNode *id_node, graph_->id_nodes) {
if (deg_copy_on_write_is_expanded(id_node->id_cow)) {
if (id_node->id_orig == id_node->id_cow) {
continue;
}
BLI_ghash_insert(cow_id_hash_,
id_node->id_orig,
id_node->id_cow);
id_node->id_cow = NULL;
}
}

View File

@ -33,7 +33,7 @@
#include "intern/builder/deg_builder_map.h"
#include "intern/depsgraph_types.h"
#include "DEG_depsgraph.h" /* used for DEG_depsgraph_use_copy_on_write() */
#include "DEG_depsgraph.h"
struct Base;
struct CacheFile;
@ -92,12 +92,7 @@ struct DepsgraphNodeBuilder {
/* For a given COW datablock get corresponding original one. */
template<typename T>
T *get_orig_datablock(const T *cow) const {
if (DEG_depsgraph_use_copy_on_write()) {
return (T *)cow->id.orig_id;
}
else {
return (T *)cow;
}
return (T *)cow->id.orig_id;
}
void begin_build();

View File

@ -145,16 +145,8 @@ void DepsgraphNodeBuilder::build_splineik_pose(Object *object,
void DepsgraphNodeBuilder::build_rig(Object *object)
{
bArmature *armature = (bArmature *)object->data;
Scene *scene_cow;
Object *object_cow;
if (DEG_depsgraph_use_copy_on_write()) {
scene_cow = get_cow_datablock(scene_);
object_cow = get_cow_datablock(object);
}
else {
scene_cow = scene_;
object_cow = object;
}
Scene *scene_cow = get_cow_datablock(scene_);
Object *object_cow = get_cow_datablock(object);
OperationDepsNode *op_node;
/* Animation and/or drivers linking posebones to base-armature used to
@ -324,13 +316,7 @@ void DepsgraphNodeBuilder::build_proxy_rig(Object *object)
{
bArmature *arm = (bArmature *)object->data;
OperationDepsNode *op_node;
Object *object_cow;
if (DEG_depsgraph_use_copy_on_write()) {
object_cow = get_cow_datablock(object);
}
else {
object_cow = object;
}
Object *object_cow = get_cow_datablock(object);
/* Sanity check. */
BLI_assert(object->pose != NULL);
/* Animation. */

View File

@ -96,13 +96,7 @@ void DepsgraphNodeBuilder::build_view_layer(
scene_ = scene;
view_layer_ = view_layer;
/* Get pointer to a CoW version of scene ID. */
Scene *scene_cow;
if (DEG_depsgraph_use_copy_on_write()) {
scene_cow = get_cow_datablock(scene);
}
else {
scene_cow = scene;
}
Scene *scene_cow = get_cow_datablock(scene);
/* Scene objects. */
int select_color = 1;
/* NOTE: Base is used for function bindings as-is, so need to pass CoW base,

View File

@ -1028,14 +1028,12 @@ void DepsgraphRelationBuilder::build_animdata_curves_targets(
/* It is possible that animation is writing to a nested ID datablock,
* need to make sure animation is evaluated after target ID is copied.
*/
if (DEG_depsgraph_use_copy_on_write()) {
const IDDepsNode *id_node_from = operation_from->owner->owner;
const IDDepsNode *id_node_to = operation_to->owner->owner;
if (id_node_from != id_node_to) {
ComponentKey cow_key(id_node_to->id_orig,
DEG_NODE_TYPE_COPY_ON_WRITE);
add_relation(cow_key, adt_key, "Target CoW -> Animation", true);
}
const IDDepsNode *id_node_from = operation_from->owner->owner;
const IDDepsNode *id_node_to = operation_to->owner->owner;
if (id_node_from != id_node_to) {
ComponentKey cow_key(id_node_to->id_orig,
DEG_NODE_TYPE_COPY_ON_WRITE);
add_relation(cow_key, adt_key, "Target CoW -> Animation", true);
}
}
}
@ -1209,7 +1207,7 @@ void DepsgraphRelationBuilder::build_driver_data(ID *id, FCurve *fcu)
* datablock, which means driver execution should wait for that
* datablock to be copied.
*/
if (DEG_depsgraph_use_copy_on_write()) {
{
PointerRNA id_ptr;
PointerRNA ptr;
RNA_id_pointer_create(id, &id_ptr);
@ -1886,18 +1884,16 @@ void DepsgraphRelationBuilder::build_lamp(Object *object)
build_nested_nodetree(&lamp->id, lamp->nodetree);
}
if (DEG_depsgraph_use_copy_on_write()) {
/* Make sure copy on write of lamp data is always properly updated for
* visible lamps.
*/
OperationKey ob_copy_on_write_key(&object->id,
DEG_NODE_TYPE_COPY_ON_WRITE,
DEG_OPCODE_COPY_ON_WRITE);
OperationKey lamp_copy_on_write_key(&lamp->id,
DEG_NODE_TYPE_COPY_ON_WRITE,
DEG_OPCODE_COPY_ON_WRITE);
add_relation(lamp_copy_on_write_key, ob_copy_on_write_key, "Eval Order");
}
/* Make sure copy on write of lamp data is always properly updated for
* visible lamps.
*/
OperationKey ob_copy_on_write_key(&object->id,
DEG_NODE_TYPE_COPY_ON_WRITE,
DEG_OPCODE_COPY_ON_WRITE);
OperationKey lamp_copy_on_write_key(&lamp->id,
DEG_NODE_TYPE_COPY_ON_WRITE,
DEG_OPCODE_COPY_ON_WRITE);
add_relation(lamp_copy_on_write_key, ob_copy_on_write_key, "Eval Order");
}
void DepsgraphRelationBuilder::build_nodetree(bNodeTree *ntree)
@ -2085,9 +2081,6 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations()
*/
void DepsgraphRelationBuilder::build_nested_datablock(ID *owner, ID *id)
{
if (!DEG_depsgraph_use_copy_on_write()) {
return;
}
OperationKey owner_copy_on_write_key(owner,
DEG_NODE_TYPE_COPY_ON_WRITE,
DEG_OPCODE_COPY_ON_WRITE);

View File

@ -70,18 +70,6 @@ extern "C" {
#include "intern/depsgraph_intern.h"
#include "util/deg_util_foreach.h"
static bool use_copy_on_write = true;
bool DEG_depsgraph_use_copy_on_write(void)
{
return use_copy_on_write;
}
void DEG_depsgraph_disable_copy_on_write(void)
{
use_copy_on_write = false;
}
namespace DEG {
static DEG_EditorUpdateIDCb deg_editor_update_id_cb = NULL;
@ -340,7 +328,7 @@ IDDepsNode *Depsgraph::add_id_node(ID *id, ID *id_cow_hint)
void Depsgraph::clear_id_nodes()
{
/* Free memory used by ID nodes. */
if (use_copy_on_write) {
{
/* Stupid workaround to ensure we free IDs in a proper order. */
foreach (IDDepsNode *id_node, id_nodes) {
if (id_node->id_cow == NULL) {

View File

@ -231,9 +231,7 @@ void DEG_graph_build_from_view_layer(Depsgraph *graph,
DEG::DepsgraphRelationBuilder relation_builder(bmain, deg_graph);
relation_builder.begin_build();
relation_builder.build_view_layer(scene, view_layer);
if (DEG_depsgraph_use_copy_on_write()) {
relation_builder.build_copy_on_write_relations();
}
relation_builder.build_copy_on_write_relations();
/* Detect and solve cycles. */
DEG::deg_graph_detect_cycles(deg_graph);

View File

@ -284,7 +284,7 @@ void depsgraph_tag_component(Depsgraph *graph,
}
}
/* If component depends on copy-on-write, tag it as well. */
if (DEG_depsgraph_use_copy_on_write() && component_node->depends_on_cow()) {
if (component_node->depends_on_cow()) {
ComponentDepsNode *cow_comp =
id_node->find_component(DEG_NODE_TYPE_COPY_ON_WRITE);
cow_comp->tag_update(graph);

View File

@ -228,9 +228,6 @@ static void depsgraph_ensure_view_layer(Depsgraph *graph)
* - It was tagged for update of CoW component.
* This allows us to have proper view layer pointer.
*/
if (!DEG_depsgraph_use_copy_on_write()) {
return;
}
Scene *scene_cow = graph->scene_cow;
if (!deg_copy_on_write_is_expanded(&scene_cow->id) ||
scene_cow->id.recalc & ID_RECALC_COPY_ON_WRITE)

View File

@ -112,14 +112,6 @@ void IDDepsNode::init(const ID *id, const char *UNUSED(subdata))
void IDDepsNode::init_copy_on_write(ID *id_cow_hint)
{
/* Early output for non-copy-on-write case: we keep CoW pointer same as
* an original one.
*/
if (!DEG_depsgraph_use_copy_on_write()) {
UNUSED_VARS(id_cow_hint);
id_cow = id_orig;
return;
}
/* Create pointer as early as possible, so we can use it for function
* bindings. Rest of data we'll be copying to the new datablock when
* it is actually needed.

View File

@ -586,9 +586,8 @@ static int arg_handle_print_help(int UNUSED(argc), const char **UNUSED(argv), vo
BLI_argsPrintArgDoc(ba, "--");
printf("\n");
printf("Experimental Features:\n");
BLI_argsPrintArgDoc(ba, "--disable-copy-on-write");
//printf("\n");
//printf("Experimental Features:\n");
/* Other options _must_ be last (anything not handled will show here) */
printf("\n");
@ -1289,16 +1288,6 @@ static int arg_handle_threads_set(int argc, const char **argv, void *UNUSED(data
}
}
static const char arg_handle_use_copy_on_write_doc[] =
"\n\tUse new dependency graph"
;
static int arg_handle_use_copy_on_write(int UNUSED(argc), const char **UNUSED(argv), void *UNUSED(data))
{
printf("Disabling copy on write. Only use for testing whether something else is at fault\n");
DEG_depsgraph_disable_copy_on_write();
return 0;
}
static const char arg_handle_verbosity_set_doc[] =
"<verbose>\n"
"\tSet logging verbosity level."
@ -1896,8 +1885,6 @@ void main_args_setup(bContext *C, bArgs *ba)
BLI_argsAdd(ba, 1, NULL, "--debug-gpu-shaders",
CB_EX(arg_handle_debug_mode_generic_set, gpumem), (void *)G_DEBUG_GPU_SHADERS);
BLI_argsAdd(ba, 1, NULL, "--disable-copy-on-write", CB(arg_handle_use_copy_on_write), NULL);
BLI_argsAdd(ba, 1, NULL, "--verbose", CB(arg_handle_verbosity_set), NULL);
BLI_argsAdd(ba, 1, NULL, "--factory-startup", CB(arg_handle_factory_startup_set), NULL);