Blender Git Commit Log
Git Commits -> Revision 31ed71c
Revision 31ed71c by Lukas Toenne (master) September 11, 2012, 11:41 (GMT) |
Performance fix for Cycles: Don't wait in the main UI thread when resetting devices. When the scene is updated Cycles resets the renderer device, cancelling all existing tasks. The main thread would wait for all running tasks to finish before continuing. This is ok when tasks can actually cancel in a timely fashion. For OSL however, this does not work, since the OSL shader group optimization takes quite a bit of time and can not be easily be cancelled once running (on my crappy machine in full debug mode: ~0.12 seconds for simple node trees). This would lead to very laggy UI behavior and make it difficult to accurately control elements such as sliders. This patch removes the wait condition from the device->task_cancel method. Instead it just sets the do_cancel flag and returns. To avoid backlog in the task pool of the device it will return early from the BlenderSession::sync function while the reset is going on (tested in Session::resetting). Once all existing tasks have finished the do_cancel flag is finally cleared again (checked in TaskPool::num_decrease). Care has to be taken to avoid race conditions on the do_cancel flag, since it can now be modified outside the TaskPool::cancel function itself. For this purpose the scope of the TaskPool::num_mutex locks has been extended, in most cases the mutex is now locked by the TaskPool itself before calling TaskScheduler methods, instead of only locking inside the num_increase/num_decrease functions themselves. The only occurrence of a lock outside of the TaskPool methods is in TaskScheduler::thread_run. This patch is most useful in combination with the OSL renderer mode, so it can probably wait until after the 2.64 release. SVM tasks tend to be cancelled quickly, so the effect is less noticeable. |
Commit Details:
Full Hash: 31ed71cb6b86278eb5c15de65eb8e2ed800821e1
SVN Revision: 50528
Parent Commit: 2cdfa33
Lines Changed: +69, -16
9 Modified Paths:
/intern/cycles/blender/blender_session.cpp (+6, -0) (Diff)
/intern/cycles/device/device.h (+1, -0) (Diff)
/intern/cycles/device/device_cpu.cpp (+5, -0) (Diff)
/intern/cycles/device/device_cuda.cpp (+5, -0) (Diff)
/intern/cycles/device/device_multi.cpp (+8, -0) (Diff)
/intern/cycles/device/device_opencl.cpp (+5, -0) (Diff)
/intern/cycles/render/session.cpp (+19, -0) (Diff)
/intern/cycles/render/session.h (+3, -0) (Diff)
/intern/cycles/util/util_task.cpp (+17, -16) (Diff)
/intern/cycles/device/device.h (+1, -0) (Diff)
/intern/cycles/device/device_cpu.cpp (+5, -0) (Diff)
/intern/cycles/device/device_cuda.cpp (+5, -0) (Diff)
/intern/cycles/device/device_multi.cpp (+8, -0) (Diff)
/intern/cycles/device/device_opencl.cpp (+5, -0) (Diff)
/intern/cycles/render/session.cpp (+19, -0) (Diff)
/intern/cycles/render/session.h (+3, -0) (Diff)
/intern/cycles/util/util_task.cpp (+17, -16) (Diff)