Blender V5.0
blender::bke::ComputeContextCache Class Reference

#include <BKE_compute_context_cache.hh>

Public Member Functions

const ModifierComputeContextfor_modifier (const ComputeContext *parent, const NodesModifierData &nmd)
const ModifierComputeContextfor_modifier (const ComputeContext *parent, int modifier_uid)
const OperatorComputeContextfor_operator (const ComputeContext *parent)
const OperatorComputeContextfor_operator (const ComputeContext *parent, const bNodeTree &tree)
const ShaderComputeContextfor_shader (const ComputeContext *parent, const bNodeTree *tree)
const GroupNodeComputeContextfor_group_node (const ComputeContext *parent, int32_t node_id, const bNodeTree *tree=nullptr)
const SimulationZoneComputeContextfor_simulation_zone (const ComputeContext *parent, int output_node_id)
const SimulationZoneComputeContextfor_simulation_zone (const ComputeContext *parent, const bNode &output_node)
const RepeatZoneComputeContextfor_repeat_zone (const ComputeContext *parent, int32_t output_node_id, int iteration)
const RepeatZoneComputeContextfor_repeat_zone (const ComputeContext *parent, const bNode &output_node, int iteration)
const ForeachGeometryElementZoneComputeContextfor_foreach_geometry_element_zone (const ComputeContext *parent, int32_t output_node_id, int index)
const ForeachGeometryElementZoneComputeContextfor_foreach_geometry_element_zone (const ComputeContext *parent, const bNode &output_node, int index)
const EvaluateClosureComputeContextfor_evaluate_closure (const ComputeContext *parent, int32_t node_id, const bNodeTree *tree=nullptr, const std::optional< nodes::ClosureSourceLocation > &closure_source_location=std::nullopt)
template<typename T, typename... Args>
const Tfor_any_uncached (Args &&...args)

Detailed Description

When traversing the computation of a node tree (like in socket_usage_inference.cc or partial_eval.cc) one often enters and exists the same compute contexts. The cache implemented here avoids re-creating the same compute contexts over and over again. While requiring less memory and having potentially better performance, it can also be used to ensure that the same compute context will always have the same pointer, even if it's created in two different places.

Constructing compute contexts through this cache can also be a bit more convenient.

Definition at line 25 of file BKE_compute_context_cache.hh.

Member Function Documentation

◆ for_any_uncached()

template<typename T, typename... Args>
const T & blender::bke::ComputeContextCache::for_any_uncached ( Args &&... args)
inline

A fallback that does not use caching and can be used for any compute context. More constructors like the ones above can be added as they become necessary.

Definition at line 88 of file BKE_compute_context_cache.hh.

References result, and T.

Referenced by for_evaluate_closure(), for_foreach_geometry_element_zone(), for_foreach_geometry_element_zone(), for_group_node(), for_modifier(), for_modifier(), for_operator(), for_operator(), for_repeat_zone(), for_repeat_zone(), for_shader(), for_simulation_zone(), and for_simulation_zone().

◆ for_evaluate_closure()

const EvaluateClosureComputeContext & blender::bke::ComputeContextCache::for_evaluate_closure ( const ComputeContext * parent,
int32_t node_id,
const bNodeTree * tree = nullptr,
const std::optional< nodes::ClosureSourceLocation > & closure_source_location = std::nullopt )

◆ for_foreach_geometry_element_zone() [1/2]

const ForeachGeometryElementZoneComputeContext & blender::bke::ComputeContextCache::for_foreach_geometry_element_zone ( const ComputeContext * parent,
const bNode & output_node,
int index )

Definition at line 313 of file compute_contexts.cc.

References for_any_uncached(), and bNode::identifier.

◆ for_foreach_geometry_element_zone() [2/2]

const ForeachGeometryElementZoneComputeContext & blender::bke::ComputeContextCache::for_foreach_geometry_element_zone ( const ComputeContext * parent,
int32_t output_node_id,
int index )

◆ for_group_node()

◆ for_modifier() [1/2]

◆ for_modifier() [2/2]

const ModifierComputeContext & blender::bke::ComputeContextCache::for_modifier ( const ComputeContext * parent,
int modifier_uid )

Definition at line 225 of file compute_contexts.cc.

References for_any_uncached().

◆ for_operator() [1/2]

const OperatorComputeContext & blender::bke::ComputeContextCache::for_operator ( const ComputeContext * parent)

◆ for_operator() [2/2]

const OperatorComputeContext & blender::bke::ComputeContextCache::for_operator ( const ComputeContext * parent,
const bNodeTree & tree )

Definition at line 239 of file compute_contexts.cc.

References for_any_uncached(), and tree.

◆ for_repeat_zone() [1/2]

const RepeatZoneComputeContext & blender::bke::ComputeContextCache::for_repeat_zone ( const ComputeContext * parent,
const bNode & output_node,
int iteration )

Definition at line 291 of file compute_contexts.cc.

References for_any_uncached(), and bNode::identifier.

◆ for_repeat_zone() [2/2]

◆ for_shader()

const ShaderComputeContext & blender::bke::ComputeContextCache::for_shader ( const ComputeContext * parent,
const bNodeTree * tree )

◆ for_simulation_zone() [1/2]

const SimulationZoneComputeContext & blender::bke::ComputeContextCache::for_simulation_zone ( const ComputeContext * parent,
const bNode & output_node )

Definition at line 271 of file compute_contexts.cc.

References for_any_uncached(), and bNode::identifier.

◆ for_simulation_zone() [2/2]


The documentation for this class was generated from the following files: