Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/NOD_geometry_nodes_eval_log.hh
| Show All 35 Lines | |||||
| #include "BLI_map.hh" | #include "BLI_map.hh" | ||||
| #include "BKE_geometry_set.hh" | #include "BKE_geometry_set.hh" | ||||
| #include "FN_generic_pointer.hh" | #include "FN_generic_pointer.hh" | ||||
| #include "NOD_derived_node_tree.hh" | #include "NOD_derived_node_tree.hh" | ||||
| #include <chrono> | |||||
| struct SpaceNode; | struct SpaceNode; | ||||
| struct SpaceSpreadsheet; | struct SpaceSpreadsheet; | ||||
| namespace blender::nodes::geometry_nodes_eval_log { | namespace blender::nodes::geometry_nodes_eval_log { | ||||
| using fn::GMutablePointer; | using fn::GMutablePointer; | ||||
| using fn::GPointer; | using fn::GPointer; | ||||
| ▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | struct NodeWarning { | ||||
| std::string message; | std::string message; | ||||
| }; | }; | ||||
| struct NodeWithWarning { | struct NodeWithWarning { | ||||
| DNode node; | DNode node; | ||||
| NodeWarning warning; | NodeWarning warning; | ||||
| }; | }; | ||||
| struct NodeWithExecutionTime { | |||||
| DNode node; | |||||
| std::chrono::microseconds exec_time; | |||||
| }; | |||||
| struct NodeWithDebugMessage { | |||||
| DNode node; | |||||
| std::string message; | |||||
| }; | |||||
| /** 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; | ||||
| }; | }; | ||||
| 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<NodeWithDebugMessage> node_debug_messages_; | |||||
| 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_debug_message(DNode node, std::string message); | |||||
| }; | }; | ||||
| /** The root logger class. */ | /** The root logger class. */ | ||||
| class GeoLogger { | class GeoLogger { | ||||
| private: | private: | ||||
| /** | /** | ||||
| * Log the entire value for these sockets, because they may be inspected afterwards. | * Log the entire value for these sockets, because they may be inspected afterwards. | ||||
| * We don't log everything, because that would take up too much memory and cause significant | * We don't log everything, because that would take up too much memory and cause significant | ||||
| ▲ Show 20 Lines • Show All 57 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_; | |||||
| 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); | |||||
| Span<SocketLog> input_logs() const | Span<SocketLog> input_logs() const | ||||
| { | { | ||||
| return input_logs_; | return input_logs_; | ||||
| } | } | ||||
| Span<SocketLog> output_logs() const | Span<SocketLog> output_logs() const | ||||
| { | { | ||||
| return output_logs_; | return output_logs_; | ||||
| } | } | ||||
| Span<NodeWarning> warnings() const | Span<NodeWarning> warnings() const | ||||
| { | { | ||||
| return warnings_; | return warnings_; | ||||
| } | } | ||||
| Span<std::string> debug_messages() const | |||||
| { | |||||
| return debug_messages_; | |||||
| } | |||||
| std::chrono::microseconds execution_time() const | |||||
| { | |||||
| return exec_time_; | |||||
| } | |||||
| Vector<const GeometryAttributeInfo *> lookup_available_attributes() const; | Vector<const GeometryAttributeInfo *> lookup_available_attributes() const; | ||||
| }; | }; | ||||
| /** Contains information that has been logged for one specific tree. */ | /** Contains information that has been logged for one specific tree. */ | ||||
| class TreeLog { | class TreeLog { | ||||
| private: | private: | ||||
| Map<std::string, destruct_ptr<NodeLog>> node_logs_; | Map<std::string, destruct_ptr<NodeLog>> node_logs_; | ||||
| Map<std::string, destruct_ptr<TreeLog>> child_logs_; | Map<std::string, destruct_ptr<TreeLog>> child_logs_; | ||||
| ▲ Show 20 Lines • Show All 55 Lines • Show Last 20 Lines | |||||