Compositor: Add Streaming Operator for NodeOperationBuilder.
For debugging purposes to convert the internal state of the NodeOperationBuilder to a graphviz. Usage: std::cout << *this << "\n"; Inside any method of the NodeOperationBuilder.
This commit is contained in:
parent
663a82b10d
commit
19ff2479cf
|
@ -259,17 +259,18 @@ std::ostream &operator<<(std::ostream &os, const NodeOperation &node_operation)
|
|||
{
|
||||
NodeOperationFlags flags = node_operation.get_flags();
|
||||
os << "NodeOperation(";
|
||||
os << "id=" << node_operation.get_id();
|
||||
if (!node_operation.get_name().empty()) {
|
||||
os << "name=" << node_operation.get_name() << ",";
|
||||
os << ",name=" << node_operation.get_name();
|
||||
}
|
||||
os << "flags={" << flags << "},";
|
||||
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 << ",write=" << (NodeOperation &)*write_operation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -251,6 +251,7 @@ struct NodeOperationFlags {
|
|||
*/
|
||||
class NodeOperation {
|
||||
private:
|
||||
int m_id;
|
||||
std::string m_name;
|
||||
Vector<NodeOperationInput> m_inputs;
|
||||
Vector<NodeOperationOutput> m_outputs;
|
||||
|
@ -307,6 +308,16 @@ class NodeOperation {
|
|||
return m_name;
|
||||
}
|
||||
|
||||
void set_id(const int id)
|
||||
{
|
||||
m_id = id;
|
||||
}
|
||||
|
||||
const int get_id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
const NodeOperationFlags get_flags() const
|
||||
{
|
||||
return flags;
|
||||
|
|
|
@ -124,6 +124,7 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system)
|
|||
|
||||
void NodeOperationBuilder::addOperation(NodeOperation *operation)
|
||||
{
|
||||
operation->set_id(m_operations.size());
|
||||
m_operations.append(operation);
|
||||
if (m_current_node) {
|
||||
operation->set_name(m_current_node->getbNode()->name);
|
||||
|
@ -691,4 +692,41 @@ void NodeOperationBuilder::group_operations()
|
|||
}
|
||||
}
|
||||
|
||||
/** Create a graphviz representation of the NodeOperationBuilder. */
|
||||
std::ostream &operator<<(std::ostream &os, const NodeOperationBuilder &builder)
|
||||
{
|
||||
os << "# Builder start\n";
|
||||
os << "digraph G {\n";
|
||||
os << " rankdir=LR;\n";
|
||||
os << " node [shape=box];\n";
|
||||
for (const NodeOperation *operation : builder.get_operations()) {
|
||||
os << " op" << operation->get_id() << " [label=\"" << *operation << "\"];\n";
|
||||
}
|
||||
|
||||
os << "\n";
|
||||
for (const NodeOperationBuilder::Link &link : builder.get_links()) {
|
||||
os << " op" << link.from()->getOperation().get_id() << " -> op"
|
||||
<< link.to()->getOperation().get_id() << ";\n";
|
||||
}
|
||||
for (const NodeOperation *operation : builder.get_operations()) {
|
||||
if (operation->get_flags().is_read_buffer_operation) {
|
||||
const ReadBufferOperation &read_operation = static_cast<const ReadBufferOperation &>(
|
||||
*operation);
|
||||
const WriteBufferOperation &write_operation =
|
||||
*read_operation.getMemoryProxy()->getWriteBufferOperation();
|
||||
os << " op" << write_operation.get_id() << " -> op" << read_operation.get_id() << ";\n";
|
||||
}
|
||||
}
|
||||
|
||||
os << "}\n";
|
||||
os << "# Builder end\n";
|
||||
return os;
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &os, const NodeOperationBuilder::Link &link)
|
||||
{
|
||||
os << link.from()->getOperation().get_id() << " -> " << link.to()->getOperation().get_id();
|
||||
return os;
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
|
|
@ -119,6 +119,16 @@ class NodeOperationBuilder {
|
|||
return m_active_viewer;
|
||||
}
|
||||
|
||||
const Vector<NodeOperation *> &get_operations() const
|
||||
{
|
||||
return m_operations;
|
||||
}
|
||||
|
||||
const Vector<Link> &get_links() const
|
||||
{
|
||||
return m_links;
|
||||
}
|
||||
|
||||
protected:
|
||||
/** Add datatype conversion where needed */
|
||||
void add_datatype_conversions();
|
||||
|
@ -160,4 +170,7 @@ class NodeOperationBuilder {
|
|||
#endif
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &os, const NodeOperationBuilder &builder);
|
||||
std::ostream &operator<<(std::ostream &os, const NodeOperationBuilder::Link &link);
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
|
Loading…
Reference in New Issue