Files
test/source/blender/blenkernel/BKE_scene_runtime.hh
Falk David 1b73a53d0c Fix #139501: VSE: Build separate dependency graph for scene strip previews
Currently, the scene strip preview uses the existing dependency
graph built for that scene. This was not a big issue before
the sequencer scene was introduced, because the user would have
to create two main Blender windows to run into problems.
Now with the sequencer scene, it's possible to look at the scene
of a scene strip within the same window.
When the user is editing the scene (e.g. moving an animated object)
any open sequencer preview will cause the edits to be flushed.
This can e.g. result in visual jumping of animated objects, and more.

This PR attempts to fix the issue in a straightforward way: Use
a separate dependency graph for rendering the sequencer preview.
While this fixes the immediate issues, there are some consequences:
* The memory usage of the scene dependency graph _can_ roughly
  double (since there are now likely two instances of the same
   dependency graph). Because of implicit sharing, unmodified data
   will not be copied. But for example modifiers on meshes would
   currently create two copies of the evaluated data in the two
   dependency graphs.
* Creating the dependency graph can be costly, which will cause the
  first frame that the scene has to render to be slower.

Note: The current code changes some properties of the original scene
like the frame, subframe etc. before rendering and then restores
the original state. In theory, this part of the code can be removed,
but may be a bit too risky for just a fix. This should be improved
at a later stage.

Also resolves #146769, #139501.

Pull Request: https://projects.blender.org/blender/blender/pulls/147457
2025-10-13 18:29:28 +02:00

53 lines
1.3 KiB
C++

/* SPDX-FileCopyrightText: 2024 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup bke
*/
#pragma once
#include "BLI_map.hh"
#include "BLI_timeit.hh"
#include "BLI_utility_mixins.hh"
#include "DNA_node_types.h"
struct Depsgraph;
namespace blender::bke {
/* Runtime data specific to the compositing trees. */
class CompositorRuntime {
public:
/* Per-node instance total execution time for the corresponding node, during the last tree
* evaluation. */
Map<bNodeInstanceKey, timeit::Nanoseconds> per_node_execution_time;
/* A dependency graph used for interactive compositing. This is initialized the first time it is
* needed, and then kept persistent for the lifetime of the scene. This is done to allow the
* compositor to track changes to resources its uses as well as reduce the overhead of creating
* the dependency graph every time it executes. */
Depsgraph *preview_depsgraph = nullptr;
~CompositorRuntime();
};
/* Runtime data specific to the sequencer, e.g. when using scene strips. */
class SequencerRuntime {
public:
Depsgraph *depsgraph = nullptr;
~SequencerRuntime();
};
class SceneRuntime : NonCopyable, NonMovable {
public:
CompositorRuntime compositor;
SequencerRuntime sequencer;
};
} // namespace blender::bke