Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-04-17 07:17:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-04-17 07:21:24 +0300
commite12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch)
tree8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/depsgraph/intern/depsgraph_debug.cc
parentb3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff)
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211. For details on usage and instructions for migrating branches without conflicts, see: https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/depsgraph/intern/depsgraph_debug.cc')
-rw-r--r--source/blender/depsgraph/intern/depsgraph_debug.cc492
1 files changed, 245 insertions, 247 deletions
diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cc b/source/blender/depsgraph/intern/depsgraph_debug.cc
index 67450d1350f..e795bed144d 100644
--- a/source/blender/depsgraph/intern/depsgraph_debug.cc
+++ b/source/blender/depsgraph/intern/depsgraph_debug.cc
@@ -28,7 +28,7 @@
extern "C" {
#include "DNA_scene_types.h"
-} /* extern "C" */
+} /* extern "C" */
#include "DNA_object_types.h"
@@ -46,49 +46,44 @@ extern "C" {
void DEG_debug_flags_set(Depsgraph *depsgraph, int flags)
{
- DEG::Depsgraph *deg_graph =
- reinterpret_cast<DEG::Depsgraph *>(depsgraph);
- deg_graph->debug_flags = flags;
+ DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph);
+ deg_graph->debug_flags = flags;
}
int DEG_debug_flags_get(const Depsgraph *depsgraph)
{
- const DEG::Depsgraph *deg_graph =
- reinterpret_cast<const DEG::Depsgraph *>(depsgraph);
- return deg_graph->debug_flags;
+ const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(depsgraph);
+ return deg_graph->debug_flags;
}
void DEG_debug_name_set(struct Depsgraph *depsgraph, const char *name)
{
- DEG::Depsgraph *deg_graph =
- reinterpret_cast<DEG::Depsgraph *>(depsgraph);
- deg_graph->debug_name = name;
+ DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph);
+ deg_graph->debug_name = name;
}
const char *DEG_debug_name_get(struct Depsgraph *depsgraph)
{
- const DEG::Depsgraph *deg_graph =
- reinterpret_cast<const DEG::Depsgraph *>(depsgraph);
- return deg_graph->debug_name.c_str();
+ const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(depsgraph);
+ return deg_graph->debug_name.c_str();
}
-bool DEG_debug_compare(const struct Depsgraph *graph1,
- const struct Depsgraph *graph2)
+bool DEG_debug_compare(const struct Depsgraph *graph1, const struct Depsgraph *graph2)
{
- BLI_assert(graph1 != NULL);
- BLI_assert(graph2 != NULL);
- const DEG::Depsgraph *deg_graph1 = reinterpret_cast<const DEG::Depsgraph *>(graph1);
- const DEG::Depsgraph *deg_graph2 = reinterpret_cast<const DEG::Depsgraph *>(graph2);
- if (deg_graph1->operations.size() != deg_graph2->operations.size()) {
- return false;
- }
- /* TODO(sergey): Currently we only do real stupid check,
- * which is fast but which isn't 100% reliable.
- *
- * Would be cool to make it more robust, but it's good enough
- * for now. Also, proper graph check is actually NP-complex
- * problem. */
- return true;
+ BLI_assert(graph1 != NULL);
+ BLI_assert(graph2 != NULL);
+ const DEG::Depsgraph *deg_graph1 = reinterpret_cast<const DEG::Depsgraph *>(graph1);
+ const DEG::Depsgraph *deg_graph2 = reinterpret_cast<const DEG::Depsgraph *>(graph2);
+ if (deg_graph1->operations.size() != deg_graph2->operations.size()) {
+ return false;
+ }
+ /* TODO(sergey): Currently we only do real stupid check,
+ * which is fast but which isn't 100% reliable.
+ *
+ * Would be cool to make it more robust, but it's good enough
+ * for now. Also, proper graph check is actually NP-complex
+ * problem. */
+ return true;
}
bool DEG_debug_graph_relations_validate(Depsgraph *graph,
@@ -96,105 +91,107 @@ bool DEG_debug_graph_relations_validate(Depsgraph *graph,
Scene *scene,
ViewLayer *view_layer)
{
- Depsgraph *temp_depsgraph = DEG_graph_new(scene, view_layer, DEG_get_mode(graph));
- bool valid = true;
- DEG_graph_build_from_view_layer(temp_depsgraph, bmain, scene, view_layer);
- if (!DEG_debug_compare(temp_depsgraph, graph)) {
- fprintf(stderr, "ERROR! Depsgraph wasn't tagged for update when it should have!\n");
- BLI_assert(!"This should not happen!");
- valid = false;
- }
- DEG_graph_free(temp_depsgraph);
- return valid;
+ Depsgraph *temp_depsgraph = DEG_graph_new(scene, view_layer, DEG_get_mode(graph));
+ bool valid = true;
+ DEG_graph_build_from_view_layer(temp_depsgraph, bmain, scene, view_layer);
+ if (!DEG_debug_compare(temp_depsgraph, graph)) {
+ fprintf(stderr, "ERROR! Depsgraph wasn't tagged for update when it should have!\n");
+ BLI_assert(!"This should not happen!");
+ valid = false;
+ }
+ DEG_graph_free(temp_depsgraph);
+ return valid;
}
bool DEG_debug_consistency_check(Depsgraph *graph)
{
- const DEG::Depsgraph *deg_graph =
- reinterpret_cast<const DEG::Depsgraph *>(graph);
- /* Validate links exists in both directions. */
- for (DEG::OperationNode *node : deg_graph->operations) {
- for (DEG::Relation *rel : node->outlinks) {
- int counter1 = 0;
- for (DEG::Relation *tmp_rel : node->outlinks) {
- if (tmp_rel == rel) {
- ++counter1;
- }
- }
- int counter2 = 0;
- for (DEG::Relation *tmp_rel : rel->to->inlinks) {
- if (tmp_rel == rel) {
- ++counter2;
- }
- }
- if (counter1 != counter2) {
- printf("Relation exists in outgoing direction but not in "
- "incoming (%d vs. %d).\n",
- counter1, counter2);
- return false;
- }
- }
- }
-
- for (DEG::OperationNode *node : deg_graph->operations) {
- for (DEG::Relation *rel : node->inlinks) {
- int counter1 = 0;
- for (DEG::Relation *tmp_rel : node->inlinks) {
- if (tmp_rel == rel) {
- ++counter1;
- }
- }
- int counter2 = 0;
- for (DEG::Relation *tmp_rel : rel->from->outlinks) {
- if (tmp_rel == rel) {
- ++counter2;
- }
- }
- if (counter1 != counter2) {
- printf("Relation exists in incoming direction but not in outcoming (%d vs. %d).\n",
- counter1, counter2);
- }
- }
- }
-
- /* Validate node valency calculated in both directions. */
- for (DEG::OperationNode *node : deg_graph->operations) {
- node->num_links_pending = 0;
- node->custom_flags = 0;
- }
-
- for (DEG::OperationNode *node : deg_graph->operations) {
- if (node->custom_flags) {
- printf("Node %s is twice in the operations!\n",
- node->identifier().c_str());
- return false;
- }
- for (DEG::Relation *rel : node->outlinks) {
- if (rel->to->type == DEG::NodeType::OPERATION) {
- DEG::OperationNode *to = (DEG::OperationNode *)rel->to;
- BLI_assert(to->num_links_pending < to->inlinks.size());
- ++to->num_links_pending;
- }
- }
- node->custom_flags = 1;
- }
-
- for (DEG::OperationNode *node : deg_graph->operations) {
- int num_links_pending = 0;
- for (DEG::Relation *rel : node->inlinks) {
- if (rel->from->type == DEG::NodeType::OPERATION) {
- ++num_links_pending;
- }
- }
- if (node->num_links_pending != num_links_pending) {
- printf("Valency mismatch: %s, %u != %d\n",
- node->identifier().c_str(),
- node->num_links_pending, num_links_pending);
- printf("Number of inlinks: %d\n", (int)node->inlinks.size());
- return false;
- }
- }
- return true;
+ const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph);
+ /* Validate links exists in both directions. */
+ for (DEG::OperationNode *node : deg_graph->operations) {
+ for (DEG::Relation *rel : node->outlinks) {
+ int counter1 = 0;
+ for (DEG::Relation *tmp_rel : node->outlinks) {
+ if (tmp_rel == rel) {
+ ++counter1;
+ }
+ }
+ int counter2 = 0;
+ for (DEG::Relation *tmp_rel : rel->to->inlinks) {
+ if (tmp_rel == rel) {
+ ++counter2;
+ }
+ }
+ if (counter1 != counter2) {
+ printf(
+ "Relation exists in outgoing direction but not in "
+ "incoming (%d vs. %d).\n",
+ counter1,
+ counter2);
+ return false;
+ }
+ }
+ }
+
+ for (DEG::OperationNode *node : deg_graph->operations) {
+ for (DEG::Relation *rel : node->inlinks) {
+ int counter1 = 0;
+ for (DEG::Relation *tmp_rel : node->inlinks) {
+ if (tmp_rel == rel) {
+ ++counter1;
+ }
+ }
+ int counter2 = 0;
+ for (DEG::Relation *tmp_rel : rel->from->outlinks) {
+ if (tmp_rel == rel) {
+ ++counter2;
+ }
+ }
+ if (counter1 != counter2) {
+ printf("Relation exists in incoming direction but not in outcoming (%d vs. %d).\n",
+ counter1,
+ counter2);
+ }
+ }
+ }
+
+ /* Validate node valency calculated in both directions. */
+ for (DEG::OperationNode *node : deg_graph->operations) {
+ node->num_links_pending = 0;
+ node->custom_flags = 0;
+ }
+
+ for (DEG::OperationNode *node : deg_graph->operations) {
+ if (node->custom_flags) {
+ printf("Node %s is twice in the operations!\n", node->identifier().c_str());
+ return false;
+ }
+ for (DEG::Relation *rel : node->outlinks) {
+ if (rel->to->type == DEG::NodeType::OPERATION) {
+ DEG::OperationNode *to = (DEG::OperationNode *)rel->to;
+ BLI_assert(to->num_links_pending < to->inlinks.size());
+ ++to->num_links_pending;
+ }
+ }
+ node->custom_flags = 1;
+ }
+
+ for (DEG::OperationNode *node : deg_graph->operations) {
+ int num_links_pending = 0;
+ for (DEG::Relation *rel : node->inlinks) {
+ if (rel->from->type == DEG::NodeType::OPERATION) {
+ ++num_links_pending;
+ }
+ }
+ if (node->num_links_pending != num_links_pending) {
+ printf("Valency mismatch: %s, %u != %d\n",
+ node->identifier().c_str(),
+ node->num_links_pending,
+ num_links_pending);
+ printf("Number of inlinks: %d\n", (int)node->inlinks.size());
+ return false;
+ }
+ }
+ return true;
}
/* ------------------------------------------------ */
@@ -205,65 +202,66 @@ bool DEG_debug_consistency_check(Depsgraph *graph)
* \param[out] r_operations The number of operation nodes in the graph
* \param[out] r_relations The number of relations between (executable) nodes in the graph
*/
-void DEG_stats_simple(const Depsgraph *graph, size_t *r_outer,
- size_t *r_operations, size_t *r_relations)
+void DEG_stats_simple(const Depsgraph *graph,
+ size_t *r_outer,
+ size_t *r_operations,
+ size_t *r_relations)
{
- const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph);
-
- /* number of operations */
- if (r_operations) {
- /* All operations should be in this list, allowing us to count the total
- * number of nodes. */
- *r_operations = deg_graph->operations.size();
- }
-
- /* Count number of outer nodes and/or relations between these. */
- if (r_outer || r_relations) {
- size_t tot_outer = 0;
- size_t tot_rels = 0;
-
- for (DEG::IDNode *id_node : deg_graph->id_nodes) {
- tot_outer++;
- GHASH_FOREACH_BEGIN(DEG::ComponentNode *, comp_node, id_node->components)
- {
- tot_outer++;
- for (DEG::OperationNode *op_node : comp_node->operations) {
- tot_rels += op_node->inlinks.size();
- }
- }
- GHASH_FOREACH_END();
- }
-
- DEG::TimeSourceNode *time_source = deg_graph->find_time_source();
- if (time_source != NULL) {
- tot_rels += time_source->inlinks.size();
- }
-
- if (r_relations) *r_relations = tot_rels;
- if (r_outer) *r_outer = tot_outer;
- }
+ const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph);
+
+ /* number of operations */
+ if (r_operations) {
+ /* All operations should be in this list, allowing us to count the total
+ * number of nodes. */
+ *r_operations = deg_graph->operations.size();
+ }
+
+ /* Count number of outer nodes and/or relations between these. */
+ if (r_outer || r_relations) {
+ size_t tot_outer = 0;
+ size_t tot_rels = 0;
+
+ for (DEG::IDNode *id_node : deg_graph->id_nodes) {
+ tot_outer++;
+ GHASH_FOREACH_BEGIN (DEG::ComponentNode *, comp_node, id_node->components) {
+ tot_outer++;
+ for (DEG::OperationNode *op_node : comp_node->operations) {
+ tot_rels += op_node->inlinks.size();
+ }
+ }
+ GHASH_FOREACH_END();
+ }
+
+ DEG::TimeSourceNode *time_source = deg_graph->find_time_source();
+ if (time_source != NULL) {
+ tot_rels += time_source->inlinks.size();
+ }
+
+ if (r_relations)
+ *r_relations = tot_rels;
+ if (r_outer)
+ *r_outer = tot_outer;
+ }
}
bool DEG_debug_is_evaluating(struct Depsgraph *depsgraph)
{
- DEG::Depsgraph *deg_graph =
- reinterpret_cast<DEG::Depsgraph *>(depsgraph);
- return deg_graph->debug_is_evaluating;
+ DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph);
+ return deg_graph->debug_is_evaluating;
}
static DEG::string depsgraph_name_for_logging(struct Depsgraph *depsgraph)
{
- const char *name = DEG_debug_name_get(depsgraph);
- if (name[0] == '\0') {
- return "";
- }
- return "[" + DEG::string(name) + "]: ";
+ const char *name = DEG_debug_name_get(depsgraph);
+ if (name[0] == '\0') {
+ return "";
+ }
+ return "[" + DEG::string(name) + "]: ";
}
void DEG_debug_print_begin(struct Depsgraph *depsgraph)
{
- fprintf(stdout, "%s",
- depsgraph_name_for_logging(depsgraph).c_str());
+ fprintf(stdout, "%s", depsgraph_name_for_logging(depsgraph).c_str());
}
void DEG_debug_print_eval(struct Depsgraph *depsgraph,
@@ -271,18 +269,18 @@ void DEG_debug_print_eval(struct Depsgraph *depsgraph,
const char *object_name,
const void *object_address)
{
- if ((DEG_debug_flags_get(depsgraph) & G_DEBUG_DEPSGRAPH_EVAL) == 0) {
- return;
- }
- fprintf(stdout,
- "%s%s on %s %s(%p)%s\n",
- depsgraph_name_for_logging(depsgraph).c_str(),
- function_name,
- object_name,
- DEG::color_for_pointer(object_address).c_str(),
- object_address,
- DEG::color_end().c_str());
- fflush(stdout);
+ if ((DEG_debug_flags_get(depsgraph) & G_DEBUG_DEPSGRAPH_EVAL) == 0) {
+ return;
+ }
+ fprintf(stdout,
+ "%s%s on %s %s(%p)%s\n",
+ depsgraph_name_for_logging(depsgraph).c_str(),
+ function_name,
+ object_name,
+ DEG::color_for_pointer(object_address).c_str(),
+ object_address,
+ DEG::color_end().c_str());
+ fflush(stdout);
}
void DEG_debug_print_eval_subdata(struct Depsgraph *depsgraph,
@@ -293,23 +291,23 @@ void DEG_debug_print_eval_subdata(struct Depsgraph *depsgraph,
const char *subdata_name,
const void *subdata_address)
{
- if ((DEG_debug_flags_get(depsgraph) & G_DEBUG_DEPSGRAPH_EVAL) == 0) {
- return;
- }
- fprintf(stdout,
- "%s%s on %s %s(%p)%s %s %s %s(%p)%s\n",
- depsgraph_name_for_logging(depsgraph).c_str(),
- function_name,
- object_name,
- DEG::color_for_pointer(object_address).c_str(),
- object_address,
- DEG::color_end().c_str(),
- subdata_comment,
- subdata_name,
- DEG::color_for_pointer(subdata_address).c_str(),
- subdata_address,
- DEG::color_end().c_str());
- fflush(stdout);
+ if ((DEG_debug_flags_get(depsgraph) & G_DEBUG_DEPSGRAPH_EVAL) == 0) {
+ return;
+ }
+ fprintf(stdout,
+ "%s%s on %s %s(%p)%s %s %s %s(%p)%s\n",
+ depsgraph_name_for_logging(depsgraph).c_str(),
+ function_name,
+ object_name,
+ DEG::color_for_pointer(object_address).c_str(),
+ object_address,
+ DEG::color_end().c_str(),
+ subdata_comment,
+ subdata_name,
+ DEG::color_for_pointer(subdata_address).c_str(),
+ subdata_address,
+ DEG::color_end().c_str());
+ fflush(stdout);
}
void DEG_debug_print_eval_subdata_index(struct Depsgraph *depsgraph,
@@ -321,24 +319,24 @@ void DEG_debug_print_eval_subdata_index(struct Depsgraph *depsgraph,
const void *subdata_address,
const int subdata_index)
{
- if ((DEG_debug_flags_get(depsgraph) & G_DEBUG_DEPSGRAPH_EVAL) == 0) {
- return;
- }
- fprintf(stdout,
- "%s%s on %s %s(%p)%s %s %s[%d] %s(%p)%s\n",
- depsgraph_name_for_logging(depsgraph).c_str(),
- function_name,
- object_name,
- DEG::color_for_pointer(object_address).c_str(),
- object_address,
- DEG::color_end().c_str(),
- subdata_comment,
- subdata_name,
- subdata_index,
- DEG::color_for_pointer(subdata_address).c_str(),
- subdata_address,
- DEG::color_end().c_str());
- fflush(stdout);
+ if ((DEG_debug_flags_get(depsgraph) & G_DEBUG_DEPSGRAPH_EVAL) == 0) {
+ return;
+ }
+ fprintf(stdout,
+ "%s%s on %s %s(%p)%s %s %s[%d] %s(%p)%s\n",
+ depsgraph_name_for_logging(depsgraph).c_str(),
+ function_name,
+ object_name,
+ DEG::color_for_pointer(object_address).c_str(),
+ object_address,
+ DEG::color_end().c_str(),
+ subdata_comment,
+ subdata_name,
+ subdata_index,
+ DEG::color_for_pointer(subdata_address).c_str(),
+ subdata_address,
+ DEG::color_end().c_str());
+ fflush(stdout);
}
void DEG_debug_print_eval_parent_typed(struct Depsgraph *depsgraph,
@@ -349,23 +347,23 @@ void DEG_debug_print_eval_parent_typed(struct Depsgraph *depsgraph,
const char *parent_name,
const void *parent_address)
{
- if ((DEG_debug_flags_get(depsgraph) & G_DEBUG_DEPSGRAPH_EVAL) == 0) {
- return;
- }
- fprintf(stdout,
- "%s%s on %s %s(%p) [%s] %s %s %s(%p)%s\n",
- depsgraph_name_for_logging(depsgraph).c_str(),
- function_name,
- object_name,
- DEG::color_for_pointer(object_address).c_str(),
- object_address,
- DEG::color_end().c_str(),
- parent_comment,
- parent_name,
- DEG::color_for_pointer(parent_address).c_str(),
- parent_address,
- DEG::color_end().c_str());
- fflush(stdout);
+ if ((DEG_debug_flags_get(depsgraph) & G_DEBUG_DEPSGRAPH_EVAL) == 0) {
+ return;
+ }
+ fprintf(stdout,
+ "%s%s on %s %s(%p) [%s] %s %s %s(%p)%s\n",
+ depsgraph_name_for_logging(depsgraph).c_str(),
+ function_name,
+ object_name,
+ DEG::color_for_pointer(object_address).c_str(),
+ object_address,
+ DEG::color_end().c_str(),
+ parent_comment,
+ parent_name,
+ DEG::color_for_pointer(parent_address).c_str(),
+ parent_address,
+ DEG::color_end().c_str());
+ fflush(stdout);
}
void DEG_debug_print_eval_time(struct Depsgraph *depsgraph,
@@ -374,17 +372,17 @@ void DEG_debug_print_eval_time(struct Depsgraph *depsgraph,
const void *object_address,
float time)
{
- if ((DEG_debug_flags_get(depsgraph) & G_DEBUG_DEPSGRAPH_EVAL) == 0) {
- return;
- }
- fprintf(stdout,
- "%s%s on %s %s(%p)%s at time %f\n",
- depsgraph_name_for_logging(depsgraph).c_str(),
- function_name,
- object_name,
- DEG::color_for_pointer(object_address).c_str(),
- object_address,
- DEG::color_end().c_str(),
- time);
- fflush(stdout);
+ if ((DEG_debug_flags_get(depsgraph) & G_DEBUG_DEPSGRAPH_EVAL) == 0) {
+ return;
+ }
+ fprintf(stdout,
+ "%s%s on %s %s(%p)%s at time %f\n",
+ depsgraph_name_for_logging(depsgraph).c_str(),
+ function_name,
+ object_name,
+ DEG::color_for_pointer(object_address).c_str(),
+ object_address,
+ DEG::color_end().c_str(),
+ time);
+ fflush(stdout);
}