diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-02-17 14:23:03 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-02-17 14:25:16 +0300 |
commit | 4660c00ac57effeb9598bb3083900dc354a4f43f (patch) | |
tree | 6e0e38abad5ecb36f15ea80e0e22c639213cb2dc /intern/cycles | |
parent | 7307f3b48564191dfcf2ccd71e730c41c6486289 (diff) |
Cycles: Make blender session aware of rendering from command line
This way we can do some more aggressive policy about releasing temporary
data during synchronization.
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/blender/addon/__init__.py | 2 | ||||
-rw-r--r-- | intern/cycles/blender/addon/engine.py | 4 | ||||
-rw-r--r-- | intern/cycles/blender/blender_python.cpp | 12 | ||||
-rw-r--r-- | intern/cycles/blender/blender_session.cpp | 15 | ||||
-rw-r--r-- | intern/cycles/blender/blender_session.h | 3 | ||||
-rw-r--r-- | intern/cycles/blender/blender_sync.cpp | 15 | ||||
-rw-r--r-- | intern/cycles/blender/blender_sync.h | 6 |
7 files changed, 33 insertions, 24 deletions
diff --git a/intern/cycles/blender/addon/__init__.py b/intern/cycles/blender/addon/__init__.py index 57025388bda..8714dfae84e 100644 --- a/intern/cycles/blender/addon/__init__.py +++ b/intern/cycles/blender/addon/__init__.py @@ -59,7 +59,7 @@ class CyclesRender(bpy.types.RenderEngine): None, None, None, use_osl) else: if not self.session: - engine.create(self, data, scene, background=bpy.app.background) + engine.create(self, data, scene, headless=bpy.app.background) else: engine.reset(self, data, scene) diff --git a/intern/cycles/blender/addon/engine.py b/intern/cycles/blender/addon/engine.py index 492a254b9b9..400cf70da8d 100644 --- a/intern/cycles/blender/addon/engine.py +++ b/intern/cycles/blender/addon/engine.py @@ -28,7 +28,7 @@ def init(): _cycles.init(path, user_path) -def create(engine, data, scene, region=None, v3d=None, rv3d=None, preview_osl=False, background=False): +def create(engine, data, scene, region=None, v3d=None, rv3d=None, preview_osl=False, headless=False): import bpy import _cycles @@ -42,7 +42,7 @@ def create(engine, data, scene, region=None, v3d=None, rv3d=None, preview_osl=Fa if rv3d: rv3d = rv3d.as_pointer() - engine.session = _cycles.create(engine.as_pointer(), userpref, data, scene, region, v3d, rv3d, preview_osl, background) + engine.session = _cycles.create(engine.as_pointer(), userpref, data, scene, region, v3d, rv3d, preview_osl, headless) def free(engine): diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp index 120d6b0d4de..78419f76283 100644 --- a/intern/cycles/blender/blender_python.cpp +++ b/intern/cycles/blender/blender_python.cpp @@ -90,10 +90,10 @@ static PyObject *init_func(PyObject *self, PyObject *args) static PyObject *create_func(PyObject *self, PyObject *args) { PyObject *pyengine, *pyuserpref, *pydata, *pyscene, *pyregion, *pyv3d, *pyrv3d; - int preview_osl, background; + int preview_osl, headless; if(!PyArg_ParseTuple(args, "OOOOOOOii", &pyengine, &pyuserpref, &pydata, &pyscene, - &pyregion, &pyv3d, &pyrv3d, &preview_osl, &background)) + &pyregion, &pyv3d, &pyrv3d, &preview_osl, &headless)) { return NULL; } @@ -146,14 +146,8 @@ static PyObject *create_func(PyObject *self, PyObject *args) RNA_boolean_set(&cscene, "use_progressive_refine", true); } - /* Use more optimal tile order when rendering from the command line. */ - if(background) { - PointerRNA cscene = RNA_pointer_get(&sceneptr, "cycles"); - RNA_enum_set(&cscene, "tile_order", (int)TILE_BOTTOM_TO_TOP); - } - /* offline session or preview render */ - session = new BlenderSession(engine, userpref, data, scene); + session = new BlenderSession(engine, userpref, data, scene, headless); } 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 eb3f54ae90c..466a39e009b 100644 --- a/intern/cycles/blender/blender_session.cpp +++ b/intern/cycles/blender/blender_session.cpp @@ -42,7 +42,7 @@ CCL_NAMESPACE_BEGIN BlenderSession::BlenderSession(BL::RenderEngine b_engine_, BL::UserPreferences b_userpref_, - BL::BlendData b_data_, BL::Scene b_scene_) + BL::BlendData b_data_, BL::Scene b_scene_, bool headless_) : b_engine(b_engine_), b_userpref(b_userpref_), b_data(b_data_), b_render(b_engine_.render()), b_scene(b_scene_), b_v3d(PointerRNA_NULL), b_rv3d(PointerRNA_NULL), python_thread_state(NULL) { @@ -52,6 +52,7 @@ BlenderSession::BlenderSession(BL::RenderEngine b_engine_, BL::UserPreferences b height = render_resolution_y(b_render); background = true; + headless = headless_; last_redraw_time = 0.0; start_resize_time = 0.0; } @@ -86,7 +87,7 @@ void BlenderSession::create() void BlenderSession::create_session() { - SessionParams session_params = BlenderSync::get_session_params(b_engine, b_userpref, b_scene, background); + SessionParams session_params = BlenderSync::get_session_params(b_engine, b_userpref, b_scene, background, headless); bool is_cpu = session_params.device.type == DEVICE_CPU; SceneParams scene_params = BlenderSync::get_scene_params(b_scene, background, is_cpu); bool session_pause = BlenderSync::get_session_pause(b_scene, background); @@ -143,7 +144,7 @@ void BlenderSession::reset_session(BL::BlendData b_data_, BL::Scene b_scene_) b_render = b_engine.render(); b_scene = b_scene_; - SessionParams session_params = BlenderSync::get_session_params(b_engine, b_userpref, b_scene, background); + SessionParams session_params = BlenderSync::get_session_params(b_engine, b_userpref, b_scene, background, headless); const bool is_cpu = session_params.device.type == DEVICE_CPU; SceneParams scene_params = BlenderSync::get_scene_params(b_scene, background, is_cpu); @@ -408,7 +409,7 @@ void BlenderSession::render() session->update_render_tile_cb = function_bind(&BlenderSession::update_render_tile, this, _1); /* get buffer parameters */ - SessionParams session_params = BlenderSync::get_session_params(b_engine, b_userpref, b_scene, background); + SessionParams session_params = BlenderSync::get_session_params(b_engine, b_userpref, b_scene, background, headless); BufferParams buffer_params = BlenderSync::get_buffer_params(b_render, b_scene, b_v3d, b_rv3d, scene->camera, width, height); /* render each layer */ @@ -540,7 +541,7 @@ void BlenderSession::bake(BL::Object b_object, const string& pass_type, BL::Bake sync->sync_data(b_v3d, b_engine.camera_override(), &python_thread_state); /* get buffer parameters */ - SessionParams session_params = BlenderSync::get_session_params(b_engine, b_userpref, b_scene, background); + SessionParams session_params = BlenderSync::get_session_params(b_engine, b_userpref, b_scene, background, headless); BufferParams buffer_params = BlenderSync::get_buffer_params(b_render, b_scene, b_v3d, b_rv3d, scene->camera, width, height); scene->bake_manager->set_shader_limit((size_t)b_engine.tile_x(), (size_t)b_engine.tile_y()); @@ -643,7 +644,7 @@ void BlenderSession::synchronize() return; /* on session/scene parameter changes, we recreate session entirely */ - SessionParams session_params = BlenderSync::get_session_params(b_engine, b_userpref, b_scene, background); + SessionParams session_params = BlenderSync::get_session_params(b_engine, b_userpref, b_scene, background, headless); const bool is_cpu = session_params.device.type == DEVICE_CPU; SceneParams scene_params = BlenderSync::get_scene_params(b_scene, background, is_cpu); bool session_pause = BlenderSync::get_session_pause(b_scene, background); @@ -744,7 +745,7 @@ bool BlenderSession::draw(int w, int h) /* reset if requested */ if(reset) { - SessionParams session_params = BlenderSync::get_session_params(b_engine, b_userpref, b_scene, background); + SessionParams session_params = BlenderSync::get_session_params(b_engine, b_userpref, b_scene, background, headless); BufferParams buffer_params = BlenderSync::get_buffer_params(b_render, b_scene, b_v3d, b_rv3d, scene->camera, width, height); bool session_pause = BlenderSync::get_session_pause(b_scene, background); diff --git a/intern/cycles/blender/blender_session.h b/intern/cycles/blender/blender_session.h index 33da3076b55..dc9f9c18f79 100644 --- a/intern/cycles/blender/blender_session.h +++ b/intern/cycles/blender/blender_session.h @@ -34,7 +34,7 @@ class RenderTile; class BlenderSession { public: BlenderSession(BL::RenderEngine b_engine, BL::UserPreferences b_userpref, - BL::BlendData b_data, BL::Scene b_scene); + BL::BlendData b_data, BL::Scene b_scene, bool is_headless); BlenderSession(BL::RenderEngine b_engine, BL::UserPreferences b_userpref, BL::BlendData b_data, BL::Scene b_scene, BL::SpaceView3D b_v3d, BL::RegionView3D b_rv3d, int width, int height); @@ -76,6 +76,7 @@ public: void update_bake_progress(); bool background; + bool headless; Session *session; Scene *scene; BlenderSync *sync; diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 79ee6d51196..fb32f67d71a 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -407,7 +407,11 @@ bool BlenderSync::get_session_pause(BL::Scene b_scene, bool background) return (background)? false: get_boolean(cscene, "preview_pause"); } -SessionParams BlenderSync::get_session_params(BL::RenderEngine b_engine, BL::UserPreferences b_userpref, BL::Scene b_scene, bool background) +SessionParams BlenderSync::get_session_params(BL::RenderEngine b_engine, + BL::UserPreferences b_userpref, + BL::Scene b_scene, + bool background, + bool headless) { SessionParams params; PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles"); @@ -496,8 +500,13 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine b_engine, BL::Use params.tile_size = make_int2(tile_x, tile_y); } - - params.tile_order = (TileOrder)RNA_enum_get(&cscene, "tile_order"); + + if(headless == false) { + params.tile_order = (TileOrder)RNA_enum_get(&cscene, "tile_order"); + } + else { + params.tile_order = TILE_BOTTOM_TO_TOP; + } params.start_resolution = get_int(cscene, "preview_start_resolution"); diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h index 8f851a14bfc..a16824f6873 100644 --- a/intern/cycles/blender/blender_sync.h +++ b/intern/cycles/blender/blender_sync.h @@ -63,7 +63,11 @@ public: /* get parameters */ static SceneParams get_scene_params(BL::Scene b_scene, bool background, bool is_cpu); - static SessionParams get_session_params(BL::RenderEngine b_engine, BL::UserPreferences b_userpref, BL::Scene b_scene, bool background); + static SessionParams get_session_params(BL::RenderEngine b_engine, + BL::UserPreferences b_userpref, + BL::Scene b_scene, + bool background, + bool headless); static bool get_session_pause(BL::Scene b_scene, bool background); static BufferParams get_buffer_params(BL::RenderSettings b_render, BL::Scene b_scene, BL::SpaceView3D b_v3d, BL::RegionView3D b_rv3d, Camera *cam, int width, int height); |