[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49501] branches/soc-2011-tomato/intern/ cycles/blender: Tomato Cycles: experimental option to cancel rendering when doing initial synchronization
Sergey Sharybin
sergey.vfx at gmail.com
Thu Aug 2 16:16:38 CEST 2012
Revision: 49501
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49501
Author: nazgul
Date: 2012-08-02 14:16:37 +0000 (Thu, 02 Aug 2012)
Log Message:
-----------
Tomato Cycles: experimental option to cancel rendering when doing initial synchronization
This required wrapping create and update pytohn callbacks as into begin/end
allow threading macroses. From quick tests this seems to be stable enough,
but more tests would be needed before considering this stable.
Modified Paths:
--------------
branches/soc-2011-tomato/intern/cycles/blender/blender_object.cpp
branches/soc-2011-tomato/intern/cycles/blender/blender_python.cpp
branches/soc-2011-tomato/intern/cycles/blender/blender_session.cpp
branches/soc-2011-tomato/intern/cycles/blender/blender_sync.cpp
branches/soc-2011-tomato/intern/cycles/blender/blender_sync.h
Modified: branches/soc-2011-tomato/intern/cycles/blender/blender_object.cpp
===================================================================
--- branches/soc-2011-tomato/intern/cycles/blender/blender_object.cpp 2012-08-02 11:33:21 UTC (rev 49500)
+++ branches/soc-2011-tomato/intern/cycles/blender/blender_object.cpp 2012-08-02 14:16:37 UTC (rev 49501)
@@ -302,14 +302,17 @@
BL::Scene b_sce = b_scene;
int particle_offset = 0;
- for(; b_sce; b_sce = b_sce.background_set()) {
- for(b_sce.objects.begin(b_ob); b_ob != b_sce.objects.end(); ++b_ob) {
+ bool cancel = false;
+
+ for(; b_sce && !cancel; b_sce = b_sce.background_set()) {
+ for(b_sce.objects.begin(b_ob); b_ob != b_sce.objects.end() && !cancel; ++b_ob) {
bool hide = (render_layer.use_viewport_visibility)? b_ob->hide(): b_ob->hide_render();
uint ob_layer = get_layer(b_ob->layers(), b_ob->layers_local_view(), object_is_light(*b_ob));
CYCLES_LOCAL_LAYER_HACK(render_layer.use_localview, ob_layer);
hide = hide || !(ob_layer & scene_layer);
if(!hide) {
+ progress.set_status("Synchronizing object", (*b_ob).name());
int num_particles = object_count_particles(*b_ob);
@@ -351,10 +354,12 @@
particle_offset += num_particles;
}
+
+ cancel = progress.get_cancel();
}
}
- if(!motion) {
+ if(!cancel && !motion) {
sync_background_light();
/* handle removed data and modified pointers */
Modified: branches/soc-2011-tomato/intern/cycles/blender/blender_python.cpp
===================================================================
--- branches/soc-2011-tomato/intern/cycles/blender/blender_python.cpp 2012-08-02 11:33:21 UTC (rev 49500)
+++ branches/soc-2011-tomato/intern/cycles/blender/blender_python.cpp 2012-08-02 14:16:37 UTC (rev 49501)
@@ -80,6 +80,8 @@
/* create session */
BlenderSession *session;
+ Py_BEGIN_ALLOW_THREADS
+
if(rv3d) {
/* interactive session */
int width = region.width();
@@ -91,7 +93,9 @@
/* offline session */
session = new BlenderSession(engine, userpref, data, scene);
}
-
+
+ Py_END_ALLOW_THREADS
+
return PyLong_FromVoidPtr(session);
}
@@ -136,9 +140,13 @@
static PyObject *sync_func(PyObject *self, PyObject *value)
{
+ Py_BEGIN_ALLOW_THREADS
+
BlenderSession *session = (BlenderSession*)PyLong_AsVoidPtr(value);
session->synchronize();
+ Py_END_ALLOW_THREADS
+
Py_RETURN_NONE;
}
Modified: branches/soc-2011-tomato/intern/cycles/blender/blender_session.cpp
===================================================================
--- branches/soc-2011-tomato/intern/cycles/blender/blender_session.cpp 2012-08-02 11:33:21 UTC (rev 49500)
+++ branches/soc-2011-tomato/intern/cycles/blender/blender_session.cpp 2012-08-02 14:16:37 UTC (rev 49501)
@@ -88,8 +88,15 @@
/* create scene */
scene = new Scene(scene_params, session_params.device);
+ /* create session */
+ session = new Session(session_params);
+ session->scene = scene;
+ session->progress.set_update_callback(function_bind(&BlenderSession::tag_redraw, this));
+ session->progress.set_cancel_callback(function_bind(&BlenderSession::test_cancel, this));
+ session->set_pause(BlenderSync::get_session_pause(b_scene, background));
+
/* create sync */
- sync = new BlenderSync(b_engine, b_data, b_scene, scene, !background);
+ sync = new BlenderSync(b_engine, b_data, b_scene, scene, !background, session->progress);
sync->sync_data(b_v3d, b_engine.camera_override());
if(b_rv3d)
@@ -97,13 +104,6 @@
else
sync->sync_camera(b_engine.camera_override(), width, height);
- /* create session */
- session = new Session(session_params);
- session->scene = scene;
- session->progress.set_update_callback(function_bind(&BlenderSession::tag_redraw, this));
- session->progress.set_cancel_callback(function_bind(&BlenderSession::test_cancel, this));
- session->set_pause(BlenderSync::get_session_pause(b_scene, background));
-
/* set buffer parameters */
BufferParams buffer_params = BlenderSync::get_buffer_params(b_scene, scene->camera, width, height);
session->reset(buffer_params, session_params.samples);
Modified: branches/soc-2011-tomato/intern/cycles/blender/blender_sync.cpp
===================================================================
--- branches/soc-2011-tomato/intern/cycles/blender/blender_sync.cpp 2012-08-02 11:33:21 UTC (rev 49500)
+++ branches/soc-2011-tomato/intern/cycles/blender/blender_sync.cpp 2012-08-02 14:16:37 UTC (rev 49501)
@@ -40,7 +40,7 @@
/* Constructor */
-BlenderSync::BlenderSync(BL::RenderEngine b_engine_, BL::BlendData b_data_, BL::Scene b_scene_, Scene *scene_, bool preview_)
+BlenderSync::BlenderSync(BL::RenderEngine b_engine_, BL::BlendData b_data_, BL::Scene b_scene_, Scene *scene_, bool preview_, Progress &progress_)
: b_engine(b_engine_),
b_data(b_data_), b_scene(b_scene_),
shader_map(&scene_->shaders),
@@ -49,7 +49,8 @@
light_map(&scene_->lights),
world_map(NULL),
world_recalc(false),
- experimental(false)
+ experimental(false),
+ progress(progress_)
{
scene = scene_;
preview = preview_;
Modified: branches/soc-2011-tomato/intern/cycles/blender/blender_sync.h
===================================================================
--- branches/soc-2011-tomato/intern/cycles/blender/blender_sync.h 2012-08-02 11:33:21 UTC (rev 49500)
+++ branches/soc-2011-tomato/intern/cycles/blender/blender_sync.h 2012-08-02 14:16:37 UTC (rev 49501)
@@ -49,7 +49,7 @@
class BlenderSync {
public:
- BlenderSync(BL::RenderEngine b_engine_, BL::BlendData b_data, BL::Scene b_scene, Scene *scene_, bool preview_);
+ BlenderSync(BL::RenderEngine b_engine_, BL::BlendData b_data, BL::Scene b_scene, Scene *scene_, bool preview_, Progress &progress_);
~BlenderSync();
/* sync */
@@ -131,6 +131,8 @@
bool use_localview;
int samples;
} render_layer;
+
+ Progress &progress;
};
/* we don't have spare bits for localview (normally 20-28)
More information about the Bf-blender-cvs
mailing list