57using bke::bNodeTreeZone;
58using bke::bNodeTreeZones;
70 if (
string.size() <= 100) {
86 if (field_inputs_ptr) {
91 for (
const FieldInput &field_input : field_inputs) {
94 std::ranges::sort(
input_tooltips, [](
const std::string &a,
const std::string &
b) {
128 switch (component->type()) {
169 if (
const bke::GizmoEditHints *gizmo_edit_hints = edit_component.gizmo_edit_hints_.get()) {
177 if (
const Volume *volume = volume_component.get()) {
197 if (unique_layer_names.
add(layer_name)) {
209struct GridIsEmptyOp {
210 const openvdb::GridBase &base_grid;
215 result =
static_cast<const GridType &
>(base_grid).empty();
224 bke::VolumeTreeAccessToken token;
225 const openvdb::GridBase &vdb_grid = grid->grid(token);
228 GridIsEmptyOp is_empty_op{vdb_grid};
229 if (BKE_volume_grid_type_operation(grid_type, is_empty_op)) {
230 this->
is_empty = is_empty_op.result;
245 const std::optional<ClosureSourceLocation> &source_location,
246 std::shared_ptr<ClosureEvalLog>
eval_log)
249 if (source_location) {
250 const bNodeTree *tree_eval = source_location->tree;
254 source_location->closure_output_node_id,
255 source_location->compute_context_hash};
308 : root_log_(root_log), tree_loggers_(std::move(tree_loggers))
312 children_hashes_.add(
hash);
327 {
node.identifier, socket.index(), std::move(value_log)});
330 auto log_generic_value = [&](
const CPPType &type,
const void *value) {
348 const bke::GVolumeGrid grid = value_variant.
extract<bke::GVolumeGrid>();
352 else if (value_variant.
is_list()) {
359 for (
const auto &item : bundle->items()) {
363 items.
append({item.key.ustr(), {socket_value->type}});
368 items.
append({item.key.ustr(), {internal_value->value->type_name()}});
377 std::optional<ClosureSourceLocation> source_location;
378 std::shared_ptr<ClosureEvalLog>
eval_log;
387 source_location = closure->source_location();
391 std::move(inputs), std::move(outputs), source_location,
eval_log));
395 if (value.
type()->
is<std::string>()) {
396 const std::string &
string = *value.
get<std::string>();
400 log_generic_value(*value.
type(), value.
get());
405 if (type.
is<std::string>()) {
406 const std::string &
string = *value.
get<std::string>();
410 log_generic_value(type, value.
get());
417 main_geometry_cache_mutex_.ensure([&]() {
420 if (item.value.is_volume_grid()) {
421 const bke::GVolumeGrid grid = *item.value.get_if<bke::GVolumeGrid>();
429 if (item.value.is_single() && item.value.get().is_type<
bke::GeometrySet>()) {
435 return main_geometry_cache_ ? &*main_geometry_cache_ :
nullptr;
440 if (reduced_node_warnings_) {
444 reduced_node_warnings_ =
true;
452 if (ID *id = *cb_data->id_pointer) {
453 if (GS(id->name) == ID_NT) {
454 const bNodeTree *tree = reinterpret_cast<const bNodeTree *>(id);
455 map.add(id->session_uid, tree);
462 this->ensure_node_warnings(map);
467 if (reduced_node_warnings_) {
472 map.
add_new(tree->id.session_uid, tree);
481 if (reduced_node_warnings_) {
484 if (tree_loggers_.is_empty()) {
487 const std::optional<uint32_t> tree_uid = tree_loggers_[0]->tree_orig_session_uid;
496 propagation =
node->warning_propagation;
506 NodeTreeLog &child_log = root_log_->get_tree_log(child_hash);
507 if (child_log.tree_loggers_.is_empty()) {
510 const NodeTreeLogger &first_child_logger = *child_log.tree_loggers_[0];
512 const std::optional<int32_t> &caller_node_id = first_child_logger.
parent_node_id;
513 if (tree && caller_node_id) {
514 if (
const bNode *caller_node = tree->node_by_id(*caller_node_id)) {
515 propagation = caller_node->warning_propagation;
519 if (caller_node_id.has_value()) {
529 reduced_node_warnings_ =
true;
534 if (reduced_execution_times_) {
539 const std::chrono::nanoseconds duration = timings.
end - timings.
start;
544 reduced_execution_times_ =
true;
549 if (reduced_socket_values_) {
563 reduced_socket_values_ =
true;
568 if (reduced_viewer_node_logs_) {
576 reduced_viewer_node_logs_ =
true;
581 if (reduced_existing_attributes_) {
586 auto handle_value_log = [&](
const ValueLog &value_log) {
588 if (geo_log ==
nullptr) {
597 for (
const ValueLog *value_log : node_log->input_values_.values()) {
598 handle_value_log(*value_log);
600 for (
const ValueLog *value_log : node_log->output_values_.values()) {
601 handle_value_log(*value_log);
604 reduced_existing_attributes_ =
true;
609 if (reduced_used_named_attributes_) {
613 auto add_attribute = [&](
const int32_t node_id,
627 NodeTreeLog &child_log = root_log_->get_tree_log(child_hash);
628 if (child_log.tree_loggers_.is_empty()) {
632 if (
const std::optional<int32_t> &parent_node_id = child_log.tree_loggers_[0]->parent_node_id)
635 add_attribute(*parent_node_id, item.key, item.value);
639 reduced_used_named_attributes_ =
true;
644 if (reduced_debug_messages_) {
650 .debug_messages.append(debug_message.
message);
653 reduced_debug_messages_ =
true;
658 if (reduced_evaluated_gizmo_nodes_) {
663 tree_logger->evaluated_gizmo_nodes)
669 reduced_evaluated_gizmo_nodes_ =
true;
674 if (reduced_layer_names_) {
680 auto handle_value_log = [&](
const ValueLog &value_log) {
691 for (
const ValueLog *value_log : node_log->input_values_.values()) {
692 handle_value_log(*value_log);
694 for (
const ValueLog *value_log : node_log->output_values_.values()) {
695 handle_value_log(*value_log);
699 reduced_layer_names_ =
true;
704 if (reduced_node_image_previews_) {
715 reduced_node_image_previews_ =
true;
724 return node_log->get();
730 identifier, [&]() {
return this->allocator_.construct<
NodeLog>(); });
731 return *node_log.get();
743 if (query_socket.is_multi_input()) {
750 sockets_to_check.
push(&query_socket);
751 added_sockets.
add(&query_socket);
752 const bNodeTree &tree = query_socket.owner_tree();
754 while (!sockets_to_check.
is_empty()) {
758 ValueLog *value_log = socket.is_input() ?
759 node_log->input_values_.lookup_default(socket.index(),
nullptr) :
760 node_log->output_values_.lookup_default(socket.index(),
nullptr);
761 if (value_log !=
nullptr) {
766 if (socket.is_input()) {
770 if (added_sockets.
add(&from_socket)) {
771 sockets_to_check.
push(&from_socket);
776 if (
node.is_reroute()) {
778 if (added_sockets.
add(&input_socket)) {
779 sockets_to_check.
push(&input_socket);
784 if (added_sockets.
add(&from_socket)) {
785 sockets_to_check.
push(&from_socket);
789 else if (
node.is_muted()) {
790 if (
const bNodeSocket *input_socket = socket.internal_link_input()) {
791 if (added_sockets.
add(input_socket)) {
792 sockets_to_check.
push(input_socket);
797 if (added_sockets.
add(&from_socket)) {
798 sockets_to_check.
push(&from_socket);
803 else if (
node.is_group_input()) {
804 const int index = socket.index();
806 for (
const bNode *other_group_input : tree.group_input_nodes()) {
808 if (added_sockets.
add(&other_socket)) {
809 sockets_to_check.
push(&other_socket);
823 const void *src_value = value_log.
value.
get();
829 if (!conversions.
is_convertible(src_type, dst_type) && src_type != dst_type) {
843 return id->session_uid;
846 return id_orig->session_uid;
853 LocalData &local_data = data_per_thread_.local();
855 local_data.tree_logger_by_context;
857 compute_context.
hash());
858 if (tree_logger_ptr) {
859 return *tree_logger_ptr;
863 tree_logger.allocator = &local_data.allocator;
865 std::optional<uint32_t> parent_tree_session_uid;
866 if (parent_compute_context !=
nullptr) {
867 tree_logger.parent_hash = parent_compute_context->
hash();
873 tree_logger.parent_node_id.emplace(context->node_id());
874 if (
const bNode *caller_node = context->node()) {
881 tree_logger.parent_node_id.emplace(context->output_node_id());
882 tree_logger.tree_orig_session_uid = parent_tree_session_uid;
884 else if (
const auto *context =
888 tree_logger.parent_node_id.emplace(context->output_node_id());
889 tree_logger.tree_orig_session_uid = parent_tree_session_uid;
894 tree_logger.parent_node_id.emplace(context->output_node_id());
895 tree_logger.tree_orig_session_uid = parent_tree_session_uid;
900 tree_logger.parent_node_id.emplace(context->node_id());
901 const std::optional<nodes::ClosureSourceLocation> &location =
902 context->closure_source_location();
903 if (location.has_value()) {
904 if (location->tree->runtime->self_geometry_nodes_lazy_function_graph_info) {
905 tree_logger.tree_orig_session_uid =
906 location->tree->runtime->self_geometry_nodes_lazy_function_graph_info
907 ->original_tree_session_uid;
911 id_cast<const ID *>(location->tree));
920 reinterpret_cast<const ID *
>(nmd->node_group));
927 reinterpret_cast<const ID *
>(context->effect().node_group));
932 if (
const bNodeTree *tree = context->tree()) {
933 tree_logger.tree_orig_session_uid = tree->id.session_uid;
941 NodeTreeLog &reduced_tree_log = *tree_logs_.lookup_or_add_cb(compute_context_hash, [&]() {
943 for (LocalData &local_data : data_per_thread_) {
945 compute_context_hash);
946 if (tree_log !=
nullptr) {
947 tree_logs.
append(tree_log->get());
950 return std::make_unique<NodeTreeLog>(
this, std::move(tree_logs));
952 return reduced_tree_log;
972 get_context_hash_by_zone_for_node_editor(
const SpaceNode &snode,
976 snode, compute_context_cache);
982 if (tree_zones ==
nullptr) {
997 std::optional<ed::space_node::ObjectAndModifier> object_and_modifier =
999 if (!object_and_modifier) {
1002 return object_and_modifier->nmd->runtime->eval_log.get();
1010 return log.log.get();
1021 const Scene *scene =
reinterpret_cast<Scene *
>(space_node.
id);
1058 for (
const auto item : hash_by_zone.
items()) {
1060 tree_logs_by_zone.
add(item.key, &tree_log);
1062 return {tree_logs_by_zone};
1067 const std::optional<ed::viewer_path::ViewerPathForGeometryNodesViewer> parsed_path =
1069 if (!parsed_path.has_value()) {
1072 const Object *
object = parsed_path->object;
1081 if (nmd ==
nullptr) {
1091 nullptr, parsed_path->object->id);
1093 object_context, *nmd);
1096 *elem, compute_context_cache, compute_context);
1097 if (!compute_context) {
1106 parsed_path->viewer_node_id,
nullptr);
1112 : tree_logs_by_zone_(std::move(tree_logs_by_zone))
1118 return tree_logs_by_zone_.lookup_default(zone,
nullptr);
1134 const bNodeTree &tree = socket.owner_tree();
1145 for (
NodeTreeLog *tree_log : tree_logs_by_zone_.values()) {
1147 callback(*tree_log);
Low-level operations for curves.
Low-level operations for grease pencil.
#define FOREACH_NODETREE_END
#define FOREACH_NODETREE_BEGIN(bmain, _nodetree, _id)
void copy_construct(const void *src, void *dst) const
void destruct(void *ptr) const
const ComputeContext * parent() const
const ComputeContextHash & hash() const
const CPPType * type() const
const CPPType * type() const
constexpr IndexRange()=default
destruct_ptr< T > construct(Args &&...args)
StringRefNull copy_string(StringRef str)
void * allocate(const int64_t size, const int64_t alignment)
Value & lookup_or_add_default(const Key &key)
bool add(const Key &key, const Value &value)
Value lookup_default(const Key &key, const Value &default_value) const
void add_new(const Key &key, const Value &value)
ItemIterator items() const &
void push(const T &value)
void append(const T &value)
void extend(Span< T > array)
std::unique_ptr< nodes::eval_log::NodesEvalLog > nodes_evaluation_log
const GeometryNodesModifierComputeContext & for_geometry_nodes_modifier(const ComputeContext *parent, const NodesModifierData &nmd)
const DataBlockComputeContext & for_data_block(const ComputeContext *parent, const uint32_t orig_session_uid, const ID *id=nullptr)
void convert_to_uninitialized(const CPPType &from_type, const CPPType &to_type, const void *from_value, void *to_value) const
bool is_convertible(const CPPType &from_type, const CPPType &to_type) const
CompositorRuntime compositor
bool is_context_dependent_field() const
bool is_volume_grid() const
Vector< bNodeTreeZone * > child_zones
Vector< bNodeTreeZone * > root_zones
const bNodeTreeZone * get_zone_by_node(const int32_t node_id) const
const bNodeTreeZone * get_zone_by_socket(const bNodeSocket &socket) const
const FieldInputsPtr & field_inputs() const
CustomIDVectorSet< Item, ItemKeyGetter > inputs
CustomIDVectorSet< Item, ItemKeyGetter > outputs
BundleValueLog(Vector< Item > items)
std::shared_ptr< ClosureEvalLog > eval_log
ClosureValueLog(Vector< Item > inputs, Vector< Item > outputs, const std::optional< ClosureSourceLocation > &source_location, std::shared_ptr< ClosureEvalLog > eval_log)
std::optional< Source > source
NodeTreeLog * get_main_tree_log(const bke::bNodeTreeZone *zone) const
ContextualNodeTreeLogs(Map< const bke::bNodeTreeZone *, NodeTreeLog * > tree_logs_by_zone={})
void foreach_tree_log(FunctionRef< void(NodeTreeLog &)> callback) const
Vector< std::string > input_tooltips
FieldInfoLog(const GField &field)
~GenericValueLog() override
std::optional< MeshInfo > mesh_info
std::optional< GreasePencilInfo > grease_pencil_info
GeometryInfoLog(const bke::GeometrySet &geometry_set)
std::optional< VolumeInfo > volume_info
std::optional< CurveInfo > curve_info
std::optional< PointCloudInfo > pointcloud_info
Vector< bke::GeometryComponent::Type > component_types
Vector< GeometryAttributeInfo > attributes
std::optional< EditDataInfo > edit_data_info
std::optional< InstancesInfo > instances_info
GridInfoLog(const bke::GVolumeGrid &grid)
const StringRefNull extension_x
const StringRefNull interpolation
ImageInfoLog(int2 data_size, int2 display_size, int2 data_offset, float3x3 transformation, StringRefNull interpolation, StringRefNull extension_x, StringRefNull extension_y, StringRefNull precision)
const StringRefNull precision
const float3x3 transformation
const StringRefNull extension_y
ListInfoLog(const GListPtr &list)
Vector< std::string > all_layer_names
void ensure_node_image_previews()
Set< int > evaluated_gizmo_nodes
std::chrono::nanoseconds execution_time
Map< int32_t, destruct_ptr< NodeLog > > nodes
void ensure_node_warnings(const NodesModifierData &nmd)
void ensure_debug_messages()
Map< int32_t, ViewerNodeLog *, 0 > viewer_node_logs
void ensure_execution_times()
NodeLog & lookup_or_add_node_log(const int32_t identifier)
Vector< const GeometryAttributeInfo * > existing_attributes
void ensure_evaluated_gizmo_nodes()
NodeTreeLog(NodesEvalLog *root_log, Vector< NodeTreeLogger * > tree_loggers)
void ensure_viewer_node_logs()
VectorSet< NodeWarning > all_warnings
void ensure_existing_attributes()
void ensure_used_named_attributes()
Map< StringRefNull, NamedAttributeUsage > used_named_attributes
NodeLog * find_node_log(int32_t identifier) const
void ensure_layer_names()
void ensure_socket_values()
bool try_convert_primitive_socket_value(const GenericValueLog &value_log, const CPPType &dst_type, void *dst)
ValueLog * find_socket_value_log(const bNodeSocket &query_socket)
linear_allocator::ChunkedList< SocketValueLog, 16 > input_socket_values
linear_allocator::ChunkedList< NodeImagePreview, 16 > node_image_previews
LinearAllocator * allocator
Vector< ComputeContextHash > children_hashes
linear_allocator::ChunkedList< SocketValueLog, 16 > output_socket_values
std::optional< uint32_t > tree_orig_session_uid
void log_value(const bNode &node, const bNodeSocket &socket, GPointer value)
std::optional< int32_t > parent_node_id
NodeTreeLogger & get_local_tree_logger(const ComputeContext &compute_context)
static ContextualNodeTreeLogs get_contextual_tree_logs(const SpaceNode &snode)
static Map< const bke::bNodeTreeZone *, ComputeContextHash > get_context_hash_by_zone_for_node_editor(const SpaceNode &snode, bke::ComputeContextCache &compute_context_cache)
NodeTreeLog & get_tree_log(const ComputeContextHash &compute_context_hash)
static const ViewerNodeLog * find_viewer_node_log_for_path(const ViewerPath &viewer_path)
const bke::GeometrySet * main_geometry() const
CustomIDVectorSet< Item, ItemIdentifierGetter > items
VolumeGridType get_type(const VolumeGridData &grid)
bool attribute_name_is_anonymous(const StringRef name)
const DataTypeConversions & get_implicit_type_conversions()
const GeoOperatorLog & node_group_operator_static_eval_log()
std::optional< ObjectAndModifier > get_geometry_nodes_modifier_for_node_editor(const SpaceNode &snode)
const ComputeContext * compute_context_for_edittree(const SpaceNode &snode, bke::ComputeContextCache &compute_context_cache)
const ComputeContext * compute_context_for_zone(const bke::bNodeTreeZone &zone, bke::ComputeContextCache &compute_context_cache, const ComputeContext *parent_compute_context)
std::optional< ViewerPathForGeometryNodesViewer > parse_geometry_nodes_viewer(const ViewerPath &viewer_path)
const ComputeContext * compute_context_for_viewer_path_elem(const ViewerPathElem &elem, bke::ComputeContextCache &compute_context_cache, const ComputeContext *parent_compute_context)
ImplicitSharingPtr< FieldInputs > FieldInputsPtr
static NodesEvalLog * get_compositor_root_log(const SpaceNode &space_node)
static std::optional< uint32_t > get_original_session_uid(const ID *id)
static void find_tree_zone_hash_recursive(const bNodeTreeZone &zone, bke::ComputeContextCache &compute_context_cache, const ComputeContext *current, Map< const bNodeTreeZone *, ComputeContextHash > &r_hash_by_zone)
static NodesEvalLog * get_geometry_nodes_root_log(const SpaceNode &snode)
static NodesEvalLog * get_root_log(const SpaceNode &snode)
ImplicitSharingPtr< Closure > ClosurePtr
bool warning_is_propagated(const NodeWarningPropagation propagation, const NodeWarningType warning_type)
ImplicitSharingPtr< Bundle > BundlePtr
bool ED_node_is_compositor(const SpaceNode *snode)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
bool ED_node_is_geometry(const SpaceNode *snode)
ID * DEG_get_original_id(ID *id)
int char char int int int BLI_strcasecmp_natural(const char *s1, const char *s2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
int BKE_volume_num_grids(const Volume *volume)
SpaceNodeGeometryNodesType
@ SNODE_GEOMETRY_MODIFIER
const bke::VolumeGridData * BKE_volume_grid_get(const Volume *volume, int grid_index)
std::unique_ptr< T, DestructValueAtAddress< T > > destruct_ptr
void IMB_refImBuf(ImBuf *ibuf)
bool DEG_is_original(const T *id)
@ NODE_WARNING_PROPAGATION_ALL
SpaceNodeCompositorNodesType
@ SNODE_COMPOSITOR_SEQUENCER
void IMB_freeImBuf(ImBuf *ibuf)
VecBase< int32_t, 2 > int2
BMesh const char void * data
void BKE_volume_grid_add(Volume *volume, const bke::VolumeGridData &grid)
MatBase< float, 3, 3 > float3x3
void * BKE_id_new_nomain(short type, const char *name)
const char * BLI_str_find_prev_char_utf8(const char *p, const char *str_start) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1
T * DEG_get_original(T *id)
void BKE_library_foreach_ID_link(Main *bmain, ID *id, FunctionRef< LibraryIDLinkCallback > callback, void *user_data, LibraryForeachIDFlag flag)
struct bNodeTree * node_group
NodesModifierRuntime * runtime
std::shared_ptr< nodes::eval_log::NodesEvalLog > eval_log
bke::SceneRuntime * runtime
struct bNodeTree * selected_node_group
struct bNodeTree * edittree
StringRefNull name() const
Vector< const GeometryComponent * > get_components() const
static GeometrySet from_volume(Volume *volume, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void attribute_foreach(Span< GeometryComponent::Type > component_types, bool include_instances, AttributeForeachCallback callback) const
const bke::bNodeSocketType * type
bool has_deformed_positions
Vector< std::string > layer_names
Vector< VolumeGridInfo > grids
NamedAttributeUsage usage
StringRefNull attribute_name
destruct_ptr< ValueLog > value
destruct_ptr< ViewerNodeLog > viewer_log
StringLog(StringRef string, LinearAllocator<> &allocator)
void reserve(int new_size)