From a0f705f18c49d98bdad55eeb8d52ba48c86f4fc9 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Fri, 2 Apr 2021 15:24:34 +0200 Subject: Compositor: Debug stream operator. Stream operators for NodeOperator and ExecutionGroup to help during debugging. --- .../compositor/intern/COM_ExecutionGroup.cc | 32 +++++++++- .../blender/compositor/intern/COM_ExecutionGroup.h | 15 ++++- source/blender/compositor/intern/COM_MemoryProxy.h | 4 +- .../blender/compositor/intern/COM_NodeOperation.cc | 69 ++++++++++++++++++++++ .../blender/compositor/intern/COM_NodeOperation.h | 14 +++++ .../compositor/intern/COM_NodeOperationBuilder.cc | 5 +- 6 files changed, 134 insertions(+), 5 deletions(-) (limited to 'source/blender/compositor/intern') diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cc b/source/blender/compositor/intern/COM_ExecutionGroup.cc index 71c22e3b473..b894f0b5e07 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.cc +++ b/source/blender/compositor/intern/COM_ExecutionGroup.cc @@ -48,8 +48,29 @@ namespace blender::compositor { -ExecutionGroup::ExecutionGroup() +std::ostream &operator<<(std::ostream &os, const ExecutionGroupFlags &flags) { + if (flags.initialized) { + os << "init,"; + } + if (flags.is_output) { + os << "output,"; + } + if (flags.complex) { + os << "complex,"; + } + if (flags.open_cl) { + os << "open_cl,"; + } + if (flags.single_threaded) { + os << "single_threaded,"; + } + return os; +} + +ExecutionGroup::ExecutionGroup(int id) +{ + m_id = id; this->m_bTree = nullptr; this->m_height = 0; this->m_width = 0; @@ -62,6 +83,15 @@ ExecutionGroup::ExecutionGroup() this->m_executionStartTime = 0; } +std::ostream &operator<<(std::ostream &os, const ExecutionGroup &execution_group) +{ + os << "ExecutionGroup(id=" << execution_group.get_id(); + os << ",flags={" << execution_group.get_flags() << "}"; + os << ",operation=" << *execution_group.getOutputOperation() << ""; + os << ")"; + return os; +} + CompositorPriority ExecutionGroup::getRenderPriority() { return this->getOutputOperation()->getRenderPriority(); diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.h b/source/blender/compositor/intern/COM_ExecutionGroup.h index 0d8fb47b5be..ebe942402f9 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.h +++ b/source/blender/compositor/intern/COM_ExecutionGroup.h @@ -73,6 +73,8 @@ struct ExecutionGroupFlags { } }; +std::ostream &operator<<(std::ostream &os, const ExecutionGroupFlags &flags); + /** * \brief Class ExecutionGroup is a group of Operations that are executed as one. * This grouping is used to combine Operations that can be executed as one whole when @@ -82,6 +84,10 @@ struct ExecutionGroupFlags { class ExecutionGroup { private: // fields + /** + * Id of the execution group. For debugging purposes. + */ + int m_id; /** * \brief list of operations in this ExecutionGroup @@ -232,7 +238,12 @@ class ExecutionGroup { public: // constructors - ExecutionGroup(); + ExecutionGroup(int id); + + int get_id() const + { + return m_id; + } const ExecutionGroupFlags get_flags() const { @@ -396,4 +407,6 @@ class ExecutionGroup { #endif }; +std::ostream &operator<<(std::ostream &os, const ExecutionGroup &execution_group); + } // namespace blender::compositor diff --git a/source/blender/compositor/intern/COM_MemoryProxy.h b/source/blender/compositor/intern/COM_MemoryProxy.h index 0966eadadb2..931fd8d2622 100644 --- a/source/blender/compositor/intern/COM_MemoryProxy.h +++ b/source/blender/compositor/intern/COM_MemoryProxy.h @@ -70,7 +70,7 @@ class MemoryProxy { /** * \brief get the ExecutionGroup that can be scheduled to calculate a certain chunk. */ - ExecutionGroup *getExecutor() + ExecutionGroup *getExecutor() const { return this->m_executor; } @@ -88,7 +88,7 @@ class MemoryProxy { * \brief get the WriteBufferOperation that is responsible for writing to this MemoryProxy * \return WriteBufferOperation */ - WriteBufferOperation *getWriteBufferOperation() + WriteBufferOperation *getWriteBufferOperation() const { return this->m_writeBufferOperation; } diff --git a/source/blender/compositor/intern/COM_NodeOperation.cc b/source/blender/compositor/intern/COM_NodeOperation.cc index 297ef100a1b..6c60a858b6c 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.cc +++ b/source/blender/compositor/intern/COM_NodeOperation.cc @@ -20,6 +20,7 @@ #include #include "COM_ExecutionSystem.h" +#include "COM_ReadBufferOperation.h" #include "COM_defines.h" #include "COM_NodeOperation.h" /* own include */ @@ -209,4 +210,72 @@ void NodeOperationOutput::determineResolution(unsigned int resolution[2], } } +std::ostream &operator<<(std::ostream &os, const NodeOperationFlags &node_operation_flags) +{ + if (node_operation_flags.complex) { + os << "complex,"; + } + if (node_operation_flags.open_cl) { + os << "open_cl,"; + } + if (node_operation_flags.single_threaded) { + os << "single_threaded,"; + } + if (node_operation_flags.use_render_border) { + os << "render_border,"; + } + if (node_operation_flags.use_viewer_border) { + os << "view_border,"; + } + if (node_operation_flags.is_resolution_set) { + os << "resolution_set,"; + } + if (node_operation_flags.is_set_operation) { + os << "set_operation,"; + } + if (node_operation_flags.is_write_buffer_operation) { + os << "write_buffer,"; + } + if (node_operation_flags.is_read_buffer_operation) { + os << "read_buffer,"; + } + if (node_operation_flags.is_proxy_operation) { + os << "proxy,"; + } + if (node_operation_flags.is_viewer_operation) { + os << "viewer,"; + } + if (node_operation_flags.is_preview_operation) { + os << "preview,"; + } + if (!node_operation_flags.use_datatype_conversion) { + os << "no_conversion,"; + } + + return os; +} + +std::ostream &operator<<(std::ostream &os, const NodeOperation &node_operation) +{ + NodeOperationFlags flags = node_operation.get_flags(); + os << "NodeOperation("; + if (!node_operation.get_name().empty()) { + os << "name=" << node_operation.get_name() << ","; + } + os << "flags={" << flags << "},"; + if (flags.is_read_buffer_operation) { + const ReadBufferOperation *read_operation = (const ReadBufferOperation *)&node_operation; + const MemoryProxy *proxy = read_operation->getMemoryProxy(); + if (proxy) { + const WriteBufferOperation *write_operation = proxy->getWriteBufferOperation(); + if (write_operation) { + os << "write=" << (NodeOperation &)*write_operation << ","; + } + } + } + os << ")"; + + return os; +} + } // namespace blender::compositor diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h index f300fb092a3..41e5d8b69fc 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.h +++ b/source/blender/compositor/intern/COM_NodeOperation.h @@ -250,6 +250,7 @@ struct NodeOperationFlags { */ class NodeOperation { private: + std::string m_name; blender::Vector m_inputs; blender::Vector m_outputs; @@ -295,6 +296,16 @@ class NodeOperation { { } + void set_name(const std::string name) + { + m_name = name; + } + + const std::string get_name() const + { + return m_name; + } + const NodeOperationFlags get_flags() const { return flags; @@ -594,4 +605,7 @@ class NodeOperation { #endif }; +std::ostream &operator<<(std::ostream &os, const NodeOperationFlags &node_operation_flags); +std::ostream &operator<<(std::ostream &os, const NodeOperation &node_operation); + } // namespace blender::compositor diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.cc b/source/blender/compositor/intern/COM_NodeOperationBuilder.cc index fdd48da3fb4..b1e1424f14e 100644 --- a/source/blender/compositor/intern/COM_NodeOperationBuilder.cc +++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.cc @@ -125,6 +125,9 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system) void NodeOperationBuilder::addOperation(NodeOperation *operation) { m_operations.append(operation); + if (m_current_node) { + operation->set_name(m_current_node->getbNode()->name); + } } void NodeOperationBuilder::mapInputSocket(NodeInput *node_socket, @@ -658,7 +661,7 @@ static void add_group_operations_recursive(Tags &visited, NodeOperation *op, Exe ExecutionGroup *NodeOperationBuilder::make_group(NodeOperation *op) { - ExecutionGroup *group = new ExecutionGroup(); + ExecutionGroup *group = new ExecutionGroup(this->m_groups.size()); m_groups.append(group); Tags visited; -- cgit v1.2.3