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.
This commit is contained in:
Sergey Sharybin
2015-08-03 15:57:22 +02:00
parent b4e1b7b18c
commit 7cfb05dcb0
6 changed files with 31 additions and 1 deletions

View File

@@ -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 */

View File

@@ -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;

View File

@@ -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}")

View File

@@ -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])

View File

@@ -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;
}

View File

@@ -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