52struct DepsgraphEvalState;
54void deg_task_run_func(TaskPool *pool,
void *taskdata);
56void schedule_children(DepsgraphEvalState *
state,
61enum class EvaluationStage {
77 SINGLE_THREADED_WORKAROUND,
80struct DepsgraphEvalState {
83 EvaluationStage stage;
84 bool need_update_pending_parents =
true;
85 bool need_single_thread_pass =
false;
90 blender::Depsgraph *depsgraph =
reinterpret_cast<blender::Depsgraph *
>(
state->graph);
93 BLI_assert_msg(!operation_node->is_noop(),
"NOOP nodes should not actually be scheduled");
95 if (
state->do_stats) {
97 operation_node->evaluate(depsgraph);
101 operation_node->evaluate(depsgraph);
111void deg_task_run_func(TaskPool *pool,
void *taskdata)
114 DepsgraphEvalState *
state =
static_cast<DepsgraphEvalState *
>(userdata_v);
118 evaluate_node(
state, operation_node);
126bool check_operation_node_visible(
const DepsgraphEvalState *
state,
OperationNode *op_node)
137 if (
state->stage == EvaluationStage::DYNAMIC_VISIBILITY) {
141 return comp_node->affects_visible_id;
147 node->num_links_pending = 0;
148 node->scheduled =
false;
150 if (!check_operation_node_visible(
state,
node)) {
164 if (!check_operation_node_visible(
state, from)) {
176void calculate_pending_parents_if_needed(DepsgraphEvalState *
state)
178 if (!
state->need_update_pending_parents) {
183 calculate_pending_parents_for_node(
state,
node);
186 state->need_update_pending_parents =
false;
189void initialize_execution(DepsgraphEvalState *
state,
Depsgraph *graph)
192 if (
state->do_stats) {
194 node->stats.reset_current();
199bool is_metaball_object_operation(
const OperationNode *operation_node)
202 const IDNode *id_node = component_node->owner;
205 if (
GS(id_node->id_cow->name) !=
ID_OB) {
208 const Object *
object =
reinterpret_cast<const Object *
>(id_node->id_cow);
216bool is_modifier_subframe_operation(
const OperationNode *operation_node)
219 const IDNode *id_node = component_node->owner;
222 if (
GS(id_node->id_cow->name) !=
ID_OB) {
225 const Object *
object =
reinterpret_cast<const Object *
>(id_node->id_cow);
226 for (
const ModifierData &md : object->modifiers) {
228 const auto &fmd =
reinterpret_cast<const FluidModifierData &
>(md);
234 const auto &dmd =
reinterpret_cast<const DynamicPaintModifierData &
>(md);
243bool need_evaluate_operation_at_stage(DepsgraphEvalState *
state,
247 switch (
state->stage) {
248 case EvaluationStage::COPY_ON_EVAL:
251 case EvaluationStage::DYNAMIC_VISIBILITY:
254 case EvaluationStage::THREADED_EVALUATION:
255 if (is_metaball_object_operation(operation_node)) {
256 state->need_single_thread_pass =
true;
259 if (is_modifier_subframe_operation(operation_node)) {
260 state->need_single_thread_pass =
true;
265 case EvaluationStage::SINGLE_THREADED_WORKAROUND:
268 BLI_assert_msg(0,
"Unhandled evaluation stage, should never happen.");
276void schedule_node(DepsgraphEvalState *
state,
282 if (!check_operation_node_visible(
state,
node)) {
298 if (
node->num_links_pending != 0) {
302 if (!need_evaluate_operation_at_stage(
state,
node)) {
309 if (
node->is_noop()) {
315 schedule_children(
state,
node, schedule_fn);
324void schedule_graph(DepsgraphEvalState *
state,
328 schedule_node(
state,
node,
false, schedule_fn);
332void schedule_children(DepsgraphEvalState *
state,
339 if (child->scheduled) {
350void evaluate_graph_threaded_stage(DepsgraphEvalState *
state,
352 const EvaluationStage stage)
354 state->stage = stage;
356 calculate_pending_parents_if_needed(
state);
365void evaluate_graph_single_threaded_if_needed(DepsgraphEvalState *
state)
367 if (!
state->need_single_thread_pass) {
373 state->stage = EvaluationStage::SINGLE_THREADED_WORKAROUND;
379 schedule_graph(
state, schedule_node_to_queue);
385 evaluate_node(
state, operation_node);
386 schedule_children(
state, operation_node, schedule_node_to_queue);
392void depsgraph_ensure_view_layer(
Depsgraph *graph)
398 Scene *scene_cow = graph->scene_cow;
405 const IDNode *scene_id_node = graph->find_id_node(&graph->scene->id);
409TaskPool *deg_evaluate_task_pool_create(DepsgraphEvalState *
state)
435 static std::atomic<uint64_t> global_update_count = 0;
436 graph->
update_count = global_update_count.fetch_add(1) + 1;
446 depsgraph_ensure_view_layer(graph);
449 DepsgraphEvalState
state;
454 initialize_execution(&
state, graph);
475 evaluate_graph_threaded_stage(&
state, task_pool, EvaluationStage::COPY_ON_EVAL);
480 state.need_update_pending_parents =
true;
482 evaluate_graph_threaded_stage(&
state, task_pool, EvaluationStage::DYNAMIC_VISIBILITY);
491 state.need_update_pending_parents =
true;
494 evaluate_graph_threaded_stage(&
state, task_pool, EvaluationStage::THREADED_EVALUATION);
498 evaluate_graph_single_threaded_if_needed(&
state);
503 if (
state.do_stats) {
Platform independent time functions.
#define BPy_BEGIN_ALLOW_THREADS
#define BPy_END_ALLOW_THREADS
Object is a sort of wrapper for general info.
Provides wrapper around system-specific atomic primitives, and some extensions (faked-atomic operatio...
ATOMIC_INLINE uint8_t atomic_fetch_and_or_uint8(uint8_t *p, uint8_t b)
ATOMIC_INLINE uint32_t atomic_sub_and_fetch_uint32(uint32_t *p, uint32_t x)
#define BLI_assert_msg(a, msg)
void begin_graph_evaluation()
void end_graph_evaluation()
bool do_time_debug() const
void deg_eval_stats_aggregate(Depsgraph *graph)
bool deg_eval_copy_is_expanded(const ID *id_cow)
void deg_graph_clear_tags(Depsgraph *graph)
ID * deg_update_eval_copy_datablock(const Depsgraph *depsgraph, const IDNode *id_node)
void deg_evaluate_on_refresh(Depsgraph *graph)
@ DEPSOP_FLAG_CLEAR_ON_EVAL
@ DEPSOP_FLAG_NEEDS_UPDATE
@ DEPSOP_FLAG_AFFECTS_VISIBILITY
void deg_graph_flush_visibility_flags_if_needed(Depsgraph *graph)
void BLI_gsqueue_push(GSQueue *queue, const void *item)
TaskPool * BLI_task_pool_create_suspended(void *userdata, eTaskPriority priority)
@ eModifierType_DynamicPaint
TaskPool * BLI_task_pool_create_no_threads(void *userdata)
void BLI_task_pool_work_and_wait(TaskPool *pool)
void BLI_gsqueue_pop(GSQueue *queue, void *r_item)
@ G_DEBUG_DEPSGRAPH_NO_THREADS
void * BLI_task_pool_user_data(TaskPool *pool)
void BLI_gsqueue_free(GSQueue *queue)
GSQueue * BLI_gsqueue_new(size_t elem_size)
@ MOD_DYNAMICPAINT_TYPE_CANVAS
void BLI_task_pool_free(TaskPool *pool)
bool BLI_gsqueue_is_empty(const GSQueue *queue)
ID_Type GS(const char *name)
double BLI_time_now_seconds()
void BLI_task_pool_push(TaskPool *pool, TaskRunFunction run, void *taskdata, bool free_taskdata, TaskFreeFunction freedata)
bool need_update_nodes_visibility
bool has_animated_visibility
Set< OperationNode * > entry_tags
uint32_t num_links_pending