Fix T65447: Mask doesn't update in compositor unless there's motion blur on

This is probably just one of the related issues.

Root of the problem was that compositor job was using original scene and node
tree for compositing. It is not guaranteed to have all the evaluated data.

Switched compositor job to use it's own render-pipeline-like dependency graph
which has everything evaluated in it.

Reviewers: brecht

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D4998
This commit is contained in:
Sergey Sharybin 2019-06-03 14:47:44 +02:00
parent b998a7b384
commit c3f00d7879
Notes: blender-bot 2023-02-14 06:49:57 +01:00
Referenced by issue #66099, Color Balance node
Referenced by issue #65447, mask doesn't update in compositor unless there's motion blur on
3 changed files with 73 additions and 2 deletions

View File

@ -33,6 +33,7 @@ struct Depsgraph;
/* ------------------------------------------------ */
struct bNodeTree;
struct CacheFile;
struct Collection;
struct CustomData_MeshMasks;
@ -65,6 +66,17 @@ void DEG_graph_build_for_render_pipeline(struct Depsgraph *graph,
struct Scene *scene,
struct ViewLayer *view_layer);
/* Builds minimal dependency graph for compositor preview.
*
* Note that compositor editor might have pinned node tree, which is different from scene's node
* tree.
*/
void DEG_graph_build_for_compositor_preview(struct Depsgraph *graph,
struct Main *bmain,
struct Scene *scene,
struct ViewLayer *view_layer,
struct bNodeTree *nodetree);
/* Tag relations from the given graph for update. */
void DEG_graph_tag_relations_update(struct Depsgraph *graph);

View File

@ -315,6 +315,42 @@ void DEG_graph_build_for_render_pipeline(Depsgraph *graph,
}
}
void DEG_graph_build_for_compositor_preview(Depsgraph *graph,
Main *bmain,
Scene *scene,
struct ViewLayer * /*view_layer*/,
bNodeTree *nodetree)
{
double start_time = 0.0;
if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) {
start_time = PIL_check_seconds_timer();
}
DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph);
/* Perform sanity checks. */
BLI_assert(deg_graph->scene == scene);
deg_graph->is_render_pipeline_depsgraph = true;
DEG::DepsgraphBuilderCache builder_cache;
/* Generate all the nodes in the graph first */
DEG::DepsgraphNodeBuilder node_builder(bmain, deg_graph, &builder_cache);
node_builder.begin_build();
node_builder.build_scene_render(scene);
node_builder.build_nodetree(nodetree);
node_builder.end_build();
/* Hook up relationships between operations - to determine evaluation
* order. */
DEG::DepsgraphRelationBuilder relation_builder(bmain, deg_graph, &builder_cache);
relation_builder.begin_build();
relation_builder.build_scene_render(scene);
relation_builder.build_nodetree(nodetree);
relation_builder.build_copy_on_write_relations();
/* Finalize building. */
graph_build_finalize_common(deg_graph, bmain);
/* Finish statistics. */
if (G.debug & (G_DEBUG_DEPSGRAPH_BUILD | G_DEBUG_DEPSGRAPH_TIME)) {
printf("Depsgraph built in %f seconds.\n", PIL_check_seconds_timer() - start_time);
}
}
/* Tag graph relations for update. */
void DEG_graph_tag_relations_update(Depsgraph *graph)
{

View File

@ -42,6 +42,8 @@
#include "BKE_scene.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
#include "DEG_depsgraph_query.h"
#include "RE_engine.h"
#include "RE_pipeline.h"
@ -79,14 +81,19 @@ enum {
};
typedef struct CompoJob {
/* Input parameters. */
Main *bmain;
Scene *scene;
ViewLayer *view_layer;
bNodeTree *ntree;
int recalc_flags;
/* Evaluated state/ */
Depsgraph *compositor_depsgraph;
bNodeTree *localtree;
/* Jon system integration. */
const short *stop;
short *do_update;
float *progress;
int recalc_flags;
} CompoJob;
static void compo_tag_output_nodes(bNodeTree *nodetree, int recalc_flags)
@ -182,6 +189,9 @@ static void compo_freejob(void *cjv)
if (cj->localtree) {
ntreeLocalMerge(cj->bmain, cj->localtree, cj->ntree);
}
if (cj->compositor_depsgraph != NULL) {
DEG_graph_free(cj->compositor_depsgraph);
}
MEM_freeN(cj);
}
@ -190,8 +200,19 @@ static void compo_freejob(void *cjv)
static void compo_initjob(void *cjv)
{
CompoJob *cj = cjv;
Main *bmain = cj->bmain;
Scene *scene = cj->scene;
ViewLayer *view_layer = cj->view_layer;
cj->localtree = ntreeLocalize(cj->ntree);
cj->compositor_depsgraph = DEG_graph_new(scene, view_layer, DAG_EVAL_RENDER);
DEG_graph_build_for_compositor_preview(
cj->compositor_depsgraph, bmain, scene, view_layer, cj->ntree);
DEG_evaluate_on_framechange(bmain, cj->compositor_depsgraph, CFRA);
bNodeTree *ntree_eval = (bNodeTree *)DEG_get_evaluated_id(cj->compositor_depsgraph,
&cj->ntree->id);
cj->localtree = ntreeLocalize(ntree_eval);
if (cj->recalc_flags) {
compo_tag_output_nodes(cj->localtree, cj->recalc_flags);
@ -283,6 +304,7 @@ void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, Scene
CompoJob *cj;
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
/* to fix bug: [#32272] */
if (G.is_rendering) {
@ -307,6 +329,7 @@ void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, Scene
/* customdata for preview thread */
cj->bmain = bmain;
cj->scene = scene;
cj->view_layer = view_layer;
cj->ntree = nodetree;
cj->recalc_flags = compo_get_recalc_flags(C);