Blender V4.3
NOD_geometry_nodes_log.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
29#pragma once
30
31#include <chrono>
32
38
39#include "BKE_geometry_set.hh"
40#include "BKE_node.hh"
42#include "BKE_viewer_path.hh"
43#include "BKE_volume_grid.hh"
44
45#include "FN_field.hh"
46
47#include "DNA_node_types.h"
48
49struct SpaceNode;
50
52
53using fn::GField;
54
56enum class NodeWarningType {
57 Error = 0,
58 Warning = 1,
59 Info = 2,
60};
61
62int node_warning_type_icon(NodeWarningType type);
63int node_warning_type_severity(NodeWarningType type);
64
67 std::string message;
68
69 uint64_t hash() const
70 {
71 return get_default_hash(this->type, this->message);
72 }
73
75};
76
78 None = 0,
79 Read = 1 << 0,
80 Write = 1 << 1,
81 Remove = 1 << 2,
82};
84
92class ValueLog {
93 public:
94 virtual ~ValueLog() = default;
95};
96
101class GenericValueLog : public ValueLog {
102 public:
107
108 GenericValueLog(const GMutablePointer value) : value(value) {}
109
111};
112
117class FieldInfoLog : public ValueLog {
118 public:
119 const CPPType &type;
121
122 FieldInfoLog(const GField &field);
123};
124
126 std::string name;
128 std::optional<bke::AttrDomain> domain;
129 std::optional<eCustomDataType> data_type;
130};
131
136class GeometryInfoLog : public ValueLog {
137 public:
138 std::string name;
141
145 struct CurveInfo {
148 };
151 };
154 };
157 };
163 struct VolumeInfo {
165 };
166 struct GridInfo {
168 };
169
170 std::optional<MeshInfo> mesh_info;
171 std::optional<CurveInfo> curve_info;
172 std::optional<PointCloudInfo> pointcloud_info;
173 std::optional<GreasePencilInfo> grease_pencil_info;
174 std::optional<InstancesInfo> instances_info;
175 std::optional<EditDataInfo> edit_data_info;
176 std::optional<VolumeInfo> volume_info;
177 std::optional<GridInfo> grid_info;
178
179 GeometryInfoLog(const bke::GeometrySet &geometry_set);
180 GeometryInfoLog(const bke::GVolumeGrid &grid);
181};
182
188 public:
190};
191
192using Clock = std::chrono::steady_clock;
193using TimePoint = Clock::time_point;
194
200 public:
201 std::optional<ComputeContextHash> parent_hash;
202 std::optional<int32_t> parent_node_id;
205 std::chrono::nanoseconds execution_time{};
206
208
239
249
252
253 void log_value(const bNode &node, const bNodeSocket &socket, GPointer value);
254 void log_viewer_node(const bNode &viewer_node, bke::GeometrySet geometry);
255};
256
282
283class GeoModifierLog;
284
293 private:
294 GeoModifierLog *modifier_log_;
295 Vector<GeoTreeLogger *> tree_loggers_;
296 VectorSet<ComputeContextHash> children_hashes_;
297 bool reduced_node_warnings_ = false;
298 bool reduced_execution_times_ = false;
299 bool reduced_socket_values_ = false;
300 bool reduced_viewer_node_logs_ = false;
301 bool reduced_existing_attributes_ = false;
302 bool reduced_used_named_attributes_ = false;
303 bool reduced_debug_messages_ = false;
304 bool reduced_evaluated_gizmo_nodes_ = false;
305
306 public:
310 std::chrono::nanoseconds execution_time{0};
314
315 GeoTreeLog(GeoModifierLog *modifier_log, Vector<GeoTreeLogger *> tree_loggers);
317
326
327 ValueLog *find_socket_value_log(const bNodeSocket &query_socket);
328 [[nodiscard]] bool try_convert_primitive_socket_value(const GenericValueLog &value_log,
329 const CPPType &dst_type,
330 void *dst);
331
332 template<typename T>
333 std::optional<T> find_primitive_socket_value(const bNodeSocket &query_socket)
334 {
335 if (auto *value_log = dynamic_cast<GenericValueLog *>(
336 this->find_socket_value_log(query_socket)))
337 {
338 T value;
339 if (this->try_convert_primitive_socket_value(*value_log, CPPType::get<T>(), &value)) {
340 return value;
341 }
342 }
343 return std::nullopt;
344 }
345};
346
399
400} // namespace blender::nodes::geo_eval_log
#define BLI_STRUCT_EQUALITY_OPERATORS_2(Type, m1, m2)
#define ENUM_OPERATORS(_type, _max)
static const CPPType & get()
GeoTreeLog & get_tree_log(const ComputeContextHash &compute_context_hash)
GeoTreeLogger & get_local_tree_logger(const ComputeContext &compute_context)
static Map< const bke::bNodeTreeZone *, GeoTreeLog * > get_tree_log_by_zone_for_node_editor(const SpaceNode &snode)
static const ViewerNodeLog * find_viewer_node_log_for_path(const ViewerPath &viewer_path)
static Map< const bke::bNodeTreeZone *, ComputeContextHash > get_context_hash_by_zone_for_node_editor(const SpaceNode &snode, StringRefNull modifier_name)
Map< StringRefNull, NamedAttributeUsage > used_named_attributes
Vector< const GeometryAttributeInfo * > existing_attributes
void ensure_node_warnings(const bNodeTree *tree)
bool try_convert_primitive_socket_value(const GenericValueLog &value_log, const CPPType &dst_type, void *dst)
GeoTreeLog(GeoModifierLog *modifier_log, Vector< GeoTreeLogger * > tree_loggers)
Map< int32_t, ViewerNodeLog *, 0 > viewer_node_logs
std::optional< T > find_primitive_socket_value(const bNodeSocket &query_socket)
Map< StringRefNull, NamedAttributeUsage > used_named_attributes
ValueLog * find_socket_value_log(const bNodeSocket &query_socket)
linear_allocator::ChunkedList< EvaluatedGizmoNode > evaluated_gizmo_nodes
linear_allocator::ChunkedList< AttributeUsageWithNode > used_named_attributes
linear_allocator::ChunkedList< NodeExecutionTime, 16 > node_execution_times
linear_allocator::ChunkedList< ViewerNodeLogWithNode > viewer_node_logs
std::optional< ComputeContextHash > parent_hash
linear_allocator::ChunkedList< WarningWithNode > node_warnings
linear_allocator::ChunkedList< DebugMessage > debug_messages
void log_viewer_node(const bNode &viewer_node, bke::GeometrySet geometry)
linear_allocator::ChunkedList< SocketValueLog, 16 > input_socket_values
void log_value(const bNode &node, const bNodeSocket &socket, GPointer value)
linear_allocator::ChunkedList< SocketValueLog, 16 > output_socket_values
GeometryInfoLog(const bke::GeometrySet &geometry_set)
std::optional< GreasePencilInfo > grease_pencil_info
Vector< bke::GeometryComponent::Type > component_types
KDTree_3d * tree
static const char * modifier_name[LS_MODIFIER_NUM]
Definition linestyle.cc:680
int node_warning_type_icon(const NodeWarningType type)
int node_warning_type_severity(const NodeWarningType type)
std::unique_ptr< T, DestructValueAtAddress< T > > destruct_ptr
uint64_t get_default_hash(const T &v)
Definition BLI_hash.hh:219
signed int int32_t
Definition stdint.h:77
unsigned __int64 uint64_t
Definition stdint.h:90