Geometry Nodes: improve debug graph for repeat zone

This makes some labels more self-explanatory in the graph generated with
`graph.to_dot()`.
This commit is contained in:
Jacques Lucke
2024-09-12 18:20:52 +02:00
parent e9ad0e506c
commit 5ee60600a3
4 changed files with 19 additions and 5 deletions

View File

@@ -208,6 +208,10 @@ class Graph : NonCopyable, NonMovable {
* Used to allocate nodes and sockets in the graph.
*/
LinearAllocator<> allocator_;
/**
* Name of the graph for debugging purposes.
*/
StringRefNull name_;
/**
* Contains all nodes in the graph so that it is efficient to iterate over them.
* The first two nodes are the interface input and output nodes.
@@ -227,9 +231,11 @@ class Graph : NonCopyable, NonMovable {
int socket_num_ = 0;
public:
Graph();
Graph(StringRef name = "unkown");
~Graph();
StringRefNull name() const;
/**
* Get all nodes in the graph. The index in the span corresponds to #Node::index_in_graph.
*/
@@ -489,6 +495,11 @@ inline const LazyFunction &FunctionNode::function() const
/** \name #Graph Inline Methods
* \{ */
inline StringRefNull Graph::name() const
{
return name_;
}
inline Span<const Node *> Graph::nodes() const
{
return nodes_;

View File

@@ -10,8 +10,9 @@
namespace blender::fn::lazy_function {
Graph::Graph()
Graph::Graph(const StringRef name)
{
name_ = allocator_.copy_string(name);
graph_input_node_ = allocator_.construct<InterfaceNode>().release();
graph_output_node_ = allocator_.construct<InterfaceNode>().release();
nodes_.append(graph_input_node_);

View File

@@ -1475,6 +1475,8 @@ GraphExecutor::GraphExecutor(const Graph &graph,
side_effect_provider_(side_effect_provider),
node_execute_wrapper_(node_execute_wrapper)
{
debug_name_ = graph.name().c_str();
/* The graph executor can handle partial execution when there are still missing inputs. */
allow_missing_requested_inputs_ = true;

View File

@@ -1860,11 +1860,11 @@ class LazyFunctionForRepeatZone : public LazyFunction {
for (const int i : inputs_.index_range()) {
const lf::Input &input = inputs_[i];
lf_inputs.append(&lf_graph.add_input(*input.type, input.debug_name));
lf_inputs.append(&lf_graph.add_input(*input.type, this->input_name(i)));
}
for (const int i : outputs_.index_range()) {
const lf::Output &output = outputs_[i];
lf_outputs.append(&lf_graph.add_output(*output.type, output.debug_name));
lf_outputs.append(&lf_graph.add_output(*output.type, this->output_name(i)));
}
/* Create body nodes. */
@@ -2474,7 +2474,7 @@ struct GeometryNodesLazyFunctionBuilder {
*/
ZoneBodyFunction &build_zone_body_function(const bNodeTreeZone &zone)
{
lf::Graph &lf_body_graph = scope_.construct<lf::Graph>();
lf::Graph &lf_body_graph = scope_.construct<lf::Graph>("Repeat Body");
BuildGraphParams graph_params{lf_body_graph};