Commit: 7cfb05dcb0790cc4aa209ecb63649aa756cb730f
Author: Sergey Sharybin
Date: Mon Aug 3 15:57:22 2015 +0200
Branches: master
https://developer.blender.org/rB7cfb05dcb0790cc4aa209ecb63649aa756cb730f
OpenSubdiv: Resolve crashes when other object depends on subsurf-ed object
Cases like using subsurfed object as a boolean operand can't be evaluated
on GPU and needs to have all the CCG on CPU.
This commit resolves existing configuration to survive, but new configurations
would need to have some sort of forced object update so all the data is being
moved on CPU if it was previously on GPU.
===================================================================
M source/blender/blenkernel/BKE_depsgraph.h
M source/blender/blenkernel/intern/depsgraph.c
M source/blender/depsgraph/CMakeLists.txt
M source/blender/depsgraph/SConscript
M source/blender/depsgraph/intern/depsgraph.cc
M source/blender/modifiers/intern/MOD_subsurf.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_depsgraph.h
b/source/blender/blenkernel/BKE_depsgraph.h
index 862f91f..7d7db33 100644
--- a/source/blender/blenkernel/BKE_depsgraph.h
+++ b/source/blender/blenkernel/BKE_depsgraph.h
@@ -72,6 +72,10 @@ enum {
* who're using curve deform, where_on_path and so.
*/
DAG_EVAL_NEED_CURVE_PATH = 1,
+ /* Scene evaluation would need to have object's data on CPU,
+ * meaning no GPU shortcuts is allowed.
+ */
+ DAG_EVAL_NEED_CPU = 2,
};
/* Global initialization/deinitialization */
diff --git a/source/blender/blenkernel/intern/depsgraph.c
b/source/blender/blenkernel/intern/depsgraph.c
index 2fd5304..b7ad438 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -1138,6 +1138,13 @@ void dag_add_relation(DagForest *forest, DagNode *fob1,
DagNode *fob2, short rel
/* parent relation is for cycle checking */
dag_add_parent_relation(forest, fob1, fob2, rel, name);
+ /* TODO(sergey): Find a better place for this. */
+#ifdef WITH_OPENSUBDIV
+ if ((rel & DAG_RL_DATA_DATA) != 0) {
+ fob1->eval_flags |= DAG_EVAL_NEED_CPU;
+ }
+#endif
+
while (itA) { /* search if relation exist already */
if (itA->node == fob2) {
itA->type |= rel;
diff --git a/source/blender/depsgraph/CMakeLists.txt
b/source/blender/depsgraph/CMakeLists.txt
index dcdb14d..f3ff709 100644
--- a/source/blender/depsgraph/CMakeLists.txt
+++ b/source/blender/depsgraph/CMakeLists.txt
@@ -115,4 +115,8 @@ if(WITH_BOOST)
add_definitions(-DHAVE_BOOST_FUNCTION_BINDINGS)
endif()
+if(WITH_OPENSUBDIV)
+ add_definitions(-DWITH_OPENSUBDIV)
+endif()
+
blender_add_lib(bf_depsgraph "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/depsgraph/SConscript
b/source/blender/depsgraph/SConscript
index dd0552e..7f49e8f 100644
--- a/source/blender/depsgraph/SConscript
+++ b/source/blender/depsgraph/SConscript
@@ -69,6 +69,9 @@ else:
if env['WITH_BF_LEGACY_DEPSGRAPH']:
defs.append('WITH_LEGACY_DEPSGRAPH')
+if env['WITH_BF_OPENSUBDIV']:
+ defs.append('WITH_OPENSUBDIV')
+
env.BlenderLib(libname='bf_depsgraph', sources=sources,
includes=incs, defines=defs,
libtype=['core', 'player'], priority=[200, 40])
diff --git a/source/blender/depsgraph/intern/depsgraph.cc
b/source/blender/depsgraph/intern/depsgraph.cc
index e9b2a06..94c01f3 100644
--- a/source/blender/depsgraph/intern/depsgraph.cc
+++ b/source/blender/depsgraph/intern/depsgraph.cc
@@ -44,6 +44,8 @@ extern "C" {
#include "DNA_object_types.h"
#include "DNA_sequence_types.h"
+#include "BKE_depsgraph.h"
+
#include "RNA_access.h"
}
@@ -351,6 +353,13 @@ DepsRelation
*Depsgraph::add_new_relation(OperationDepsNode *from,
{
/* Create new relation, and add it to the graph. */
DepsRelation *rel = OBJECT_GUARDED_NEW(DepsRelation, from, to, type,
description);
+ /* TODO(sergey): Find a better place for this. */
+#ifdef WITH_OPENSUBDIV
+ if (type == DEPSREL_TYPE_GEOMETRY_EVAL) {
+ IDDepsNode *id_to = to->owner->owner;
+ id_to->eval_flags |= DAG_EVAL_NEED_CPU;
+ }
+#endif
return rel;
}
diff --git a/source/blender/modifiers/intern/MOD_subsurf.c
b/source/blender/modifiers/intern/MOD_subsurf.c
index 5a03da9..ff778e6 100644
--- a/source/blender/modifiers/intern/MOD_subsurf.c
+++ b/source/blender/modifiers/intern/MOD_subsurf.c
@@ -42,6 +42,7 @@
#include "BKE_cdderivedmesh.h"
+#include "BKE_depsgraph.h"
#include "BKE_scene.h"
#include "BKE_subsurf.h"
@@ -120,7 +121,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object
*ob,
* could be disabled.
*/
if (md->next == NULL && allow_gpu && do_cddm_convert == false) {
- subsurf_flags |= SUBSURF_USE_GPU_BACKEND;
+ if ((DAG_get_eval_flags_for_object(md->scene, ob) &
DAG_EVAL_NEED_CPU) == 0) {
+ subsurf_flags |= SUBSURF_USE_GPU_BACKEND;
+ }
}
#endif
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs