WIP: Fix #119211: GPU Compositor: Masks are not updating correctly in Backdrop/Viewer Node #119561

Draft
Habib Gahbiche wants to merge 2 commits from zazizizou/blender:com-fix-mask-not-updating into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
7 changed files with 23 additions and 5 deletions

View File

@ -105,6 +105,9 @@ class Context {
* The ID recalculate flag is a mechanism through which one can identify if an ID has changed
* since the last time the flag was reset, hence why the method reset the flag after querying it,
* that is, to ready it to track the next change. */
virtual IDRecalcFlag query_id_recalc_draw_flag(ID *id) const = 0;
/* Similar to query_id_recalc_draw_flag() but ID is not assumed to have DrawDataList. */
virtual IDRecalcFlag query_id_recalc_flag(ID *id) const = 0;
/* Get a pointer to the render context of this context. A render context stores information about

View File

@ -307,7 +307,7 @@ GPUTexture *CachedImageContainer::get(Context &context,
auto &cached_images_for_id = map_.lookup_or_add_default(image->id.name);
/* Invalidate the cache for that image ID if it was changed and reset the recalculate flag. */
if (context.query_id_recalc_flag(reinterpret_cast<ID *>(image)) & ID_RECALC_ALL) {
if (context.query_id_recalc_draw_flag(reinterpret_cast<ID *>(image)) & ID_RECALC_ALL) {
cached_images_for_id.clear();
}

View File

@ -192,7 +192,8 @@ CachedMask &CachedMaskContainer::get(Context &context,
auto &cached_masks_for_id = map_.lookup_or_add_default(mask->id.name);
/* Invalidate the cache for that mask ID if it was changed and reset the recalculate flag. */
if (context.query_id_recalc_flag(reinterpret_cast<ID *>(mask)) & ID_RECALC_ALL) {
if (context.query_id_recalc_draw_flag(reinterpret_cast<ID *>(mask)) & ID_RECALC_ALL ||
context.query_id_recalc_flag(reinterpret_cast<ID *>(mask)) & ID_RECALC_ALL) {
cached_masks_for_id.clear();
}

View File

@ -159,7 +159,7 @@ CachedTexture &CachedTextureContainer::get(Context &context,
auto &cached_textures_for_id = map_.lookup_or_add_default(texture->id.name);
/* Invalidate the cache for that texture ID if it was changed and reset the recalculate flag. */
if (context.query_id_recalc_flag(reinterpret_cast<ID *>(texture)) & ID_RECALC_ALL) {
if (context.query_id_recalc_draw_flag(reinterpret_cast<ID *>(texture)) & ID_RECALC_ALL) {
cached_textures_for_id.clear();
}

View File

@ -247,7 +247,7 @@ KeyingScreen &KeyingScreenContainer::get(Context &context,
/* Invalidate the keying screen cache for that MovieClip ID if it was changed and reset the
* recalculate flag. */
if (context.query_id_recalc_flag(reinterpret_cast<ID *>(movie_clip)) & ID_RECALC_ALL) {
if (context.query_id_recalc_draw_flag(reinterpret_cast<ID *>(movie_clip)) & ID_RECALC_ALL) {
cached_keying_screens_for_id.clear();
}

View File

@ -179,6 +179,13 @@ class Context : public realtime_compositor::Context {
}
IDRecalcFlag query_id_recalc_flag(ID *id) const override
{
IDRecalcFlag recalc_flag = IDRecalcFlag(id->recalc);
id->recalc = IDRecalcFlag(0);
return recalc_flag;
}
IDRecalcFlag query_id_recalc_draw_flag(ID *id) const override
{
DrawEngineType *owner = &draw_engine_compositor_type;
DrawData *draw_data = DRW_drawdata_ensure(id, owner, sizeof(DrawData), nullptr, nullptr);

View File

@ -352,7 +352,7 @@ class Context : public realtime_compositor::Context {
* incomplete support, and leave more specific message to individual nodes? */
}
IDRecalcFlag query_id_recalc_flag(ID *id) const override
IDRecalcFlag query_id_recalc_draw_flag(ID *id) const override
{
DrawEngineType *owner = (DrawEngineType *)this;
DrawData *draw_data = DRW_drawdata_ensure(id, owner, sizeof(DrawData), nullptr, nullptr);
@ -361,6 +361,13 @@ class Context : public realtime_compositor::Context {
return recalc_flag;
}
IDRecalcFlag query_id_recalc_flag(ID *id) const override
{
IDRecalcFlag recalc_flag = IDRecalcFlag(id->recalc);
id->recalc = IDRecalcFlag(0);
return recalc_flag;
}
void output_to_render_result()
{
if (!output_texture_) {