[Bf-blender-cvs] [382218beb29] blender2.8: Point cache: Pass EvaluationContext for all the related functions

Dalai Felinto noreply at git.blender.org
Wed Feb 28 17:57:49 CET 2018


Commit: 382218beb29f52e1ea5c10803edf95a937878308
Author: Dalai Felinto
Date:   Wed Feb 28 13:54:00 2018 -0300
Branches: blender2.8
https://developer.blender.org/rB382218beb29f52e1ea5c10803edf95a937878308

Point cache: Pass EvaluationContext for all the related functions

Now the only missing bit seems to be in Cycles to pass depsgraph to
builtin_image_float_pixels().

Ideally we could get evaluation context instead of using depsgraph + settings.
But for the other rna EvaluationContext functions this is how we are doing.

Reviewers: sergey, brecht

Differential Revision: https://developer.blender.org/D3087

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

M	intern/cycles/blender/blender_session.cpp
M	intern/cycles/blender/blender_shader.cpp
M	intern/cycles/blender/blender_texture.cpp
M	intern/cycles/blender/blender_texture.h
M	source/blender/depsgraph/DEG_depsgraph.h
M	source/blender/depsgraph/intern/depsgraph_eval.cc
M	source/blender/makesrna/intern/rna_nodetree.c
M	source/blender/render/extern/include/RE_render_ext.h
M	source/blender/render/intern/source/pointdensity.c
M	source/blenderplayer/bad_level_call_stubs/stubs.c

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

diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index 12b707d8f95..c6bfaea238d 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -1280,9 +1280,8 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name,
 	else {
 		/* TODO: fix point density to work with new view layer depsgraph */
 #if 0
-		/* We originally were passing view_layer here but in reality we need a whole EvaluationContext
-		 * in the RE_point_density_minmax() function.
-		 * Note: There is not a single EvaluationContext for the entire render. They are per RenderLayer now.
+		/* We originally were passing view_layer here but in reality we need a whole EvaluationContext or at the
+		 * very least a dpesgraph to pass to the RE_point_density_minmax() function.
 		 */
 		/* TODO(sergey): Check we're indeed in shader node tree. */
 		PointerRNA ptr;
@@ -1292,7 +1291,7 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name,
 			BL::ShaderNodeTexPointDensity b_point_density_node(b_node);
 			int length;
 			int settings = background ? 1 : 0;  /* 1 - render settings, 0 - vewport settings. */
-			b_point_density_node.calc_point_density(b_scene, b_view_layer, settings, &length, &pixels);
+			b_point_density_node.calc_point_density(b_depsgraph, settings, &length, &pixels);
 		}
 #endif
 	}
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index f371515825e..d6e3f33fa9d 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -234,8 +234,8 @@ static void get_tex_mapping(TextureMapping *mapping,
 static ShaderNode *add_node(Scene *scene,
                             BL::RenderEngine& b_engine,
                             BL::BlendData& b_data,
+                            BL::Depsgraph& b_depsgraph,
                             BL::Scene& b_scene,
-                            BL::ViewLayer& b_view_layer,
                             const bool background,
                             ShaderGraph *graph,
                             BL::ShaderNodeTree& b_ntree,
@@ -848,7 +848,7 @@ static ShaderNode *add_node(Scene *scene,
 
 		/* TODO(sergey): Use more proper update flag. */
 		if(true) {
-			b_point_density_node.cache_point_density(b_scene, b_view_layer, settings);
+			b_point_density_node.cache_point_density(b_depsgraph, settings);
 			scene->image_manager->tag_reload_image(
 			        point_density->filename.string(),
 			        point_density->builtin_data,
@@ -866,7 +866,7 @@ static ShaderNode *add_node(Scene *scene,
 		BL::Object b_ob(b_point_density_node.object());
 		if(b_ob) {
 			float3 loc, size;
-			point_density_texture_space(b_scene, b_view_layer,
+			point_density_texture_space(b_depsgraph,
 			                            b_point_density_node,
 			                            settings,
 			                            loc,
@@ -1006,8 +1006,8 @@ static BL::ShaderNode find_output_node(BL::ShaderNodeTree& b_ntree)
 static void add_nodes(Scene *scene,
                       BL::RenderEngine& b_engine,
                       BL::BlendData& b_data,
+                      BL::Depsgraph& b_depsgraph,
                       BL::Scene& b_scene,
-                      BL::ViewLayer& b_view_layer,
                       const bool background,
                       ShaderGraph *graph,
                       BL::ShaderNodeTree& b_ntree,
@@ -1093,8 +1093,8 @@ static void add_nodes(Scene *scene,
 				add_nodes(scene,
 				          b_engine,
 				          b_data,
+				          b_depsgraph,
 				          b_scene,
-				          b_view_layer,
 				          background,
 				          graph,
 				          b_group_ntree,
@@ -1141,8 +1141,8 @@ static void add_nodes(Scene *scene,
 				node = add_node(scene,
 				                b_engine,
 				                b_data,
+				                b_depsgraph,
 				                b_scene,
-				                b_view_layer,
 				                background,
 				                graph,
 				                b_ntree,
@@ -1205,8 +1205,8 @@ static void add_nodes(Scene *scene,
 static void add_nodes(Scene *scene,
                       BL::RenderEngine& b_engine,
                       BL::BlendData& b_data,
+                      BL::Depsgraph& b_depsgraph,
                       BL::Scene& b_scene,
-                      BL::ViewLayer& b_view_layer,
                       const bool background,
                       ShaderGraph *graph,
                       BL::ShaderNodeTree& b_ntree)
@@ -1215,8 +1215,8 @@ static void add_nodes(Scene *scene,
 	add_nodes(scene,
 	          b_engine,
 	          b_data,
+	          b_depsgraph,
 	          b_scene,
-	          b_view_layer,
 	          background,
 	          graph,
 	          b_ntree,
@@ -1228,7 +1228,6 @@ static void add_nodes(Scene *scene,
 
 void BlenderSync::sync_materials(BL::Depsgraph& b_depsgraph, bool update_all)
 {
-	BL::ViewLayer b_view_layer(b_depsgraph.view_layer());
 	shader_map.set_default(scene->default_surface);
 
 	TaskPool pool;
@@ -1256,7 +1255,7 @@ void BlenderSync::sync_materials(BL::Depsgraph& b_depsgraph, bool update_all)
 			if(b_mat->use_nodes() && b_mat->node_tree()) {
 				BL::ShaderNodeTree b_ntree(b_mat->node_tree());
 
-				add_nodes(scene, b_engine, b_data, b_scene, b_view_layer, !preview, graph, b_ntree);
+				add_nodes(scene, b_engine, b_data, b_depsgraph, b_scene, !preview, graph, b_ntree);
 			}
 			else {
 				DiffuseBsdfNode *diffuse = new DiffuseBsdfNode();
@@ -1314,7 +1313,6 @@ void BlenderSync::sync_materials(BL::Depsgraph& b_depsgraph, bool update_all)
 
 void BlenderSync::sync_world(BL::Depsgraph& b_depsgraph, bool update_all)
 {
-	BL::ViewLayer b_view_layer(b_depsgraph.view_layer());
 	Background *background = scene->background;
 	Background prevbackground = *background;
 
@@ -1328,7 +1326,7 @@ void BlenderSync::sync_world(BL::Depsgraph& b_depsgraph, bool update_all)
 		if(b_world && b_world.use_nodes() && b_world.node_tree()) {
 			BL::ShaderNodeTree b_ntree(b_world.node_tree());
 
-			add_nodes(scene, b_engine, b_data, b_scene, b_view_layer, !preview, graph, b_ntree);
+			add_nodes(scene, b_engine, b_data, b_depsgraph, b_scene, !preview, graph, b_ntree);
 
 			/* volume */
 			PointerRNA cworld = RNA_pointer_get(&b_world.ptr, "cycles");
@@ -1407,7 +1405,6 @@ void BlenderSync::sync_world(BL::Depsgraph& b_depsgraph, bool update_all)
 
 void BlenderSync::sync_lamps(BL::Depsgraph& b_depsgraph, bool update_all)
 {
-	BL::ViewLayer b_view_layer(b_depsgraph.view_layer());
 	shader_map.set_default(scene->default_light);
 
 	/* lamp loop */
@@ -1431,7 +1428,7 @@ void BlenderSync::sync_lamps(BL::Depsgraph& b_depsgraph, bool update_all)
 
 				BL::ShaderNodeTree b_ntree(b_lamp->node_tree());
 
-				add_nodes(scene, b_engine, b_data, b_scene, b_view_layer, !preview, graph, b_ntree);
+				add_nodes(scene, b_engine, b_data, b_depsgraph, b_scene, !preview, graph, b_ntree);
 			}
 			else {
 				float strength = 1.0f;
diff --git a/intern/cycles/blender/blender_texture.cpp b/intern/cycles/blender/blender_texture.cpp
index 3b06fb720de..637f3632a49 100644
--- a/intern/cycles/blender/blender_texture.cpp
+++ b/intern/cycles/blender/blender_texture.cpp
@@ -34,7 +34,7 @@ void density_texture_space_invert(float3& loc,
 
 }  /* namespace */
 
-void point_density_texture_space(BL::Scene& b_scene, BL::ViewLayer& b_view_layer,
+void point_density_texture_space(BL::Depsgraph& b_depsgraph,
                                  BL::ShaderNodeTexPointDensity& b_point_density_node,
                                  int settings,
                                  float3& loc,
@@ -47,8 +47,7 @@ void point_density_texture_space(BL::Scene& b_scene, BL::ViewLayer& b_view_layer
 		return;
 	}
 	float3 min, max;
-	b_point_density_node.calc_point_density_minmax(b_scene,
-	                                               b_view_layer,
+	b_point_density_node.calc_point_density_minmax(b_depsgraph,
 	                                               settings,
 	                                               &min[0],
 	                                               &max[0]);
diff --git a/intern/cycles/blender/blender_texture.h b/intern/cycles/blender/blender_texture.h
index 3d4b8739d49..9c921d1e9f8 100644
--- a/intern/cycles/blender/blender_texture.h
+++ b/intern/cycles/blender/blender_texture.h
@@ -22,7 +22,7 @@
 
 CCL_NAMESPACE_BEGIN
 
-void point_density_texture_space(BL::Scene& b_scene, BL::ViewLayer& b_view_layer,
+void point_density_texture_space(BL::Depsgraph& b_depsgraph,
                                  BL::ShaderNodeTexPointDensity& b_point_density_node,
                                  const int settings,
                                  float3& loc,
diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h
index e96ef847137..477c0dd36ea 100644
--- a/source/blender/depsgraph/DEG_depsgraph.h
+++ b/source/blender/depsgraph/DEG_depsgraph.h
@@ -230,6 +230,11 @@ void DEG_evaluation_context_init_from_view_layer_for_render(
         struct Scene *scene,
         struct ViewLayer *view_layer);
 
+void DEG_evaluation_context_init_from_depsgraph(
+        struct EvaluationContext *eval_ctx,
+        struct Depsgraph *depsgraph,
+        eEvaluationMode mode);
+
 /* Free evaluation context. */
 void DEG_evaluation_context_free(struct EvaluationContext *eval_ctx);
 
diff --git a/source/blender/depsgraph/intern/depsgraph_eval.cc b/source/blender/depsgraph/intern/depsgraph_eval.cc
index ddb049a0043..d76eba29628 100644
--- a/source/blender/depsgraph/intern/depsgraph_eval.cc
+++ b/source/blender/depsgraph/intern/depsgraph_eval.cc
@@ -39,10 +39,12 @@
 extern "C" {
 #include "BKE_scene.h"
 
+#include "DNA_object_types.h"
 #include "DNA_scene_types.h"
 } /* extern "C" */
 
 #include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
 
 #include "intern/eval/deg_eval.h"
 #include "intern/eval/deg_eval_flush.h"
@@ -111,6 +113,20 @@ void DEG_evaluation_context_init_from_view_layer_for_render(
 	eval_ctx->engine_type = NULL;
 }
 
+void DEG_evaluation_context_init_from_depsgraph(
+        EvaluationContext *eval_ctx,
+        Depsgraph *depsgraph,
+  

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list