so that independent types of jobs can use the same queue.
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
}
job = queue->jobs[queue->read_idx];
- queue->jobs[queue->read_idx].job = NULL;
+ memset(&queue->jobs[queue->read_idx], 0, sizeof(struct util_queue_job));
queue->read_idx = (queue->read_idx + 1) % queue->max_jobs;
queue->num_queued--;
pipe_mutex_unlock(queue->lock);
if (job.job) {
- queue->execute_job(job.job, thread_index);
+ job.execute(job.job, thread_index);
util_queue_fence_signal(job.fence);
}
}
util_queue_init(struct util_queue *queue,
const char *name,
unsigned max_jobs,
- unsigned num_threads,
- void (*execute_job)(void *, int))
+ unsigned num_threads)
{
unsigned i;
if (!queue->jobs)
goto fail;
- queue->execute_job = execute_job;
pipe_mutex_init(queue->lock);
queue->num_queued = 0;
void
util_queue_add_job(struct util_queue *queue,
void *job,
- struct util_queue_fence *fence)
+ struct util_queue_fence *fence,
+ util_queue_execute_func execute)
{
struct util_queue_job *ptr;
assert(ptr->job == NULL);
ptr->job = job;
ptr->fence = fence;
+ ptr->execute = execute;
queue->write_idx = (queue->write_idx + 1) % queue->max_jobs;
queue->num_queued++;
int signalled;
};
+typedef void (*util_queue_execute_func)(void *job, int thread_index);
+
struct util_queue_job {
void *job;
struct util_queue_fence *fence;
+ util_queue_execute_func execute;
};
/* Put this into your context. */
int max_jobs;
int write_idx, read_idx; /* ring buffer pointers */
struct util_queue_job *jobs;
- void (*execute_job)(void *job, int thread_index);
};
bool util_queue_init(struct util_queue *queue,
const char *name,
unsigned max_jobs,
- unsigned num_threads,
- void (*execute_job)(void *, int));
+ unsigned num_threads);
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);
void util_queue_add_job(struct util_queue *queue,
void *job,
- struct util_queue_fence *fence);
+ struct util_queue_fence *fence,
+ util_queue_execute_func execute);
void util_queue_job_wait(struct util_queue_fence *fence);
/* util_queue needs to be cleared to zeroes for this to work */
/* Submit. */
if ((flags & RADEON_FLUSH_ASYNC) &&
util_queue_is_initialized(&ws->cs_queue)) {
- util_queue_add_job(&ws->cs_queue, cs, &cs->flush_completed);
+ util_queue_add_job(&ws->cs_queue, cs, &cs->flush_completed,
+ amdgpu_cs_submit_ib);
} else {
amdgpu_cs_submit_ib(cs, 0);
}
pipe_mutex_init(ws->bo_fence_lock);
if (sysconf(_SC_NPROCESSORS_ONLN) > 1 && debug_get_option_thread())
- util_queue_init(&ws->cs_queue, "amdgpu_cs", 8, 1, amdgpu_cs_submit_ib);
+ util_queue_init(&ws->cs_queue, "amdgpu_cs", 8, 1);
/* Create the screen at the end. The winsys must be initialized
* completely.
}
if (util_queue_is_initialized(&cs->ws->cs_queue)) {
- util_queue_add_job(&cs->ws->cs_queue, cs, &cs->flush_completed);
+ util_queue_add_job(&cs->ws->cs_queue, cs, &cs->flush_completed,
+ radeon_drm_cs_emit_ioctl_oneshot);
if (!(flags & RADEON_FLUSH_ASYNC))
radeon_drm_cs_sync_flush(rcs);
} else {
ws->info.gart_page_size = sysconf(_SC_PAGESIZE);
if (ws->num_cpus > 1 && debug_get_option_thread())
- util_queue_init(&ws->cs_queue, "radeon_cs", 8, 1,
- radeon_drm_cs_emit_ioctl_oneshot);
+ util_queue_init(&ws->cs_queue, "radeon_cs", 8, 1);
/* Create the screen at the end. The winsys must be initialized
* completely.