[Mesa-dev] [PATCH] gallium/util: replace pipe_condvar with cnd_t
Timothy Arceri
tarceri at itsqueeze.com
Sun Mar 5 23:41:39 UTC 2017
pipe_condvar was made unnecessary with fd33a6bcd7f12.
Cc: Emil Velikov <emil.l.velikov at gmail.com>
---
src/gallium/auxiliary/os/os_thread.h | 8 ++------
src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c | 2 +-
src/gallium/auxiliary/util/u_queue.h | 6 +++---
src/gallium/auxiliary/util/u_ringbuffer.c | 2 +-
src/gallium/drivers/llvmpipe/lp_fence.h | 2 +-
src/gallium/drivers/rbug/rbug_context.h | 2 +-
src/gallium/state_trackers/nine/nine_queue.c | 4 ++--
src/gallium/state_trackers/nine/nine_state.c | 2 +-
8 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/src/gallium/auxiliary/os/os_thread.h b/src/gallium/auxiliary/os/os_thread.h
index ad2cda4..b15dd05 100644
--- a/src/gallium/auxiliary/os/os_thread.h
+++ b/src/gallium/auxiliary/os/os_thread.h
@@ -114,24 +114,20 @@ __pipe_mutex_assert_locked(mtx_t *mutex)
/* NOTE: this would not work for recursive mutexes, but
* mtx_t doesn't support those
*/
int ret = mtx_trylock(mutex);
assert(ret == thrd_busy);
if (ret == thrd_success)
mtx_unlock(mutex);
#endif
}
-/* pipe_condvar
- */
-typedef cnd_t pipe_condvar;
-
/*
* pipe_barrier
*/
#if (defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_HURD)) && !defined(PIPE_OS_ANDROID)
typedef pthread_barrier_t pipe_barrier;
static inline void pipe_barrier_init(pipe_barrier *barrier, unsigned count)
@@ -150,21 +146,21 @@ static inline void pipe_barrier_wait(pipe_barrier *barrier)
}
#else /* If the OS doesn't have its own, implement barriers using a mutex and a condvar */
typedef struct {
unsigned count;
unsigned waiters;
uint64_t sequence;
mtx_t mutex;
- pipe_condvar condvar;
+ cnd_t condvar;
} pipe_barrier;
static inline void pipe_barrier_init(pipe_barrier *barrier, unsigned count)
{
barrier->count = count;
barrier->waiters = 0;
barrier->sequence = 0;
(void) mtx_init(&barrier->mutex, mtx_plain);
cnd_init(&barrier->condvar);
}
@@ -202,21 +198,21 @@ static inline void pipe_barrier_wait(pipe_barrier *barrier)
#endif
/*
* Semaphores
*/
typedef struct
{
mtx_t mutex;
- pipe_condvar cond;
+ cnd_t cond;
int counter;
} pipe_semaphore;
static inline void
pipe_semaphore_init(pipe_semaphore *sema, int init_val)
{
(void) mtx_init(&sema->mutex, mtx_plain);
cnd_init(&sema->cond);
sema->counter = init_val;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
index a89236e..96c0683 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
@@ -64,21 +64,21 @@ struct pb_slab_buffer
struct list_head head;
unsigned mapCount;
/** Offset relative to the start of the slab buffer. */
pb_size start;
/** Use when validating, to signal that all mappings are finished */
/* TODO: Actually validation does not reach this stage yet */
- pipe_condvar event;
+ cnd_t event;
};
/**
* Slab -- a contiguous piece of memory.
*/
struct pb_slab
{
struct list_head head;
struct list_head freeBuffers;
diff --git a/src/gallium/auxiliary/util/u_queue.h b/src/gallium/auxiliary/util/u_queue.h
index 635545f..d62d87d 100644
--- a/src/gallium/auxiliary/util/u_queue.h
+++ b/src/gallium/auxiliary/util/u_queue.h
@@ -34,39 +34,39 @@
#define U_QUEUE_H
#include "os/os_thread.h"
#include "util/list.h"
/* Job completion fence.
* Put this into your job structure.
*/
struct util_queue_fence {
mtx_t mutex;
- pipe_condvar cond;
+ cnd_t cond;
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;
util_queue_execute_func cleanup;
};
/* Put this into your context. */
struct util_queue {
const char *name;
mtx_t lock;
- pipe_condvar has_queued_cond;
- pipe_condvar has_space_cond;
+ cnd_t has_queued_cond;
+ cnd_t has_space_cond;
thrd_t *threads;
int num_queued;
unsigned num_threads;
int kill_threads;
int max_jobs;
int write_idx, read_idx; /* ring buffer pointers */
struct util_queue_job *jobs;
/* for cleanup at exit(), protected by exit_mutex */
struct list_head head;
diff --git a/src/gallium/auxiliary/util/u_ringbuffer.c b/src/gallium/auxiliary/util/u_ringbuffer.c
index fd51f26..4d61668 100644
--- a/src/gallium/auxiliary/util/u_ringbuffer.c
+++ b/src/gallium/auxiliary/util/u_ringbuffer.c
@@ -9,21 +9,21 @@
*/
struct util_ringbuffer
{
struct util_packet *buf;
unsigned mask;
/* Can this be done with atomic variables??
*/
unsigned head;
unsigned tail;
- pipe_condvar change;
+ cnd_t change;
mtx_t mutex;
};
struct util_ringbuffer *util_ringbuffer_create( unsigned dwords )
{
struct util_ringbuffer *ring = CALLOC_STRUCT(util_ringbuffer);
if (!ring)
return NULL;
diff --git a/src/gallium/drivers/llvmpipe/lp_fence.h b/src/gallium/drivers/llvmpipe/lp_fence.h
index 4fc0801..b720264 100644
--- a/src/gallium/drivers/llvmpipe/lp_fence.h
+++ b/src/gallium/drivers/llvmpipe/lp_fence.h
@@ -37,21 +37,21 @@
struct pipe_screen;
struct lp_fence
{
struct pipe_reference reference;
unsigned id;
mtx_t mutex;
- pipe_condvar signalled;
+ cnd_t signalled;
boolean issued;
unsigned rank;
unsigned count;
};
struct lp_fence *
lp_fence_create(unsigned rank);
diff --git a/src/gallium/drivers/rbug/rbug_context.h b/src/gallium/drivers/rbug/rbug_context.h
index 6f11fa4..e89c6ea 100644
--- a/src/gallium/drivers/rbug/rbug_context.h
+++ b/src/gallium/drivers/rbug/rbug_context.h
@@ -52,21 +52,21 @@ struct rbug_context {
struct rbug_resource *texs[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_SAMPLER_VIEWS];
unsigned num_views[PIPE_SHADER_TYPES];
unsigned nr_cbufs;
struct rbug_resource *cbufs[PIPE_MAX_COLOR_BUFS];
struct rbug_resource *zsbuf;
} curr;
/* draw locking */
mtx_t draw_mutex;
- pipe_condvar draw_cond;
+ cnd_t draw_cond;
unsigned draw_num_rules;
int draw_blocker;
int draw_blocked;
struct {
struct rbug_shader *shader[PIPE_SHADER_TYPES];
struct rbug_resource *texture;
struct rbug_resource *surf;
diff --git a/src/gallium/state_trackers/nine/nine_queue.c b/src/gallium/state_trackers/nine/nine_queue.c
index 2a65a1e..7a85798 100644
--- a/src/gallium/state_trackers/nine/nine_queue.c
+++ b/src/gallium/state_trackers/nine/nine_queue.c
@@ -65,22 +65,22 @@ struct nine_cmdbuf {
void *mem_pool;
BOOL full;
};
struct nine_queue_pool {
struct nine_cmdbuf pool[NINE_CMD_BUFS];
unsigned head;
unsigned tail;
unsigned cur_instr;
BOOL worker_wait;
- pipe_condvar event_pop;
- pipe_condvar event_push;
+ cnd_t event_pop;
+ cnd_t event_push;
mtx_t mutex_pop;
mtx_t mutex_push;
};
/* Consumer functions: */
void
nine_queue_wait_flush(struct nine_queue_pool* ctx)
{
struct nine_cmdbuf *cmdbuf = &ctx->pool[ctx->tail];
diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
index bfceeee..e6d215a 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -56,21 +56,21 @@
/* Nine CSMT */
struct csmt_instruction {
int (* func)(struct NineDevice9 *This, struct csmt_instruction *instr);
};
struct csmt_context {
thrd_t worker;
struct nine_queue_pool* pool;
BOOL terminate;
- pipe_condvar event_processed;
+ cnd_t event_processed;
mtx_t mutex_processed;
struct NineDevice9 *device;
BOOL processed;
BOOL toPause;
BOOL hasPaused;
mtx_t thread_running;
mtx_t thread_resume;
};
/* Wait for instruction to be processed.
--
2.9.3
More information about the mesa-dev
mailing list