aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-09-10 16:52:05 -0600
committerBrian <[email protected]>2007-09-10 16:52:05 -0600
commit6275b40063d7d06e0b05767ebca3963ce7e9c34e (patch)
tree1323c9c266075c70ae186e0f31ca8d09999a088b /src/mesa/drivers
parent051a2a3028370da66c15c44fa49fa9474b23d668 (diff)
merge buffer_unreference(), buffer_reference()
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c18
-rw-r--r--src/mesa/drivers/x11/xm_winsys.c42
2 files changed, 29 insertions, 31 deletions
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c b/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c
index 33aacf2a431..668bedcbdab 100644
--- a/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c
+++ b/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c
@@ -84,22 +84,21 @@ static void intel_buffer_unmap(struct pipe_winsys *sws,
}
-static struct pipe_buffer_handle *
+static void
intel_buffer_reference(struct pipe_winsys *sws,
+ struct pipe_buffer_handle **ptr,
struct pipe_buffer_handle *buf)
{
- return pipe_bo( driBOReference( dri_bo(buf) ) );
-}
-
-static void intel_buffer_unreference(struct pipe_winsys *sws,
- struct pipe_buffer_handle **buf)
-{
- if (*buf) {
- driBOUnReference( dri_bo(*buf) );
+ if (*ptr) {
+ driBOUnReference( dri_bo(*ptr) );
*buf = NULL;
}
+
+ driBOReference( dri_bo(buf) );
+ *ptr = buf;
}
+
/* Grabs the hardware lock!
*/
static void intel_buffer_data(struct pipe_winsys *sws,
@@ -208,7 +207,6 @@ intel_create_pipe_winsys( struct intel_context *intel )
iws->winsys.buffer_map = intel_buffer_map;
iws->winsys.buffer_unmap = intel_buffer_unmap;
iws->winsys.buffer_reference = intel_buffer_reference;
- iws->winsys.buffer_unreference = intel_buffer_unreference;
iws->winsys.buffer_data = intel_buffer_data;
iws->winsys.buffer_subdata = intel_buffer_subdata;
iws->winsys.buffer_get_subdata = intel_buffer_get_subdata;
diff --git a/src/mesa/drivers/x11/xm_winsys.c b/src/mesa/drivers/x11/xm_winsys.c
index f1ecbf531f7..b7b2941490c 100644
--- a/src/mesa/drivers/x11/xm_winsys.c
+++ b/src/mesa/drivers/x11/xm_winsys.c
@@ -108,30 +108,31 @@ xm_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer_handle *buf)
xm_buf->mapped = NULL;
}
-
-static struct pipe_buffer_handle *
-xm_buffer_reference(struct pipe_winsys *pws, struct pipe_buffer_handle *buf)
-{
- struct xm_buffer *xm_buf = xm_bo(buf);
- xm_buf->refcount++;
- return buf;
-}
-
static void
-xm_buffer_unreference(struct pipe_winsys *pws, struct pipe_buffer_handle **buf)
+xm_buffer_reference(struct pipe_winsys *pws,
+ struct pipe_buffer_handle **ptr,
+ struct pipe_buffer_handle *buf)
{
- if (*buf) {
- struct xm_buffer *xm_buf = xm_bo(*buf);
- xm_buf->refcount--;
- assert(xm_buf->refcount >= 0);
- if (xm_buf->refcount == 0) {
- if (xm_buf->data) {
- free(xm_buf->data);
- xm_buf->data = NULL;
+ if (*ptr) {
+ struct xm_buffer *oldBuf = xm_bo(*ptr);
+ oldBuf->refcount--;
+ assert(oldBuf->refcount >= 0);
+ if (oldBuf->refcount == 0) {
+ if (oldBuf->data) {
+ free(oldBuf->data);
+ oldBuf->data = NULL;
}
- free(xm_buf);
+ free(oldBuf);
}
- *buf = NULL;
+ *ptr = NULL;
+ }
+
+ assert(!(*ptr));
+
+ if (buf) {
+ struct xm_buffer *newBuf = xm_bo(buf);
+ newBuf->refcount++;
+ *ptr = buf;
}
}
@@ -237,7 +238,6 @@ xmesa_create_pipe_winsys( XMesaContext xmesa )
xws->winsys.buffer_map = xm_buffer_map;
xws->winsys.buffer_unmap = xm_buffer_unmap;
xws->winsys.buffer_reference = xm_buffer_reference;
- xws->winsys.buffer_unreference = xm_buffer_unreference;
xws->winsys.buffer_data = xm_buffer_data;
xws->winsys.buffer_subdata = xm_buffer_subdata;
xws->winsys.buffer_get_subdata = xm_buffer_get_subdata;