summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/util
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2016-07-13 12:17:05 -0400
committerRob Clark <[email protected]>2016-07-16 10:00:04 -0400
commit44bbfedbd9983c61f6a461cbfe2e0dc74eda6d37 (patch)
tree54af9e04c52b8e9f2cedc72515bc13ba846fb8eb /src/gallium/auxiliary/util
parent6f73c7595fab450ae9fd1af67aaed322bca02ee0 (diff)
gallium/u_queue: add optional cleanup callback
Adds a second optional cleanup callback, called after the fence is signaled. This is needed if, for example, the queue has the last reference to the object that embeds the util_queue_fence. In this case we cannot drop the ref in the main callback, since that would result in the fence being destroyed before it is signaled. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r--src/gallium/auxiliary/util/u_queue.c6
-rw-r--r--src/gallium/auxiliary/util/u_queue.h6
2 files changed, 10 insertions, 2 deletions
diff --git a/src/gallium/auxiliary/util/u_queue.c b/src/gallium/auxiliary/util/u_queue.c
index ac3afa17773..838464fb9a6 100644
--- a/src/gallium/auxiliary/util/u_queue.c
+++ b/src/gallium/auxiliary/util/u_queue.c
@@ -91,6 +91,8 @@ static PIPE_THREAD_ROUTINE(util_queue_thread_func, input)
if (job.job) {
job.execute(job.job, thread_index);
util_queue_fence_signal(job.fence);
+ if (job.cleanup)
+ job.cleanup(job.job, thread_index);
}
}
@@ -213,7 +215,8 @@ void
util_queue_add_job(struct util_queue *queue,
void *job,
struct util_queue_fence *fence,
- util_queue_execute_func execute)
+ util_queue_execute_func execute,
+ util_queue_execute_func cleanup)
{
struct util_queue_job *ptr;
@@ -232,6 +235,7 @@ util_queue_add_job(struct util_queue *queue,
ptr->job = job;
ptr->fence = fence;
ptr->execute = execute;
+ ptr->cleanup = cleanup;
queue->write_idx = (queue->write_idx + 1) % queue->max_jobs;
queue->num_queued++;
diff --git a/src/gallium/auxiliary/util/u_queue.h b/src/gallium/auxiliary/util/u_queue.h
index f70d6466887..59646cc298b 100644
--- a/src/gallium/auxiliary/util/u_queue.h
+++ b/src/gallium/auxiliary/util/u_queue.h
@@ -50,6 +50,7 @@ struct util_queue_job {
void *job;
struct util_queue_fence *fence;
util_queue_execute_func execute;
+ util_queue_execute_func cleanup;
};
/* Put this into your context. */
@@ -75,10 +76,13 @@ void util_queue_destroy(struct util_queue *queue);
void util_queue_fence_init(struct util_queue_fence *fence);
void util_queue_fence_destroy(struct util_queue_fence *fence);
+/* optional cleanup callback is called after fence is signaled: */
void util_queue_add_job(struct util_queue *queue,
void *job,
struct util_queue_fence *fence,
- util_queue_execute_func execute);
+ util_queue_execute_func execute,
+ util_queue_execute_func cleanup);
+
void util_queue_job_wait(struct util_queue_fence *fence);
/* util_queue needs to be cleared to zeroes for this to work */