[Bf-blender-cvs] [3ededb19d8b] blender2.8: Depsgraph: Fix crash when updating materials with copy on write enabled
Sergey Sharybin
noreply at git.blender.org
Thu Jul 20 17:48:47 CEST 2017
Commit: 3ededb19d8bb42c97188a0db027a46fac064f963
Author: Sergey Sharybin
Date: Thu Jul 20 17:45:00 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB3ededb19d8bb42c97188a0db027a46fac064f963
Depsgraph: Fix crash when updating materials with copy on write enabled
The code was freeing GPU materials from non-main thread.
===================================================================
M source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
===================================================================
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
index da06cfdf330..46841c3c8a3 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
@@ -664,9 +664,38 @@ ID *deg_update_copy_on_write_datablock(/*const*/ Depsgraph *depsgraph,
/* For the rest if datablock types we use simple logic:
* - Free previously expanded data, if any.
* - Perform full datablock copy.
+ *
+ * Note that we never free GPU materials from here since that's not
+ * safe for threading and GPU materials are likely to be re-used.
*/
+ ListBase gpumaterial_backup;
+ ListBase *gpumaterial_ptr = NULL;
+ if (check_datablock_expanded(id_cow)) {
+ switch (GS(id_orig->name)) {
+ case ID_MA:
+ {
+ Material *material = (Material *)id_cow;
+ gpumaterial_ptr = &material->gpumaterial;
+ break;
+ }
+ case ID_WO:
+ {
+ World *world = (World *)id_cow;
+ gpumaterial_ptr = &world->gpumaterial;
+ break;
+ }
+ }
+ if (gpumaterial_ptr != NULL) {
+ gpumaterial_backup = *gpumaterial_ptr;
+ gpumaterial_ptr->first = gpumaterial_ptr->last = NULL;
+ }
+ }
deg_free_copy_on_write_datablock(id_cow);
deg_expand_copy_on_write_datablock(depsgraph, id_node, false);
+ /* Restore GPU materials. */
+ if (gpumaterial_ptr != NULL) {
+ *gpumaterial_ptr = gpumaterial_backup;
+ }
return id_cow;
}
More information about the Bf-blender-cvs
mailing list