Revert r50528: "Performance fix for Cycles: Don't wait in the main UI thread when resetting devices."

This commit leads to random freezes in Cycles rendering:
https://projects.blender.org/tracker/index.php?func=detail&aid=32545&group_id=9&atid=498

The goal of this commit was to remove UI lag for OSL, but since that is not officially supported yet, better revert it until a proper fix can be implemented in 2.65.
This commit is contained in:
Lukas Toenne
2012-09-17 12:07:06 +00:00
parent aecb2f7039
commit efaf512406
9 changed files with 16 additions and 69 deletions

View File

@@ -372,12 +372,6 @@ void BlenderSession::synchronize()
return; return;
} }
/* if the session is still resetting the device come back later */
if(session->resetting()) {
tag_update();
return;
}
/* increase samples, but never decrease */ /* increase samples, but never decrease */
session->set_samples(session_params.samples); session->set_samples(session_params.samples);
session->set_pause(BlenderSync::get_session_pause(b_scene, background)); session->set_pause(BlenderSync::get_session_pause(b_scene, background));

View File

@@ -115,7 +115,6 @@ public:
virtual void task_add(DeviceTask& task) = 0; virtual void task_add(DeviceTask& task) = 0;
virtual void task_wait() = 0; virtual void task_wait() = 0;
virtual void task_cancel() = 0; virtual void task_cancel() = 0;
virtual bool task_cancelled() = 0;
/* opengl drawing */ /* opengl drawing */
virtual void draw_pixels(device_memory& mem, int y, int w, int h, virtual void draw_pixels(device_memory& mem, int y, int w, int h,

View File

@@ -273,11 +273,6 @@ public:
{ {
task_pool.cancel(); task_pool.cancel();
} }
bool task_cancelled()
{
return task_pool.cancelled();
}
}; };
Device *device_cpu_create(DeviceInfo& info, int threads) Device *device_cpu_create(DeviceInfo& info, int threads)

View File

@@ -892,11 +892,6 @@ public:
{ {
task_pool.cancel(); task_pool.cancel();
} }
bool task_cancelled()
{
return task_pool.cancelled();
}
}; };
Device *device_cuda_create(DeviceInfo& info, bool background) Device *device_cuda_create(DeviceInfo& info, bool background)

View File

@@ -312,14 +312,6 @@ public:
foreach(SubDevice& sub, devices) foreach(SubDevice& sub, devices)
sub.device->task_cancel(); sub.device->task_cancel();
} }
bool task_cancelled()
{
foreach(SubDevice& sub, devices)
if (sub.device->task_cancelled())
return true;
return false;
}
}; };
Device *device_multi_create(DeviceInfo& info, bool background) Device *device_multi_create(DeviceInfo& info, bool background)

View File

@@ -724,11 +724,6 @@ public:
{ {
task_pool.cancel(); task_pool.cancel();
} }
bool task_cancelled()
{
return task_pool.cancelled();
}
}; };
Device *device_opencl_create(DeviceInfo& info, bool background) Device *device_opencl_create(DeviceInfo& info, bool background)

View File

@@ -140,12 +140,6 @@ void Session::reset_gpu(BufferParams& buffer_params, int samples)
pause_cond.notify_all(); pause_cond.notify_all();
} }
bool Session::resetting_gpu() const
{
/* no need to wait for gpu device */
return false;
}
bool Session::draw_gpu(BufferParams& buffer_params) bool Session::draw_gpu(BufferParams& buffer_params)
{ {
/* block for buffer access */ /* block for buffer access */
@@ -296,11 +290,6 @@ void Session::reset_cpu(BufferParams& buffer_params, int samples)
pause_cond.notify_all(); pause_cond.notify_all();
} }
bool Session::resetting_cpu() const
{
return device->task_cancelled();
}
bool Session::draw_cpu(BufferParams& buffer_params) bool Session::draw_cpu(BufferParams& buffer_params)
{ {
thread_scoped_lock display_lock(display_mutex); thread_scoped_lock display_lock(display_mutex);
@@ -595,14 +584,6 @@ void Session::reset(BufferParams& buffer_params, int samples)
reset_cpu(buffer_params, samples); reset_cpu(buffer_params, samples);
} }
bool Session::resetting() const
{
if(device_use_gl)
return resetting_gpu();
else
return resetting_cpu();
}
void Session::set_samples(int samples) void Session::set_samples(int samples)
{ {
if(samples != params.samples) { if(samples != params.samples) {

View File

@@ -116,7 +116,6 @@ public:
bool ready_to_reset(); bool ready_to_reset();
void reset(BufferParams& params, int samples); void reset(BufferParams& params, int samples);
bool resetting() const;
void set_samples(int samples); void set_samples(int samples);
void set_pause(bool pause); void set_pause(bool pause);
@@ -140,12 +139,10 @@ protected:
void run_cpu(); void run_cpu();
bool draw_cpu(BufferParams& params); bool draw_cpu(BufferParams& params);
void reset_cpu(BufferParams& params, int samples); void reset_cpu(BufferParams& params, int samples);
bool resetting_cpu() const;
void run_gpu(); void run_gpu();
bool draw_gpu(BufferParams& params); bool draw_gpu(BufferParams& params);
void reset_gpu(BufferParams& params, int samples); void reset_gpu(BufferParams& params, int samples);
bool resetting_gpu() const;
bool acquire_tile(Device *tile_device, RenderTile& tile); bool acquire_tile(Device *tile_device, RenderTile& tile);
void update_tile_sample(RenderTile& tile); void update_tile_sample(RenderTile& tile);

View File

@@ -38,8 +38,6 @@ TaskPool::~TaskPool()
void TaskPool::push(Task *task, bool front) void TaskPool::push(Task *task, bool front)
{ {
thread_scoped_lock num_lock(num_mutex);
TaskScheduler::Entry entry; TaskScheduler::Entry entry;
entry.task = task; entry.task = task;
@@ -104,17 +102,22 @@ void TaskPool::wait_work()
void TaskPool::cancel() void TaskPool::cancel()
{ {
thread_scoped_lock num_lock(num_mutex);
do_cancel = true; do_cancel = true;
TaskScheduler::clear(this); TaskScheduler::clear(this);
{
thread_scoped_lock num_lock(num_mutex);
while(num)
num_cond.wait(num_lock);
}
do_cancel = false;
} }
void TaskPool::stop() void TaskPool::stop()
{ {
thread_scoped_lock num_lock(num_mutex);
TaskScheduler::clear(this); TaskScheduler::clear(this);
assert(num == 0); assert(num == 0);
@@ -127,20 +130,20 @@ bool TaskPool::cancelled()
void TaskPool::num_decrease(int done) void TaskPool::num_decrease(int done)
{ {
num_mutex.lock();
num -= done; num -= done;
assert(num >= 0); assert(num >= 0);
if(num == 0)
if(num == 0) {
do_cancel = false;
num_cond.notify_all(); num_cond.notify_all();
}
num_mutex.unlock();
} }
void TaskPool::num_increase() void TaskPool::num_increase()
{ {
thread_scoped_lock num_lock(num_mutex);
num++; num++;
num_cond.notify_all(); num_cond.notify_all();
} }
@@ -236,11 +239,7 @@ void TaskScheduler::thread_run(int thread_id)
delete entry.task; delete entry.task;
/* notify pool task was done */ /* notify pool task was done */
{ entry.pool->num_decrease(1);
/* not called from TaskPool, have to explicitly lock the mutex here */
thread_scoped_lock num_lock(entry.pool->num_mutex);
entry.pool->num_decrease(1);
}
} }
} }