Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2016-04-20 19:12:26 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2016-04-20 19:17:24 +0300
commit9bd1c8caf72e9b1c2a71929a8968389eea8ca5b3 (patch)
tree0d878197621f451c6f426f3d43abb5fe942d767e /intern/cycles/render/object.h
parent02213b867ed68a00683fa931ebce12a23ed3e77b (diff)
Cycles: Multi-thread object transform update
Simple idea, use threads when dealing with "Copying Transformations to device" scene update step. Only do it if there's enough objects in the scene. Hopefully only brings less synchronization time and doesn't break anything. From tests on my desktop this brings down transform update time from 58sec to 11sec on victor_cpu.blend scene from out benchmark.
Diffstat (limited to 'intern/cycles/render/object.h')
-rw-r--r--intern/cycles/render/object.h60
1 files changed, 59 insertions, 1 deletions
diff --git a/intern/cycles/render/object.h b/intern/cycles/render/object.h
index 379d1748cdd..c2a79ca8dc4 100644
--- a/intern/cycles/render/object.h
+++ b/intern/cycles/render/object.h
@@ -17,9 +17,12 @@
#ifndef __OBJECT_H__
#define __OBJECT_H__
+#include "scene.h"
+
#include "util_boundbox.h"
#include "util_param.h"
#include "util_transform.h"
+#include "util_thread.h"
#include "util_types.h"
CCL_NAMESPACE_BEGIN
@@ -76,7 +79,12 @@ public:
~ObjectManager();
void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
- void device_update_transforms(Device *device, DeviceScene *dscene, Scene *scene, uint *object_flag, Progress& progress);
+ void device_update_transforms(Device *device,
+ DeviceScene *dscene,
+ Scene *scene,
+ uint *object_flag,
+ Progress& progress);
+
void device_update_flags(Device *device,
DeviceScene *dscene,
Scene *scene,
@@ -87,6 +95,56 @@ public:
void tag_update(Scene *scene);
void apply_static_transforms(DeviceScene *dscene, Scene *scene, uint *object_flag, Progress& progress);
+
+protected:
+ /* Global state of object transform update. */
+ struct UpdateObejctTransformState {
+ /* Global state used by device_update_object_transform().
+ * Common for both threaded and non-threaded update.
+ */
+
+ /* Type of the motion required by the scene settings. */
+ Scene::MotionType need_motion;
+
+ /* Mapping from particle system to a index in packed particle array.
+ * Only used for read.
+ */
+ map<ParticleSystem*, int> particle_offset;
+
+ /* Mesh area.
+ * Used to avoid calculation of mesh area multiple times. Used for both
+ * read and write. Acquire surface_area_lock to keep it all thread safe.
+ */
+ map<Mesh*, float> surface_area_map;
+
+ /* Packed object arrays. Those will be filled in. */
+ uint *object_flag;
+ float4 *objects;
+ float4 *objects_vector;
+
+ /* Flags which will be synchronized to Integrator. */
+ bool have_motion;
+ bool have_curves;
+
+ /* ** Scheduling queue. ** */
+
+ Scene *scene;
+
+ /* Some locks to keep everything thread-safe. */
+ thread_spin_lock queue_lock;
+ thread_spin_lock surface_area_lock;
+
+ /* First unused object index in the queue. */
+ int queue_start_object;
+ };
+ void device_update_object_transform(UpdateObejctTransformState *state,
+ Object *ob,
+ const int object_index);
+ void device_update_object_transform_task(UpdateObejctTransformState *state);
+ bool device_update_object_transform_pop_work(
+ UpdateObejctTransformState *state,
+ int *start_index,
+ int *num_objects);
};
CCL_NAMESPACE_END