Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/render/object.cpp
| Show First 20 Lines • Show All 279 Lines • ▼ Show 20 Lines | ObjectManager::ObjectManager() | ||||
| need_update = true; | need_update = true; | ||||
| need_flags_update = true; | need_flags_update = true; | ||||
| } | } | ||||
| ObjectManager::~ObjectManager() | ObjectManager::~ObjectManager() | ||||
| { | { | ||||
| } | } | ||||
| void ObjectManager::device_update_object_transform(UpdateObejctTransformState *state, | void ObjectManager::device_update_object_transform(UpdateObjectTransformState *state, | ||||
| Object *ob, | Object *ob, | ||||
| int object_index) | int object_index) | ||||
| { | { | ||||
| float4 *objects = state->objects; | float4 *objects = state->objects; | ||||
| float4 *objects_vector = state->objects_vector; | float4 *objects_vector = state->objects_vector; | ||||
| Mesh *mesh = ob->mesh; | Mesh *mesh = ob->mesh; | ||||
| uint flag = 0; | uint flag = 0; | ||||
| ▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | void ObjectManager::device_update_object_transform(UpdateObjectTransformState *state, | ||||
| /* Have curves. */ | /* Have curves. */ | ||||
| if(mesh->num_curves()) { | if(mesh->num_curves()) { | ||||
| state->have_curves = true; | state->have_curves = true; | ||||
| } | } | ||||
| } | } | ||||
| bool ObjectManager::device_update_object_transform_pop_work( | bool ObjectManager::device_update_object_transform_pop_work( | ||||
| UpdateObejctTransformState *state, | UpdateObjectTransformState *state, | ||||
| int *start_index, | int *start_index, | ||||
| int *num_objects) | int *num_objects) | ||||
| { | { | ||||
| /* Tweakable parameter, number of objects per chunk. | /* Tweakable parameter, number of objects per chunk. | ||||
| * Too small value will cause some extra overhead due to spin lock, | * Too small value will cause some extra overhead due to spin lock, | ||||
| * too big value might not use all threads nicely. | * too big value might not use all threads nicely. | ||||
| */ | */ | ||||
| static const int OBJECTS_PER_TASK = 32; | static const int OBJECTS_PER_TASK = 32; | ||||
| bool have_work = false; | bool have_work = false; | ||||
| state->queue_lock.lock(); | state->queue_lock.lock(); | ||||
| int num_scene_objects = state->scene->objects.size(); | int num_scene_objects = state->scene->objects.size(); | ||||
| if(state->queue_start_object < num_scene_objects) { | if(state->queue_start_object < num_scene_objects) { | ||||
| int count = min(OBJECTS_PER_TASK, | int count = min(OBJECTS_PER_TASK, | ||||
| num_scene_objects - state->queue_start_object); | num_scene_objects - state->queue_start_object); | ||||
| *start_index = state->queue_start_object; | *start_index = state->queue_start_object; | ||||
| *num_objects = count; | *num_objects = count; | ||||
| state->queue_start_object += count; | state->queue_start_object += count; | ||||
| have_work = true; | have_work = true; | ||||
| } | } | ||||
| state->queue_lock.unlock(); | state->queue_lock.unlock(); | ||||
| return have_work; | return have_work; | ||||
| } | } | ||||
| void ObjectManager::device_update_object_transform_task( | void ObjectManager::device_update_object_transform_task( | ||||
| UpdateObejctTransformState *state) | UpdateObjectTransformState *state) | ||||
| { | { | ||||
| int start_index, num_objects; | int start_index, num_objects; | ||||
| while(device_update_object_transform_pop_work(state, | while(device_update_object_transform_pop_work(state, | ||||
| &start_index, | &start_index, | ||||
| &num_objects)) | &num_objects)) | ||||
| { | { | ||||
| for(int i = 0; i < num_objects; ++i) { | for(int i = 0; i < num_objects; ++i) { | ||||
| const int object_index = start_index + i; | const int object_index = start_index + i; | ||||
| Object *ob = state->scene->objects[object_index]; | Object *ob = state->scene->objects[object_index]; | ||||
| device_update_object_transform(state, ob, object_index); | device_update_object_transform(state, ob, object_index); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void ObjectManager::device_update_transforms(DeviceScene *dscene, | void ObjectManager::device_update_transforms(DeviceScene *dscene, | ||||
| Scene *scene, | Scene *scene, | ||||
| uint *object_flag, | uint *object_flag, | ||||
| Progress& progress) | Progress& progress) | ||||
| { | { | ||||
| UpdateObejctTransformState state; | UpdateObjectTransformState state; | ||||
| state.need_motion = scene->need_motion(); | state.need_motion = scene->need_motion(); | ||||
| state.have_motion = false; | state.have_motion = false; | ||||
| state.have_curves = false; | state.have_curves = false; | ||||
| state.scene = scene; | state.scene = scene; | ||||
| state.queue_start_object = 0; | state.queue_start_object = 0; | ||||
| state.object_flag = object_flag; | state.object_flag = object_flag; | ||||
| state.objects = dscene->objects.alloc(OBJECT_SIZE*scene->objects.size()); | state.objects = dscene->objects.alloc(OBJECT_SIZE*scene->objects.size()); | ||||
| ▲ Show 20 Lines • Show All 265 Lines • Show Last 20 Lines | |||||