diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-02-20 18:55:02 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-02-28 00:25:54 +0300 |
commit | 06420c5fe8fda54c543f26f9d95d2c6fcf5161cd (patch) | |
tree | 2cb566ad03dd15a34f3d04d0826c33aa096efada /intern | |
parent | bd119ab0177a380a1736677278c02790d8235be4 (diff) |
Refactor depsgraph/render logic to serve evaluated depsgraph to engines
User notes
----------
Compositing, rendering of multi-layers in Eevee should be fully working now.
Development notes
-----------------
Up until now we were still using the same depsgraph for rendering and viewport
evaluation. And we had to go out of our ways to be sure the depsgraphs were
updated.
Now we iterate over the (to be rendered) view layers and create a depsgraph to
each one, fully evaluated and call the render engines (Cycles, Eevee, ...) with
this viewlayer/depsgraph/evaluation context.
At this time we are not handling data persistency, Depsgraph is created from
scratch prior to rendering each frame. So I got rid of most of the partial
update calls we had during the render pipeline.
Cycles: Brecht Van Lommel did a patch to tackle some of the required Cycles
changes but this commit mark these changes as TODOs. Basically Cycles needs to
render one layer at a time.
Reviewers: sergey, brecht
Differential Revision: https://developer.blender.org/D3073
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/blender/addon/__init__.py | 4 | ||||
-rw-r--r-- | intern/cycles/blender/blender_python.cpp | 12 | ||||
-rw-r--r-- | intern/cycles/blender/blender_session.cpp | 25 | ||||
-rw-r--r-- | intern/cycles/blender/blender_session.h | 4 | ||||
-rw-r--r-- | intern/cycles/blender/blender_sync.cpp | 3 | ||||
-rw-r--r-- | intern/cycles/blender/blender_sync.h | 1 |
6 files changed, 28 insertions, 21 deletions
diff --git a/intern/cycles/blender/addon/__init__.py b/intern/cycles/blender/addon/__init__.py index 1cb7835d14d..e5a0cbc316f 100644 --- a/intern/cycles/blender/addon/__init__.py +++ b/intern/cycles/blender/addon/__init__.py @@ -79,8 +79,8 @@ class CyclesRender(bpy.types.RenderEngine): else: engine.reset(self, data, scene) - def render_to_image(self, depsgraph): - engine.render(self, depsgraph) + def render_to_image(self, data, scene): + engine.render(self, data, scene) def bake(self, scene, obj, pass_type, pass_filter, object_id, pixel_array, num_pixels, depth, result): engine.bake(self, obj, pass_type, pass_filter, object_id, pixel_array, num_pixels, depth, result) diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp index 9ade27d57d7..17bf8ceef36 100644 --- a/intern/cycles/blender/blender_python.cpp +++ b/intern/cycles/blender/blender_python.cpp @@ -203,10 +203,10 @@ static PyObject *exit_func(PyObject * /*self*/, PyObject * /*args*/) static PyObject *create_func(PyObject * /*self*/, PyObject *args) { - PyObject *pyengine, *pyuserpref, *pydata, *pygraph, *pyscene, *pyregion, *pyv3d, *pyrv3d; + PyObject *pyengine, *pyuserpref, *pydata, *pyscene, *pyregion, *pyv3d, *pyrv3d; int preview_osl; - if(!PyArg_ParseTuple(args, "OOOOOOOOi", &pyengine, &pyuserpref, &pydata, &pygraph, &pyscene, + if(!PyArg_ParseTuple(args, "OOOOOOOi", &pyengine, &pyuserpref, &pydata, &pyscene, &pyregion, &pyv3d, &pyrv3d, &preview_osl)) { return NULL; @@ -225,10 +225,6 @@ static PyObject *create_func(PyObject * /*self*/, PyObject *args) RNA_main_pointer_create((Main*)PyLong_AsVoidPtr(pydata), &dataptr); BL::BlendData data(dataptr); - PointerRNA graphptr; - RNA_id_pointer_create((ID*)PyLong_AsVoidPtr(pygraph), &graphptr); - BL::Depsgraph graph(graphptr); - PointerRNA sceneptr; RNA_id_pointer_create((ID*)PyLong_AsVoidPtr(pyscene), &sceneptr); BL::Scene scene(sceneptr); @@ -253,7 +249,7 @@ static PyObject *create_func(PyObject * /*self*/, PyObject *args) int width = region.width(); int height = region.height(); - session = new BlenderSession(engine, userpref, data, graph, scene, v3d, rv3d, width, height); + session = new BlenderSession(engine, userpref, data, scene, v3d, rv3d, width, height); } else { /* override some settings for preview */ @@ -265,7 +261,7 @@ static PyObject *create_func(PyObject * /*self*/, PyObject *args) } /* offline session or preview render */ - session = new BlenderSession(engine, userpref, data, graph, scene); + session = new BlenderSession(engine, userpref, data, scene); } python_thread_state_save(&session->python_thread_state); diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp index a40ba0706b4..952410c03f4 100644 --- a/intern/cycles/blender/blender_session.cpp +++ b/intern/cycles/blender/blender_session.cpp @@ -52,15 +52,12 @@ int BlenderSession::end_resumable_chunk = 0; BlenderSession::BlenderSession(BL::RenderEngine& b_engine, BL::UserPreferences& b_userpref, BL::BlendData& b_data, - BL::Depsgraph& b_depsgraph, BL::Scene& b_scene) : b_engine(b_engine), b_userpref(b_userpref), b_data(b_data), b_render(b_engine.render()), - b_depsgraph(b_depsgraph), b_scene(b_scene), - b_view_layer(b_engine.view_layer()), b_v3d(PointerRNA_NULL), b_rv3d(PointerRNA_NULL), python_thread_state(NULL) @@ -79,7 +76,6 @@ BlenderSession::BlenderSession(BL::RenderEngine& b_engine, BlenderSession::BlenderSession(BL::RenderEngine& b_engine, BL::UserPreferences& b_userpref, BL::BlendData& b_data, - BL::Depsgraph& b_depsgraph, BL::Scene& b_scene, BL::SpaceView3D& b_v3d, BL::RegionView3D& b_rv3d, @@ -88,9 +84,7 @@ BlenderSession::BlenderSession(BL::RenderEngine& b_engine, b_userpref(b_userpref), b_data(b_data), b_render(b_scene.render()), - b_depsgraph(b_depsgraph), b_scene(b_scene), - b_view_layer(b_engine.view_layer()), b_v3d(b_v3d), b_rv3d(b_rv3d), width(width), @@ -147,6 +141,13 @@ void BlenderSession::create_session() session->scene = scene; +#if 0 + /* There is no single depsgraph to use for the entire render. + * So we need to handle this differently. + * + * We could loop over the final render result render layers in pipeline and keep Cycles unaware of multiple layers, + * or perhaps move syncing further down in the pipeline. + */ /* create sync */ sync = new BlenderSync(b_engine, b_data, b_depsgraph, b_scene, scene, !background, session->progress); BL::Object b_camera_override(b_engine.camera_override()); @@ -169,6 +170,7 @@ void BlenderSession::create_session() sync->sync_integrator(); sync->sync_camera(b_render, b_camera_override, width, height, ""); } +#endif /* set buffer parameters */ BufferParams buffer_params = BlenderSync::get_buffer_params(b_render, b_v3d, b_rv3d, scene->camera, width, height); @@ -216,6 +218,10 @@ void BlenderSession::reset_session(BL::BlendData& b_data_, BL::Scene& b_scene_) */ session->stats.mem_peak = session->stats.mem_used; +#if 0 + /* There is no single depsgraph to use for the entire render. + * See note on create_session(). + */ /* sync object should be re-created */ sync = new BlenderSync(b_engine, b_data, b_depsgraph, b_scene, scene, !background, session->progress); @@ -225,6 +231,7 @@ void BlenderSession::reset_session(BL::BlendData& b_data_, BL::Scene& b_scene_) sync->sync_view_layers(b_v3d, NULL); sync->sync_integrator(); sync->sync_camera(b_render, b_camera_override, width, height, ""); +#endif BL::SpaceView3D b_null_space_view3d(PointerRNA_NULL); BL::RegionView3D b_null_region_view3d(PointerRNA_NULL); @@ -1311,6 +1318,11 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name, fprintf(stderr, "Cycles error: unexpected smoke volume resolution, skipping\n"); } else { +#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. + */ /* TODO(sergey): Check we're indeed in shader node tree. */ PointerRNA ptr; RNA_pointer_create(NULL, &RNA_Node, builtin_data, &ptr); @@ -1321,6 +1333,7 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name, 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); } +#endif } return false; diff --git a/intern/cycles/blender/blender_session.h b/intern/cycles/blender/blender_session.h index 8694c9499b8..cbd2303d282 100644 --- a/intern/cycles/blender/blender_session.h +++ b/intern/cycles/blender/blender_session.h @@ -36,13 +36,11 @@ public: BlenderSession(BL::RenderEngine& b_engine, BL::UserPreferences& b_userpref, BL::BlendData& b_data, - BL::Depsgraph& b_depsgraph, BL::Scene& b_scene); BlenderSession(BL::RenderEngine& b_engine, BL::UserPreferences& b_userpref, BL::BlendData& b_data, - BL::Depsgraph& b_depsgraph, BL::Scene& b_scene, BL::SpaceView3D& b_v3d, BL::RegionView3D& b_rv3d, @@ -106,9 +104,7 @@ public: BL::UserPreferences b_userpref; BL::BlendData b_data; BL::RenderSettings b_render; - BL::Depsgraph b_depsgraph; BL::Scene b_scene; - BL::ViewLayer b_view_layer; BL::SpaceView3D b_v3d; BL::RegionView3D b_rv3d; string b_rlay_name; diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 08d76582f03..148db9fc3cf 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -46,6 +46,7 @@ BlenderSync::BlenderSync(BL::RenderEngine& b_engine, BL::BlendData& b_data, BL::Depsgraph& b_depsgraph, BL::Scene& b_scene, + BL::ViewLayer& b_view_layer, Scene *scene, bool preview, Progress &progress) @@ -53,7 +54,7 @@ BlenderSync::BlenderSync(BL::RenderEngine& b_engine, b_data(b_data), b_depsgraph(b_depsgraph), b_scene(b_scene), - b_view_layer(b_engine.view_layer()), + b_view_layer(b_view_layer), shader_map(&scene->shaders), object_map(&scene->objects), mesh_map(&scene->meshes), diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h index c4dd17714be..ce9155ee7ef 100644 --- a/intern/cycles/blender/blender_sync.h +++ b/intern/cycles/blender/blender_sync.h @@ -54,6 +54,7 @@ public: BL::BlendData& b_data, BL::Depsgraph& b_graph, BL::Scene& b_scene, + BL::ViewLayer& b_view_layer, Scene *scene, bool preview, Progress &progress); |