Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/NOD_geometry_nodes_eval_log.hh
| Show First 20 Lines • Show All 164 Lines • ▼ Show 20 Lines | |||||
| }; | }; | ||||
| /** The same value can be referenced by multiple sockets when they are linked. */ | /** The same value can be referenced by multiple sockets when they are linked. */ | ||||
| struct ValueOfSockets { | struct ValueOfSockets { | ||||
| Span<DSocket> sockets; | Span<DSocket> sockets; | ||||
| destruct_ptr<ValueLog> value; | destruct_ptr<ValueLog> value; | ||||
| }; | }; | ||||
| enum class NamedAttributeUsage { | |||||
| None = 0, | |||||
| Read = 1 << 0, | |||||
| Write = 1 << 1, | |||||
| Remove = 1 << 2, | |||||
| }; | |||||
| ENUM_OPERATORS(NamedAttributeUsage, NamedAttributeUsage::Remove); | |||||
| struct UsedNamedAttribute { | |||||
| std::string name; | |||||
| NamedAttributeUsage usage; | |||||
| }; | |||||
| struct NodeWithUsedNamedAttribute { | |||||
| DNode node; | |||||
| UsedNamedAttribute attribute; | |||||
| }; | |||||
| class GeoLogger; | class GeoLogger; | ||||
| class ModifierLog; | class ModifierLog; | ||||
| /** Every thread has its own local logger to avoid having to communicate between threads during | /** Every thread has its own local logger to avoid having to communicate between threads during | ||||
| * evaluation. After evaluation the individual logs are combined. */ | * evaluation. After evaluation the individual logs are combined. */ | ||||
| class LocalGeoLogger { | class LocalGeoLogger { | ||||
| private: | private: | ||||
| /* Back pointer to the owner of this local logger. */ | /* Back pointer to the owner of this local logger. */ | ||||
| GeoLogger *main_logger_; | GeoLogger *main_logger_; | ||||
| /* Allocator for the many small allocations during logging. This is in a `unique_ptr` so that | /* Allocator for the many small allocations during logging. This is in a `unique_ptr` so that | ||||
| * ownership can be transferred later on. */ | * ownership can be transferred later on. */ | ||||
| std::unique_ptr<LinearAllocator<>> allocator_; | std::unique_ptr<LinearAllocator<>> allocator_; | ||||
| Vector<ValueOfSockets> values_; | Vector<ValueOfSockets> values_; | ||||
| Vector<NodeWithWarning> node_warnings_; | Vector<NodeWithWarning> node_warnings_; | ||||
| Vector<NodeWithExecutionTime> node_exec_times_; | Vector<NodeWithExecutionTime> node_exec_times_; | ||||
| Vector<NodeWithDebugMessage> node_debug_messages_; | Vector<NodeWithDebugMessage> node_debug_messages_; | ||||
| Vector<NodeWithUsedNamedAttribute> used_named_attributes_; | |||||
| friend ModifierLog; | friend ModifierLog; | ||||
| public: | public: | ||||
| LocalGeoLogger(GeoLogger &main_logger) : main_logger_(&main_logger) | LocalGeoLogger(GeoLogger &main_logger) : main_logger_(&main_logger) | ||||
| { | { | ||||
| this->allocator_ = std::make_unique<LinearAllocator<>>(); | this->allocator_ = std::make_unique<LinearAllocator<>>(); | ||||
| } | } | ||||
| void log_value_for_sockets(Span<DSocket> sockets, GPointer value); | void log_value_for_sockets(Span<DSocket> sockets, GPointer value); | ||||
| void log_multi_value_socket(DSocket socket, Span<GPointer> values); | void log_multi_value_socket(DSocket socket, Span<GPointer> values); | ||||
| void log_node_warning(DNode node, NodeWarningType type, std::string message); | void log_node_warning(DNode node, NodeWarningType type, std::string message); | ||||
| void log_execution_time(DNode node, std::chrono::microseconds exec_time); | void log_execution_time(DNode node, std::chrono::microseconds exec_time); | ||||
| void log_used_named_attribute(DNode node, std::string attribute_name, NamedAttributeUsage usage); | |||||
| /** | /** | ||||
| * Log a message that will be displayed in the node editor next to the node. | * Log a message that will be displayed in the node editor next to the node. | ||||
| * This should only be used for debugging purposes and not to display information to users. | * This should only be used for debugging purposes and not to display information to users. | ||||
| */ | */ | ||||
| void log_debug_message(DNode node, std::string message); | void log_debug_message(DNode node, std::string message); | ||||
| }; | }; | ||||
| /** The root logger class. */ | /** The root logger class. */ | ||||
| ▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
| /** Contains information that has been logged for one specific node. */ | /** Contains information that has been logged for one specific node. */ | ||||
| class NodeLog { | class NodeLog { | ||||
| private: | private: | ||||
| Vector<SocketLog> input_logs_; | Vector<SocketLog> input_logs_; | ||||
| Vector<SocketLog> output_logs_; | Vector<SocketLog> output_logs_; | ||||
| Vector<NodeWarning, 0> warnings_; | Vector<NodeWarning, 0> warnings_; | ||||
| Vector<std::string, 0> debug_messages_; | Vector<std::string, 0> debug_messages_; | ||||
| Vector<UsedNamedAttribute, 0> used_named_attributes_; | |||||
| std::chrono::microseconds exec_time_; | std::chrono::microseconds exec_time_; | ||||
| friend ModifierLog; | friend ModifierLog; | ||||
| public: | public: | ||||
| const SocketLog *lookup_socket_log(eNodeSocketInOut in_out, int index) const; | const SocketLog *lookup_socket_log(eNodeSocketInOut in_out, int index) const; | ||||
| const SocketLog *lookup_socket_log(const bNode &node, const bNodeSocket &socket) const; | const SocketLog *lookup_socket_log(const bNode &node, const bNodeSocket &socket) const; | ||||
| void execution_time(std::chrono::microseconds exec_time); | void execution_time(std::chrono::microseconds exec_time); | ||||
| Show All 13 Lines | Span<NodeWarning> warnings() const | ||||
| return warnings_; | return warnings_; | ||||
| } | } | ||||
| Span<std::string> debug_messages() const | Span<std::string> debug_messages() const | ||||
| { | { | ||||
| return debug_messages_; | return debug_messages_; | ||||
| } | } | ||||
| Span<UsedNamedAttribute> used_named_attributes() const | |||||
| { | |||||
| return used_named_attributes_; | |||||
| } | |||||
| std::chrono::microseconds execution_time() const | std::chrono::microseconds execution_time() const | ||||
| { | { | ||||
| return exec_time_; | return exec_time_; | ||||
| } | } | ||||
| Vector<const GeometryAttributeInfo *> lookup_available_attributes() const; | Vector<const GeometryAttributeInfo *> lookup_available_attributes() const; | ||||
| }; | }; | ||||
| ▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines | |||||