[Bf-blender-cvs] [f6d133e2d2e] master: Fix possible wrongly highlighted tiles

Sergey Sharybin noreply at git.blender.org
Tue Aug 31 11:06:07 CEST 2021


Commit: f6d133e2d2ee30efd6d9c89dd5df2898983c3584
Author: Sergey Sharybin
Date:   Tue Aug 31 11:03:33 2021 +0200
Branches: master
https://developer.blender.org/rBf6d133e2d2ee30efd6d9c89dd5df2898983c3584

Fix possible wrongly highlighted tiles

Run into it when was re-working tiles in the Cycles X project.
Make sure the storage of highlighted tiles is emptied when the
render is finished or cancelled).

The error is only possible to happen if the engine did not do
something correct, but is still good to deal with such situations
more gracefully.

===================================================================

M	source/blender/render/intern/pipeline.c

===================================================================

diff --git a/source/blender/render/intern/pipeline.c b/source/blender/render/intern/pipeline.c
index bf42adbab87..0f9e1c944f5 100644
--- a/source/blender/render/intern/pipeline.c
+++ b/source/blender/render/intern/pipeline.c
@@ -1870,6 +1870,21 @@ static void render_pipeline_free(Render *re)
   }
   /* Destroy the opengl context in the correct thread. */
   RE_gl_context_destroy(re);
+
+  /* In the case the engine did not mark tiles as finished (un-highlight, which could happen in the
+   * case of cancelled render) ensure the storage is empty. */
+  if (re->highlighted_tiles != NULL) {
+    BLI_mutex_lock(&re->highlighted_tiles_mutex);
+
+    /* Rendering is supposed to be finished here, so no new tiles are expected to be written.
+     * Only make it so possible read-only access to the highlighted tiles is thread-safe. */
+    BLI_assert(re->highlighted_tiles);
+
+    BLI_gset_free(re->highlighted_tiles, MEM_freeN);
+    re->highlighted_tiles = NULL;
+
+    BLI_mutex_unlock(&re->highlighted_tiles_mutex);
+  }
 }
 
 /* general Blender frame render call */



More information about the Bf-blender-cvs mailing list