Changeset View
Changeset View
Standalone View
Standalone View
source/blender/compositor/intern/COM_Debug.cc
| Show All 35 Lines | |||||||||||
| #include "COM_ExecutionSystem.h" | #include "COM_ExecutionSystem.h" | ||||||||||
| #include "COM_Node.h" | #include "COM_Node.h" | ||||||||||
| #include "COM_ReadBufferOperation.h" | #include "COM_ReadBufferOperation.h" | ||||||||||
| #include "COM_ViewerOperation.h" | #include "COM_ViewerOperation.h" | ||||||||||
| #include "COM_WriteBufferOperation.h" | #include "COM_WriteBufferOperation.h" | ||||||||||
| namespace blender::compositor { | namespace blender::compositor { | ||||||||||
| #ifdef COM_DEBUG | |||||||||||
| int DebugInfo::m_file_index = 0; | int DebugInfo::m_file_index = 0; | ||||||||||
jbakkerUnsubmitted Not Done Inline Actions
jbakker: | |||||||||||
| DebugInfo::NodeNameMap DebugInfo::m_node_names; | DebugInfo::NodeNameMap DebugInfo::m_node_names; | ||||||||||
| DebugInfo::OpNameMap DebugInfo::m_op_names; | DebugInfo::OpNameMap DebugInfo::m_op_names; | ||||||||||
| std::string DebugInfo::m_current_node_name; | std::string DebugInfo::m_current_node_name; | ||||||||||
| std::string DebugInfo::m_current_op_name; | std::string DebugInfo::m_current_op_name; | ||||||||||
| DebugInfo::GroupStateMap DebugInfo::m_group_states; | DebugInfo::GroupStateMap DebugInfo::m_group_states; | ||||||||||
| std::string DebugInfo::node_name(const Node *node) | std::string DebugInfo::node_name(const Node *node) | ||||||||||
| { | { | ||||||||||
| NodeNameMap::const_iterator it = m_node_names.find(node); | NodeNameMap::const_iterator it = m_node_names.find(node); | ||||||||||
Not Done Inline ActionsNot needed, this is an internal method jbakker: Not needed, this is an internal method | |||||||||||
| if (it != m_node_names.end()) { | if (it != m_node_names.end()) { | ||||||||||
| return it->second; | return it->second; | ||||||||||
| } | } | ||||||||||
| return ""; | return ""; | ||||||||||
| } | } | ||||||||||
| std::string DebugInfo::operation_name(const NodeOperation *op) | std::string DebugInfo::operation_name(const NodeOperation *op) | ||||||||||
| { | { | ||||||||||
| OpNameMap::const_iterator it = m_op_names.find(op); | OpNameMap::const_iterator it = m_op_names.find(op); | ||||||||||
Not Done Inline ActionsNot needed this is an internal method jbakker: Not needed this is an internal method | |||||||||||
| if (it != m_op_names.end()) { | if (it != m_op_names.end()) { | ||||||||||
| return it->second; | return it->second; | ||||||||||
| } | } | ||||||||||
| return ""; | return ""; | ||||||||||
| } | } | ||||||||||
| void DebugInfo::convert_started() | |||||||||||
| { | |||||||||||
| m_op_names.clear(); | |||||||||||
| } | |||||||||||
| void DebugInfo::execute_started(const ExecutionSystem *system) | |||||||||||
| { | |||||||||||
| m_file_index = 1; | |||||||||||
| m_group_states.clear(); | |||||||||||
| for (ExecutionGroup *execution_group : system->m_groups) { | |||||||||||
| m_group_states[execution_group] = EG_WAIT; | |||||||||||
| } | |||||||||||
| } | |||||||||||
| void DebugInfo::node_added(const Node *node) | |||||||||||
| { | |||||||||||
| m_node_names[node] = std::string(node->getbNode() ? node->getbNode()->name : ""); | |||||||||||
| } | |||||||||||
| void DebugInfo::node_to_operations(const Node *node) | |||||||||||
| { | |||||||||||
| m_current_node_name = m_node_names[node]; | |||||||||||
| } | |||||||||||
| void DebugInfo::operation_added(const NodeOperation *operation) | |||||||||||
| { | |||||||||||
| m_op_names[operation] = m_current_node_name; | |||||||||||
| } | |||||||||||
| void DebugInfo::operation_read_write_buffer(const NodeOperation *operation) | |||||||||||
| { | |||||||||||
| m_current_op_name = m_op_names[operation]; | |||||||||||
| } | |||||||||||
| void DebugInfo::execution_group_started(const ExecutionGroup *group) | |||||||||||
| { | |||||||||||
| m_group_states[group] = EG_RUNNING; | |||||||||||
| } | |||||||||||
| void DebugInfo::execution_group_finished(const ExecutionGroup *group) | |||||||||||
| { | |||||||||||
| m_group_states[group] = EG_FINISHED; | |||||||||||
| } | |||||||||||
| int DebugInfo::graphviz_operation(const ExecutionSystem *system, | int DebugInfo::graphviz_operation(const ExecutionSystem *system, | ||||||||||
Not Done Inline ActionsMove convert_started, execute_started, node_added, node_to_operations, operation_added, operation_read_write_buffer, execution_group_started and execution_group_finished into the header file. This way it will be inlined during compilation. jbakker: Move convert_started, execute_started, node_added, node_to_operations, operation_added… | |||||||||||
| NodeOperation *operation, | NodeOperation *operation, | ||||||||||
| const ExecutionGroup *group, | const ExecutionGroup *group, | ||||||||||
| char *str, | char *str, | ||||||||||
| int maxlen) | int maxlen) | ||||||||||
| { | { | ||||||||||
| int len = 0; | int len = 0; | ||||||||||
| std::string fillcolor = "gainsboro"; | std::string fillcolor = "gainsboro"; | ||||||||||
| ▲ Show 20 Lines • Show All 312 Lines • ▼ Show 20 Lines | bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int maxlen) | ||||||||||
| len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "}\r\n"); | len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "}\r\n"); | ||||||||||
| return (len < maxlen); | return (len < maxlen); | ||||||||||
| } | } | ||||||||||
| void DebugInfo::graphviz(const ExecutionSystem *system) | void DebugInfo::graphviz(const ExecutionSystem *system) | ||||||||||
| { | { | ||||||||||
| if (!COM_EXPORT_GRAPHVIZ) { | |||||||||||
| return; | |||||||||||
| } | |||||||||||
| char str[1000000]; | char str[1000000]; | ||||||||||
| if (graphviz_system(system, str, sizeof(str) - 1)) { | if (graphviz_system(system, str, sizeof(str) - 1)) { | ||||||||||
| char basename[FILE_MAX]; | char basename[FILE_MAX]; | ||||||||||
| char filename[FILE_MAX]; | char filename[FILE_MAX]; | ||||||||||
| BLI_snprintf(basename, sizeof(basename), "compositor_%d.dot", m_file_index); | BLI_snprintf(basename, sizeof(basename), "compositor_%d.dot", m_file_index); | ||||||||||
| BLI_join_dirfile(filename, sizeof(filename), BKE_tempdir_session(), basename); | BLI_join_dirfile(filename, sizeof(filename), BKE_tempdir_session(), basename); | ||||||||||
| m_file_index++; | m_file_index++; | ||||||||||
| std::cout << "Writing compositor debug to: " << filename << "\n"; | std::cout << "Writing compositor debug to: " << filename << "\n"; | ||||||||||
| FILE *fp = BLI_fopen(filename, "wb"); | FILE *fp = BLI_fopen(filename, "wb"); | ||||||||||
| fputs(str, fp); | fputs(str, fp); | ||||||||||
| fclose(fp); | fclose(fp); | ||||||||||
| } | } | ||||||||||
| } | } | ||||||||||
| #else | |||||||||||
| std::string DebugInfo::node_name(const Node * /*node*/) | |||||||||||
| { | |||||||||||
| return ""; | |||||||||||
| } | |||||||||||
| std::string DebugInfo::operation_name(const NodeOperation * /*op*/) | |||||||||||
| { | |||||||||||
| return ""; | |||||||||||
| } | |||||||||||
| void DebugInfo::convert_started() | |||||||||||
| { | |||||||||||
| } | |||||||||||
| void DebugInfo::execute_started(const ExecutionSystem * /*system*/) | |||||||||||
| { | |||||||||||
| } | |||||||||||
| void DebugInfo::node_added(const Node * /*node*/) | |||||||||||
| { | |||||||||||
| } | |||||||||||
| void DebugInfo::node_to_operations(const Node * /*node*/) | |||||||||||
| { | |||||||||||
| } | |||||||||||
| void DebugInfo::operation_added(const NodeOperation * /*operation*/) | |||||||||||
| { | |||||||||||
| } | |||||||||||
| void DebugInfo::operation_read_write_buffer(const NodeOperation * /*operation*/) | |||||||||||
| { | |||||||||||
| } | |||||||||||
| void DebugInfo::execution_group_started(const ExecutionGroup * /*group*/) | |||||||||||
| { | |||||||||||
| } | |||||||||||
| void DebugInfo::execution_group_finished(const ExecutionGroup * /*group*/) | |||||||||||
| { | |||||||||||
| } | |||||||||||
| void DebugInfo::graphviz(const ExecutionSystem * /*system*/) | |||||||||||
| { | |||||||||||
| } | |||||||||||
| #endif | |||||||||||
| } // namespace blender::compositor | } // namespace blender::compositor | ||||||||||