diff options
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r-- | intern/cycles/blender/addon/engine.py | 6 | ||||
-rw-r--r-- | intern/cycles/blender/blender_object.cpp | 6 | ||||
-rw-r--r-- | intern/cycles/blender/blender_sync.cpp | 21 | ||||
-rw-r--r-- | intern/cycles/blender/blender_sync.h | 6 |
4 files changed, 32 insertions, 7 deletions
diff --git a/intern/cycles/blender/addon/engine.py b/intern/cycles/blender/addon/engine.py index dfa696714fb..d8398772a84 100644 --- a/intern/cycles/blender/addon/engine.py +++ b/intern/cycles/blender/addon/engine.py @@ -19,16 +19,16 @@ from __future__ import annotations def _is_using_buggy_driver(): - import bgl + import gpu # We need to be conservative here because in multi-GPU systems display card # might be quite old, but others one might be just good. # # So We shouldn't disable possible good dedicated cards just because display # card seems weak. And instead we only blacklist configurations which are # proven to cause problems. - if bgl.glGetString(bgl.GL_VENDOR) == "ATI Technologies Inc.": + if gpu.platform.vendor_get() == "ATI Technologies Inc.": import re - version = bgl.glGetString(bgl.GL_VERSION) + version = gpu.platform.version_get() if version.endswith("Compatibility Profile Context"): # Old HD 4xxx and 5xxx series drivers did not have driver version # in the version string, but those cards do not quite work and diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp index dcf6e3cc949..cb84013c551 100644 --- a/intern/cycles/blender/blender_object.cpp +++ b/intern/cycles/blender/blender_object.cpp @@ -564,10 +564,12 @@ void BlenderSync::sync_objects(BL::Depsgraph &b_depsgraph, if (!cancel && !motion) { sync_background_light(b_v3d, use_portal); - /* handle removed data and modified pointers */ + /* Handle removed data and modified pointers, as this may free memory, delete Nodes in the + * right order to ensure that dependent data is freed after their users. Objects should be + * freed before particle systems and geometries. */ light_map.post_sync(); - geometry_map.post_sync(); object_map.post_sync(); + geometry_map.post_sync(); particle_system_map.post_sync(); } diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 4af8da402b1..9d0f9f29f94 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -69,7 +69,8 @@ BlenderSync::BlenderSync(BL::RenderEngine &b_engine, experimental(false), dicing_rate(1.0f), max_subdivisions(12), - progress(progress) + progress(progress), + has_updates_(true) { PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles"); dicing_rate = preview ? RNA_float_get(&cscene, "preview_dicing_rate") : @@ -84,7 +85,9 @@ BlenderSync::~BlenderSync() void BlenderSync::reset(BL::BlendData &b_data, BL::Scene &b_scene) { /* Update data and scene pointers in case they change in session reset, - * for example after undo. */ + * for example after undo. + * Note that we do not modify the `has_updates_` flag here because the sync + * reset is also used during viewport navigation. */ this->b_data = b_data; this->b_scene = b_scene; } @@ -117,6 +120,8 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d } if (dicing_prop_changed) { + has_updates_ = true; + for (const pair<const GeometryKey, Geometry *> &iter : geometry_map.key_to_scene_data()) { Geometry *geom = iter.second; if (geom->is_mesh()) { @@ -133,6 +138,12 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d /* Iterate over all IDs in this depsgraph. */ for (BL::DepsgraphUpdate &b_update : b_depsgraph.updates) { + /* TODO(sergey): Can do more selective filter here. For example, ignore changes made to + * screen datablock. Note that sync_data() needs to be called after object deletion, and + * currently this is ensured by the scene ID tagged for update, which sets the `has_updates_` + * flag. */ + has_updates_ = true; + BL::ID b_id(b_update.id()); /* Material */ @@ -227,6 +238,10 @@ void BlenderSync::sync_data(BL::RenderSettings &b_render, int height, void **python_thread_state) { + if (!has_updates_) { + return; + } + scoped_timer timer; BL::ViewLayer b_view_layer = b_depsgraph.view_layer_eval(); @@ -254,6 +269,8 @@ void BlenderSync::sync_data(BL::RenderSettings &b_render, free_data_after_sync(b_depsgraph); VLOG(1) << "Total time spent synchronizing data: " << timer.get_time(); + + has_updates_ = false; } /* Integrator */ diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h index a222c5e490e..15a10f2b46b 100644 --- a/intern/cycles/blender/blender_sync.h +++ b/intern/cycles/blender/blender_sync.h @@ -264,6 +264,12 @@ class BlenderSync { } view_layer; Progress &progress; + + protected: + /* Indicates that `sync_recalc()` detected changes in the scene. + * If this flag is false then the data is considered to be up-to-date and will not be + * synchronized at all. */ + bool has_updates_ = true; }; CCL_NAMESPACE_END |