summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2007-05-22 15:19:11 +0100
committerKeith Whitwell <keith@tungstengraphics.com>2007-05-22 16:37:20 +0100
commit6f3f2f3487b9ecbc6ea819171ece35a0a913fc3f (patch)
tree423d2def23b2d767d000e8622c9cd38311ad6096
parent36546ea24d70f158a8bcc8ba11a15f9f23e87718 (diff)
Add driBOAddListItemAndReference()
Increment refcount at the same time a buffer is added to a list. Reduces pthread mutex lock/unlock overhead.
-rw-r--r--src/mesa/drivers/dri/common/dri_bufmgr.c25
-rw-r--r--src/mesa/drivers/dri/common/dri_bufmgr.h5
2 files changed, 30 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/common/dri_bufmgr.c b/src/mesa/drivers/dri/common/dri_bufmgr.c
index 4e50be1532..f5a4945a3b 100644
--- a/src/mesa/drivers/dri/common/dri_bufmgr.c
+++ b/src/mesa/drivers/dri/common/dri_bufmgr.c
@@ -508,6 +508,31 @@ driBOAddListItem(struct _DriBufferList * list, struct _DriBufferObject *buf,
_glthread_UNLOCK_MUTEX(buf->mutex);
}
+
+void
+driBOAddListItemAndReference(struct _DriBufferList * list,
+ struct _DriBufferObject *buf,
+ unsigned flags, unsigned mask)
+{
+ int newItem;
+
+ _glthread_LOCK_MUTEX(buf->mutex);
+ _glthread_LOCK_MUTEX(bmMutex);
+ BM_CKFATAL(drmAddValidateItem(&list->drmBuffers, driBOKernel(buf),
+ flags, mask, &newItem));
+ if (buf->pool->validate)
+ BM_CKFATAL(drmAddValidateItem(&list->driBuffers, (drmBO *) buf,
+ flags, mask, &newItem));
+
+ if (++buf->refCount == 1) {
+ BM_CKFATAL(-EINVAL);
+ }
+
+ _glthread_UNLOCK_MUTEX(bmMutex);
+ _glthread_UNLOCK_MUTEX(buf->mutex);
+}
+
+
void
driBOFence(struct _DriBufferObject *buf, struct _DriFenceObject *fence)
{
diff --git a/src/mesa/drivers/dri/common/dri_bufmgr.h b/src/mesa/drivers/dri/common/dri_bufmgr.h
index 0fbcb29af0..4e45745668 100644
--- a/src/mesa/drivers/dri/common/dri_bufmgr.h
+++ b/src/mesa/drivers/dri/common/dri_bufmgr.h
@@ -87,6 +87,11 @@ extern void driBOResetList(struct _DriBufferList * list);
extern void driBOAddListItem(struct _DriBufferList * list,
struct _DriBufferObject *buf,
unsigned flags, unsigned mask);
+
+extern void driBOAddListItemAndReference(struct _DriBufferList * list,
+ struct _DriBufferObject *buf,
+ unsigned flags, unsigned mask);
+
extern void driBOValidateList(int fd, struct _DriBufferList * list);
extern void driBOFreeList(struct _DriBufferList * list);