From b20bacf6577e14b27145ced1058109e2083acf28 Mon Sep 17 00:00:00 2001 From: Miguel Pozo Date: Fri, 5 Jul 2024 18:05:27 +0200 Subject: [PATCH] Fix #123758: Viewport Render Animation doesn't track World updates Viewport instances created by the Viewport Render Animation operator don't get `view_updated` notifications. Fix update detection by implementing a `last_update` timestamp for `World`, similar to the ones added in #115196. Pull Request: https://projects.blender.org/blender/blender/pulls/124114 --- source/blender/blenkernel/intern/world.cc | 5 ++++- .../draw/engines/eevee_next/eevee_instance.cc | 1 - .../draw/engines/eevee_next/eevee_instance.hh | 5 +++++ source/blender/draw/engines/eevee_next/eevee_sync.cc | 12 ++---------- source/blender/draw/engines/eevee_next/eevee_sync.hh | 6 +----- .../blender/draw/engines/eevee_next/eevee_world.cc | 2 +- source/blender/makesdna/DNA_world_types.h | 5 +++++ 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/source/blender/blenkernel/intern/world.cc b/source/blender/blenkernel/intern/world.cc index 293defe066b..20e79379a61 100644 --- a/source/blender/blenkernel/intern/world.cc +++ b/source/blender/blenkernel/intern/world.cc @@ -144,8 +144,10 @@ static void world_blend_write(BlendWriter *writer, ID *id, const void *id_addres { World *wrld = (World *)id; - /* Clean up, important in undo case to reduce false detection of changed datablocks. */ + /* Clean up runtime data, important in undo case to reduce false detection of changed + * datablocks. */ BLI_listbase_clear(&wrld->gpumaterial); + wrld->last_update = 0; /* write LibData */ BLO_write_id_struct(writer, World, id_address, &wrld->id); @@ -226,4 +228,5 @@ void BKE_world_eval(Depsgraph *depsgraph, World *world) { DEG_debug_print_eval(depsgraph, __func__, world->id.name, world); GPU_material_free(&world->gpumaterial); + world->last_update = DEG_get_update_count(depsgraph); } diff --git a/source/blender/draw/engines/eevee_next/eevee_instance.cc b/source/blender/draw/engines/eevee_next/eevee_instance.cc index 804be3a8eb1..cce2c718b29 100644 --- a/source/blender/draw/engines/eevee_next/eevee_instance.cc +++ b/source/blender/draw/engines/eevee_next/eevee_instance.cc @@ -175,7 +175,6 @@ void Instance::update_eval_members() void Instance::view_update() { sampling.reset(); - sync.view_update(); } /** \} */ diff --git a/source/blender/draw/engines/eevee_next/eevee_instance.hh b/source/blender/draw/engines/eevee_next/eevee_instance.hh index 08cf5f980c6..522a44b3c17 100644 --- a/source/blender/draw/engines/eevee_next/eevee_instance.hh +++ b/source/blender/draw/engines/eevee_next/eevee_instance.hh @@ -318,6 +318,11 @@ class Instance { return flags; } + int get_recalc_flags(const ::World &world) + { + return world.last_update > depsgraph_last_update_ ? ID_RECALC_SHADING : 0; + } + private: static void object_sync_render(void *instance_, Object *ob, diff --git a/source/blender/draw/engines/eevee_next/eevee_sync.cc b/source/blender/draw/engines/eevee_next/eevee_sync.cc index 8ecaf52ef5a..46171956962 100644 --- a/source/blender/draw/engines/eevee_next/eevee_sync.cc +++ b/source/blender/draw/engines/eevee_next/eevee_sync.cc @@ -34,13 +34,6 @@ namespace blender::eevee { * * \{ */ -void SyncModule::view_update() -{ - if (DEG_id_type_updated(inst_.depsgraph, ID_WO)) { - world_updated_ = true; - } -} - ObjectHandle &SyncModule::sync_object(const ObjectRef &ob_ref) { ObjectKey key(ob_ref.object); @@ -56,11 +49,10 @@ ObjectHandle &SyncModule::sync_object(const ObjectRef &ob_ref) return handle; } -WorldHandle SyncModule::sync_world() +WorldHandle SyncModule::sync_world(const ::World &world) { WorldHandle handle; - handle.recalc = world_updated_ ? int(ID_RECALC_SHADING) : 0; - world_updated_ = false; + handle.recalc = inst_.get_recalc_flags(world); return handle; } diff --git a/source/blender/draw/engines/eevee_next/eevee_sync.hh b/source/blender/draw/engines/eevee_next/eevee_sync.hh index 7b5690a723b..4b925dad894 100644 --- a/source/blender/draw/engines/eevee_next/eevee_sync.hh +++ b/source/blender/draw/engines/eevee_next/eevee_sync.hh @@ -155,16 +155,12 @@ class SyncModule { Map ob_handles = {}; - bool world_updated_ = false; - public: SyncModule(Instance &inst) : inst_(inst){}; ~SyncModule(){}; - void view_update(); - ObjectHandle &sync_object(const ObjectRef &ob_ref); - WorldHandle sync_world(); + WorldHandle sync_world(const ::World &world); void sync_mesh(Object *ob, ObjectHandle &ob_handle, diff --git a/source/blender/draw/engines/eevee_next/eevee_world.cc b/source/blender/draw/engines/eevee_next/eevee_world.cc index ff564c8566d..cd59f24762f 100644 --- a/source/blender/draw/engines/eevee_next/eevee_world.cc +++ b/source/blender/draw/engines/eevee_next/eevee_world.cc @@ -104,7 +104,7 @@ void World::sync() WorldHandle wo_handle = {0}; if (inst_.scene->world != nullptr) { /* Detect world update before overriding it. */ - wo_handle = inst_.sync.sync_world(); + wo_handle = inst_.sync.sync_world(*inst_.scene->world); has_update = wo_handle.recalc != 0; } diff --git a/source/blender/makesdna/DNA_world_types.h b/source/blender/makesdna/DNA_world_types.h index e5b6ba7f446..0f8afcf0d0d 100644 --- a/source/blender/makesdna/DNA_world_types.h +++ b/source/blender/makesdna/DNA_world_types.h @@ -91,8 +91,13 @@ typedef struct World { /** Light-group membership information. */ struct LightgroupMembership *lightgroup; + void *_pad1; + /** Runtime. */ ListBase gpumaterial; + /* The Depsgraph::update_count when this World was last updated. */ + uint64_t last_update; + } World; /* **************** WORLD ********************* */