Blender V4.5
blender::bke::node_tree_reference_lifetimes Namespace Reference

Classes

class  bNodeTreeBitGroupVectorOptions
 
struct  ReferenceLifetimesInfo
 
struct  ReferenceSetInfo
 

Enumerations

enum class  ReferenceSetType {
  GroupOutputData , ClosureOutputData , GroupInputReferenceSet , ClosureInputReferenceSet ,
  LocalReferenceSet
}
 

Functions

bool analyse_reference_lifetimes (bNodeTree &tree)
 
bool can_contain_reference (eNodeSocketDatatype socket_type)
 
bool can_contain_referenced_data (eNodeSocketDatatype socket_type)
 
std::ostream & operator<< (std::ostream &stream, const ReferenceSetInfo &info)
 
static bool socket_may_have_reference (const bNodeTree &tree, const bNodeSocket &socket)
 
static bool or_into_each_other_masked (MutableBoundedBitSpan a, MutableBoundedBitSpan b, const BoundedBitSpan mask)
 
static bool or_into_each_other (MutableBoundedBitSpan a, MutableBoundedBitSpan b)
 
static const bNodeTreeZoneget_zone_of_node_if_full (const bNodeTreeZones *zones, const bNode &node)
 
static Array< const aal::RelationsInNode * > prepare_relations_by_node (const bNodeTree &tree, ResourceScope &scope)
 
static Vector< ReferenceSetInfofind_reference_sets (const bNodeTree &tree, const Span< const aal::RelationsInNode * > &relations_by_node, Vector< int > &r_group_output_reference_sets, MultiValueMap< const bNodeTreeZone *, int > &r_output_set_sources_by_closure_zone)
 
static void set_initial_data_and_reference_bits (const bNodeTree &tree, const Span< ReferenceSetInfo > reference_sets, BitGroupVector<> &r_potential_data_by_socket, BitGroupVector<> &r_potential_reference_by_socket)
 
static BitVector get_references_coming_from_outside_zone (const bNodeTreeZone &zone, const Span< const BitGroupVector<> * > sources)
 
static bool pass_left_to_right (const bNodeTree &tree, const Span< const aal::RelationsInNode * > &relations_by_node, BitGroupVector<> &r_potential_data_by_socket, BitGroupVector<> &r_potential_reference_by_socket)
 
static void prepare_required_data_for_group_outputs (const bNodeTree &tree, const Span< ReferenceSetInfo > reference_sets, const Span< int > group_output_set_sources, const BitGroupVector<> &potential_data_by_socket, const BitGroupVector<> &potential_reference_by_socket, BitGroupVector<> &r_required_data_by_socket)
 
static void prepare_required_data_for_closure_outputs (const bNodeTree &tree, const Span< ReferenceSetInfo > reference_sets, MultiValueMap< const bNodeTreeZone *, int > &output_set_sources_by_closure_zone, const BitGroupVector<> &potential_data_by_socket, const BitGroupVector<> &potential_reference_by_socket, BitGroupVector<> &r_required_data_by_socket)
 
static void prepare_required_data_for_outputs (const bNodeTree &tree, const Span< ReferenceSetInfo > reference_sets, const Span< int > group_output_set_sources, MultiValueMap< const bNodeTreeZone *, int > &output_set_sources_by_closure_zone, const BitGroupVector<> &potential_data_by_socket, const BitGroupVector<> &potential_reference_by_socket, BitGroupVector<> &r_required_data_by_socket)
 
static bool pass_right_to_left (const bNodeTree &tree, const Span< const aal::RelationsInNode * > &relations_by_node, const BitGroupVector<> &potential_reference_by_socket, BitGroupVector<> &r_required_data_by_socket)
 
static aal::RelationsInNode get_tree_relations (const bNodeTree &tree, const Span< ReferenceSetInfo > reference_sets, const BitGroupVector<> &potential_data_by_socket, const BitGroupVector<> &potential_reference_by_socket, const BitGroupVector<> &required_data_by_socket)
 
static std::unique_ptr< ReferenceLifetimesInfomake_reference_lifetimes_info (const bNodeTree &tree)
 

Detailed Description

Geometry nodes has the concept of anonymous attributes. These are attributes that are created by some node with an internal name that is not exposed to the user. The only way to use this attribute is to make a link in the node tree to the node that should use it. This explicitness allows us to automatically determine when anonymous attributes are not needed anymore and should be deleted (or not created in the first place).

This file is used to determine the lifetimes of these anonymous attributes. The logic is fairly straight forward to extend to other kinds of referenced data, but for now we only have anonymous attributes.

The lifetime analysis uses information provided in the node declaration and hardcoded behavior for some special nodes like zones to determine the following things among others.

  • Where are new references (like anonymous attributes) created?
  • Which data sockets (like geometry) contain the referenced data?
  • Which nodes have to propagate which referenced data to which outputs?

This information is later used when evaluating geometry nodes to reduce the lifetime of anonymous attributes automatically.

Enumeration Type Documentation

◆ ReferenceSetType

Enumerator
GroupOutputData 

Corresponds to geometry outputs that may contain attributes that are propagated from a group input. In such cases, the caller may provide a set of attributes that should be propagated.

ClosureOutputData 
GroupInputReferenceSet 

Field inputs may require attributes that need to be propagated from other geometry inputs to the node that evaluates the field.

ClosureInputReferenceSet 
LocalReferenceSet 

Locally created anonymous attributes (like with the Capture Attribute node) need to be propagated to the nodes that use them or even to the group output.

Definition at line 41 of file BKE_node_tree_reference_lifetimes.hh.

Function Documentation

◆ analyse_reference_lifetimes()

bool blender::bke::node_tree_reference_lifetimes::analyse_reference_lifetimes ( bNodeTree & tree)

◆ can_contain_reference()

bool blender::bke::node_tree_reference_lifetimes::can_contain_reference ( eNodeSocketDatatype socket_type)

The socket type allows storing references to data stored elsewhere.

Definition at line 83 of file node_tree_reference_lifetimes.cc.

References ELEM, SOCK_BUNDLE, SOCK_CLOSURE, and blender::nodes::socket_type_supports_fields().

Referenced by find_reference_sets().

◆ can_contain_referenced_data()

bool blender::bke::node_tree_reference_lifetimes::can_contain_referenced_data ( eNodeSocketDatatype socket_type)

◆ find_reference_sets()

◆ get_references_coming_from_outside_zone()

static BitVector blender::bke::node_tree_reference_lifetimes::get_references_coming_from_outside_zone ( const bNodeTreeZone & zone,
const Span< const BitGroupVector<> * > sources )
static

◆ get_tree_relations()

static aal::RelationsInNode blender::bke::node_tree_reference_lifetimes::get_tree_relations ( const bNodeTree & tree,
const Span< ReferenceSetInfo > reference_sets,
const BitGroupVector<> & potential_data_by_socket,
const BitGroupVector<> & potential_reference_by_socket,
const BitGroupVector<> & required_data_by_socket )
static

◆ get_zone_of_node_if_full()

static const bNodeTreeZone * blender::bke::node_tree_reference_lifetimes::get_zone_of_node_if_full ( const bNodeTreeZones * zones,
const bNode & node )
static

◆ make_reference_lifetimes_info()

◆ operator<<()

std::ostream & blender::bke::node_tree_reference_lifetimes::operator<< ( std::ostream & stream,
const ReferenceSetInfo & info )

Definition at line 29 of file node_tree_reference_lifetimes.cc.

◆ or_into_each_other()

static bool blender::bke::node_tree_reference_lifetimes::or_into_each_other ( MutableBoundedBitSpan a,
MutableBoundedBitSpan b )
static

Definition at line 73 of file node_tree_reference_lifetimes.cc.

References b, and blender::bits::spans_equal().

Referenced by pass_right_to_left().

◆ or_into_each_other_masked()

static bool blender::bke::node_tree_reference_lifetimes::or_into_each_other_masked ( MutableBoundedBitSpan a,
MutableBoundedBitSpan b,
const BoundedBitSpan mask )
static

◆ pass_left_to_right()

static bool blender::bke::node_tree_reference_lifetimes::pass_left_to_right ( const bNodeTree & tree,
const Span< const aal::RelationsInNode * > & relations_by_node,
BitGroupVector<> & r_potential_data_by_socket,
BitGroupVector<> & r_potential_reference_by_socket )
static

◆ pass_right_to_left()

static bool blender::bke::node_tree_reference_lifetimes::pass_right_to_left ( const bNodeTree & tree,
const Span< const aal::RelationsInNode * > & relations_by_node,
const BitGroupVector<> & potential_reference_by_socket,
BitGroupVector<> & r_required_data_by_socket )
static

◆ prepare_relations_by_node()

◆ prepare_required_data_for_closure_outputs()

static void blender::bke::node_tree_reference_lifetimes::prepare_required_data_for_closure_outputs ( const bNodeTree & tree,
const Span< ReferenceSetInfo > reference_sets,
MultiValueMap< const bNodeTreeZone *, int > & output_set_sources_by_closure_zone,
const BitGroupVector<> & potential_data_by_socket,
const BitGroupVector<> & potential_reference_by_socket,
BitGroupVector<> & r_required_data_by_socket )
static

◆ prepare_required_data_for_group_outputs()

static void blender::bke::node_tree_reference_lifetimes::prepare_required_data_for_group_outputs ( const bNodeTree & tree,
const Span< ReferenceSetInfo > reference_sets,
const Span< int > group_output_set_sources,
const BitGroupVector<> & potential_data_by_socket,
const BitGroupVector<> & potential_reference_by_socket,
BitGroupVector<> & r_required_data_by_socket )
static

◆ prepare_required_data_for_outputs()

static void blender::bke::node_tree_reference_lifetimes::prepare_required_data_for_outputs ( const bNodeTree & tree,
const Span< ReferenceSetInfo > reference_sets,
const Span< int > group_output_set_sources,
MultiValueMap< const bNodeTreeZone *, int > & output_set_sources_by_closure_zone,
const BitGroupVector<> & potential_data_by_socket,
const BitGroupVector<> & potential_reference_by_socket,
BitGroupVector<> & r_required_data_by_socket )
static

◆ set_initial_data_and_reference_bits()

◆ socket_may_have_reference()

static bool blender::bke::node_tree_reference_lifetimes::socket_may_have_reference ( const bNodeTree & tree,
const bNodeSocket & socket )
static

Definition at line 56 of file node_tree_reference_lifetimes.cc.

References blender::bke::IsField, and tree.

Referenced by prepare_relations_by_node().