summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/xlib
diff options
context:
space:
mode:
authorMichel Dänzer <michel@tungstengraphics.com>2008-01-25 17:01:01 +0100
committerMichel Dänzer <michel@tungstengraphics.com>2008-01-25 17:01:01 +0100
commit756d52ec12c41ee90ee9598dc9028cc134806bd2 (patch)
treea112f0b2a933faccb8e759c3b039f8b492daa8ed /src/mesa/pipe/xlib
parent7a207682aafc05c62cbc5851cc6c98c43aa3d9bd (diff)
gallium: Simplify winsys buffer interface.
The properties of a buffer represented by struct pipe_buffer_handle are now basically constant over its lifetime. The state tracker gets to deal with any more complex buffer semantics it may need to provide.
Diffstat (limited to 'src/mesa/pipe/xlib')
-rw-r--r--src/mesa/pipe/xlib/xm_winsys.c69
-rw-r--r--src/mesa/pipe/xlib/xm_winsys_aub.c119
2 files changed, 35 insertions, 153 deletions
diff --git a/src/mesa/pipe/xlib/xm_winsys.c b/src/mesa/pipe/xlib/xm_winsys.c
index 432431aca1..cb043ef394 100644
--- a/src/mesa/pipe/xlib/xm_winsys.c
+++ b/src/mesa/pipe/xlib/xm_winsys.c
@@ -165,48 +165,6 @@ xm_buffer_reference(struct pipe_winsys *pws,
}
}
-static int
-xm_buffer_data(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
- unsigned size, const void *data, unsigned usage )
-{
- struct xm_buffer *xm_buf = xm_bo(buf);
- assert(!xm_buf->userBuffer);
- if (xm_buf->size != size) {
- if (xm_buf->data)
- align_free(xm_buf->data);
- /* align to 16-byte multiple for Cell */
- xm_buf->data = align_malloc(size, 16);
- xm_buf->size = size;
- }
- if (data)
- memcpy(xm_buf->data, data, size);
- return 0;
-}
-
-static int
-xm_buffer_subdata(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
- unsigned long offset, unsigned long size, const void *data)
-{
- struct xm_buffer *xm_buf = xm_bo(buf);
- GLubyte *b = (GLubyte *) xm_buf->data;
- assert(!xm_buf->userBuffer);
- assert(b);
- memcpy(b + offset, data, size);
- return 0;
-}
-
-static int
-xm_buffer_get_subdata(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
- unsigned long offset, unsigned long size, void *data)
-{
- const struct xm_buffer *xm_buf = xm_bo(buf);
- const GLubyte *b = (GLubyte *) xm_buf->data;
- assert(!xm_buf->userBuffer);
- assert(b);
- memcpy(data, b + offset, size);
- return 0;
-}
-
/**
* Display a surface that's in a tiled configuration. That is, all the
@@ -317,11 +275,16 @@ xm_get_name(struct pipe_winsys *pws)
static struct pipe_buffer_handle *
xm_buffer_create(struct pipe_winsys *pws,
unsigned alignment,
- unsigned flags,
- unsigned hints)
+ unsigned usage,
+ unsigned size)
{
struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer);
buffer->refcount = 1;
+
+ /* align to 16-byte multiple for Cell */
+ buffer->data = align_malloc(size, max(alignment, 16));
+ buffer->size = size;
+
return pipe_bo(buffer);
}
@@ -359,7 +322,6 @@ xm_surface_alloc_storage(struct pipe_winsys *winsys,
unsigned flags)
{
const unsigned alignment = 64;
- int ret;
surf->width = width;
surf->height = height;
@@ -372,19 +334,11 @@ xm_surface_alloc_storage(struct pipe_winsys *winsys,
#endif
assert(!surf->buffer);
- surf->buffer = winsys->buffer_create(winsys, alignment, 0, 0);
+ surf->buffer = winsys->buffer_create(winsys, alignment,
+ PIPE_BUFFER_USAGE_PIXEL,
+ surf->pitch * surf->cpp * height);
if(!surf->buffer)
return -1;
-
- ret = winsys->buffer_data(winsys,
- surf->buffer,
- surf->pitch * surf->cpp * height,
- NULL,
- 0);
- if(ret) {
- winsys->buffer_reference(winsys, &surf->buffer, NULL);
- return ret;
- }
return 0;
}
@@ -454,9 +408,6 @@ xmesa_get_pipe_winsys_aub(void)
ws->buffer_map = xm_buffer_map;
ws->buffer_unmap = xm_buffer_unmap;
ws->buffer_reference = xm_buffer_reference;
- ws->buffer_data = xm_buffer_data;
- ws->buffer_subdata = xm_buffer_subdata;
- ws->buffer_get_subdata = xm_buffer_get_subdata;
ws->surface_alloc = xm_surface_alloc;
ws->surface_alloc_storage = xm_surface_alloc_storage;
diff --git a/src/mesa/pipe/xlib/xm_winsys_aub.c b/src/mesa/pipe/xlib/xm_winsys_aub.c
index 980c0be540..28dd07bc6e 100644
--- a/src/mesa/pipe/xlib/xm_winsys_aub.c
+++ b/src/mesa/pipe/xlib/xm_winsys_aub.c
@@ -101,7 +101,7 @@ static void *aub_buffer_map(struct pipe_winsys *winsys,
assert(sbo->data);
- if (flags & PIPE_BUFFER_FLAG_WRITE)
+ if (flags & PIPE_BUFFER_USAGE_CPU_WRITE)
sbo->dump_on_unmap = 1;
sbo->map_count++;
@@ -150,61 +150,6 @@ aub_buffer_reference(struct pipe_winsys *winsys,
}
-static int aub_buffer_data(struct pipe_winsys *winsys,
- struct pipe_buffer_handle *buf,
- unsigned size, const void *data,
- unsigned usage )
-{
- struct aub_pipe_winsys *iws = aub_pipe_winsys(winsys);
- struct aub_buffer *sbo = aub_bo(buf);
-
- /* Could reuse buffers that are not referenced in current
- * batchbuffer. Can't do that atm, so always reallocate:
- */
- if (1 || sbo->size < size) {
- assert(iws->used + size < iws->size);
- sbo->data = iws->pool + iws->used;
- sbo->offset = AUB_BUF_START + iws->used;
- iws->used += align(size, 4096);
- }
-
- sbo->size = size;
-
- if (data != NULL) {
- memcpy(sbo->data, data, size);
-
- brw_aub_gtt_data( iws->aubfile,
- sbo->offset,
- sbo->data,
- sbo->size,
- 0,
- 0 );
- }
- return 0;
-}
-
-static int aub_buffer_subdata(struct pipe_winsys *winsys,
- struct pipe_buffer_handle *buf,
- unsigned long offset,
- unsigned long size,
- const void *data)
-{
- struct aub_pipe_winsys *iws = aub_pipe_winsys(winsys);
- struct aub_buffer *sbo = aub_bo(buf);
-
- assert(sbo->size > offset + size);
- memcpy(sbo->data + offset, data, size);
-
- brw_aub_gtt_data( iws->aubfile,
- sbo->offset + offset,
- sbo->data + offset,
- size,
- 0,
- 0 );
- return 0;
-}
-
-
void xmesa_buffer_subdata_aub(struct pipe_winsys *winsys,
struct pipe_buffer_handle *buf,
unsigned long offset,
@@ -258,29 +203,30 @@ void xmesa_display_aub( /* struct pipe_winsys *winsys, */
-static int aub_buffer_get_subdata(struct pipe_winsys *winsys,
- struct pipe_buffer_handle *buf,
- unsigned long offset,
- unsigned long size,
- void *data)
-{
- struct aub_buffer *sbo = aub_bo(buf);
- assert(sbo->size >= offset + size);
- memcpy(data, sbo->data + offset, size);
- return 0;
-}
-
/* Pipe has no concept of pools. We choose the tex/region pool
* for all buffers.
*/
static struct pipe_buffer_handle *
aub_buffer_create(struct pipe_winsys *winsys,
- unsigned alignment,
- unsigned flags,
- unsigned hint)
+ unsigned alignment,
+ unsigned usage,
+ unsigned size)
{
+ struct aub_pipe_winsys *iws = aub_pipe_winsys(winsys);
struct aub_buffer *sbo = CALLOC_STRUCT(aub_buffer);
+
sbo->refcount = 1;
+
+ /* Could reuse buffers that are not referenced in current
+ * batchbuffer. Can't do that atm, so always reallocate:
+ */
+ assert(iws->used + size < iws->size);
+ sbo->data = iws->pool + iws->used;
+ sbo->offset = AUB_BUF_START + iws->used;
+ iws->used += align(size, 4096);
+
+ sbo->size = size;
+
return pipe_bo(sbo);
}
@@ -288,17 +234,14 @@ aub_buffer_create(struct pipe_winsys *winsys,
static struct pipe_buffer_handle *
aub_user_buffer_create(struct pipe_winsys *winsys, void *ptr, unsigned bytes)
{
- struct aub_buffer *sbo = CALLOC_STRUCT(aub_buffer);
-
- sbo->refcount = 1;
+ struct aub_buffer *sbo;
/* Lets hope this is meant for upload, not as a result!
*/
- aub_buffer_data( winsys,
- pipe_bo(sbo),
- bytes,
- ptr,
- 0 );
+ sbo = aub_bo(aub_buffer_create( winsys, 0, 0, 0 ));
+
+ sbo->data = ptr;
+ sbo->size = bytes;
return pipe_bo(sbo);
}
@@ -345,7 +288,6 @@ aub_i915_surface_alloc_storage(struct pipe_winsys *winsys,
unsigned flags)
{
const unsigned alignment = 64;
- int ret;
surf->width = width;
surf->height = height;
@@ -354,20 +296,12 @@ aub_i915_surface_alloc_storage(struct pipe_winsys *winsys,
surf->pitch = round_up(width, alignment / surf->cpp);
assert(!surf->buffer);
- surf->buffer = winsys->buffer_create(winsys, alignment, 0, 0);
+ surf->buffer = winsys->buffer_create(winsys, alignment,
+ PIPE_BUFFER_USAGE_PIXEL,
+ surf->pitch * surf->cpp * height);
if(!surf->buffer)
return -1;
- ret = winsys->buffer_data(winsys,
- surf->buffer,
- surf->pitch * surf->cpp * height,
- NULL,
- 0);
- if(ret) {
- winsys->buffer_reference(winsys, &surf->buffer, NULL);
- return ret;
- }
-
return 0;
}
@@ -418,9 +352,6 @@ xmesa_create_pipe_winsys_aub( void )
iws->winsys.buffer_map = aub_buffer_map;
iws->winsys.buffer_unmap = aub_buffer_unmap;
iws->winsys.buffer_reference = aub_buffer_reference;
- iws->winsys.buffer_data = aub_buffer_data;
- iws->winsys.buffer_subdata = aub_buffer_subdata;
- iws->winsys.buffer_get_subdata = aub_buffer_get_subdata;
iws->winsys.flush_frontbuffer = aub_flush_frontbuffer;
iws->winsys.printf = aub_printf;
iws->winsys.get_name = aub_get_name;