summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2008-01-25 20:53:31 +0000
committerKeith Whitwell <[email protected]>2008-01-25 20:53:31 +0000
commit1e0d30a515e4cac891b6c590f12a33e0e8a8e295 (patch)
tree72ffec9e89bd0bd9202fcfc39f5e7bdf881adcf2 /src/mesa/drivers
parent756d52ec12c41ee90ee9598dc9028cc134806bd2 (diff)
gallium: rename pipe_buffer_handle to pipe_buffer, rework pipebuffer/ code
Provide an actual definition of the pipe_buffer struct, containing the parameters used to create the buffer, and its refcount. Shift refcounting buffers out of the winsys interface, similar to surfaces & textures. Rework pipebuffer/ to reflect the fact these changes, and also Michel's reworking of the buffer interface.
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_winsys.h23
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c2
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c53
-rw-r--r--src/mesa/drivers/x11/xm_winsys.c24
4 files changed, 53 insertions, 49 deletions
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_winsys.h b/src/mesa/drivers/dri/intel_winsys/intel_winsys.h
index 89e63e0a797..ffc40782be7 100644
--- a/src/mesa/drivers/dri/intel_winsys/intel_winsys.h
+++ b/src/mesa/drivers/dri/intel_winsys/intel_winsys.h
@@ -28,10 +28,12 @@
#ifndef INTEL_WINSYS_H
#define INTEL_WINSYS_H
+#include "pipe/p_state.h"
+
struct intel_context;
struct pipe_context;
struct pipe_winsys;
-struct pipe_buffer_handle;
+struct pipe_buffer;
struct _DriBufferObject;
struct pipe_winsys *
@@ -49,20 +51,21 @@ intel_create_i915simple( struct intel_context *intel,
struct pipe_winsys *winsys );
+struct intel_buffer {
+ struct pipe_buffer base;
+ struct _DriBufferObject *driBO;
+};
-/* Turn the pipe opaque buffer pointer into a dri_bufmgr opaque
- * buffer pointer...
- */
-static INLINE struct _DriBufferObject *
-dri_bo( struct pipe_buffer_handle *bo )
+static INLINE struct intel_buffer *
+intel_buffer( struct pipe_buffer *buf )
{
- return (struct _DriBufferObject *)bo;
+ return (struct intel_buffer *)buf;
}
-static INLINE struct pipe_buffer_handle *
-pipe_bo( struct _DriBufferObject *bo )
+static INLINE struct _DriBufferObject *
+dri_bo( struct pipe_buffer *buf )
{
- return (struct pipe_buffer_handle *)bo;
+ return intel_buffer(buf)->driBO;
}
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c b/src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c
index 8e0eea43922..1ba6a9e1b25 100644
--- a/src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c
+++ b/src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c
@@ -85,7 +85,7 @@ static void intel_i915_batch_dword( struct i915_winsys *sws,
}
static void intel_i915_batch_reloc( struct i915_winsys *sws,
- struct pipe_buffer_handle *buf,
+ struct pipe_buffer *buf,
unsigned access_flags,
unsigned delta )
{
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 43ed0602a4b..910c0d2cc5e 100644
--- a/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c
+++ b/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c
@@ -43,6 +43,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
#include "pipe/p_util.h"
+#include "pipe/p_inlines.h"
@@ -65,7 +66,7 @@ intel_pipe_winsys( struct pipe_winsys *winsys )
/* Most callbacks map direcly onto dri_bufmgr operations:
*/
static void *intel_buffer_map(struct pipe_winsys *winsys,
- struct pipe_buffer_handle *buf,
+ struct pipe_buffer *buf,
unsigned flags )
{
unsigned drm_flags = 0;
@@ -80,26 +81,17 @@ static void *intel_buffer_map(struct pipe_winsys *winsys,
}
static void intel_buffer_unmap(struct pipe_winsys *winsys,
- struct pipe_buffer_handle *buf)
+ struct pipe_buffer *buf)
{
driBOUnmap( dri_bo(buf) );
}
static void
-intel_buffer_reference(struct pipe_winsys *winsys,
- struct pipe_buffer_handle **ptr,
- struct pipe_buffer_handle *buf)
+intel_buffer_destroy(struct pipe_winsys *winsys,
+ struct pipe_buffer *buf)
{
- if (*ptr) {
- driBOUnReference( dri_bo(*ptr) );
- *ptr = NULL;
- }
-
- if (buf) {
- driBOReference( dri_bo(buf) );
- *ptr = buf;
- }
+ driBOUnReference( dri_bo(buf) );
}
@@ -107,16 +99,21 @@ intel_buffer_reference(struct pipe_winsys *winsys,
* for all buffers.
* Grabs the hardware lock!
*/
-static struct pipe_buffer_handle *
+static struct pipe_buffer *
intel_buffer_create(struct pipe_winsys *winsys,
unsigned alignment,
unsigned usage,
unsigned size )
{
- struct _DriBufferObject *buffer;
+ struct intel_buffer *buffer = CALLOC_STRUCT( intel_buffer );
struct intel_pipe_winsys *iws = intel_pipe_winsys(winsys);
unsigned flags = 0;
+ buffer->base.refcount = 1;
+ buffer->base.alignment = alignment;
+ buffer->base.usage = usage;
+ buffer->base.size = size;
+
if (usage & (PIPE_BUFFER_USAGE_VERTEX /*| IWS_BUFFER_USAGE_LOCAL*/)) {
flags |= DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_CACHED;
} else {
@@ -143,20 +140,24 @@ intel_buffer_create(struct pipe_winsys *winsys,
#endif
driGenBuffers( iws->regionPool,
- "pipe buffer", 1, &buffer, alignment, flags, 0 );
- driBOData( buffer, size, NULL, 0 );
- return pipe_bo(buffer);
+ "pipe buffer", 1, &buffer->driBO, alignment, flags, 0 );
+
+ driBOData( buffer->driBO, size, NULL, 0 );
+
+ return &buffer->base;
}
-static struct pipe_buffer_handle *
+static struct pipe_buffer *
intel_user_buffer_create(struct pipe_winsys *winsys, void *ptr, unsigned bytes)
{
- struct _DriBufferObject *buffer;
+ struct intel_buffer *buffer = CALLOC_STRUCT( intel_buffer );
struct intel_pipe_winsys *iws = intel_pipe_winsys(winsys);
+
driGenUserBuffer( iws->regionPool,
- "pipe user buffer", &buffer, ptr, bytes);
- return pipe_bo(buffer);
+ "pipe user buffer", &buffer->driBO, ptr, bytes);
+
+ return &buffer->base;
}
@@ -224,7 +225,7 @@ intel_i915_surface_alloc_storage(struct pipe_winsys *winsys,
return -1;
if(ret) {
- winsys->buffer_reference(winsys, &surf->buffer, NULL);
+ pipe_buffer_reference(winsys, &surf->buffer, NULL);
return ret;
}
@@ -239,7 +240,7 @@ intel_i915_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s)
surf->refcount--;
if (surf->refcount == 0) {
if (surf->buffer)
- winsys->buffer_reference(winsys, &surf->buffer, NULL);
+ pipe_buffer_reference(winsys, &surf->buffer, NULL);
free(surf);
}
*s = NULL;
@@ -279,7 +280,7 @@ intel_create_pipe_winsys( int fd )
iws->winsys.user_buffer_create = intel_user_buffer_create;
iws->winsys.buffer_map = intel_buffer_map;
iws->winsys.buffer_unmap = intel_buffer_unmap;
- iws->winsys.buffer_reference = intel_buffer_reference;
+ iws->winsys.buffer_destroy = intel_buffer_destroy;
iws->winsys.flush_frontbuffer = intel_flush_frontbuffer;
iws->winsys.printf = intel_printf;
iws->winsys.get_name = intel_get_name;
diff --git a/src/mesa/drivers/x11/xm_winsys.c b/src/mesa/drivers/x11/xm_winsys.c
index dafbe96a1ec..a690df27727 100644
--- a/src/mesa/drivers/x11/xm_winsys.c
+++ b/src/mesa/drivers/x11/xm_winsys.c
@@ -71,15 +71,15 @@ struct xm_buffer
* buffer pointer...
*/
static inline struct xm_buffer *
-xm_bo( struct pipe_buffer_handle *bo )
+xm_bo( struct pipe_buffer *bo )
{
return (struct xm_buffer *) bo;
}
-static inline struct pipe_buffer_handle *
+static inline struct pipe_buffer *
pipe_bo( struct xm_buffer *bo )
{
- return (struct pipe_buffer_handle *) bo;
+ return (struct pipe_buffer *) bo;
}
/* Turn a softpipe winsys into an xm/softpipe winsys:
@@ -94,7 +94,7 @@ xm_winsys(struct softpipe_winsys *sws)
/* Most callbacks map direcly onto dri_bufmgr operations:
*/
static void *
-xm_buffer_map(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
+xm_buffer_map(struct pipe_winsys *pws, struct pipe_buffer *buf,
unsigned flags)
{
struct xm_buffer *xm_buf = xm_bo(buf);
@@ -103,7 +103,7 @@ xm_buffer_map(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
}
static void
-xm_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer_handle *buf)
+xm_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf)
{
struct xm_buffer *xm_buf = xm_bo(buf);
xm_buf->mapped = NULL;
@@ -111,8 +111,8 @@ xm_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer_handle *buf)
static void
xm_buffer_reference(struct pipe_winsys *pws,
- struct pipe_buffer_handle **ptr,
- struct pipe_buffer_handle *buf)
+ struct pipe_buffer **ptr,
+ struct pipe_buffer *buf)
{
if (*ptr) {
struct xm_buffer *oldBuf = xm_bo(*ptr);
@@ -139,7 +139,7 @@ xm_buffer_reference(struct pipe_winsys *pws,
}
static void
-xm_buffer_data(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
+xm_buffer_data(struct pipe_winsys *pws, struct pipe_buffer *buf,
unsigned size, const void *data, unsigned usage)
{
struct xm_buffer *xm_buf = xm_bo(buf);
@@ -155,7 +155,7 @@ xm_buffer_data(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
}
static void
-xm_buffer_subdata(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
+xm_buffer_subdata(struct pipe_winsys *pws, struct pipe_buffer *buf,
unsigned long offset, unsigned long size, const void *data)
{
struct xm_buffer *xm_buf = xm_bo(buf);
@@ -166,7 +166,7 @@ xm_buffer_subdata(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
}
static void
-xm_buffer_get_subdata(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
+xm_buffer_get_subdata(struct pipe_winsys *pws, struct pipe_buffer *buf,
unsigned long offset, unsigned long size, void *data)
{
const struct xm_buffer *xm_buf = xm_bo(buf);
@@ -209,7 +209,7 @@ xm_get_name(struct pipe_winsys *pws)
}
-static struct pipe_buffer_handle *
+static struct pipe_buffer *
xm_buffer_create(struct pipe_winsys *pws,
unsigned alignment,
unsigned flags,
@@ -224,7 +224,7 @@ xm_buffer_create(struct pipe_winsys *pws,
/**
* Create buffer which wraps user-space data.
*/
-static struct pipe_buffer_handle *
+static struct pipe_buffer *
xm_user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes)
{
struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer);