Geometry Nodes: deterministic anonymous attribute lifetimes

Previously, the lifetimes of anonymous attributes were determined by
reference counts which were non-deterministic when multiple threads
are used. Now the lifetimes of anonymous attributes are handled
more explicitly and deterministically. This is a prerequisite for any kind
of caching, because caching the output of nodes that do things
non-deterministically and have "invisible inputs" (reference counts)
doesn't really work.

For more details for how deterministic lifetimes are achieved, see D16858.

No functional changes are expected. Small performance changes are expected
as well (within few percent, anything larger regressions should be reported as
bugs).

Differential Revision: https://developer.blender.org/D16858
This commit is contained in:
Jacques Lucke
2023-01-05 14:05:30 +01:00
parent 4813c37ae2
commit 2ffd08e952
90 changed files with 3003 additions and 822 deletions

View File

@@ -86,6 +86,14 @@ void Graph::add_link(OutputSocket &from, InputSocket &to)
from.targets_.append(&to);
}
void Graph::clear_origin(InputSocket &socket)
{
if (socket.origin_ != nullptr) {
socket.origin_->targets_.remove_first_occurrence_and_reorder(&socket);
socket.origin_ = nullptr;
}
}
void Graph::update_node_indices()
{
for (const int i : nodes_.index_range()) {
@@ -93,6 +101,20 @@ void Graph::update_node_indices()
}
}
void Graph::update_socket_indices()
{
int socket_counter = 0;
for (const int i : nodes_.index_range()) {
for (InputSocket *socket : nodes_[i]->inputs()) {
socket->index_in_graph_ = socket_counter++;
}
for (OutputSocket *socket : nodes_[i]->outputs()) {
socket->index_in_graph_ = socket_counter++;
}
}
socket_num_ = socket_counter;
}
bool Graph::node_indices_are_valid() const
{
for (const int i : nodes_.index_range()) {
@@ -152,6 +174,21 @@ std::string DummyDebugInfo::output_name(const int /*i*/) const
return fallback_name;
}
std::string SimpleDummyDebugInfo::node_name() const
{
return this->name;
}
std::string SimpleDummyDebugInfo::input_name(const int i) const
{
return this->input_names[i];
}
std::string SimpleDummyDebugInfo::output_name(const int i) const
{
return this->output_names[i];
}
std::string Graph::ToDotOptions::socket_name(const Socket &socket) const
{
return socket.name();