gallium: thread wrapper clean-up
In p_thread.h replace _glthread_* functions with new pipe_* functions. Remove other old cruft.
This commit is contained in:
@@ -69,7 +69,7 @@
|
|||||||
|
|
||||||
struct fenced_buffer_list
|
struct fenced_buffer_list
|
||||||
{
|
{
|
||||||
_glthread_Mutex mutex;
|
pipe_mutex mutex;
|
||||||
|
|
||||||
struct pipe_winsys *winsys;
|
struct pipe_winsys *winsys;
|
||||||
|
|
||||||
@@ -240,7 +240,7 @@ fenced_buffer_destroy(struct pb_buffer *buf)
|
|||||||
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
|
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
|
||||||
struct fenced_buffer_list *fenced_list = fenced_buf->list;
|
struct fenced_buffer_list *fenced_list = fenced_buf->list;
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(fenced_list->mutex);
|
pipe_mutex_lock(fenced_list->mutex);
|
||||||
assert(fenced_buf->base.base.refcount == 0);
|
assert(fenced_buf->base.base.refcount == 0);
|
||||||
if (fenced_buf->fence) {
|
if (fenced_buf->fence) {
|
||||||
struct pipe_winsys *winsys = fenced_list->winsys;
|
struct pipe_winsys *winsys = fenced_list->winsys;
|
||||||
@@ -263,7 +263,7 @@ fenced_buffer_destroy(struct pb_buffer *buf)
|
|||||||
else {
|
else {
|
||||||
_fenced_buffer_destroy(fenced_buf);
|
_fenced_buffer_destroy(fenced_buf);
|
||||||
}
|
}
|
||||||
_glthread_UNLOCK_MUTEX(fenced_list->mutex);
|
pipe_mutex_unlock(fenced_list->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -396,7 +396,7 @@ buffer_fence(struct pb_buffer *buf,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(fenced_list->mutex);
|
pipe_mutex_lock(fenced_list->mutex);
|
||||||
if (fenced_buf->fence)
|
if (fenced_buf->fence)
|
||||||
_fenced_buffer_remove(fenced_list, fenced_buf);
|
_fenced_buffer_remove(fenced_list, fenced_buf);
|
||||||
if (fence) {
|
if (fence) {
|
||||||
@@ -404,7 +404,7 @@ buffer_fence(struct pb_buffer *buf,
|
|||||||
fenced_buf->flags |= flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE;
|
fenced_buf->flags |= flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE;
|
||||||
_fenced_buffer_add(fenced_buf);
|
_fenced_buffer_add(fenced_buf);
|
||||||
}
|
}
|
||||||
_glthread_UNLOCK_MUTEX(fenced_list->mutex);
|
pipe_mutex_unlock(fenced_list->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -423,7 +423,7 @@ fenced_buffer_list_create(struct pipe_winsys *winsys)
|
|||||||
|
|
||||||
fenced_list->numDelayed = 0;
|
fenced_list->numDelayed = 0;
|
||||||
|
|
||||||
_glthread_INIT_MUTEX(fenced_list->mutex);
|
pipe_mutex_init(fenced_list->mutex);
|
||||||
|
|
||||||
return fenced_list;
|
return fenced_list;
|
||||||
}
|
}
|
||||||
@@ -433,28 +433,28 @@ void
|
|||||||
fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
|
fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
|
||||||
int wait)
|
int wait)
|
||||||
{
|
{
|
||||||
_glthread_LOCK_MUTEX(fenced_list->mutex);
|
pipe_mutex_lock(fenced_list->mutex);
|
||||||
_fenced_buffer_list_check_free(fenced_list, wait);
|
_fenced_buffer_list_check_free(fenced_list, wait);
|
||||||
_glthread_UNLOCK_MUTEX(fenced_list->mutex);
|
pipe_mutex_unlock(fenced_list->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list)
|
fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list)
|
||||||
{
|
{
|
||||||
_glthread_LOCK_MUTEX(fenced_list->mutex);
|
pipe_mutex_lock(fenced_list->mutex);
|
||||||
|
|
||||||
/* Wait on outstanding fences */
|
/* Wait on outstanding fences */
|
||||||
while (fenced_list->numDelayed) {
|
while (fenced_list->numDelayed) {
|
||||||
_glthread_UNLOCK_MUTEX(fenced_list->mutex);
|
pipe_mutex_unlock(fenced_list->mutex);
|
||||||
#if defined(PIPE_OS_LINUX)
|
#if defined(PIPE_OS_LINUX)
|
||||||
sched_yield();
|
sched_yield();
|
||||||
#endif
|
#endif
|
||||||
_fenced_buffer_list_check_free(fenced_list, 1);
|
_fenced_buffer_list_check_free(fenced_list, 1);
|
||||||
_glthread_LOCK_MUTEX(fenced_list->mutex);
|
pipe_mutex_lock(fenced_list->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
_glthread_UNLOCK_MUTEX(fenced_list->mutex);
|
pipe_mutex_unlock(fenced_list->mutex);
|
||||||
|
|
||||||
FREE(fenced_list);
|
FREE(fenced_list);
|
||||||
}
|
}
|
||||||
|
@@ -79,7 +79,7 @@ struct pb_cache_manager
|
|||||||
struct pb_manager *provider;
|
struct pb_manager *provider;
|
||||||
unsigned usecs;
|
unsigned usecs;
|
||||||
|
|
||||||
_glthread_Mutex mutex;
|
pipe_mutex mutex;
|
||||||
|
|
||||||
struct list_head delayed;
|
struct list_head delayed;
|
||||||
size_t numDelayed;
|
size_t numDelayed;
|
||||||
@@ -153,7 +153,7 @@ pb_cache_buffer_destroy(struct pb_buffer *_buf)
|
|||||||
struct pb_cache_buffer *buf = pb_cache_buffer(_buf);
|
struct pb_cache_buffer *buf = pb_cache_buffer(_buf);
|
||||||
struct pb_cache_manager *mgr = buf->mgr;
|
struct pb_cache_manager *mgr = buf->mgr;
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(mgr->mutex);
|
pipe_mutex_lock(mgr->mutex);
|
||||||
assert(buf->base.base.refcount == 0);
|
assert(buf->base.base.refcount == 0);
|
||||||
|
|
||||||
_pb_cache_buffer_list_check_free(mgr);
|
_pb_cache_buffer_list_check_free(mgr);
|
||||||
@@ -162,7 +162,7 @@ pb_cache_buffer_destroy(struct pb_buffer *_buf)
|
|||||||
util_time_add(&buf->start, mgr->usecs, &buf->end);
|
util_time_add(&buf->start, mgr->usecs, &buf->end);
|
||||||
LIST_ADDTAIL(&buf->head, &mgr->delayed);
|
LIST_ADDTAIL(&buf->head, &mgr->delayed);
|
||||||
++mgr->numDelayed;
|
++mgr->numDelayed;
|
||||||
_glthread_UNLOCK_MUTEX(mgr->mutex);
|
pipe_mutex_unlock(mgr->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -235,7 +235,7 @@ pb_cache_manager_create_buffer(struct pb_manager *_mgr,
|
|||||||
struct list_head *curr, *next;
|
struct list_head *curr, *next;
|
||||||
struct util_time now;
|
struct util_time now;
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(mgr->mutex);
|
pipe_mutex_lock(mgr->mutex);
|
||||||
|
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
curr = mgr->delayed.next;
|
curr = mgr->delayed.next;
|
||||||
@@ -264,12 +264,12 @@ pb_cache_manager_create_buffer(struct pb_manager *_mgr,
|
|||||||
|
|
||||||
if(buf) {
|
if(buf) {
|
||||||
LIST_DEL(&buf->head);
|
LIST_DEL(&buf->head);
|
||||||
_glthread_UNLOCK_MUTEX(mgr->mutex);
|
pipe_mutex_unlock(mgr->mutex);
|
||||||
++buf->base.base.refcount;
|
++buf->base.base.refcount;
|
||||||
return &buf->base;
|
return &buf->base;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glthread_UNLOCK_MUTEX(mgr->mutex);
|
pipe_mutex_unlock(mgr->mutex);
|
||||||
|
|
||||||
buf = CALLOC_STRUCT(pb_cache_buffer);
|
buf = CALLOC_STRUCT(pb_cache_buffer);
|
||||||
if(!buf)
|
if(!buf)
|
||||||
@@ -305,7 +305,7 @@ pb_cache_flush(struct pb_manager *_mgr)
|
|||||||
struct list_head *curr, *next;
|
struct list_head *curr, *next;
|
||||||
struct pb_cache_buffer *buf;
|
struct pb_cache_buffer *buf;
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(mgr->mutex);
|
pipe_mutex_lock(mgr->mutex);
|
||||||
curr = mgr->delayed.next;
|
curr = mgr->delayed.next;
|
||||||
next = curr->next;
|
next = curr->next;
|
||||||
while(curr != &mgr->delayed) {
|
while(curr != &mgr->delayed) {
|
||||||
@@ -314,7 +314,7 @@ pb_cache_flush(struct pb_manager *_mgr)
|
|||||||
curr = next;
|
curr = next;
|
||||||
next = curr->next;
|
next = curr->next;
|
||||||
}
|
}
|
||||||
_glthread_UNLOCK_MUTEX(mgr->mutex);
|
pipe_mutex_unlock(mgr->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -345,7 +345,7 @@ pb_cache_manager_create(struct pb_manager *provider,
|
|||||||
mgr->usecs = usecs;
|
mgr->usecs = usecs;
|
||||||
LIST_INITHEAD(&mgr->delayed);
|
LIST_INITHEAD(&mgr->delayed);
|
||||||
mgr->numDelayed = 0;
|
mgr->numDelayed = 0;
|
||||||
_glthread_INIT_MUTEX(mgr->mutex);
|
pipe_mutex_init(mgr->mutex);
|
||||||
|
|
||||||
return &mgr->base;
|
return &mgr->base;
|
||||||
}
|
}
|
||||||
|
@@ -53,7 +53,7 @@ struct mm_pb_manager
|
|||||||
{
|
{
|
||||||
struct pb_manager base;
|
struct pb_manager base;
|
||||||
|
|
||||||
_glthread_Mutex mutex;
|
pipe_mutex mutex;
|
||||||
|
|
||||||
size_t size;
|
size_t size;
|
||||||
struct mem_block *heap;
|
struct mem_block *heap;
|
||||||
@@ -99,10 +99,10 @@ mm_buffer_destroy(struct pb_buffer *buf)
|
|||||||
|
|
||||||
assert(buf->base.refcount == 0);
|
assert(buf->base.refcount == 0);
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(mm->mutex);
|
pipe_mutex_lock(mm->mutex);
|
||||||
mmFreeMem(mm_buf->block);
|
mmFreeMem(mm_buf->block);
|
||||||
FREE(buf);
|
FREE(buf);
|
||||||
_glthread_UNLOCK_MUTEX(mm->mutex);
|
pipe_mutex_unlock(mm->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -158,11 +158,11 @@ mm_bufmgr_create_buffer(struct pb_manager *mgr,
|
|||||||
if(desc->alignment % (1 << mm->align2))
|
if(desc->alignment % (1 << mm->align2))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(mm->mutex);
|
pipe_mutex_lock(mm->mutex);
|
||||||
|
|
||||||
mm_buf = CALLOC_STRUCT(mm_buffer);
|
mm_buf = CALLOC_STRUCT(mm_buffer);
|
||||||
if (!mm_buf) {
|
if (!mm_buf) {
|
||||||
_glthread_UNLOCK_MUTEX(mm->mutex);
|
pipe_mutex_unlock(mm->mutex);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,7 +185,7 @@ mm_bufmgr_create_buffer(struct pb_manager *mgr,
|
|||||||
mm_buf->block = mmAllocMem(mm->heap, size, mm->align2, 0);
|
mm_buf->block = mmAllocMem(mm->heap, size, mm->align2, 0);
|
||||||
if(!mm_buf->block) {
|
if(!mm_buf->block) {
|
||||||
FREE(mm_buf);
|
FREE(mm_buf);
|
||||||
_glthread_UNLOCK_MUTEX(mm->mutex);
|
pipe_mutex_unlock(mm->mutex);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -194,7 +194,7 @@ mm_bufmgr_create_buffer(struct pb_manager *mgr,
|
|||||||
assert(0 <= (unsigned)mm_buf->block->ofs && (unsigned)mm_buf->block->ofs < mm->size);
|
assert(0 <= (unsigned)mm_buf->block->ofs && (unsigned)mm_buf->block->ofs < mm->size);
|
||||||
assert(size <= (unsigned)mm_buf->block->size && (unsigned)mm_buf->block->ofs + (unsigned)mm_buf->block->size <= mm->size);
|
assert(size <= (unsigned)mm_buf->block->size && (unsigned)mm_buf->block->ofs + (unsigned)mm_buf->block->size <= mm->size);
|
||||||
|
|
||||||
_glthread_UNLOCK_MUTEX(mm->mutex);
|
pipe_mutex_unlock(mm->mutex);
|
||||||
return SUPER(mm_buf);
|
return SUPER(mm_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,14 +204,14 @@ mm_bufmgr_destroy(struct pb_manager *mgr)
|
|||||||
{
|
{
|
||||||
struct mm_pb_manager *mm = mm_pb_manager(mgr);
|
struct mm_pb_manager *mm = mm_pb_manager(mgr);
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(mm->mutex);
|
pipe_mutex_lock(mm->mutex);
|
||||||
|
|
||||||
mmDestroy(mm->heap);
|
mmDestroy(mm->heap);
|
||||||
|
|
||||||
pb_unmap(mm->buffer);
|
pb_unmap(mm->buffer);
|
||||||
pb_reference(&mm->buffer, NULL);
|
pb_reference(&mm->buffer, NULL);
|
||||||
|
|
||||||
_glthread_UNLOCK_MUTEX(mm->mutex);
|
pipe_mutex_unlock(mm->mutex);
|
||||||
|
|
||||||
FREE(mgr);
|
FREE(mgr);
|
||||||
}
|
}
|
||||||
@@ -236,7 +236,7 @@ mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
|
|||||||
mm->size = size;
|
mm->size = size;
|
||||||
mm->align2 = align2; /* 64-byte alignment */
|
mm->align2 = align2; /* 64-byte alignment */
|
||||||
|
|
||||||
_glthread_INIT_MUTEX(mm->mutex);
|
pipe_mutex_init(mm->mutex);
|
||||||
|
|
||||||
mm->buffer = buffer;
|
mm->buffer = buffer;
|
||||||
|
|
||||||
|
@@ -56,7 +56,7 @@ struct pool_pb_manager
|
|||||||
{
|
{
|
||||||
struct pb_manager base;
|
struct pb_manager base;
|
||||||
|
|
||||||
_glthread_Mutex mutex;
|
pipe_mutex mutex;
|
||||||
|
|
||||||
size_t bufSize;
|
size_t bufSize;
|
||||||
size_t bufAlign;
|
size_t bufAlign;
|
||||||
@@ -110,10 +110,10 @@ pool_buffer_destroy(struct pb_buffer *buf)
|
|||||||
|
|
||||||
assert(pool_buf->base.base.refcount == 0);
|
assert(pool_buf->base.base.refcount == 0);
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(pool->mutex);
|
pipe_mutex_lock(pool->mutex);
|
||||||
LIST_ADD(&pool_buf->head, &pool->free);
|
LIST_ADD(&pool_buf->head, &pool->free);
|
||||||
pool->numFree++;
|
pool->numFree++;
|
||||||
_glthread_UNLOCK_MUTEX(pool->mutex);
|
pipe_mutex_unlock(pool->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -124,9 +124,9 @@ pool_buffer_map(struct pb_buffer *buf, unsigned flags)
|
|||||||
struct pool_pb_manager *pool = pool_buf->mgr;
|
struct pool_pb_manager *pool = pool_buf->mgr;
|
||||||
void *map;
|
void *map;
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(pool->mutex);
|
pipe_mutex_lock(pool->mutex);
|
||||||
map = (unsigned char *) pool->map + pool_buf->start;
|
map = (unsigned char *) pool->map + pool_buf->start;
|
||||||
_glthread_UNLOCK_MUTEX(pool->mutex);
|
pipe_mutex_unlock(pool->mutex);
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,10 +171,10 @@ pool_bufmgr_create_buffer(struct pb_manager *mgr,
|
|||||||
assert(size == pool->bufSize);
|
assert(size == pool->bufSize);
|
||||||
assert(pool->bufAlign % desc->alignment == 0);
|
assert(pool->bufAlign % desc->alignment == 0);
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(pool->mutex);
|
pipe_mutex_lock(pool->mutex);
|
||||||
|
|
||||||
if (pool->numFree == 0) {
|
if (pool->numFree == 0) {
|
||||||
_glthread_UNLOCK_MUTEX(pool->mutex);
|
pipe_mutex_unlock(pool->mutex);
|
||||||
debug_printf("warning: out of fixed size buffer objects\n");
|
debug_printf("warning: out of fixed size buffer objects\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -182,7 +182,7 @@ pool_bufmgr_create_buffer(struct pb_manager *mgr,
|
|||||||
item = pool->free.next;
|
item = pool->free.next;
|
||||||
|
|
||||||
if (item == &pool->free) {
|
if (item == &pool->free) {
|
||||||
_glthread_UNLOCK_MUTEX(pool->mutex);
|
pipe_mutex_unlock(pool->mutex);
|
||||||
debug_printf("error: fixed size buffer pool corruption\n");
|
debug_printf("error: fixed size buffer pool corruption\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -190,7 +190,7 @@ pool_bufmgr_create_buffer(struct pb_manager *mgr,
|
|||||||
LIST_DEL(item);
|
LIST_DEL(item);
|
||||||
--pool->numFree;
|
--pool->numFree;
|
||||||
|
|
||||||
_glthread_UNLOCK_MUTEX(pool->mutex);
|
pipe_mutex_unlock(pool->mutex);
|
||||||
|
|
||||||
pool_buf = LIST_ENTRY(struct pool_buffer, item, head);
|
pool_buf = LIST_ENTRY(struct pool_buffer, item, head);
|
||||||
assert(pool_buf->base.base.refcount == 0);
|
assert(pool_buf->base.base.refcount == 0);
|
||||||
@@ -206,14 +206,14 @@ static void
|
|||||||
pool_bufmgr_destroy(struct pb_manager *mgr)
|
pool_bufmgr_destroy(struct pb_manager *mgr)
|
||||||
{
|
{
|
||||||
struct pool_pb_manager *pool = pool_pb_manager(mgr);
|
struct pool_pb_manager *pool = pool_pb_manager(mgr);
|
||||||
_glthread_LOCK_MUTEX(pool->mutex);
|
pipe_mutex_lock(pool->mutex);
|
||||||
|
|
||||||
FREE(pool->bufs);
|
FREE(pool->bufs);
|
||||||
|
|
||||||
pb_unmap(pool->buffer);
|
pb_unmap(pool->buffer);
|
||||||
pb_reference(&pool->buffer, NULL);
|
pb_reference(&pool->buffer, NULL);
|
||||||
|
|
||||||
_glthread_UNLOCK_MUTEX(pool->mutex);
|
pipe_mutex_unlock(pool->mutex);
|
||||||
|
|
||||||
FREE(mgr);
|
FREE(mgr);
|
||||||
}
|
}
|
||||||
@@ -246,7 +246,7 @@ pool_bufmgr_create(struct pb_manager *provider,
|
|||||||
pool->bufSize = bufSize;
|
pool->bufSize = bufSize;
|
||||||
pool->bufAlign = desc->alignment;
|
pool->bufAlign = desc->alignment;
|
||||||
|
|
||||||
_glthread_INIT_MUTEX(pool->mutex);
|
pipe_mutex_init(pool->mutex);
|
||||||
|
|
||||||
pool->buffer = provider->create_buffer(provider, numBufs*bufSize, desc);
|
pool->buffer = provider->create_buffer(provider, numBufs*bufSize, desc);
|
||||||
if (!pool->buffer)
|
if (!pool->buffer)
|
||||||
|
@@ -57,7 +57,7 @@ struct pb_slab_buffer
|
|||||||
struct list_head head;
|
struct list_head head;
|
||||||
unsigned mapCount;
|
unsigned mapCount;
|
||||||
size_t start;
|
size_t start;
|
||||||
_glthread_Cond event;
|
pipe_condvar event;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct pb_slab
|
struct pb_slab
|
||||||
@@ -85,7 +85,7 @@ struct pb_slab_manager
|
|||||||
struct list_head slabs;
|
struct list_head slabs;
|
||||||
struct list_head freeSlabs;
|
struct list_head freeSlabs;
|
||||||
|
|
||||||
_glthread_Mutex mutex;
|
pipe_mutex mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -143,7 +143,7 @@ pb_slab_buffer_destroy(struct pb_buffer *_buf)
|
|||||||
struct pb_slab_manager *mgr = slab->mgr;
|
struct pb_slab_manager *mgr = slab->mgr;
|
||||||
struct list_head *list = &buf->head;
|
struct list_head *list = &buf->head;
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(mgr->mutex);
|
pipe_mutex_lock(mgr->mutex);
|
||||||
|
|
||||||
assert(buf->base.base.refcount == 0);
|
assert(buf->base.base.refcount == 0);
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ pb_slab_buffer_destroy(struct pb_buffer *_buf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_glthread_UNLOCK_MUTEX(mgr->mutex);
|
pipe_mutex_unlock(mgr->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ pb_slab_buffer_unmap(struct pb_buffer *_buf)
|
|||||||
|
|
||||||
--buf->mapCount;
|
--buf->mapCount;
|
||||||
if (buf->mapCount == 0)
|
if (buf->mapCount == 0)
|
||||||
_glthread_COND_BROADCAST(buf->event);
|
pipe_condvar_broadcast(buf->event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -283,7 +283,7 @@ pb_slab_create(struct pb_slab_manager *mgr)
|
|||||||
buf->slab = slab;
|
buf->slab = slab;
|
||||||
buf->start = i* mgr->bufSize;
|
buf->start = i* mgr->bufSize;
|
||||||
buf->mapCount = 0;
|
buf->mapCount = 0;
|
||||||
_glthread_INIT_COND(buf->event);
|
pipe_condvar_init(buf->event);
|
||||||
LIST_ADDTAIL(&buf->head, &slab->freeBuffers);
|
LIST_ADDTAIL(&buf->head, &slab->freeBuffers);
|
||||||
slab->numFree++;
|
slab->numFree++;
|
||||||
buf++;
|
buf++;
|
||||||
@@ -328,11 +328,11 @@ pb_slab_manager_create_buffer(struct pb_manager *_mgr,
|
|||||||
if(!pb_check_usage(desc->usage, mgr->desc.usage))
|
if(!pb_check_usage(desc->usage, mgr->desc.usage))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(mgr->mutex);
|
pipe_mutex_lock(mgr->mutex);
|
||||||
if (mgr->slabs.next == &mgr->slabs) {
|
if (mgr->slabs.next == &mgr->slabs) {
|
||||||
(void) pb_slab_create(mgr);
|
(void) pb_slab_create(mgr);
|
||||||
if (mgr->slabs.next == &mgr->slabs) {
|
if (mgr->slabs.next == &mgr->slabs) {
|
||||||
_glthread_UNLOCK_MUTEX(mgr->mutex);
|
pipe_mutex_unlock(mgr->mutex);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -344,7 +344,7 @@ pb_slab_manager_create_buffer(struct pb_manager *_mgr,
|
|||||||
list = slab->freeBuffers.next;
|
list = slab->freeBuffers.next;
|
||||||
LIST_DELINIT(list);
|
LIST_DELINIT(list);
|
||||||
|
|
||||||
_glthread_UNLOCK_MUTEX(mgr->mutex);
|
pipe_mutex_unlock(mgr->mutex);
|
||||||
buf = LIST_ENTRY(struct pb_slab_buffer, list, head);
|
buf = LIST_ENTRY(struct pb_slab_buffer, list, head);
|
||||||
|
|
||||||
++buf->base.base.refcount;
|
++buf->base.base.refcount;
|
||||||
@@ -388,7 +388,7 @@ pb_slab_manager_create(struct pb_manager *provider,
|
|||||||
LIST_INITHEAD(&mgr->slabs);
|
LIST_INITHEAD(&mgr->slabs);
|
||||||
LIST_INITHEAD(&mgr->freeSlabs);
|
LIST_INITHEAD(&mgr->freeSlabs);
|
||||||
|
|
||||||
_glthread_INIT_MUTEX(mgr->mutex);
|
pipe_mutex_init(mgr->mutex);
|
||||||
|
|
||||||
return &mgr->base;
|
return &mgr->base;
|
||||||
}
|
}
|
||||||
|
@@ -47,11 +47,12 @@
|
|||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#include "pipe/p_thread.h"
|
||||||
#include "util/u_mm.h"
|
#include "util/u_mm.h"
|
||||||
|
|
||||||
#define EXEC_HEAP_SIZE (10*1024*1024)
|
#define EXEC_HEAP_SIZE (10*1024*1024)
|
||||||
|
|
||||||
_glthread_DECLARE_STATIC_MUTEX(exec_mutex);
|
pipe_static_mutex(exec_mutex);
|
||||||
|
|
||||||
static struct mem_block *exec_heap = NULL;
|
static struct mem_block *exec_heap = NULL;
|
||||||
static unsigned char *exec_mem = NULL;
|
static unsigned char *exec_mem = NULL;
|
||||||
@@ -76,7 +77,7 @@ rtasm_exec_malloc(size_t size)
|
|||||||
struct mem_block *block = NULL;
|
struct mem_block *block = NULL;
|
||||||
void *addr = NULL;
|
void *addr = NULL;
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(exec_mutex);
|
pipe_mutex_lock(exec_mutex);
|
||||||
|
|
||||||
init_heap();
|
init_heap();
|
||||||
|
|
||||||
@@ -90,7 +91,7 @@ rtasm_exec_malloc(size_t size)
|
|||||||
else
|
else
|
||||||
debug_printf("rtasm_exec_malloc failed\n");
|
debug_printf("rtasm_exec_malloc failed\n");
|
||||||
|
|
||||||
_glthread_UNLOCK_MUTEX(exec_mutex);
|
pipe_mutex_unlock(exec_mutex);
|
||||||
|
|
||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
@@ -99,7 +100,7 @@ rtasm_exec_malloc(size_t size)
|
|||||||
void
|
void
|
||||||
rtasm_exec_free(void *addr)
|
rtasm_exec_free(void *addr)
|
||||||
{
|
{
|
||||||
_glthread_LOCK_MUTEX(exec_mutex);
|
pipe_mutex_lock(exec_mutex);
|
||||||
|
|
||||||
if (exec_heap) {
|
if (exec_heap) {
|
||||||
struct mem_block *block = mmFindBlock(exec_heap, (unsigned char *)addr - exec_mem);
|
struct mem_block *block = mmFindBlock(exec_heap, (unsigned char *)addr - exec_mem);
|
||||||
@@ -108,7 +109,7 @@ rtasm_exec_free(void *addr)
|
|||||||
mmFreeMem(block);
|
mmFreeMem(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
_glthread_UNLOCK_MUTEX(exec_mutex);
|
pipe_mutex_unlock(exec_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -23,307 +23,199 @@
|
|||||||
*
|
*
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file
|
* Thread, mutex, condition var and thread-specific data functions.
|
||||||
* Thread
|
|
||||||
*
|
|
||||||
* Initial version by John Stone (j.stone@acm.org) (johns@cs.umr.edu)
|
|
||||||
* and Christoph Poliwoda (poliwoda@volumegraphics.com)
|
|
||||||
* Revised by Keith Whitwell
|
|
||||||
* Adapted for new gl dispatcher by Brian Paul
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* DOCUMENTATION
|
|
||||||
*
|
|
||||||
* This thread module exports the following types:
|
|
||||||
* _glthread_TSD Thread-specific data area
|
|
||||||
* _glthread_Thread Thread datatype
|
|
||||||
* _glthread_Mutex Mutual exclusion lock
|
|
||||||
*
|
|
||||||
* Macros:
|
|
||||||
* _glthread_DECLARE_STATIC_MUTEX(name) Declare a non-local mutex
|
|
||||||
* _glthread_INIT_MUTEX(name) Initialize a mutex
|
|
||||||
* _glthread_LOCK_MUTEX(name) Lock a mutex
|
|
||||||
* _glthread_UNLOCK_MUTEX(name) Unlock a mutex
|
|
||||||
*
|
|
||||||
* Functions:
|
|
||||||
* _glthread_GetID(v) Get integer thread ID
|
|
||||||
* _glthread_InitTSD() Initialize thread-specific data
|
|
||||||
* _glthread_GetTSD() Get thread-specific data
|
|
||||||
* _glthread_SetTSD() Set thread-specific data
|
|
||||||
*
|
|
||||||
* If this file is accidentally included by a non-threaded build,
|
|
||||||
* it should not cause the build to fail, or otherwise cause problems.
|
|
||||||
* In general, it should only be included when needed however.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _P_THREAD_H_
|
|
||||||
#define _P_THREAD_H_
|
#ifndef _P_THREAD2_H_
|
||||||
|
#define _P_THREAD2_H_
|
||||||
|
|
||||||
|
|
||||||
#if (defined(PTHREADS) || defined(SOLARIS_THREADS) ||\
|
#include "pipe/p_compiler.h"
|
||||||
defined(WIN32_THREADS) || defined(USE_XTHREADS) || defined(BEOS_THREADS)) \
|
|
||||||
&& !defined(THREADS)
|
|
||||||
# define THREADS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef VMS
|
|
||||||
#include <GL/vms_x_fix.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
#if defined(PIPE_OS_LINUX)
|
||||||
* POSIX threads. This should be your choice in the Unix world
|
|
||||||
* whenever possible. When building with POSIX threads, be sure
|
|
||||||
* to enable any compiler flags which will cause the MT-safe
|
|
||||||
* libc (if one exists) to be used when linking, as well as any
|
|
||||||
* header macros for MT-safe errno, etc. For Solaris, this is the -mt
|
|
||||||
* compiler flag. On Solaris with gcc, use -D_REENTRANT to enable
|
|
||||||
* proper compiling for MT-safe libc etc.
|
|
||||||
*/
|
|
||||||
#if defined(PTHREADS)
|
|
||||||
#include <pthread.h> /* POSIX threads headers */
|
#include <pthread.h> /* POSIX threads headers */
|
||||||
|
#include <stdio.h> /* for perror() */
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
pthread_key_t key;
|
|
||||||
int initMagic;
|
|
||||||
} _glthread_TSD;
|
|
||||||
|
|
||||||
typedef pthread_t _glthread_Thread;
|
typedef pthread_t pipe_thread;
|
||||||
|
typedef pthread_mutex_t pipe_mutex;
|
||||||
|
typedef pthread_cond_t pipe_condvar;
|
||||||
|
|
||||||
typedef pthread_mutex_t _glthread_Mutex;
|
#define pipe_static_mutex(mutex) \
|
||||||
|
static pipe_mutex mutex = PTHREAD_MUTEX_INITIALIZER
|
||||||
|
|
||||||
#define _glthread_DECLARE_STATIC_MUTEX(name) \
|
#define pipe_mutex_init(mutex) \
|
||||||
static _glthread_Mutex name = PTHREAD_MUTEX_INITIALIZER
|
pthread_mutex_init(&(mutex), NULL)
|
||||||
|
|
||||||
#define _glthread_INIT_MUTEX(name) \
|
#define pipe_mutex_destroy(mutex) \
|
||||||
pthread_mutex_init(&(name), NULL)
|
pthread_mutex_destroy(&(mutex))
|
||||||
|
|
||||||
#define _glthread_DESTROY_MUTEX(name) \
|
#define pipe_mutex_lock(mutex) \
|
||||||
pthread_mutex_destroy(&(name))
|
(void) pthread_mutex_lock(&(mutex))
|
||||||
|
|
||||||
#define _glthread_LOCK_MUTEX(name) \
|
#define pipe_mutex_unlock(mutex) \
|
||||||
(void) pthread_mutex_lock(&(name))
|
(void) pthread_mutex_unlock(&(mutex))
|
||||||
|
|
||||||
#define _glthread_UNLOCK_MUTEX(name) \
|
#define pipe_static_condvar(mutex) \
|
||||||
(void) pthread_mutex_unlock(&(name))
|
static pipe_condvar mutex = PTHREAD_COND_INITIALIZER
|
||||||
|
|
||||||
typedef pthread_cond_t _glthread_Cond;
|
#define pipe_condvar_init(cond) \
|
||||||
|
|
||||||
#define _glthread_DECLARE_STATIC_COND(name) \
|
|
||||||
static _glthread_Cond name = PTHREAD_COND_INITIALIZER
|
|
||||||
|
|
||||||
#define _glthread_INIT_COND(cond) \
|
|
||||||
pthread_cond_init(&(cond), NULL)
|
pthread_cond_init(&(cond), NULL)
|
||||||
|
|
||||||
#define _glthread_DESTROY_COND(name) \
|
#define pipe_condvar_destroy(cond) \
|
||||||
pthread_cond_destroy(&(name))
|
pthread_cond_destroy(&(cond))
|
||||||
|
|
||||||
#define _glthread_COND_WAIT(cond, mutex) \
|
#define pipe_condvar_wait(cond, mutex) \
|
||||||
pthread_cond_wait(&(cond), &(mutex))
|
pthread_cond_wait(&(cond), &(mutex))
|
||||||
|
|
||||||
#define _glthread_COND_SIGNAL(cond) \
|
#define pipe_condvar_signal(cond) \
|
||||||
pthread_cond_signal(&(cond))
|
pthread_cond_signal(&(cond))
|
||||||
|
|
||||||
#define _glthread_COND_BROADCAST(cond) \
|
#define pipe_condvar_broadcast(cond) \
|
||||||
pthread_cond_broadcast(&(cond))
|
pthread_cond_broadcast(&(cond))
|
||||||
|
|
||||||
#endif /* PTHREADS */
|
|
||||||
|
|
||||||
|
#elif defined(PIPE_OS_WINDOWS)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Solaris threads. Use only up to Solaris 2.4.
|
|
||||||
* Solaris 2.5 and higher provide POSIX threads.
|
|
||||||
* Be sure to compile with -mt on the Solaris compilers, or
|
|
||||||
* use -D_REENTRANT if using gcc.
|
|
||||||
*/
|
|
||||||
#ifdef SOLARIS_THREADS
|
|
||||||
#include <thread.h>
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
thread_key_t key;
|
|
||||||
mutex_t keylock;
|
|
||||||
int initMagic;
|
|
||||||
} _glthread_TSD;
|
|
||||||
|
|
||||||
typedef thread_t _glthread_Thread;
|
|
||||||
|
|
||||||
typedef mutex_t _glthread_Mutex;
|
|
||||||
|
|
||||||
/* XXX need to really implement mutex-related macros */
|
|
||||||
#define _glthread_DECLARE_STATIC_MUTEX(name) static _glthread_Mutex name = 0
|
|
||||||
#define _glthread_INIT_MUTEX(name) (void) name
|
|
||||||
#define _glthread_DESTROY_MUTEX(name) (void) name
|
|
||||||
#define _glthread_LOCK_MUTEX(name) (void) name
|
|
||||||
#define _glthread_UNLOCK_MUTEX(name) (void) name
|
|
||||||
|
|
||||||
#endif /* SOLARIS_THREADS */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Windows threads. Should work with Windows NT and 95.
|
|
||||||
* IMPORTANT: Link with multithreaded runtime library when THREADS are
|
|
||||||
* used!
|
|
||||||
*/
|
|
||||||
#ifdef WIN32_THREADS
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef HANDLE pipe_thread;
|
||||||
DWORD key;
|
typedef CRITICAL_SECTION pipe_mutex;
|
||||||
int initMagic;
|
|
||||||
} _glthread_TSD;
|
|
||||||
|
|
||||||
typedef HANDLE _glthread_Thread;
|
#define pipe_static_mutex(name) \
|
||||||
|
/*static*/ pipe_mutex name = {0,0,0,0,0,0}
|
||||||
|
|
||||||
typedef CRITICAL_SECTION _glthread_Mutex;
|
#define pipe_mutex_init(name) \
|
||||||
|
InitializeCriticalSection(&name)
|
||||||
|
|
||||||
#define _glthread_DECLARE_STATIC_MUTEX(name) /*static*/ _glthread_Mutex name = {0,0,0,0,0,0}
|
#define pipe_mutex_destroy(name) \
|
||||||
#define _glthread_INIT_MUTEX(name) InitializeCriticalSection(&name)
|
DeleteCriticalSection(&name)
|
||||||
#define _glthread_DESTROY_MUTEX(name) DeleteCriticalSection(&name)
|
|
||||||
#define _glthread_LOCK_MUTEX(name) EnterCriticalSection(&name)
|
|
||||||
#define _glthread_UNLOCK_MUTEX(name) LeaveCriticalSection(&name)
|
|
||||||
|
|
||||||
#endif /* WIN32_THREADS */
|
#define pipe_mutex_lock(name) \
|
||||||
|
EnterCriticalSection(&name)
|
||||||
|
|
||||||
|
#define pipe_mutex_unlock(name) \
|
||||||
|
LeaveCriticalSection(&name)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* XFree86 has its own thread wrapper, Xthreads.h
|
|
||||||
* We wrap it again for GL.
|
|
||||||
*/
|
|
||||||
#ifdef USE_XTHREADS
|
|
||||||
#include <X11/Xthreads.h>
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
xthread_key_t key;
|
|
||||||
int initMagic;
|
|
||||||
} _glthread_TSD;
|
|
||||||
|
|
||||||
typedef xthread_t _glthread_Thread;
|
|
||||||
|
|
||||||
typedef xmutex_rec _glthread_Mutex;
|
|
||||||
|
|
||||||
#ifdef XMUTEX_INITIALIZER
|
|
||||||
#define _glthread_DECLARE_STATIC_MUTEX(name) \
|
|
||||||
static _glthread_Mutex name = XMUTEX_INITIALIZER
|
|
||||||
#else
|
#else
|
||||||
#define _glthread_DECLARE_STATIC_MUTEX(name) \
|
|
||||||
static _glthread_Mutex name
|
/** Dummy definitions */
|
||||||
|
|
||||||
|
typedef unsigned pipe_thread;
|
||||||
|
typedef unsigned pipe_mutex;
|
||||||
|
typedef unsigned pipe_condvar;
|
||||||
|
typedef unsigned pipe_tsd;
|
||||||
|
|
||||||
|
#define pipe_static_mutex(mutex) \
|
||||||
|
static pipe_mutex mutex = 0
|
||||||
|
|
||||||
|
#define pipe_mutex_init(mutex) \
|
||||||
|
(void) mutex
|
||||||
|
|
||||||
|
#define pipe_mutex_destroy(mutex) \
|
||||||
|
(void) mutex
|
||||||
|
|
||||||
|
#define pipe_mutex_lock(mutex) \
|
||||||
|
(void) mutex
|
||||||
|
|
||||||
|
#define pipe_mutex_unlock(mutex) \
|
||||||
|
(void) mutex
|
||||||
|
|
||||||
|
#define pipe_static_condvar(condvar) \
|
||||||
|
static _glthread_Cond condvar = 0
|
||||||
|
|
||||||
|
#define pipe_condvar_init(condvar) \
|
||||||
|
(void) condvar
|
||||||
|
|
||||||
|
#define pipe_condvar_destroy(condvar) \
|
||||||
|
(void) condvar
|
||||||
|
|
||||||
|
#define pipe_condvar_wait(condvar, mutex) \
|
||||||
|
(void) condvar
|
||||||
|
|
||||||
|
#define pipe_condvar_signal(condvar) \
|
||||||
|
(void) condvar
|
||||||
|
|
||||||
|
#define pipe_condvar_broadcast(condvar) \
|
||||||
|
(void) condvar
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* PIPE_OS_? */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Thread-specific data.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
#if defined(PIPE_OS_LINUX)
|
||||||
|
pthread_key_t key;
|
||||||
|
#elif defined(PIPE_OS_WINDOWS)
|
||||||
|
DWORD key;
|
||||||
#endif
|
#endif
|
||||||
|
int initMagic;
|
||||||
|
} pipe_tsd;
|
||||||
|
|
||||||
#define _glthread_INIT_MUTEX(name) \
|
|
||||||
xmutex_init(&(name))
|
|
||||||
|
|
||||||
#define _glthread_DESTROY_MUTEX(name) \
|
#define PIPE_TSD_INIT_MAGIC 0xff8adc98
|
||||||
xmutex_clear(&(name))
|
|
||||||
|
|
||||||
#define _glthread_LOCK_MUTEX(name) \
|
|
||||||
(void) xmutex_lock(&(name))
|
|
||||||
|
|
||||||
#define _glthread_UNLOCK_MUTEX(name) \
|
static INLINE void
|
||||||
(void) xmutex_unlock(&(name))
|
pipe_tsd_init(pipe_tsd *tsd)
|
||||||
|
{
|
||||||
|
#if defined(PIPE_OS_LINUX)
|
||||||
|
if (pthread_key_create(&tsd->key, NULL/*free*/) != 0) {
|
||||||
|
perror("pthread_key_create(): failed to allocate key for thread specific data");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
#elif defined(PIPE_OS_WINDOWS)
|
||||||
|
assert(0);
|
||||||
|
#endif
|
||||||
|
tsd->initMagic = PIPE_TSD_INIT_MAGIC;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* USE_XTHREADS */
|
static INLINE void *
|
||||||
|
pipe_tsd_get(pipe_tsd *tsd)
|
||||||
|
{
|
||||||
|
if (tsd->initMagic != (int) PIPE_TSD_INIT_MAGIC) {
|
||||||
|
pipe_tsd_init(tsd);
|
||||||
|
}
|
||||||
|
#if defined(PIPE_OS_LINUX)
|
||||||
|
return pthread_getspecific(tsd->key);
|
||||||
|
#elif defined(PIPE_OS_WINDOWS)
|
||||||
|
assert(0);
|
||||||
|
return NULL;
|
||||||
|
#else
|
||||||
|
assert(0);
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static INLINE void
|
||||||
|
pipe_tsd_set(pipe_tsd *tsd, void *value)
|
||||||
|
{
|
||||||
|
if (tsd->initMagic != (int) PIPE_TSD_INIT_MAGIC) {
|
||||||
|
pipe_tsd_init(tsd);
|
||||||
|
}
|
||||||
|
#if defined(PIPE_OS_LINUX)
|
||||||
|
if (pthread_setspecific(tsd->key, value) != 0) {
|
||||||
|
perror("pthread_set_specific() failed");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
#elif defined(PIPE_OS_WINDOWS)
|
||||||
|
assert(0);
|
||||||
|
#else
|
||||||
|
assert(0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
#endif /* _P_THREAD2_H_ */
|
||||||
* BeOS threads. R5.x required.
|
|
||||||
*/
|
|
||||||
#ifdef BEOS_THREADS
|
|
||||||
|
|
||||||
#include <kernel/OS.h>
|
|
||||||
#include <support/TLS.h>
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int32 key;
|
|
||||||
int initMagic;
|
|
||||||
} _glthread_TSD;
|
|
||||||
|
|
||||||
typedef thread_id _glthread_Thread;
|
|
||||||
|
|
||||||
/* Use Benaphore, aka speeder semaphore */
|
|
||||||
typedef struct {
|
|
||||||
int32 lock;
|
|
||||||
sem_id sem;
|
|
||||||
} benaphore;
|
|
||||||
typedef benaphore _glthread_Mutex;
|
|
||||||
|
|
||||||
#define _glthread_DECLARE_STATIC_MUTEX(name) static _glthread_Mutex name = { 0, 0 }
|
|
||||||
#define _glthread_INIT_MUTEX(name) name.sem = create_sem(0, #name"_benaphore"), name.lock = 0
|
|
||||||
#define _glthread_DESTROY_MUTEX(name) delete_sem(name.sem), name.lock = 0
|
|
||||||
#define _glthread_LOCK_MUTEX(name) if (name.sem == 0) _glthread_INIT_MUTEX(name); \
|
|
||||||
if (atomic_add(&(name.lock), 1) >= 1) acquire_sem(name.sem)
|
|
||||||
#define _glthread_UNLOCK_MUTEX(name) if (atomic_add(&(name.lock), -1) > 1) release_sem(name.sem)
|
|
||||||
|
|
||||||
#endif /* BEOS_THREADS */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef THREADS
|
|
||||||
|
|
||||||
/*
|
|
||||||
* THREADS not defined
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef unsigned _glthread_TSD;
|
|
||||||
|
|
||||||
typedef unsigned _glthread_Thread;
|
|
||||||
|
|
||||||
typedef unsigned _glthread_Mutex;
|
|
||||||
|
|
||||||
#define _glthread_DECLARE_STATIC_MUTEX(name) static _glthread_Mutex name = 0
|
|
||||||
|
|
||||||
#define _glthread_INIT_MUTEX(name) (void) name
|
|
||||||
|
|
||||||
#define _glthread_DESTROY_MUTEX(name) (void) name
|
|
||||||
|
|
||||||
#define _glthread_LOCK_MUTEX(name) (void) name
|
|
||||||
|
|
||||||
#define _glthread_UNLOCK_MUTEX(name) (void) name
|
|
||||||
|
|
||||||
typedef unsigned _glthread_Cond;
|
|
||||||
|
|
||||||
#define _glthread_DECLARE_STATIC_COND(name) static _glthread_Cond name = 0
|
|
||||||
|
|
||||||
#define _glthread_INIT_COND(name) (void) name
|
|
||||||
|
|
||||||
#define _glthread_DESTROY_COND(name) (void) name
|
|
||||||
|
|
||||||
#define _glthread_COND_WAIT(name, mutex) (void) name
|
|
||||||
|
|
||||||
#define _glthread_COND_SIGNAL(name) (void) name
|
|
||||||
|
|
||||||
#define _glthread_COND_BROADCAST(name) (void) name
|
|
||||||
|
|
||||||
#endif /* THREADS */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Platform independent thread specific data API.
|
|
||||||
*/
|
|
||||||
|
|
||||||
extern unsigned long
|
|
||||||
_glthread_GetID(void);
|
|
||||||
|
|
||||||
|
|
||||||
extern void
|
|
||||||
_glthread_InitTSD(_glthread_TSD *);
|
|
||||||
|
|
||||||
|
|
||||||
extern void *
|
|
||||||
_glthread_GetTSD(_glthread_TSD *);
|
|
||||||
|
|
||||||
|
|
||||||
extern void
|
|
||||||
_glthread_SetTSD(_glthread_TSD *, void *);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* _P_THREAD_H_ */
|
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
#include <xf86drm.h>
|
#include <xf86drm.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "glthread.h"
|
#include "pipe/p_thread.h"
|
||||||
#include "errno.h"
|
#include "errno.h"
|
||||||
#include "ws_dri_bufmgr.h"
|
#include "ws_dri_bufmgr.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
@@ -51,8 +51,8 @@
|
|||||||
* driBufferObject mutex - > this rw lock.
|
* driBufferObject mutex - > this rw lock.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
_glthread_DECLARE_STATIC_MUTEX(bmMutex);
|
pipe_static_mutex(bmMutex);
|
||||||
_glthread_DECLARE_STATIC_COND(bmCond);
|
pipe_static_condvar(bmCond);
|
||||||
|
|
||||||
static int kernelReaders = 0;
|
static int kernelReaders = 0;
|
||||||
static int num_buffers = 0;
|
static int num_buffers = 0;
|
||||||
@@ -241,29 +241,29 @@ static int drmBOResetList(drmBOList *list)
|
|||||||
|
|
||||||
void driWriteLockKernelBO(void)
|
void driWriteLockKernelBO(void)
|
||||||
{
|
{
|
||||||
_glthread_LOCK_MUTEX(bmMutex);
|
pipe_mutex_lock(bmMutex);
|
||||||
while(kernelReaders != 0)
|
while(kernelReaders != 0)
|
||||||
_glthread_COND_WAIT(bmCond, bmMutex);
|
pipe_condvar_wait(bmCond, bmMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void driWriteUnlockKernelBO(void)
|
void driWriteUnlockKernelBO(void)
|
||||||
{
|
{
|
||||||
_glthread_UNLOCK_MUTEX(bmMutex);
|
pipe_mutex_unlock(bmMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void driReadLockKernelBO(void)
|
void driReadLockKernelBO(void)
|
||||||
{
|
{
|
||||||
_glthread_LOCK_MUTEX(bmMutex);
|
pipe_mutex_lock(bmMutex);
|
||||||
kernelReaders++;
|
kernelReaders++;
|
||||||
_glthread_UNLOCK_MUTEX(bmMutex);
|
pipe_mutex_unlock(bmMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void driReadUnlockKernelBO(void)
|
void driReadUnlockKernelBO(void)
|
||||||
{
|
{
|
||||||
_glthread_LOCK_MUTEX(bmMutex);
|
pipe_mutex_lock(bmMutex);
|
||||||
if (--kernelReaders == 0)
|
if (--kernelReaders == 0)
|
||||||
_glthread_COND_BROADCAST(bmCond);
|
pipe_condvar_broadcast(bmCond);
|
||||||
_glthread_UNLOCK_MUTEX(bmMutex);
|
pipe_mutex_unlock(bmMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -277,7 +277,7 @@ void driReadUnlockKernelBO(void)
|
|||||||
typedef struct _DriBufferObject
|
typedef struct _DriBufferObject
|
||||||
{
|
{
|
||||||
DriBufferPool *pool;
|
DriBufferPool *pool;
|
||||||
_glthread_Mutex mutex;
|
pipe_mutx mutex;
|
||||||
int refCount;
|
int refCount;
|
||||||
const char *name;
|
const char *name;
|
||||||
uint64_t flags;
|
uint64_t flags;
|
||||||
@@ -318,12 +318,12 @@ driBOKernel(struct _DriBufferObject *buf)
|
|||||||
drmBO *ret;
|
drmBO *ret;
|
||||||
|
|
||||||
driReadLockKernelBO();
|
driReadLockKernelBO();
|
||||||
_glthread_LOCK_MUTEX(buf->mutex);
|
pipe_mutex_lock(buf->mutex);
|
||||||
assert(buf->private != NULL);
|
assert(buf->private != NULL);
|
||||||
ret = buf->pool->kernel(buf->pool, buf->private);
|
ret = buf->pool->kernel(buf->pool, buf->private);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
BM_CKFATAL(-EINVAL);
|
BM_CKFATAL(-EINVAL);
|
||||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
pipe_mutex_unlock(buf->mutex);
|
||||||
driReadUnlockKernelBO();
|
driReadUnlockKernelBO();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -338,9 +338,9 @@ driBOWaitIdle(struct _DriBufferObject *buf, int lazy)
|
|||||||
* that time??
|
* that time??
|
||||||
*/
|
*/
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(buf->mutex);
|
pipe_mutex_lock(buf->mutex);
|
||||||
BM_CKFATAL(buf->pool->waitIdle(buf->pool, buf->private, &buf->mutex, lazy));
|
BM_CKFATAL(buf->pool->waitIdle(buf->pool, buf->private, &buf->mutex, lazy));
|
||||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
pipe_mutex_unlock(buf->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
@@ -353,11 +353,11 @@ driBOMap(struct _DriBufferObject *buf, unsigned flags, unsigned hint)
|
|||||||
return buf->userData;
|
return buf->userData;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(buf->mutex);
|
pipe_mutex_lock(buf->mutex);
|
||||||
assert(buf->private != NULL);
|
assert(buf->private != NULL);
|
||||||
retval = buf->pool->map(buf->pool, buf->private, flags, hint,
|
retval = buf->pool->map(buf->pool, buf->private, flags, hint,
|
||||||
&buf->mutex, &virtual);
|
&buf->mutex, &virtual);
|
||||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
pipe_mutex_unlock(buf->mutex);
|
||||||
|
|
||||||
return retval == 0 ? virtual : NULL;
|
return retval == 0 ? virtual : NULL;
|
||||||
}
|
}
|
||||||
@@ -369,9 +369,9 @@ driBOUnmap(struct _DriBufferObject *buf)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
assert(buf->private != NULL);
|
assert(buf->private != NULL);
|
||||||
_glthread_LOCK_MUTEX(buf->mutex);
|
pipe_mutex_lock(buf->mutex);
|
||||||
BM_CKFATAL(buf->pool->unmap(buf->pool, buf->private));
|
BM_CKFATAL(buf->pool->unmap(buf->pool, buf->private));
|
||||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
pipe_mutex_unlock(buf->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long
|
unsigned long
|
||||||
@@ -381,9 +381,9 @@ driBOOffset(struct _DriBufferObject *buf)
|
|||||||
|
|
||||||
assert(buf->private != NULL);
|
assert(buf->private != NULL);
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(buf->mutex);
|
pipe_mutex_lock(buf->mutex);
|
||||||
ret = buf->pool->offset(buf->pool, buf->private);
|
ret = buf->pool->offset(buf->pool, buf->private);
|
||||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
pipe_mutex_unlock(buf->mutex);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -394,9 +394,9 @@ driBOPoolOffset(struct _DriBufferObject *buf)
|
|||||||
|
|
||||||
assert(buf->private != NULL);
|
assert(buf->private != NULL);
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(buf->mutex);
|
pipe_mutex_lock(buf->mutex);
|
||||||
ret = buf->pool->poolOffset(buf->pool, buf->private);
|
ret = buf->pool->poolOffset(buf->pool, buf->private);
|
||||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
pipe_mutex_unlock(buf->mutex);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -408,9 +408,9 @@ driBOFlags(struct _DriBufferObject *buf)
|
|||||||
assert(buf->private != NULL);
|
assert(buf->private != NULL);
|
||||||
|
|
||||||
driReadLockKernelBO();
|
driReadLockKernelBO();
|
||||||
_glthread_LOCK_MUTEX(buf->mutex);
|
pipe_mutex_lock(buf->mutex);
|
||||||
ret = buf->pool->flags(buf->pool, buf->private);
|
ret = buf->pool->flags(buf->pool, buf->private);
|
||||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
pipe_mutex_unlock(buf->mutex);
|
||||||
driReadUnlockKernelBO();
|
driReadUnlockKernelBO();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -418,12 +418,12 @@ driBOFlags(struct _DriBufferObject *buf)
|
|||||||
struct _DriBufferObject *
|
struct _DriBufferObject *
|
||||||
driBOReference(struct _DriBufferObject *buf)
|
driBOReference(struct _DriBufferObject *buf)
|
||||||
{
|
{
|
||||||
_glthread_LOCK_MUTEX(buf->mutex);
|
pipe_mutex_lock(buf->mutex);
|
||||||
if (++buf->refCount == 1) {
|
if (++buf->refCount == 1) {
|
||||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
pipe_mutex_unlock(buf->mutex);
|
||||||
BM_CKFATAL(-EINVAL);
|
BM_CKFATAL(-EINVAL);
|
||||||
}
|
}
|
||||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
pipe_mutex_unlock(buf->mutex);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -435,10 +435,10 @@ driBOUnReference(struct _DriBufferObject *buf)
|
|||||||
if (!buf)
|
if (!buf)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(buf->mutex);
|
pipe_mutex_lock(buf->mutex);
|
||||||
tmp = --buf->refCount;
|
tmp = --buf->refCount;
|
||||||
if (!tmp) {
|
if (!tmp) {
|
||||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
pipe_mutex_unlock(buf->mutex);
|
||||||
if (buf->private) {
|
if (buf->private) {
|
||||||
if (buf->createdByReference)
|
if (buf->createdByReference)
|
||||||
buf->pool->unreference(buf->pool, buf->private);
|
buf->pool->unreference(buf->pool, buf->private);
|
||||||
@@ -451,7 +451,7 @@ driBOUnReference(struct _DriBufferObject *buf)
|
|||||||
num_buffers--;
|
num_buffers--;
|
||||||
free(buf);
|
free(buf);
|
||||||
} else
|
} else
|
||||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
pipe_mutex_unlock(buf->mutex);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -469,7 +469,7 @@ driBOData(struct _DriBufferObject *buf,
|
|||||||
|
|
||||||
assert(!buf->userBuffer); /* XXX just do a memcpy? */
|
assert(!buf->userBuffer); /* XXX just do a memcpy? */
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(buf->mutex);
|
pipe_mutex_lock(buf->mutex);
|
||||||
pool = buf->pool;
|
pool = buf->pool;
|
||||||
|
|
||||||
if (pool == NULL && newPool != NULL) {
|
if (pool == NULL && newPool != NULL) {
|
||||||
@@ -556,7 +556,7 @@ driBOData(struct _DriBufferObject *buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
pipe_mutex_unlock(buf->mutex);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
@@ -569,7 +569,7 @@ driBOSubData(struct _DriBufferObject *buf,
|
|||||||
|
|
||||||
assert(!buf->userBuffer); /* XXX just do a memcpy? */
|
assert(!buf->userBuffer); /* XXX just do a memcpy? */
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(buf->mutex);
|
pipe_mutex_lock(buf->mutex);
|
||||||
if (size && data) {
|
if (size && data) {
|
||||||
BM_CKFATAL(buf->pool->map(buf->pool, buf->private,
|
BM_CKFATAL(buf->pool->map(buf->pool, buf->private,
|
||||||
DRM_BO_FLAG_WRITE, 0, &buf->mutex,
|
DRM_BO_FLAG_WRITE, 0, &buf->mutex,
|
||||||
@@ -577,7 +577,7 @@ driBOSubData(struct _DriBufferObject *buf,
|
|||||||
memcpy((unsigned char *) virtual + offset, data, size);
|
memcpy((unsigned char *) virtual + offset, data, size);
|
||||||
BM_CKFATAL(buf->pool->unmap(buf->pool, buf->private));
|
BM_CKFATAL(buf->pool->unmap(buf->pool, buf->private));
|
||||||
}
|
}
|
||||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
pipe_mutex_unlock(buf->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -588,21 +588,21 @@ driBOGetSubData(struct _DriBufferObject *buf,
|
|||||||
|
|
||||||
assert(!buf->userBuffer); /* XXX just do a memcpy? */
|
assert(!buf->userBuffer); /* XXX just do a memcpy? */
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(buf->mutex);
|
pipe_mutex_lock(buf->mutex);
|
||||||
if (size && data) {
|
if (size && data) {
|
||||||
BM_CKFATAL(buf->pool->map(buf->pool, buf->private,
|
BM_CKFATAL(buf->pool->map(buf->pool, buf->private,
|
||||||
DRM_BO_FLAG_READ, 0, &buf->mutex, &virtual));
|
DRM_BO_FLAG_READ, 0, &buf->mutex, &virtual));
|
||||||
memcpy(data, (unsigned char *) virtual + offset, size);
|
memcpy(data, (unsigned char *) virtual + offset, size);
|
||||||
BM_CKFATAL(buf->pool->unmap(buf->pool, buf->private));
|
BM_CKFATAL(buf->pool->unmap(buf->pool, buf->private));
|
||||||
}
|
}
|
||||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
pipe_mutex_unlock(buf->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
driBOSetReferenced(struct _DriBufferObject *buf,
|
driBOSetReferenced(struct _DriBufferObject *buf,
|
||||||
unsigned long handle)
|
unsigned long handle)
|
||||||
{
|
{
|
||||||
_glthread_LOCK_MUTEX(buf->mutex);
|
pipe_mutex_lock(buf->mutex);
|
||||||
if (buf->private != NULL) {
|
if (buf->private != NULL) {
|
||||||
assert((size_t)"Invalid buffer for setReferenced\n" & 0);
|
assert((size_t)"Invalid buffer for setReferenced\n" & 0);
|
||||||
BM_CKFATAL(-EINVAL);
|
BM_CKFATAL(-EINVAL);
|
||||||
@@ -619,7 +619,7 @@ driBOSetReferenced(struct _DriBufferObject *buf,
|
|||||||
}
|
}
|
||||||
buf->createdByReference = TRUE;
|
buf->createdByReference = TRUE;
|
||||||
buf->flags = buf->pool->kernel(buf->pool, buf->private)->flags;
|
buf->flags = buf->pool->kernel(buf->pool, buf->private)->flags;
|
||||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
pipe_mutex_unlock(buf->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -644,8 +644,8 @@ driGenBuffers(struct _DriBufferPool *pool,
|
|||||||
if (!buf)
|
if (!buf)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
_glthread_INIT_MUTEX(buf->mutex);
|
pipe_mutex_init(buf->mutex);
|
||||||
_glthread_LOCK_MUTEX(buf->mutex);
|
pipe_mutex_lock(buf->mutex);
|
||||||
buf->refCount = 1;
|
buf->refCount = 1;
|
||||||
buf->flags = flags;
|
buf->flags = flags;
|
||||||
buf->hint = hint;
|
buf->hint = hint;
|
||||||
@@ -653,7 +653,7 @@ driGenBuffers(struct _DriBufferPool *pool,
|
|||||||
buf->alignment = alignment;
|
buf->alignment = alignment;
|
||||||
buf->pool = pool;
|
buf->pool = pool;
|
||||||
buf->createdByReference = 0;
|
buf->createdByReference = 0;
|
||||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
pipe_mutex_unlock(buf->mutex);
|
||||||
buffers[i] = buf;
|
buffers[i] = buf;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -818,7 +818,7 @@ driBOAddListItem(struct _DriBufferList * list, struct _DriBufferObject *buf,
|
|||||||
{
|
{
|
||||||
int newItem;
|
int newItem;
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(buf->mutex);
|
pipe_mutex_lock(buf->mutex);
|
||||||
BM_CKFATAL(driAddValidateItem(&list->drmBuffers,
|
BM_CKFATAL(driAddValidateItem(&list->drmBuffers,
|
||||||
buf->pool->kernel(buf->pool, buf->private),
|
buf->pool->kernel(buf->pool, buf->private),
|
||||||
flags, mask, itemLoc, node));
|
flags, mask, itemLoc, node));
|
||||||
@@ -827,7 +827,7 @@ driBOAddListItem(struct _DriBufferList * list, struct _DriBufferObject *buf,
|
|||||||
if (newItem)
|
if (newItem)
|
||||||
buf->refCount++;
|
buf->refCount++;
|
||||||
|
|
||||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
pipe_mutex_unlock(buf->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
drmBOList *driGetdrmBOList(struct _DriBufferList *list)
|
drmBOList *driGetdrmBOList(struct _DriBufferList *list)
|
||||||
@@ -845,10 +845,10 @@ void driPutdrmBOList(struct _DriBufferList *list)
|
|||||||
void
|
void
|
||||||
driBOFence(struct _DriBufferObject *buf, struct _DriFenceObject *fence)
|
driBOFence(struct _DriBufferObject *buf, struct _DriFenceObject *fence)
|
||||||
{
|
{
|
||||||
_glthread_LOCK_MUTEX(buf->mutex);
|
pipe_mutex_lock(buf->mutex);
|
||||||
if (buf->pool->fence)
|
if (buf->pool->fence)
|
||||||
BM_CKFATAL(buf->pool->fence(buf->pool, buf->private, fence));
|
BM_CKFATAL(buf->pool->fence(buf->pool, buf->private, fence));
|
||||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
pipe_mutex_unlock(buf->mutex);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -908,10 +908,10 @@ driBOValidateUserList(struct _DriBufferList * list)
|
|||||||
|
|
||||||
while (curBuf) {
|
while (curBuf) {
|
||||||
buf = (struct _DriBufferObject *) drmBOListBuf(curBuf);
|
buf = (struct _DriBufferObject *) drmBOListBuf(curBuf);
|
||||||
_glthread_LOCK_MUTEX(buf->mutex);
|
pipe_mutex_lock(buf->mutex);
|
||||||
if (buf->pool->validate)
|
if (buf->pool->validate)
|
||||||
BM_CKFATAL(buf->pool->validate(buf->pool, buf->private, &buf->mutex));
|
BM_CKFATAL(buf->pool->validate(buf->pool, buf->private, &buf->mutex));
|
||||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
pipe_mutex_unlock(buf->mutex);
|
||||||
curBuf = drmBOListNext(&list->driBuffers, curBuf);
|
curBuf = drmBOListNext(&list->driBuffers, curBuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -929,9 +929,9 @@ driBOSize(struct _DriBufferObject *buf)
|
|||||||
{
|
{
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(buf->mutex);
|
pipe_mutex_lock(buf->mutex);
|
||||||
size = buf->pool->size(buf->pool, buf->private);
|
size = buf->pool->size(buf->pool, buf->private);
|
||||||
_glthread_UNLOCK_MUTEX(buf->mutex);
|
pipe_mutex_unlock(buf->mutex);
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
|
|
||||||
|
@@ -33,14 +33,14 @@
|
|||||||
#define _PSB_BUFPOOL_H_
|
#define _PSB_BUFPOOL_H_
|
||||||
|
|
||||||
#include <xf86drm.h>
|
#include <xf86drm.h>
|
||||||
#include <glthread.h>
|
#include "pipe/p_thread.h"
|
||||||
struct _DriFenceObject;
|
struct _DriFenceObject;
|
||||||
|
|
||||||
typedef struct _DriBufferPool
|
typedef struct _DriBufferPool
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
int (*map) (struct _DriBufferPool * pool, void *private,
|
int (*map) (struct _DriBufferPool * pool, void *private,
|
||||||
unsigned flags, int hint, _glthread_Mutex *mutex,
|
unsigned flags, int hint, pipe_mutex *mutex,
|
||||||
void **virtual);
|
void **virtual);
|
||||||
int (*unmap) (struct _DriBufferPool * pool, void *private);
|
int (*unmap) (struct _DriBufferPool * pool, void *private);
|
||||||
int (*destroy) (struct _DriBufferPool * pool, void *private);
|
int (*destroy) (struct _DriBufferPool * pool, void *private);
|
||||||
@@ -55,8 +55,8 @@ typedef struct _DriBufferPool
|
|||||||
int (*fence) (struct _DriBufferPool * pool, void *private,
|
int (*fence) (struct _DriBufferPool * pool, void *private,
|
||||||
struct _DriFenceObject * fence);
|
struct _DriFenceObject * fence);
|
||||||
drmBO *(*kernel) (struct _DriBufferPool * pool, void *private);
|
drmBO *(*kernel) (struct _DriBufferPool * pool, void *private);
|
||||||
int (*validate) (struct _DriBufferPool * pool, void *private, _glthread_Mutex *mutex);
|
int (*validate) (struct _DriBufferPool * pool, void *private, pipe_mutex *mutex);
|
||||||
int (*waitIdle) (struct _DriBufferPool *pool, void *private, _glthread_Mutex *mutex,
|
int (*waitIdle) (struct _DriBufferPool *pool, void *private, pipe_mutex *mutex,
|
||||||
int lazy);
|
int lazy);
|
||||||
int (*setStatus) (struct _DriBufferPool *pool, void *private,
|
int (*setStatus) (struct _DriBufferPool *pool, void *private,
|
||||||
uint64_t flag_diff, uint64_t old_flags);
|
uint64_t flag_diff, uint64_t old_flags);
|
||||||
|
@@ -113,7 +113,7 @@ pool_unreference(struct _DriBufferPool *pool, void *private)
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
pool_map(struct _DriBufferPool *pool, void *private, unsigned flags,
|
pool_map(struct _DriBufferPool *pool, void *private, unsigned flags,
|
||||||
int hint, _glthread_Mutex *mutex, void **virtual)
|
int hint, pipe_mutex *mutex, void **virtual)
|
||||||
{
|
{
|
||||||
drmBO *buf = (drmBO *) private;
|
drmBO *buf = (drmBO *) private;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -202,7 +202,7 @@ pool_kernel(struct _DriBufferPool *pool, void *private)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
pool_waitIdle(struct _DriBufferPool *pool, void *private, _glthread_Mutex *mutex,
|
pool_waitIdle(struct _DriBufferPool *pool, void *private, pipe_mutex *mutex,
|
||||||
int lazy)
|
int lazy)
|
||||||
{
|
{
|
||||||
drmBO *buf = (drmBO *) private;
|
drmBO *buf = (drmBO *) private;
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
#include "ws_dri_fencemgr.h"
|
#include "ws_dri_fencemgr.h"
|
||||||
#include "glthread.h"
|
#include "pipe/p_thread.h"
|
||||||
#include <xf86mm.h>
|
#include <xf86mm.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -20,7 +20,7 @@ struct _DriFenceMgr {
|
|||||||
/*
|
/*
|
||||||
* These members are protected by this->mutex
|
* These members are protected by this->mutex
|
||||||
*/
|
*/
|
||||||
_glthread_Mutex mutex;
|
pipe_mutex mutex;
|
||||||
int refCount;
|
int refCount;
|
||||||
drmMMListHead *heads;
|
drmMMListHead *heads;
|
||||||
int num_fences;
|
int num_fences;
|
||||||
@@ -44,7 +44,7 @@ struct _DriFenceObject {
|
|||||||
/*
|
/*
|
||||||
* These members are protected by this->mutex.
|
* These members are protected by this->mutex.
|
||||||
*/
|
*/
|
||||||
_glthread_Mutex mutex;
|
pipe_mutex mutex;
|
||||||
uint32_t signaled_type;
|
uint32_t signaled_type;
|
||||||
void *private;
|
void *private;
|
||||||
};
|
};
|
||||||
@@ -65,8 +65,8 @@ driFenceMgrCreate(const struct _DriFenceMgrCreateInfo *info)
|
|||||||
if (!tmp)
|
if (!tmp)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
_glthread_INIT_MUTEX(tmp->mutex);
|
pipe_mutex_init(tmp->mutex);
|
||||||
_glthread_LOCK_MUTEX(tmp->mutex);
|
pipe_mutex_lock(tmp->mutex);
|
||||||
tmp->refCount = 1;
|
tmp->refCount = 1;
|
||||||
tmp->info = *info;
|
tmp->info = *info;
|
||||||
tmp->num_fences = 0;
|
tmp->num_fences = 0;
|
||||||
@@ -77,7 +77,7 @@ driFenceMgrCreate(const struct _DriFenceMgrCreateInfo *info)
|
|||||||
for (i=0; i<tmp->info.num_classes; ++i) {
|
for (i=0; i<tmp->info.num_classes; ++i) {
|
||||||
DRMINITLISTHEAD(&tmp->heads[i]);
|
DRMINITLISTHEAD(&tmp->heads[i]);
|
||||||
}
|
}
|
||||||
_glthread_UNLOCK_MUTEX(tmp->mutex);
|
pipe_mutex_unlock(tmp->mutex);
|
||||||
return tmp;
|
return tmp;
|
||||||
|
|
||||||
out_err:
|
out_err:
|
||||||
@@ -95,13 +95,13 @@ driFenceMgrUnrefUnlock(struct _DriFenceMgr **pMgr)
|
|||||||
if (--mgr->refCount == 0)
|
if (--mgr->refCount == 0)
|
||||||
free(mgr);
|
free(mgr);
|
||||||
else
|
else
|
||||||
_glthread_UNLOCK_MUTEX(mgr->mutex);
|
pipe_mutex_unlock(mgr->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
driFenceMgrUnReference(struct _DriFenceMgr **pMgr)
|
driFenceMgrUnReference(struct _DriFenceMgr **pMgr)
|
||||||
{
|
{
|
||||||
_glthread_LOCK_MUTEX((*pMgr)->mutex);
|
pipe_mutex_lock((*pMgr)->mutex);
|
||||||
driFenceMgrUnrefUnlock(pMgr);
|
driFenceMgrUnrefUnlock(pMgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,9 +143,9 @@ driSignalPreviousFencesLocked(struct _DriFenceMgr *mgr,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
++entry->refCount;
|
++entry->refCount;
|
||||||
_glthread_UNLOCK_MUTEX(mgr->mutex);
|
pipe_mutex_unlock(mgr->mutex);
|
||||||
_glthread_LOCK_MUTEX(entry->mutex);
|
pipe_mutex_lock(entry->mutex);
|
||||||
_glthread_LOCK_MUTEX(mgr->mutex);
|
pipe_mutex_lock(mgr->mutex);
|
||||||
|
|
||||||
prev = list->prev;
|
prev = list->prev;
|
||||||
|
|
||||||
@@ -157,7 +157,7 @@ driSignalPreviousFencesLocked(struct _DriFenceMgr *mgr,
|
|||||||
* Somebody else removed the entry from the list.
|
* Somebody else removed the entry from the list.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
_glthread_UNLOCK_MUTEX(entry->mutex);
|
pipe_mutex_unlock(entry->mutex);
|
||||||
driFenceUnReferenceLocked(&entry);
|
driFenceUnReferenceLocked(&entry);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -167,7 +167,7 @@ driSignalPreviousFencesLocked(struct _DriFenceMgr *mgr,
|
|||||||
DRMLISTDELINIT(list);
|
DRMLISTDELINIT(list);
|
||||||
mgr->info.unreference(mgr, &entry->private);
|
mgr->info.unreference(mgr, &entry->private);
|
||||||
}
|
}
|
||||||
_glthread_UNLOCK_MUTEX(entry->mutex);
|
pipe_mutex_unlock(entry->mutex);
|
||||||
driFenceUnReferenceLocked(&entry);
|
driFenceUnReferenceLocked(&entry);
|
||||||
list = prev;
|
list = prev;
|
||||||
}
|
}
|
||||||
@@ -181,7 +181,7 @@ driFenceFinish(struct _DriFenceObject *fence, uint32_t fence_type,
|
|||||||
struct _DriFenceMgr *mgr = fence->mgr;
|
struct _DriFenceMgr *mgr = fence->mgr;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(fence->mutex);
|
pipe_mutex_lock(fence->mutex);
|
||||||
|
|
||||||
if ((fence->signaled_type & fence_type) == fence_type)
|
if ((fence->signaled_type & fence_type) == fence_type)
|
||||||
goto out0;
|
goto out0;
|
||||||
@@ -190,16 +190,16 @@ driFenceFinish(struct _DriFenceObject *fence, uint32_t fence_type,
|
|||||||
if (ret)
|
if (ret)
|
||||||
goto out0;
|
goto out0;
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(mgr->mutex);
|
pipe_mutex_lock(mgr->mutex);
|
||||||
_glthread_UNLOCK_MUTEX(fence->mutex);
|
pipe_mutex_unlock(fence->mutex);
|
||||||
|
|
||||||
driSignalPreviousFencesLocked(mgr, &fence->head, fence->fence_class,
|
driSignalPreviousFencesLocked(mgr, &fence->head, fence->fence_class,
|
||||||
fence_type);
|
fence_type);
|
||||||
_glthread_UNLOCK_MUTEX(mgr->mutex);
|
pipe_mutex_unlock(mgr->mutex);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out0:
|
out0:
|
||||||
_glthread_UNLOCK_MUTEX(fence->mutex);
|
pipe_mutex_unlock(fence->mutex);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,9 +207,9 @@ uint32_t driFenceSignaledTypeCached(struct _DriFenceObject *fence)
|
|||||||
{
|
{
|
||||||
uint32_t ret;
|
uint32_t ret;
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(fence->mutex);
|
pipe_mutex_lock(fence->mutex);
|
||||||
ret = fence->signaled_type;
|
ret = fence->signaled_type;
|
||||||
_glthread_UNLOCK_MUTEX(fence->mutex);
|
pipe_mutex_unlock(fence->mutex);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -221,7 +221,7 @@ driFenceSignaledType(struct _DriFenceObject *fence, uint32_t flush_type,
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct _DriFenceMgr *mgr;
|
struct _DriFenceMgr *mgr;
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(fence->mutex);
|
pipe_mutex_lock(fence->mutex);
|
||||||
mgr = fence->mgr;
|
mgr = fence->mgr;
|
||||||
*signaled = fence->signaled_type;
|
*signaled = fence->signaled_type;
|
||||||
if ((fence->signaled_type & flush_type) == flush_type)
|
if ((fence->signaled_type & flush_type) == flush_type)
|
||||||
@@ -236,25 +236,25 @@ driFenceSignaledType(struct _DriFenceObject *fence, uint32_t flush_type,
|
|||||||
if ((fence->signaled_type | *signaled) == fence->signaled_type)
|
if ((fence->signaled_type | *signaled) == fence->signaled_type)
|
||||||
goto out0;
|
goto out0;
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(mgr->mutex);
|
pipe_mutex_lock(mgr->mutex);
|
||||||
_glthread_UNLOCK_MUTEX(fence->mutex);
|
pipe_mutex_unlock(fence->mutex);
|
||||||
|
|
||||||
driSignalPreviousFencesLocked(mgr, &fence->head, fence->fence_class,
|
driSignalPreviousFencesLocked(mgr, &fence->head, fence->fence_class,
|
||||||
*signaled);
|
*signaled);
|
||||||
|
|
||||||
_glthread_UNLOCK_MUTEX(mgr->mutex);
|
pipe_mutex_unlock(mgr->mutex);
|
||||||
return 0;
|
return 0;
|
||||||
out0:
|
out0:
|
||||||
_glthread_UNLOCK_MUTEX(fence->mutex);
|
pipe_mutex_unlock(fence->mutex);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct _DriFenceObject *
|
struct _DriFenceObject *
|
||||||
driFenceReference(struct _DriFenceObject *fence)
|
driFenceReference(struct _DriFenceObject *fence)
|
||||||
{
|
{
|
||||||
_glthread_LOCK_MUTEX(fence->mgr->mutex);
|
pipe_mutex_lock(fence->mgr->mutex);
|
||||||
++fence->refCount;
|
++fence->refCount;
|
||||||
_glthread_UNLOCK_MUTEX(fence->mgr->mutex);
|
pipe_mutex_unlock(fence->mgr->mutex);
|
||||||
return fence;
|
return fence;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,7 +267,7 @@ driFenceUnReference(struct _DriFenceObject **pFence)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
mgr = (*pFence)->mgr;
|
mgr = (*pFence)->mgr;
|
||||||
_glthread_LOCK_MUTEX(mgr->mutex);
|
pipe_mutex_lock(mgr->mutex);
|
||||||
++mgr->refCount;
|
++mgr->refCount;
|
||||||
driFenceUnReferenceLocked(pFence);
|
driFenceUnReferenceLocked(pFence);
|
||||||
driFenceMgrUnrefUnlock(&mgr);
|
driFenceMgrUnrefUnlock(&mgr);
|
||||||
@@ -294,15 +294,15 @@ struct _DriFenceObject
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glthread_INIT_MUTEX(fence->mutex);
|
pipe_mutex_init(fence->mutex);
|
||||||
_glthread_LOCK_MUTEX(fence->mutex);
|
pipe_mutex_lock(fence->mutex);
|
||||||
_glthread_LOCK_MUTEX(mgr->mutex);
|
pipe_mutex_lock(mgr->mutex);
|
||||||
fence->refCount = 1;
|
fence->refCount = 1;
|
||||||
DRMLISTADDTAIL(&fence->head, &mgr->heads[fence_class]);
|
DRMLISTADDTAIL(&fence->head, &mgr->heads[fence_class]);
|
||||||
fence->mgr = mgr;
|
fence->mgr = mgr;
|
||||||
++mgr->refCount;
|
++mgr->refCount;
|
||||||
++mgr->num_fences;
|
++mgr->num_fences;
|
||||||
_glthread_UNLOCK_MUTEX(mgr->mutex);
|
pipe_mutex_unlock(mgr->mutex);
|
||||||
fence->fence_class = fence_class;
|
fence->fence_class = fence_class;
|
||||||
fence->fence_type = fence_type;
|
fence->fence_type = fence_type;
|
||||||
fence->signaled_type = 0;
|
fence->signaled_type = 0;
|
||||||
@@ -312,7 +312,7 @@ struct _DriFenceObject
|
|||||||
memcpy(fence->private, private, private_size);
|
memcpy(fence->private, private, private_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
_glthread_UNLOCK_MUTEX(fence->mutex);
|
pipe_mutex_unlock(fence->mutex);
|
||||||
return fence;
|
return fence;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "pipe/p_debug.h"
|
#include "pipe/p_debug.h"
|
||||||
#include "glthread.h"
|
#include "pipe/p_thread.h"
|
||||||
#include "ws_dri_bufpool.h"
|
#include "ws_dri_bufpool.h"
|
||||||
#include "ws_dri_bufmgr.h"
|
#include "ws_dri_bufmgr.h"
|
||||||
|
|
||||||
@@ -60,14 +60,14 @@ pool_destroy(struct _DriBufferPool *pool, void *private)
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
pool_waitIdle(struct _DriBufferPool *pool, void *private,
|
pool_waitIdle(struct _DriBufferPool *pool, void *private,
|
||||||
_glthread_Mutex *mutex, int lazy)
|
pipe_mutex *mutex, int lazy)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
pool_map(struct _DriBufferPool *pool, void *private, unsigned flags,
|
pool_map(struct _DriBufferPool *pool, void *private, unsigned flags,
|
||||||
int hint, _glthread_Mutex *mutex, void **virtual)
|
int hint, pipe_mutex *mutex, void **virtual)
|
||||||
{
|
{
|
||||||
*virtual = (void *)((unsigned long *)private + 2);
|
*virtual = (void *)((unsigned long *)private + 2);
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -37,7 +37,7 @@
|
|||||||
#include "ws_dri_bufpool.h"
|
#include "ws_dri_bufpool.h"
|
||||||
#include "ws_dri_fencemgr.h"
|
#include "ws_dri_fencemgr.h"
|
||||||
#include "ws_dri_bufmgr.h"
|
#include "ws_dri_bufmgr.h"
|
||||||
#include "glthread.h"
|
#include "pipe/p_thread.h"
|
||||||
|
|
||||||
#define DRI_SLABPOOL_ALLOC_RETRIES 100
|
#define DRI_SLABPOOL_ALLOC_RETRIES 100
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ struct _DriSlabBuffer {
|
|||||||
uint32_t start;
|
uint32_t start;
|
||||||
uint32_t fenceType;
|
uint32_t fenceType;
|
||||||
int unFenced;
|
int unFenced;
|
||||||
_glthread_Cond event;
|
pipe_condvar event;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _DriKernelBO {
|
struct _DriKernelBO {
|
||||||
@@ -84,7 +84,7 @@ struct _DriSlabSizeHeader {
|
|||||||
uint32_t numDelayed;
|
uint32_t numDelayed;
|
||||||
struct _DriSlabPool *slabPool;
|
struct _DriSlabPool *slabPool;
|
||||||
uint32_t bufSize;
|
uint32_t bufSize;
|
||||||
_glthread_Mutex mutex;
|
pipe_mutex mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _DriFreeSlabManager {
|
struct _DriFreeSlabManager {
|
||||||
@@ -94,7 +94,7 @@ struct _DriFreeSlabManager {
|
|||||||
drmMMListHead timeoutList;
|
drmMMListHead timeoutList;
|
||||||
drmMMListHead unCached;
|
drmMMListHead unCached;
|
||||||
drmMMListHead cached;
|
drmMMListHead cached;
|
||||||
_glthread_Mutex mutex;
|
pipe_mutex mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -196,7 +196,7 @@ driSetKernelBOFree(struct _DriFreeSlabManager *fMan,
|
|||||||
{
|
{
|
||||||
struct timeval time;
|
struct timeval time;
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(fMan->mutex);
|
pipe_mutex_lock(fMan->mutex);
|
||||||
gettimeofday(&time, NULL);
|
gettimeofday(&time, NULL);
|
||||||
driTimeAdd(&time, &fMan->slabTimeout);
|
driTimeAdd(&time, &fMan->slabTimeout);
|
||||||
|
|
||||||
@@ -210,7 +210,7 @@ driSetKernelBOFree(struct _DriFreeSlabManager *fMan,
|
|||||||
DRMLISTADDTAIL(&kbo->timeoutHead, &fMan->timeoutList);
|
DRMLISTADDTAIL(&kbo->timeoutHead, &fMan->timeoutList);
|
||||||
driFreeTimeoutKBOsLocked(fMan, &time);
|
driFreeTimeoutKBOsLocked(fMan, &time);
|
||||||
|
|
||||||
_glthread_UNLOCK_MUTEX(fMan->mutex);
|
pipe_mutex_unlock(fMan->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -237,7 +237,7 @@ driAllocKernelBO(struct _DriSlabSizeHeader *header)
|
|||||||
|
|
||||||
size = (size <= slabPool->maxSlabSize) ? size : slabPool->maxSlabSize;
|
size = (size <= slabPool->maxSlabSize) ? size : slabPool->maxSlabSize;
|
||||||
size = (size + slabPool->pageSize - 1) & ~(slabPool->pageSize - 1);
|
size = (size + slabPool->pageSize - 1) & ~(slabPool->pageSize - 1);
|
||||||
_glthread_LOCK_MUTEX(fMan->mutex);
|
pipe_mutex_lock(fMan->mutex);
|
||||||
|
|
||||||
kbo = NULL;
|
kbo = NULL;
|
||||||
|
|
||||||
@@ -269,7 +269,7 @@ driAllocKernelBO(struct _DriSlabSizeHeader *header)
|
|||||||
DRMLISTDELINIT(&kbo->timeoutHead);
|
DRMLISTDELINIT(&kbo->timeoutHead);
|
||||||
}
|
}
|
||||||
|
|
||||||
_glthread_UNLOCK_MUTEX(fMan->mutex);
|
pipe_mutex_unlock(fMan->mutex);
|
||||||
|
|
||||||
if (kbo) {
|
if (kbo) {
|
||||||
uint64_t new_mask = kbo->bo.proposedFlags ^ slabPool->proposedFlags;
|
uint64_t new_mask = kbo->bo.proposedFlags ^ slabPool->proposedFlags;
|
||||||
@@ -360,7 +360,7 @@ driAllocSlab(struct _DriSlabSizeHeader *header)
|
|||||||
buf->start = i* header->bufSize;
|
buf->start = i* header->bufSize;
|
||||||
buf->mapCount = 0;
|
buf->mapCount = 0;
|
||||||
buf->isSlabBuffer = 1;
|
buf->isSlabBuffer = 1;
|
||||||
_glthread_INIT_COND(buf->event);
|
pipe_condvar_init(buf->event);
|
||||||
DRMLISTADDTAIL(&buf->head, &slab->freeBuffers);
|
DRMLISTADDTAIL(&buf->head, &slab->freeBuffers);
|
||||||
slab->numFree++;
|
slab->numFree++;
|
||||||
buf++;
|
buf++;
|
||||||
@@ -494,23 +494,23 @@ driSlabAllocBuffer(struct _DriSlabSizeHeader *header)
|
|||||||
drmMMListHead *list;
|
drmMMListHead *list;
|
||||||
int count = DRI_SLABPOOL_ALLOC_RETRIES;
|
int count = DRI_SLABPOOL_ALLOC_RETRIES;
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(header->mutex);
|
pipe_mutex_lock(header->mutex);
|
||||||
while(header->slabs.next == &header->slabs && count > 0) {
|
while(header->slabs.next == &header->slabs && count > 0) {
|
||||||
driSlabCheckFreeLocked(header, 0);
|
driSlabCheckFreeLocked(header, 0);
|
||||||
if (header->slabs.next != &header->slabs)
|
if (header->slabs.next != &header->slabs)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
_glthread_UNLOCK_MUTEX(header->mutex);
|
pipe_mutex_unlock(header->mutex);
|
||||||
if (count != DRI_SLABPOOL_ALLOC_RETRIES)
|
if (count != DRI_SLABPOOL_ALLOC_RETRIES)
|
||||||
usleep(1);
|
usleep(1);
|
||||||
_glthread_LOCK_MUTEX(header->mutex);
|
pipe_mutex_lock(header->mutex);
|
||||||
(void) driAllocSlab(header);
|
(void) driAllocSlab(header);
|
||||||
count--;
|
count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
list = header->slabs.next;
|
list = header->slabs.next;
|
||||||
if (list == &header->slabs) {
|
if (list == &header->slabs) {
|
||||||
_glthread_UNLOCK_MUTEX(header->mutex);
|
pipe_mutex_unlock(header->mutex);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
slab = DRMLISTENTRY(struct _DriSlab, list, head);
|
slab = DRMLISTENTRY(struct _DriSlab, list, head);
|
||||||
@@ -520,7 +520,7 @@ driSlabAllocBuffer(struct _DriSlabSizeHeader *header)
|
|||||||
list = slab->freeBuffers.next;
|
list = slab->freeBuffers.next;
|
||||||
DRMLISTDELINIT(list);
|
DRMLISTDELINIT(list);
|
||||||
|
|
||||||
_glthread_UNLOCK_MUTEX(header->mutex);
|
pipe_mutex_unlock(header->mutex);
|
||||||
buf = DRMLISTENTRY(struct _DriSlabBuffer, list, head);
|
buf = DRMLISTENTRY(struct _DriSlabBuffer, list, head);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
@@ -618,7 +618,7 @@ pool_destroy(struct _DriBufferPool *driPool, void *private)
|
|||||||
slab = buf->parent;
|
slab = buf->parent;
|
||||||
header = slab->header;
|
header = slab->header;
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(header->mutex);
|
pipe_mutex_lock(header->mutex);
|
||||||
buf->unFenced = 0;
|
buf->unFenced = 0;
|
||||||
buf->mapCount = 0;
|
buf->mapCount = 0;
|
||||||
|
|
||||||
@@ -631,18 +631,18 @@ pool_destroy(struct _DriBufferPool *driPool, void *private)
|
|||||||
driSlabFreeBufferLocked(buf);
|
driSlabFreeBufferLocked(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
_glthread_UNLOCK_MUTEX(header->mutex);
|
pipe_mutex_unlock(header->mutex);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
pool_waitIdle(struct _DriBufferPool *driPool, void *private,
|
pool_waitIdle(struct _DriBufferPool *driPool, void *private,
|
||||||
_glthread_Mutex *mutex, int lazy)
|
pipe_mutex *mutex, int lazy)
|
||||||
{
|
{
|
||||||
struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
|
struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
|
||||||
|
|
||||||
while(buf->unFenced)
|
while(buf->unFenced)
|
||||||
_glthread_COND_WAIT(buf->event, *mutex);
|
pipe_condvar_wait(buf->event, *mutex);
|
||||||
|
|
||||||
if (!buf->fence)
|
if (!buf->fence)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -655,7 +655,7 @@ pool_waitIdle(struct _DriBufferPool *driPool, void *private,
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
pool_map(struct _DriBufferPool *pool, void *private, unsigned flags,
|
pool_map(struct _DriBufferPool *pool, void *private, unsigned flags,
|
||||||
int hint, _glthread_Mutex *mutex, void **virtual)
|
int hint, pipe_mutex *mutex, void **virtual)
|
||||||
{
|
{
|
||||||
struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
|
struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
|
||||||
int busy;
|
int busy;
|
||||||
@@ -689,7 +689,7 @@ pool_unmap(struct _DriBufferPool *pool, void *private)
|
|||||||
|
|
||||||
--buf->mapCount;
|
--buf->mapCount;
|
||||||
if (buf->mapCount == 0 && buf->isSlabBuffer)
|
if (buf->mapCount == 0 && buf->isSlabBuffer)
|
||||||
_glthread_COND_BROADCAST(buf->event);
|
pipe_condvar_broadcast(buf->event);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -760,7 +760,7 @@ pool_fence(struct _DriBufferPool *pool, void *private,
|
|||||||
buf->fenceType = bo->fenceFlags;
|
buf->fenceType = bo->fenceFlags;
|
||||||
|
|
||||||
buf->unFenced = 0;
|
buf->unFenced = 0;
|
||||||
_glthread_COND_BROADCAST(buf->event);
|
pipe_condvar_broadcast(buf->event);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -775,7 +775,7 @@ pool_kernel(struct _DriBufferPool *pool, void *private)
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
pool_validate(struct _DriBufferPool *pool, void *private,
|
pool_validate(struct _DriBufferPool *pool, void *private,
|
||||||
_glthread_Mutex *mutex)
|
pipe_mutex *mutex)
|
||||||
{
|
{
|
||||||
struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
|
struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
|
||||||
|
|
||||||
@@ -783,7 +783,7 @@ pool_validate(struct _DriBufferPool *pool, void *private,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
while(buf->mapCount != 0)
|
while(buf->mapCount != 0)
|
||||||
_glthread_COND_WAIT(buf->event, *mutex);
|
pipe_condvar_wait(buf->event, *mutex);
|
||||||
|
|
||||||
buf->unFenced = 1;
|
buf->unFenced = 1;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -799,8 +799,8 @@ driInitFreeSlabManager(uint32_t checkIntervalMsec, uint32_t slabTimeoutMsec)
|
|||||||
if (!tmp)
|
if (!tmp)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
_glthread_INIT_MUTEX(tmp->mutex);
|
pipe_mutex_init(tmp->mutex);
|
||||||
_glthread_LOCK_MUTEX(tmp->mutex);
|
pipe_mutex_lock(tmp->mutex);
|
||||||
tmp->slabTimeout.tv_usec = slabTimeoutMsec*1000;
|
tmp->slabTimeout.tv_usec = slabTimeoutMsec*1000;
|
||||||
tmp->slabTimeout.tv_sec = tmp->slabTimeout.tv_usec / 1000000;
|
tmp->slabTimeout.tv_sec = tmp->slabTimeout.tv_usec / 1000000;
|
||||||
tmp->slabTimeout.tv_usec -= tmp->slabTimeout.tv_sec*1000000;
|
tmp->slabTimeout.tv_usec -= tmp->slabTimeout.tv_sec*1000000;
|
||||||
@@ -814,7 +814,7 @@ driInitFreeSlabManager(uint32_t checkIntervalMsec, uint32_t slabTimeoutMsec)
|
|||||||
DRMINITLISTHEAD(&tmp->timeoutList);
|
DRMINITLISTHEAD(&tmp->timeoutList);
|
||||||
DRMINITLISTHEAD(&tmp->unCached);
|
DRMINITLISTHEAD(&tmp->unCached);
|
||||||
DRMINITLISTHEAD(&tmp->cached);
|
DRMINITLISTHEAD(&tmp->cached);
|
||||||
_glthread_UNLOCK_MUTEX(tmp->mutex);
|
pipe_mutex_unlock(tmp->mutex);
|
||||||
|
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
@@ -827,9 +827,9 @@ driFinishFreeSlabManager(struct _DriFreeSlabManager *fMan)
|
|||||||
time = fMan->nextCheck;
|
time = fMan->nextCheck;
|
||||||
driTimeAdd(&time, &fMan->checkInterval);
|
driTimeAdd(&time, &fMan->checkInterval);
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(fMan->mutex);
|
pipe_mutex_lock(fMan->mutex);
|
||||||
driFreeTimeoutKBOsLocked(fMan, &time);
|
driFreeTimeoutKBOsLocked(fMan, &time);
|
||||||
_glthread_UNLOCK_MUTEX(fMan->mutex);
|
pipe_mutex_unlock(fMan->mutex);
|
||||||
|
|
||||||
assert(fMan->timeoutList.next == &fMan->timeoutList);
|
assert(fMan->timeoutList.next == &fMan->timeoutList);
|
||||||
assert(fMan->unCached.next == &fMan->unCached);
|
assert(fMan->unCached.next == &fMan->unCached);
|
||||||
@@ -842,8 +842,8 @@ static void
|
|||||||
driInitSizeHeader(struct _DriSlabPool *pool, uint32_t size,
|
driInitSizeHeader(struct _DriSlabPool *pool, uint32_t size,
|
||||||
struct _DriSlabSizeHeader *header)
|
struct _DriSlabSizeHeader *header)
|
||||||
{
|
{
|
||||||
_glthread_INIT_MUTEX(header->mutex);
|
pipe_mutex_init(header->mutex);
|
||||||
_glthread_LOCK_MUTEX(header->mutex);
|
pipe_mutex_lock(header->mutex);
|
||||||
|
|
||||||
DRMINITLISTHEAD(&header->slabs);
|
DRMINITLISTHEAD(&header->slabs);
|
||||||
DRMINITLISTHEAD(&header->freeSlabs);
|
DRMINITLISTHEAD(&header->freeSlabs);
|
||||||
@@ -853,7 +853,7 @@ driInitSizeHeader(struct _DriSlabPool *pool, uint32_t size,
|
|||||||
header->slabPool = pool;
|
header->slabPool = pool;
|
||||||
header->bufSize = size;
|
header->bufSize = size;
|
||||||
|
|
||||||
_glthread_UNLOCK_MUTEX(header->mutex);
|
pipe_mutex_unlock(header->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -862,7 +862,7 @@ driFinishSizeHeader(struct _DriSlabSizeHeader *header)
|
|||||||
drmMMListHead *list, *next;
|
drmMMListHead *list, *next;
|
||||||
struct _DriSlabBuffer *buf;
|
struct _DriSlabBuffer *buf;
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(header->mutex);
|
pipe_mutex_lock(header->mutex);
|
||||||
for (list = header->delayedBuffers.next, next = list->next;
|
for (list = header->delayedBuffers.next, next = list->next;
|
||||||
list != &header->delayedBuffers;
|
list != &header->delayedBuffers;
|
||||||
list = next, next = list->next) {
|
list = next, next = list->next) {
|
||||||
@@ -875,7 +875,7 @@ driFinishSizeHeader(struct _DriSlabSizeHeader *header)
|
|||||||
header->numDelayed--;
|
header->numDelayed--;
|
||||||
driSlabFreeBufferLocked(buf);
|
driSlabFreeBufferLocked(buf);
|
||||||
}
|
}
|
||||||
_glthread_UNLOCK_MUTEX(header->mutex);
|
pipe_mutex_unlock(header->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "main/glheader.h"
|
#include "main/glheader.h"
|
||||||
#include "glapi/glthread.h"
|
#include "pipe/p_lthread.h"
|
||||||
#include <GL/internal/glcore.h>
|
#include <GL/internal/glcore.h>
|
||||||
#include "state_tracker/st_public.h"
|
#include "state_tracker/st_public.h"
|
||||||
#include "intel_context.h"
|
#include "intel_context.h"
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
_glthread_DECLARE_STATIC_MUTEX( lockMutex );
|
pipe_static_mutex( lockMutex );
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -72,7 +72,7 @@ void LOCK_HARDWARE( struct intel_context *intel )
|
|||||||
{
|
{
|
||||||
char __ret = 0;
|
char __ret = 0;
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(lockMutex);
|
pipe_mutex_lock(lockMutex);
|
||||||
assert(!intel->locked);
|
assert(!intel->locked);
|
||||||
|
|
||||||
DRM_CAS(intel->driHwLock, intel->hHWContext,
|
DRM_CAS(intel->driHwLock, intel->hHWContext,
|
||||||
@@ -96,7 +96,7 @@ void UNLOCK_HARDWARE( struct intel_context *intel )
|
|||||||
|
|
||||||
DRM_UNLOCK(intel->driFd, intel->driHwLock, intel->hHWContext);
|
DRM_UNLOCK(intel->driFd, intel->driHwLock, intel->hHWContext);
|
||||||
|
|
||||||
_glthread_UNLOCK_MUTEX(lockMutex);
|
pipe_mutex_unlock(lockMutex);
|
||||||
|
|
||||||
DBG(LOCK, "%s - unlocked\n", __progname);
|
DBG(LOCK, "%s - unlocked\n", __progname);
|
||||||
}
|
}
|
||||||
|
@@ -37,6 +37,7 @@
|
|||||||
#include "main/glheader.h"
|
#include "main/glheader.h"
|
||||||
#include "glapi/glapi.h"
|
#include "glapi/glapi.h"
|
||||||
#include "glxapi.h"
|
#include "glxapi.h"
|
||||||
|
#include "pipe/p_thread.h"
|
||||||
|
|
||||||
|
|
||||||
extern struct _glxapi_table *_real_GetGLXDispatchTable(void);
|
extern struct _glxapi_table *_real_GetGLXDispatchTable(void);
|
||||||
@@ -127,26 +128,13 @@ get_dispatch(Display *dpy)
|
|||||||
/**
|
/**
|
||||||
* GLX API current context.
|
* GLX API current context.
|
||||||
*/
|
*/
|
||||||
#if defined(GLX_USE_TLS)
|
pipe_tsd ContextTSD;
|
||||||
PUBLIC __thread void * CurrentContext
|
|
||||||
__attribute__((tls_model("initial-exec")));
|
|
||||||
#elif defined(THREADS)
|
|
||||||
static _glthread_TSD ContextTSD; /**< Per-thread context pointer */
|
|
||||||
#else
|
|
||||||
static GLXContext CurrentContext = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
SetCurrentContext(GLXContext c)
|
SetCurrentContext(GLXContext c)
|
||||||
{
|
{
|
||||||
#if defined(GLX_USE_TLS)
|
pipe_tsd_set(&ContextTSD, c);
|
||||||
CurrentContext = c;
|
|
||||||
#elif defined(THREADS)
|
|
||||||
_glthread_SetTSD(&ContextTSD, c);
|
|
||||||
#else
|
|
||||||
CurrentContext = c;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -238,13 +226,7 @@ glXGetConfig(Display *dpy, XVisualInfo *visinfo, int attrib, int *value)
|
|||||||
GLXContext PUBLIC
|
GLXContext PUBLIC
|
||||||
glXGetCurrentContext(void)
|
glXGetCurrentContext(void)
|
||||||
{
|
{
|
||||||
#if defined(GLX_USE_TLS)
|
return (GLXContext) pipe_tsd_get(&ContextTSD);
|
||||||
return CurrentContext;
|
|
||||||
#elif defined(THREADS)
|
|
||||||
return (GLXContext) _glthread_GetTSD(&ContextTSD);
|
|
||||||
#else
|
|
||||||
return CurrentContext;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -62,7 +62,6 @@
|
|||||||
#include "xmesaP.h"
|
#include "xmesaP.h"
|
||||||
#include "main/context.h"
|
#include "main/context.h"
|
||||||
#include "main/framebuffer.h"
|
#include "main/framebuffer.h"
|
||||||
#include "glapi/glthread.h"
|
|
||||||
|
|
||||||
#include "state_tracker/st_public.h"
|
#include "state_tracker/st_public.h"
|
||||||
#include "state_tracker/st_context.h"
|
#include "state_tracker/st_context.h"
|
||||||
@@ -75,7 +74,7 @@
|
|||||||
/**
|
/**
|
||||||
* Global X driver lock
|
* Global X driver lock
|
||||||
*/
|
*/
|
||||||
_glthread_Mutex _xmesa_lock;
|
pipe_mutex _xmesa_lock;
|
||||||
|
|
||||||
|
|
||||||
int xmesa_mode;
|
int xmesa_mode;
|
||||||
@@ -245,10 +244,10 @@ xmesa_get_window_size(XMesaDisplay *dpy, XMesaBuffer b,
|
|||||||
#else
|
#else
|
||||||
Status stat;
|
Status stat;
|
||||||
|
|
||||||
_glthread_LOCK_MUTEX(_xmesa_lock);
|
pipe_mutex_lock(_xmesa_lock);
|
||||||
XSync(b->xm_visual->display, 0); /* added for Chromium */
|
XSync(b->xm_visual->display, 0); /* added for Chromium */
|
||||||
stat = get_drawable_size(dpy, b->drawable, width, height);
|
stat = get_drawable_size(dpy, b->drawable, width, height);
|
||||||
_glthread_UNLOCK_MUTEX(_xmesa_lock);
|
pipe_mutex_unlock(_xmesa_lock);
|
||||||
|
|
||||||
if (!stat) {
|
if (!stat) {
|
||||||
/* probably querying a window that's recently been destroyed */
|
/* probably querying a window that's recently been destroyed */
|
||||||
@@ -779,7 +778,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
|
|||||||
uint pf;
|
uint pf;
|
||||||
|
|
||||||
if (firstTime) {
|
if (firstTime) {
|
||||||
_glthread_INIT_MUTEX(_xmesa_lock);
|
pipe_mutex_init(_xmesa_lock);
|
||||||
firstTime = GL_FALSE;
|
firstTime = GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -35,9 +35,10 @@
|
|||||||
|
|
||||||
#include "state_tracker/st_context.h"
|
#include "state_tracker/st_context.h"
|
||||||
#include "state_tracker/st_public.h"
|
#include "state_tracker/st_public.h"
|
||||||
|
#include "pipe/p_thread.h"
|
||||||
|
|
||||||
|
|
||||||
extern _glthread_Mutex _xmesa_lock;
|
extern pipe_mutex _xmesa_lock;
|
||||||
|
|
||||||
extern XMesaBuffer XMesaBufferList;
|
extern XMesaBuffer XMesaBufferList;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user