Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/NOD_geometry_nodes_eval_log.hh
| Show First 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | struct InstancesInfo { | ||||
| int tot_instances; | int tot_instances; | ||||
| }; | }; | ||||
| std::optional<MeshInfo> mesh_info; | std::optional<MeshInfo> mesh_info; | ||||
| std::optional<CurveInfo> curve_info; | std::optional<CurveInfo> curve_info; | ||||
| std::optional<PointCloudInfo> pointcloud_info; | std::optional<PointCloudInfo> pointcloud_info; | ||||
| std::optional<InstancesInfo> instances_info; | std::optional<InstancesInfo> instances_info; | ||||
| GeometryValueLog(const GeometrySet &geometry_set, bool log_full_geometry); | GeometryValueLog(const GeometrySet &geometry_set, bool log_full_geometry = false); | ||||
| Span<GeometryAttributeInfo> attributes() const | Span<GeometryAttributeInfo> attributes() const | ||||
| { | { | ||||
| return attributes_; | return attributes_; | ||||
| } | } | ||||
| Span<GeometryComponentType> component_types() const | Span<GeometryComponentType> component_types() const | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | |||||
| class GeoLogger { | class GeoLogger { | ||||
| private: | private: | ||||
| /** The entire geometry of sockets in this set should be cached, because e.g. the spreadsheet | /** The entire geometry of sockets in this set should be cached, because e.g. the spreadsheet | ||||
| * displays the data. We don't log the entire geometry at all places, because that would require | * displays the data. We don't log the entire geometry at all places, because that would require | ||||
| * way too much memory. */ | * way too much memory. */ | ||||
| Set<DSocket> log_full_geometry_sockets_; | Set<DSocket> log_full_geometry_sockets_; | ||||
| threading::EnumerableThreadSpecific<LocalGeoLogger> threadlocals_; | threading::EnumerableThreadSpecific<LocalGeoLogger> threadlocals_; | ||||
| /* These are only optional since they don't have a default constructor. */ | |||||
| std::optional<GeometryValueLog> input_geometry_log_; | |||||
JacquesLucke: Think this should just be a `unique_ptr` instead of `optional`. Same in `ModifierLog`.
We… | |||||
HooglyBooglyAuthorUnsubmitted Done Inline ActionsA unique_ptr is fine I suppose, but how does that remove the assumption that there is a single input or output? HooglyBoogly: A `unique_ptr` is fine I suppose, but how does that remove the assumption that there is a… | |||||
JacquesLuckeUnsubmitted Not Done Inline ActionsIt doesn't remove the assumption here, but below in ModifierLog where it should be a unique_ptr as well. JacquesLucke: It doesn't remove the assumption here, but below in `ModifierLog` where it should be a… | |||||
| std::optional<GeometryValueLog> output_geometry_log_; | |||||
| friend LocalGeoLogger; | friend LocalGeoLogger; | ||||
| friend ModifierLog; | |||||
| public: | public: | ||||
| GeoLogger(Set<DSocket> log_full_geometry_sockets) | GeoLogger(Set<DSocket> log_full_geometry_sockets) | ||||
| : log_full_geometry_sockets_(std::move(log_full_geometry_sockets)), | : log_full_geometry_sockets_(std::move(log_full_geometry_sockets)), | ||||
| threadlocals_([this]() { return LocalGeoLogger(*this); }) | threadlocals_([this]() { return LocalGeoLogger(*this); }) | ||||
| { | { | ||||
| } | } | ||||
| void log_input_geometry(const GeometrySet &geometry) | |||||
| { | |||||
| input_geometry_log_.emplace(geometry); | |||||
| } | |||||
| void log_output_geometry(const GeometrySet &geometry) | |||||
| { | |||||
| output_geometry_log_.emplace(geometry); | |||||
| } | |||||
| LocalGeoLogger &local() | LocalGeoLogger &local() | ||||
| { | { | ||||
| return threadlocals_.local(); | return threadlocals_.local(); | ||||
| } | } | ||||
| auto begin() | auto begin() | ||||
| { | { | ||||
| return threadlocals_.begin(); | return threadlocals_.begin(); | ||||
| ▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | |||||
| class ModifierLog { | class ModifierLog { | ||||
| private: | private: | ||||
| LinearAllocator<> allocator_; | LinearAllocator<> allocator_; | ||||
| /* Allocators of the individual loggers. */ | /* Allocators of the individual loggers. */ | ||||
| Vector<std::unique_ptr<LinearAllocator<>>> logger_allocators_; | Vector<std::unique_ptr<LinearAllocator<>>> logger_allocators_; | ||||
| destruct_ptr<TreeLog> root_tree_logs_; | destruct_ptr<TreeLog> root_tree_logs_; | ||||
| Vector<destruct_ptr<ValueLog>> logged_values_; | Vector<destruct_ptr<ValueLog>> logged_values_; | ||||
| GeometryValueLog input_geometry_log_; | |||||
| GeometryValueLog output_geometry_log_; | |||||
| public: | public: | ||||
| ModifierLog(GeoLogger &logger); | ModifierLog(GeoLogger &logger); | ||||
| const TreeLog &root_tree() const | const TreeLog &root_tree() const | ||||
| { | { | ||||
| return *root_tree_logs_; | return *root_tree_logs_; | ||||
| } | } | ||||
| /* Utilities to find logged information for a specific context. */ | /* Utilities to find logged information for a specific context. */ | ||||
| static const ModifierLog *find_root_by_node_editor_context(const SpaceNode &snode); | static const ModifierLog *find_root_by_node_editor_context(const SpaceNode &snode); | ||||
| static const TreeLog *find_tree_by_node_editor_context(const SpaceNode &snode); | static const TreeLog *find_tree_by_node_editor_context(const SpaceNode &snode); | ||||
| static const NodeLog *find_node_by_node_editor_context(const SpaceNode &snode, | static const NodeLog *find_node_by_node_editor_context(const SpaceNode &snode, | ||||
| const bNode &node); | const bNode &node); | ||||
| static const SocketLog *find_socket_by_node_editor_context(const SpaceNode &snode, | static const SocketLog *find_socket_by_node_editor_context(const SpaceNode &snode, | ||||
| const bNode &node, | const bNode &node, | ||||
| const bNodeSocket &socket); | const bNodeSocket &socket); | ||||
| static const NodeLog *find_node_by_spreadsheet_editor_context( | static const NodeLog *find_node_by_spreadsheet_editor_context( | ||||
| const SpaceSpreadsheet &sspreadsheet); | const SpaceSpreadsheet &sspreadsheet); | ||||
| void foreach_node_log(FunctionRef<void(const NodeLog &)> fn) const; | void foreach_node_log(FunctionRef<void(const NodeLog &)> fn) const; | ||||
| const GeometryValueLog &input_geometry_log() const; | |||||
| const GeometryValueLog &output_geometry_log() const; | |||||
| private: | private: | ||||
| using LogByTreeContext = Map<const DTreeContext *, TreeLog *>; | using LogByTreeContext = Map<const DTreeContext *, TreeLog *>; | ||||
| TreeLog &lookup_or_add_tree_log(LogByTreeContext &log_by_tree_context, | TreeLog &lookup_or_add_tree_log(LogByTreeContext &log_by_tree_context, | ||||
| const DTreeContext &tree_context); | const DTreeContext &tree_context); | ||||
| NodeLog &lookup_or_add_node_log(LogByTreeContext &log_by_tree_context, DNode node); | NodeLog &lookup_or_add_node_log(LogByTreeContext &log_by_tree_context, DNode node); | ||||
| SocketLog &lookup_or_add_socket_log(LogByTreeContext &log_by_tree_context, DSocket socket); | SocketLog &lookup_or_add_socket_log(LogByTreeContext &log_by_tree_context, DSocket socket); | ||||
| }; | }; | ||||
| } // namespace blender::nodes::geometry_nodes_eval_log | } // namespace blender::nodes::geometry_nodes_eval_log | ||||
Think this should just be a unique_ptr instead of optional. Same in ModifierLog.
We shouldn't add assumptions for having exactly one geometry input/output if not necessary.