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

#include <BKE_compute_context_cache.hh>

Public Member Functions

const DataBlockComputeContext & for_data_block (const ComputeContext *parent, const uint32_t orig_session_uid, const ID *id=nullptr)
const DataBlockComputeContext & for_data_block (const ComputeContext *parent, const ID &id)
const GeometryNodesModifierComputeContext & for_geometry_nodes_modifier (const ComputeContext *parent, const NodesModifierData &nmd)
const GeometryNodesModifierComputeContext & for_geometry_nodes_modifier (const ComputeContext *parent, int modifier_uid)
const SceneCompositorEffectComputeContext & for_scene_compositor_effect (const ComputeContext *parent, const SceneCompositorEffect &effect)
const OperatorComputeContext & for_operator (const ComputeContext *parent)
const OperatorComputeContext & for_operator (const ComputeContext *parent, const bNodeTree &tree)
const ShaderComputeContext & for_shader (const ComputeContext *parent, const bNodeTree *tree)
const GroupNodeComputeContext & for_group_node (const ComputeContext *parent, int32_t node_id, const bNodeTree *tree=nullptr)
const SimulationZoneComputeContext & for_simulation_zone (const ComputeContext *parent, int output_node_id)
const SimulationZoneComputeContext & for_simulation_zone (const ComputeContext *parent, const bNode &output_node)
const RepeatZoneComputeContext & for_repeat_zone (const ComputeContext *parent, int32_t output_node_id, int iteration)
const RepeatZoneComputeContext & for_repeat_zone (const ComputeContext *parent, const bNode &output_node, int iteration)
const ForeachGeometryElementZoneComputeContext & for_foreach_geometry_element_zone (const ComputeContext *parent, int32_t output_node_id, int index)
const ForeachGeometryElementZoneComputeContext & for_foreach_geometry_element_zone (const ComputeContext *parent, const bNode &output_node, int index)
const EvaluateClosureComputeContext & for_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 T & for_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 29 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 105 of file BKE_compute_context_cache.hh.

References blender::result, and T.

Referenced by for_data_block(), for_evaluate_closure(), for_foreach_geometry_element_zone(), for_foreach_geometry_element_zone(), for_geometry_nodes_modifier(), for_geometry_nodes_modifier(), for_group_node(), for_operator(), for_operator(), for_repeat_zone(), for_repeat_zone(), for_scene_compositor_effect(), for_shader(), for_simulation_zone(), and for_simulation_zone().

◆ for_data_block() [1/2]

const DataBlockComputeContext & blender::bke::ComputeContextCache::for_data_block ( const ComputeContext * parent,
const ID & id )

◆ for_data_block() [2/2]

◆ 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 420 of file compute_contexts.cc.

References for_any_uncached(), and blender::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_geometry_nodes_modifier() [1/2]

◆ for_geometry_nodes_modifier() [2/2]

const GeometryNodesModifierComputeContext & blender::bke::ComputeContextCache::for_geometry_nodes_modifier ( const ComputeContext * parent,
int modifier_uid )

Definition at line 322 of file compute_contexts.cc.

References for_any_uncached().

◆ for_group_node()

◆ 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 346 of file compute_contexts.cc.

References for_any_uncached().

◆ 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 398 of file compute_contexts.cc.

References for_any_uncached(), and blender::bNode::identifier.

◆ for_repeat_zone() [2/2]

◆ for_scene_compositor_effect()

◆ 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 378 of file compute_contexts.cc.

References for_any_uncached(), and blender::bNode::identifier.

◆ for_simulation_zone() [2/2]


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