Merge branch 'master' into blender2.8

This commit is contained in:
Sergey Sharybin 2018-04-23 16:44:09 +02:00
commit fc9624e485
6 changed files with 77 additions and 42 deletions

@ -241,13 +241,14 @@ bool DepsgraphRelationBuilder::has_node(const OperationKey &key) const
return find_node(key) != NULL; return find_node(key) != NULL;
} }
void DepsgraphRelationBuilder::add_time_relation(TimeSourceDepsNode *timesrc, DepsRelation *DepsgraphRelationBuilder::add_time_relation(
DepsNode *node_to, TimeSourceDepsNode *timesrc,
const char *description, DepsNode *node_to,
bool check_unique) const char *description,
bool check_unique)
{ {
if (timesrc && node_to) { if (timesrc && node_to) {
graph_->add_new_relation(timesrc, node_to, description, check_unique); return graph_->add_new_relation(timesrc, node_to, description, check_unique);
} }
else { else {
DEG_DEBUG_PRINTF(BUILD, "add_time_relation(%p = %s, %p = %s, %s) Failed\n", DEG_DEBUG_PRINTF(BUILD, "add_time_relation(%p = %s, %p = %s, %s) Failed\n",
@ -255,16 +256,20 @@ void DepsgraphRelationBuilder::add_time_relation(TimeSourceDepsNode *timesrc,
node_to, (node_to) ? node_to->identifier().c_str() : "<None>", node_to, (node_to) ? node_to->identifier().c_str() : "<None>",
description); description);
} }
return NULL;
} }
void DepsgraphRelationBuilder::add_operation_relation( DepsRelation *DepsgraphRelationBuilder::add_operation_relation(
OperationDepsNode *node_from, OperationDepsNode *node_from,
OperationDepsNode *node_to, OperationDepsNode *node_to,
const char *description, const char *description,
bool check_unique) bool check_unique)
{ {
if (node_from && node_to) { if (node_from && node_to) {
graph_->add_new_relation(node_from, node_to, description, check_unique); return graph_->add_new_relation(node_from,
node_to,
description,
check_unique);
} }
else { else {
DEG_DEBUG_PRINTF(BUILD, "add_operation_relation(%p = %s, %p = %s, %s) Failed\n", DEG_DEBUG_PRINTF(BUILD, "add_operation_relation(%p = %s, %p = %s, %s) Failed\n",
@ -272,6 +277,7 @@ void DepsgraphRelationBuilder::add_operation_relation(
node_to, (node_to) ? node_to->identifier().c_str() : "<None>", node_to, (node_to) ? node_to->identifier().c_str() : "<None>",
description); description);
} }
return NULL;
} }
void DepsgraphRelationBuilder::add_collision_relations( void DepsgraphRelationBuilder::add_collision_relations(

@ -83,6 +83,7 @@ namespace DEG {
struct Depsgraph; struct Depsgraph;
struct DepsNode; struct DepsNode;
struct DepsNodeHandle; struct DepsNodeHandle;
struct DepsRelation;
struct RootDepsNode; struct RootDepsNode;
struct IDDepsNode; struct IDDepsNode;
struct TimeSourceDepsNode; struct TimeSourceDepsNode;
@ -176,22 +177,22 @@ struct DepsgraphRelationBuilder
void begin_build(); void begin_build();
template <typename KeyFrom, typename KeyTo> template <typename KeyFrom, typename KeyTo>
void add_relation(const KeyFrom& key_from, DepsRelation *add_relation(const KeyFrom& key_from,
const KeyTo& key_to, const KeyTo& key_to,
const char *description, const char *description,
bool check_unique = false); bool check_unique = false);
template <typename KeyTo> template <typename KeyTo>
void add_relation(const TimeSourceKey& key_from, DepsRelation *add_relation(const TimeSourceKey& key_from,
const KeyTo& key_to, const KeyTo& key_to,
const char *description, const char *description,
bool check_unique = false); bool check_unique = false);
template <typename KeyType> template <typename KeyType>
void add_node_handle_relation(const KeyType& key_from, DepsRelation *add_node_handle_relation(const KeyType& key_from,
const DepsNodeHandle *handle, const DepsNodeHandle *handle,
const char *description, const char *description,
bool check_unique = false); bool check_unique = false);
void build_view_layer(Scene *scene, ViewLayer *view_layer); void build_view_layer(Scene *scene, ViewLayer *view_layer);
void build_group(Object *object, Group *group); void build_group(Object *object, Group *group);
@ -280,14 +281,14 @@ protected:
OperationDepsNode *find_node(const OperationKey &key) const; OperationDepsNode *find_node(const OperationKey &key) const;
bool has_node(const OperationKey &key) const; bool has_node(const OperationKey &key) const;
void add_time_relation(TimeSourceDepsNode *timesrc, DepsRelation *add_time_relation(TimeSourceDepsNode *timesrc,
DepsNode *node_to, DepsNode *node_to,
const char *description, const char *description,
bool check_unique = false); bool check_unique = false);
void add_operation_relation(OperationDepsNode *node_from, DepsRelation *add_operation_relation(OperationDepsNode *node_from,
OperationDepsNode *node_to, OperationDepsNode *node_to,
const char *description, const char *description,
bool check_unique = false); bool check_unique = false);
template <typename KeyType> template <typename KeyType>
DepsNodeHandle create_node_handle(const KeyType& key, DepsNodeHandle create_node_handle(const KeyType& key,

@ -46,17 +46,17 @@ OperationDepsNode *DepsgraphRelationBuilder::find_operation_node(const KeyType&
} }
template <typename KeyFrom, typename KeyTo> template <typename KeyFrom, typename KeyTo>
void DepsgraphRelationBuilder::add_relation(const KeyFrom &key_from, DepsRelation *DepsgraphRelationBuilder::add_relation(const KeyFrom &key_from,
const KeyTo &key_to, const KeyTo &key_to,
const char *description, const char *description,
bool check_unique) bool check_unique)
{ {
DepsNode *node_from = get_node(key_from); DepsNode *node_from = get_node(key_from);
DepsNode *node_to = get_node(key_to); DepsNode *node_to = get_node(key_to);
OperationDepsNode *op_from = node_from ? node_from->get_exit_operation() : NULL; OperationDepsNode *op_from = node_from ? node_from->get_exit_operation() : NULL;
OperationDepsNode *op_to = node_to ? node_to->get_entry_operation() : NULL; OperationDepsNode *op_to = node_to ? node_to->get_entry_operation() : NULL;
if (op_from && op_to) { if (op_from && op_to) {
add_operation_relation(op_from, op_to, description, check_unique); return add_operation_relation(op_from, op_to, description, check_unique);
} }
else { else {
if (!op_from) { if (!op_from) {
@ -78,24 +78,27 @@ void DepsgraphRelationBuilder::add_relation(const KeyFrom &key_from,
description, key_to.identifier().c_str()); description, key_to.identifier().c_str());
} }
} }
return NULL;
} }
template <typename KeyTo> template <typename KeyTo>
void DepsgraphRelationBuilder::add_relation(const TimeSourceKey &key_from, DepsRelation *DepsgraphRelationBuilder::add_relation(
const KeyTo &key_to, const TimeSourceKey &key_from,
const char *description, const KeyTo &key_to,
bool check_unique) const char *description,
bool check_unique)
{ {
TimeSourceDepsNode *time_from = get_node(key_from); TimeSourceDepsNode *time_from = get_node(key_from);
DepsNode *node_to = get_node(key_to); DepsNode *node_to = get_node(key_to);
OperationDepsNode *op_to = node_to ? node_to->get_entry_operation() : NULL; OperationDepsNode *op_to = node_to ? node_to->get_entry_operation() : NULL;
if (time_from != NULL && op_to != NULL) { if (time_from != NULL && op_to != NULL) {
add_time_relation(time_from, op_to, description, check_unique); return add_time_relation(time_from, op_to, description, check_unique);
} }
return NULL;
} }
template <typename KeyType> template <typename KeyType>
void DepsgraphRelationBuilder::add_node_handle_relation( DepsRelation *DepsgraphRelationBuilder::add_node_handle_relation(
const KeyType &key_from, const KeyType &key_from,
const DepsNodeHandle *handle, const DepsNodeHandle *handle,
const char *description, const char *description,
@ -105,7 +108,7 @@ void DepsgraphRelationBuilder::add_node_handle_relation(
OperationDepsNode *op_from = node_from ? node_from->get_exit_operation() : NULL; OperationDepsNode *op_from = node_from ? node_from->get_exit_operation() : NULL;
OperationDepsNode *op_to = handle->node->get_entry_operation(); OperationDepsNode *op_to = handle->node->get_entry_operation();
if (op_from != NULL && op_to != NULL) { if (op_from != NULL && op_to != NULL) {
add_operation_relation(op_from, op_to, description, check_unique); return add_operation_relation(op_from, op_to, description, check_unique);
} }
else { else {
if (!op_from) { if (!op_from) {
@ -117,6 +120,7 @@ void DepsgraphRelationBuilder::add_node_handle_relation(
description, key_from.identifier().c_str()); description, key_from.identifier().c_str());
} }
} }
return NULL;
} }
template <typename KeyType> template <typename KeyType>

@ -259,6 +259,18 @@ static void deg_debug_graphviz_relation_color(const DebugContext &ctx,
deg_debug_fprintf(ctx, "%s", color); deg_debug_fprintf(ctx, "%s", color);
} }
static void deg_debug_graphviz_relation_style(const DebugContext &ctx,
const DepsRelation *rel)
{
const char *style_default = "solid";
const char *style_no_flush = "dashed";
const char *style = style_default;
if (rel->flag & DEPSREL_FLAG_NO_FLUSH) {
style = style_no_flush;
}
deg_debug_fprintf(ctx, "%s", style);
}
static void deg_debug_graphviz_node_style(const DebugContext &ctx, const DepsNode *node) static void deg_debug_graphviz_node_style(const DebugContext &ctx, const DepsNode *node)
{ {
const char *base_style = "filled"; /* default style */ const char *base_style = "filled"; /* default style */
@ -468,16 +480,23 @@ static void deg_debug_graphviz_node_relations(const DebugContext &ctx,
/* Note: without label an id seem necessary to avoid bugs in graphviz/dot */ /* Note: without label an id seem necessary to avoid bugs in graphviz/dot */
deg_debug_fprintf(ctx, "id=\"%s\"", rel->name); deg_debug_fprintf(ctx, "id=\"%s\"", rel->name);
// deg_debug_fprintf(ctx, "label=\"%s\"", rel->name); // deg_debug_fprintf(ctx, "label=\"%s\"", rel->name);
deg_debug_fprintf(ctx, ",color="); deg_debug_graphviz_relation_color(ctx, rel); deg_debug_fprintf(ctx, ",color=");
deg_debug_graphviz_relation_color(ctx, rel);
deg_debug_fprintf(ctx, ",style=");
deg_debug_graphviz_relation_style(ctx, rel);
deg_debug_fprintf(ctx, ",penwidth=\"%f\"", penwidth); deg_debug_fprintf(ctx, ",penwidth=\"%f\"", penwidth);
/* NOTE: edge from node to own cluster is not possible and gives graphviz /* NOTE: edge from node to own cluster is not possible and gives graphviz
* warning, avoid this here by just linking directly to the invisible * warning, avoid this here by just linking directly to the invisible
* placeholder node * placeholder node
*/ */
if (deg_debug_graphviz_is_cluster(tail) && !deg_debug_graphviz_is_owner(head, tail)) { if (deg_debug_graphviz_is_cluster(tail) &&
!deg_debug_graphviz_is_owner(head, tail))
{
deg_debug_fprintf(ctx, ",ltail=\"cluster_%p\"", tail); deg_debug_fprintf(ctx, ",ltail=\"cluster_%p\"", tail);
} }
if (deg_debug_graphviz_is_cluster(head) && !deg_debug_graphviz_is_owner(tail, head)) { if (deg_debug_graphviz_is_cluster(head) &&
!deg_debug_graphviz_is_owner(tail, head))
{
deg_debug_fprintf(ctx, ",lhead=\"cluster_%p\"", head); deg_debug_fprintf(ctx, ",lhead=\"cluster_%p\"", head);
} }
deg_debug_fprintf(ctx, "];" NL); deg_debug_fprintf(ctx, "];" NL);

@ -68,6 +68,8 @@ typedef enum eDepsRelation_Flag {
* which triggers a cyclic relationship to exist in the graph. * which triggers a cyclic relationship to exist in the graph.
*/ */
DEPSREL_FLAG_CYCLIC = (1 << 0), DEPSREL_FLAG_CYCLIC = (1 << 0),
/* Update flush will not go through this relation. */
DEPSREL_FLAG_NO_FLUSH = (1 << 1),
} eDepsRelation_Flag; } eDepsRelation_Flag;
/* B depends on A (A -> B) */ /* B depends on A (A -> B) */

@ -182,6 +182,9 @@ BLI_INLINE OperationDepsNode *flush_schedule_children(
{ {
OperationDepsNode *result = NULL; OperationDepsNode *result = NULL;
foreach (DepsRelation *rel, op_node->outlinks) { foreach (DepsRelation *rel, op_node->outlinks) {
if (rel->flag & DEPSREL_FLAG_NO_FLUSH) {
continue;
}
OperationDepsNode *to_node = (OperationDepsNode *)rel->to; OperationDepsNode *to_node = (OperationDepsNode *)rel->to;
if (to_node->scheduled == false) { if (to_node->scheduled == false) {
if (result != NULL) { if (result != NULL) {