Blender V5.0
blender::bke::node_tree_reference_lifetimes Namespace Reference

Classes

struct  ReferenceSetInfo
struct  ReferenceLifetimesInfo
class  bNodeTreeBitGroupVectorOptions
class  NodeDeclaration

Typedefs

using BitInt

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 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.

Typedef Documentation

◆ BitInt

Using a large integer type is better because then it's easier to process many bits at once.

Definition at line 27 of file BLI_bit_ref.hh.

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)

Definition at line 1072 of file node_tree_reference_lifetimes.cc.

References make_reference_lifetimes_info(), and tree.

◆ can_contain_reference()

◆ can_contain_referenced_data()

◆ find_reference_sets()

◆ get_references_coming_from_outside_zone()

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()

◆ get_zone_of_node_if_full()

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()

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()

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

◆ pass_left_to_right()

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()

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()

◆ prepare_required_data_for_group_outputs()

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()

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()

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

Definition at line 56 of file node_tree_reference_lifetimes.cc.

References ELEM, SOCK_BUNDLE, SOCK_CLOSURE, and bNodeSocket::type.

Referenced by prepare_relations_by_node().