This refactors how a geometry nodes node tree is converted to a lazy-function graph. Previously, all nodes were inserted into a single graph. This was fine because every node was evaluated at most once per node group evaluation. However, loops (#108896) break this assumption since now nodes may be evaluated multiple times and thus a single flat graph does not work anymore. Now, a separate lazy-function is build for every zone which gives us much more flexibility for what can happen in a zone. Right now, the change only applies to simulation zones since that's the only kind of zone we have. Technically, those zones could be inlined, but turning them into a separate lazy-function also does not hurt and makes it possible to test this refactor without implementing loops first. Also, having them as separate functions might help in the future if we integrate a substep loop directly into the simulation zone. The most tricky part here is to just link everything up correctly, especially with respect to deterministic anonymous attribute lifetimes. Fortunately, correctness can be checked visually by looking at the generated graphs. The logging/viewer system also had to be refactored a bit, because now there can be multiple different `ComputeContext` in a single node tree. Each zone is in a separate `ComputeContext`. To make it work, the `ViewerPath` system now explicitly supports zones and drawing code will look up the right logger for showing inspection data. No functional changes are expected, except that the spreadsheet now shows "Simulation Zone" in the context path if the viewer is in a simulation.
63 lines
2.5 KiB
C
63 lines
2.5 KiB
C
/* SPDX-FileCopyrightText: 2023 Blender Foundation
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#pragma once
|
|
|
|
/**
|
|
* A #ViewerPath is a path to data that is viewed/debugged by the user. It is a list of
|
|
* #ViewerPathElem.
|
|
*
|
|
* This is only used for geometry nodes currently. When the user activates a viewer node the
|
|
* corresponding path contains the following elements:
|
|
* - Object the viewer is activated on.
|
|
* - Modifier that contains the corresponding geometry node group.
|
|
* - Node tree path in case the viewer node is in a nested node group.
|
|
* - Viewer node name.
|
|
*
|
|
* The entire path is necessary (instead of just the combination of node group and viewer name),
|
|
* because the same node group may be used in many different places.
|
|
*
|
|
* This file contains basic functions for creating/deleting a #ViewerPath. For more use-case
|
|
* specific functions look in `ED_viewer_path.hh`.
|
|
*/
|
|
|
|
#include "DNA_viewer_path_types.h"
|
|
|
|
struct BlendWriter;
|
|
struct BlendDataReader;
|
|
struct BlendLibReader;
|
|
struct LibraryForeachIDData;
|
|
struct Library;
|
|
struct IDRemapper;
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
void BKE_viewer_path_init(ViewerPath *viewer_path);
|
|
void BKE_viewer_path_clear(ViewerPath *viewer_path);
|
|
void BKE_viewer_path_copy(ViewerPath *dst, const ViewerPath *src);
|
|
bool BKE_viewer_path_equal(const ViewerPath *a, const ViewerPath *b);
|
|
void BKE_viewer_path_blend_write(struct BlendWriter *writer, const ViewerPath *viewer_path);
|
|
void BKE_viewer_path_blend_read_data(struct BlendDataReader *reader, ViewerPath *viewer_path);
|
|
void BKE_viewer_path_blend_read_lib(struct BlendLibReader *reader,
|
|
struct ID *self_id,
|
|
ViewerPath *viewer_path);
|
|
void BKE_viewer_path_foreach_id(struct LibraryForeachIDData *data, ViewerPath *viewer_path);
|
|
void BKE_viewer_path_id_remap(ViewerPath *viewer_path, const struct IDRemapper *mappings);
|
|
|
|
ViewerPathElem *BKE_viewer_path_elem_new(ViewerPathElemType type);
|
|
IDViewerPathElem *BKE_viewer_path_elem_new_id(void);
|
|
ModifierViewerPathElem *BKE_viewer_path_elem_new_modifier(void);
|
|
GroupNodeViewerPathElem *BKE_viewer_path_elem_new_group_node(void);
|
|
SimulationZoneViewerPathElem *BKE_viewer_path_elem_new_simulation_zone(void);
|
|
ViewerNodeViewerPathElem *BKE_viewer_path_elem_new_viewer_node(void);
|
|
ViewerPathElem *BKE_viewer_path_elem_copy(const ViewerPathElem *src);
|
|
bool BKE_viewer_path_elem_equal(const ViewerPathElem *a, const ViewerPathElem *b);
|
|
void BKE_viewer_path_elem_free(ViewerPathElem *elem);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|