summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/llvmpipe/lp_rast.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2010-02-24 17:30:43 -0700
committerBrian Paul <[email protected]>2010-02-24 17:30:43 -0700
commitbc04ae21c10bedcc75d3483784d3eaf7bf090f55 (patch)
treead541dd3fb5fa4523e0990eea5e0bf20fd421b05 /src/gallium/drivers/llvmpipe/lp_rast.c
parent072aeb57bd20b5fc39cf9d46a693a1a9aa9de11e (diff)
llvmpipe: clean up rasterization threads upon context destruction
Fixes glean hang, bug 26536.
Diffstat (limited to 'src/gallium/drivers/llvmpipe/lp_rast.c')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_rast.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c
index 07817efd748..82c006d78b0 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast.c
@@ -826,6 +826,9 @@ static PIPE_THREAD_ROUTINE( thread_func, init_data )
debug_printf("thread %d waiting for work\n", task->thread_index);
pipe_semaphore_wait(&task->work_ready);
+ if (rast->exit_flag)
+ break;
+
if (task->thread_index == 0) {
/* thread[0]:
* - get next scene to rasterize
@@ -961,6 +964,20 @@ void lp_rast_destroy( struct lp_rasterizer *rast )
align_free(rast->tasks[i].tile.color[cbuf]);
}
+ /* Set exit_flag and signal each thread's work_ready semaphore.
+ * Each thread will be woken up, notice that the exit_flag is set and
+ * break out of its main loop. The thread will then exit.
+ */
+ rast->exit_flag = TRUE;
+ for (i = 0; i < rast->num_threads; i++) {
+ pipe_semaphore_signal(&rast->tasks[i].work_ready);
+ }
+
+ for (i = 0; i < rast->num_threads; i++) {
+ pipe_semaphore_destroy(&rast->tasks[i].work_ready);
+ pipe_semaphore_destroy(&rast->tasks[i].work_done);
+ }
+
/* for synchronizing rasterization threads */
pipe_barrier_destroy( &rast->barrier );