summaryrefslogtreecommitdiff
path: root/src/mesa/pipe
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
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')
-rw-r--r--src/mesa/pipe/i915simple/i915_context.c4
-rw-r--r--src/mesa/pipe/i915simple/i915_prim_vbuf.c8
-rw-r--r--src/mesa/pipe/i915simple/i915_state.c3
-rw-r--r--src/mesa/pipe/i915simple/i915_texture.c14
-rw-r--r--src/mesa/pipe/i965simple/brw_curbe.c7
-rw-r--r--src/mesa/pipe/i965simple/brw_draw_upload.c6
-rw-r--r--src/mesa/pipe/i965simple/brw_misc_state.c6
-rw-r--r--src/mesa/pipe/i965simple/brw_state_pool.c10
-rw-r--r--src/mesa/pipe/i965simple/brw_tex_layout.c14
-rw-r--r--src/mesa/pipe/p_defines.h26
-rw-r--r--src/mesa/pipe/p_inlines.h4
-rw-r--r--src/mesa/pipe/p_winsys.h59
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_handle.c52
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_handle.h4
-rw-r--r--src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c3
-rw-r--r--src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c4
-rw-r--r--src/mesa/pipe/softpipe/sp_draw_arrays.c6
-rw-r--r--src/mesa/pipe/softpipe/sp_texture.c9
-rw-r--r--src/mesa/pipe/xlib/xm_winsys.c69
-rw-r--r--src/mesa/pipe/xlib/xm_winsys_aub.c119
20 files changed, 105 insertions, 322 deletions
diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c
index 1c6b8cbb05..c2b96d2554 100644
--- a/src/mesa/pipe/i915simple/i915_context.c
+++ b/src/mesa/pipe/i915simple/i915_context.c
@@ -185,7 +185,7 @@ i915_draw_elements( struct pipe_context *pipe,
void *buf
= pipe->winsys->buffer_map(pipe->winsys,
i915->vertex_buffer[i].buffer,
- PIPE_BUFFER_FLAG_READ);
+ PIPE_BUFFER_USAGE_CPU_READ);
draw_set_mapped_vertex_buffer(draw, i, buf);
}
}
@@ -193,7 +193,7 @@ i915_draw_elements( struct pipe_context *pipe,
if (indexBuffer) {
void *mapped_indexes
= pipe->winsys->buffer_map(pipe->winsys, indexBuffer,
- PIPE_BUFFER_FLAG_READ);
+ PIPE_BUFFER_USAGE_CPU_READ);
draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes);
}
else {
diff --git a/src/mesa/pipe/i915simple/i915_prim_vbuf.c b/src/mesa/pipe/i915simple/i915_prim_vbuf.c
index edc62e25e5..0887f9a1c6 100644
--- a/src/mesa/pipe/i915simple/i915_prim_vbuf.c
+++ b/src/mesa/pipe/i915simple/i915_prim_vbuf.c
@@ -99,16 +99,14 @@ i915_vbuf_render_allocate_vertices( struct vbuf_render *render,
/* FIXME: handle failure */
assert(!i915->vbo);
- i915->vbo = winsys->buffer_create(winsys, 64, 0, 0);
- winsys->buffer_data( winsys, i915->vbo,
- size, NULL,
- I915_BUFFER_USAGE_LIT_VERTEX );
+ i915->vbo = winsys->buffer_create(winsys, 64, I915_BUFFER_USAGE_LIT_VERTEX,
+ size);
i915->dirty |= I915_NEW_VBO;
return winsys->buffer_map(winsys,
i915->vbo,
- PIPE_BUFFER_FLAG_WRITE );
+ PIPE_BUFFER_USAGE_CPU_WRITE);
}
diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c
index 1190e05699..950ea52d60 100644
--- a/src/mesa/pipe/i915simple/i915_state.c
+++ b/src/mesa/pipe/i915simple/i915_state.c
@@ -476,7 +476,8 @@ static void i915_set_constant_buffer(struct pipe_context *pipe,
{
void *mapped;
if (buf->size &&
- (mapped = ws->buffer_map(ws, buf->buffer, PIPE_BUFFER_FLAG_READ))) {
+ (mapped = ws->buffer_map(ws, buf->buffer,
+ PIPE_BUFFER_USAGE_CPU_READ))) {
memcpy(i915->current.constants[shader], mapped, buf->size);
ws->buffer_unmap(ws, buf->buffer);
i915->current.num_user_constants[shader]
diff --git a/src/mesa/pipe/i915simple/i915_texture.c b/src/mesa/pipe/i915simple/i915_texture.c
index 6b0a4a96f3..bf80e18233 100644
--- a/src/mesa/pipe/i915simple/i915_texture.c
+++ b/src/mesa/pipe/i915simple/i915_texture.c
@@ -490,15 +490,11 @@ i915_texture_create(struct pipe_context *pipe, struct pipe_texture **pt)
sizeof(struct i915_texture) - sizeof(struct pipe_texture));
if (i915->flags.is_i945 ? i945_miptree_layout(pipe, tex) :
- i915_miptree_layout(pipe, tex)) {
- tex->buffer = pipe->winsys->buffer_create(pipe->winsys, 64, 0, 0);
-
- if (tex->buffer)
- pipe->winsys->buffer_data(pipe->winsys, tex->buffer,
- tex->pitch * tex->base.cpp *
- tex->total_height, NULL,
- PIPE_BUFFER_USAGE_PIXEL);
- }
+ i915_miptree_layout(pipe, tex))
+ tex->buffer = pipe->winsys->buffer_create(pipe->winsys, 64,
+ PIPE_BUFFER_USAGE_PIXEL,
+ tex->pitch * tex->base.cpp *
+ tex->total_height);
if (!tex->buffer) {
FREE(tex);
diff --git a/src/mesa/pipe/i965simple/brw_curbe.c b/src/mesa/pipe/i965simple/brw_curbe.c
index 4d79a7abe2..2733eb4e75 100644
--- a/src/mesa/pipe/i965simple/brw_curbe.c
+++ b/src/mesa/pipe/i965simple/brw_curbe.c
@@ -255,15 +255,12 @@ static void upload_constant_buffer(struct brw_context *brw)
/* FIXME: buffer size is num_consts + num_immediates */
if (brw->vs.prog_data->num_consts) {
/* map the vertex constant buffer and copy to curbe: */
- ws->buffer_map(ws, cbuffer->buffer, 0);
+ void *data = ws->buffer_map(ws, cbuffer->buffer, 0);
/* FIXME: this is wrong. the cbuffer->size currently
* represents size of consts + immediates. so if we'll
* have both we'll copy over the end of the buffer
* with the subsequent memcpy */
- ws->buffer_get_subdata(ws, cbuffer->buffer,
- 0,
- cbuffer->size,
- &buf[offset]);
+ memcpy(&buf[offset], data, cbuffer->size);
ws->buffer_unmap(ws, cbuffer->buffer);
offset += cbuffer->size;
}
diff --git a/src/mesa/pipe/i965simple/brw_draw_upload.c b/src/mesa/pipe/i965simple/brw_draw_upload.c
index 88d6c9d111..43e53914e9 100644
--- a/src/mesa/pipe/i965simple/brw_draw_upload.c
+++ b/src/mesa/pipe/i965simple/brw_draw_upload.c
@@ -240,7 +240,7 @@ boolean brw_upload_vertex_buffers( struct brw_context *brw )
for (i = 0; i < nr_enabled; i++) {
OUT_BATCH( vbp.vb[i].vb0.dword );
- OUT_RELOC( vbp.vb[i].buffer, PIPE_BUFFER_FLAG_READ,
+ OUT_RELOC( vbp.vb[i].buffer, PIPE_BUFFER_USAGE_GPU_READ,
vbp.vb[i].offset);
OUT_BATCH( vbp.vb[i].max_index );
OUT_BATCH( vbp.vb[i].instance_data_step_rate );
@@ -290,8 +290,8 @@ boolean brw_upload_indices( struct brw_context *brw,
BEGIN_BATCH(4, 0);
OUT_BATCH( ib.header.dword );
- OUT_RELOC( index_buffer, PIPE_BUFFER_FLAG_READ, start);
- OUT_RELOC( index_buffer, PIPE_BUFFER_FLAG_READ, start + count);
+ OUT_RELOC( index_buffer, PIPE_BUFFER_USAGE_GPU_READ, start);
+ OUT_RELOC( index_buffer, PIPE_BUFFER_USAGE_GPU_READ, start + count);
OUT_BATCH( 0 );
ADVANCE_BATCH();
}
diff --git a/src/mesa/pipe/i965simple/brw_misc_state.c b/src/mesa/pipe/i965simple/brw_misc_state.c
index 3b7f36dd1d..925049ecc1 100644
--- a/src/mesa/pipe/i965simple/brw_misc_state.c
+++ b/src/mesa/pipe/i965simple/brw_misc_state.c
@@ -245,7 +245,7 @@ static void upload_depthbuffer(struct brw_context *brw)
// (depth_surface->region->tiled << 27) |
(BRW_SURFACE_2D << 29));
OUT_RELOC(depth_surface->buffer,
- PIPE_BUFFER_FLAG_READ | PIPE_BUFFER_FLAG_WRITE, 0);
+ PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE, 0);
OUT_BATCH((BRW_SURFACE_MIPMAPLAYOUT_BELOW << 1) |
((depth_surface->pitch - 1) << 6) |
((depth_surface->height - 1) << 19));
@@ -465,10 +465,10 @@ static void upload_state_base_address( struct brw_context *brw )
BEGIN_BATCH(6, INTEL_BATCH_NO_CLIPRECTS);
OUT_BATCH(CMD_STATE_BASE_ADDRESS << 16 | (6 - 2));
OUT_RELOC(brw->pool[BRW_GS_POOL].buffer,
- PIPE_BUFFER_FLAG_READ,
+ PIPE_BUFFER_USAGE_GPU_READ,
1); /* General state base address */
OUT_RELOC(brw->pool[BRW_SS_POOL].buffer,
- PIPE_BUFFER_FLAG_READ,
+ PIPE_BUFFER_USAGE_GPU_READ,
1); /* Surface state base address */
OUT_BATCH(1); /* Indirect object base address */
OUT_BATCH(1); /* General state upper bound */
diff --git a/src/mesa/pipe/i965simple/brw_state_pool.c b/src/mesa/pipe/i965simple/brw_state_pool.c
index 78268ed8f2..2f930be837 100644
--- a/src/mesa/pipe/i965simple/brw_state_pool.c
+++ b/src/mesa/pipe/i965simple/brw_state_pool.c
@@ -91,13 +91,9 @@ static void brw_init_pool( struct brw_context *brw,
pool->brw = brw;
pool->buffer = brw->pipe.winsys->buffer_create(brw->pipe.winsys,
- 4096, 0, 0);
-
- brw->pipe.winsys->buffer_data(brw->pipe.winsys,
- pool->buffer,
- size,
- NULL,
- 0 /* DRM_BO_FLAG_MEM_TT */);
+ 4096,
+ 0 /* DRM_BO_FLAG_MEM_TT */,
+ size);
}
static void brw_destroy_pool( struct brw_context *brw,
diff --git a/src/mesa/pipe/i965simple/brw_tex_layout.c b/src/mesa/pipe/i965simple/brw_tex_layout.c
index 2b2bf16f1b..eadacbf09e 100644
--- a/src/mesa/pipe/i965simple/brw_tex_layout.c
+++ b/src/mesa/pipe/i965simple/brw_tex_layout.c
@@ -308,15 +308,11 @@ brw_texture_create(struct pipe_context *pipe, struct pipe_texture **pt)
memset(&tex->base + 1, 0,
sizeof(struct brw_texture) - sizeof(struct pipe_texture));
- if (brw_miptree_layout(pipe, tex)) {
- tex->buffer = pipe->winsys->buffer_create(pipe->winsys, 64, 0, 0);
-
- if (tex->buffer)
- pipe->winsys->buffer_data(pipe->winsys, tex->buffer,
- tex->pitch * tex->base.cpp *
- tex->total_height, NULL,
- PIPE_BUFFER_USAGE_PIXEL);
- }
+ if (brw_miptree_layout(pipe, tex))
+ tex->buffer = pipe->winsys->buffer_create(pipe->winsys, 64,
+ PIPE_BUFFER_USAGE_PIXEL,
+ tex->pitch * tex->base.cpp *
+ tex->total_height);
if (!tex->buffer) {
FREE(tex);
diff --git a/src/mesa/pipe/p_defines.h b/src/mesa/pipe/p_defines.h
index 50bea691e7..90eebd5e6c 100644
--- a/src/mesa/pipe/p_defines.h
+++ b/src/mesa/pipe/p_defines.h
@@ -178,25 +178,19 @@ enum pipe_texture_target {
/**
- * Buffer access flags
- */
-#define PIPE_BUFFER_FLAG_READ 0x1
-#define PIPE_BUFFER_FLAG_WRITE 0x2
-#define PIPE_BUFFER_FLAG_MEM_LOCAL 0x4
-#define PIPE_BUFFER_FLAG_CACHED 0x8
-#define PIPE_BUFFER_FLAG_CUSTOM (1<<16)
-
-
-
-/**
* Buffer usage flags
*/
-#define PIPE_BUFFER_USAGE_PIXEL (1 << 0)
-#define PIPE_BUFFER_USAGE_VERTEX (1 << 1)
-#define PIPE_BUFFER_USAGE_INDEX (1 << 2)
-#define PIPE_BUFFER_USAGE_CONSTANT (1 << 3)
+#define PIPE_BUFFER_USAGE_CPU_READ (1 << 0)
+#define PIPE_BUFFER_USAGE_CPU_WRITE (1 << 1)
+#define PIPE_BUFFER_USAGE_GPU_READ (1 << 2)
+#define PIPE_BUFFER_USAGE_GPU_WRITE (1 << 3)
+#define PIPE_BUFFER_USAGE_PIXEL (1 << 4)
+#define PIPE_BUFFER_USAGE_VERTEX (1 << 5)
+#define PIPE_BUFFER_USAGE_INDEX (1 << 6)
+#define PIPE_BUFFER_USAGE_CONSTANT (1 << 7)
/** Pipe driver custam usage flags should be greater or equal to this value */
-#define PIPE_BUFFER_USAGE_CUSTOM (1 << 16)
+#define PIPE_BUFFER_USAGE_CUSTOM (1 << 16)
+
/**
* Flush types:
diff --git a/src/mesa/pipe/p_inlines.h b/src/mesa/pipe/p_inlines.h
index 6976d087f9..8ee0820f92 100644
--- a/src/mesa/pipe/p_inlines.h
+++ b/src/mesa/pipe/p_inlines.h
@@ -37,8 +37,8 @@ static INLINE void *
pipe_surface_map(struct pipe_surface *surface)
{
return (char *)surface->winsys->buffer_map( surface->winsys, surface->buffer,
- PIPE_BUFFER_FLAG_WRITE |
- PIPE_BUFFER_FLAG_READ )
+ PIPE_BUFFER_USAGE_CPU_WRITE |
+ PIPE_BUFFER_USAGE_CPU_READ )
+ surface->offset;
}
diff --git a/src/mesa/pipe/p_winsys.h b/src/mesa/pipe/p_winsys.h
index 75c6dc7e85..9742f59a4d 100644
--- a/src/mesa/pipe/p_winsys.h
+++ b/src/mesa/pipe/p_winsys.h
@@ -1,4 +1,4 @@
-/**************************************************************************
+ /**************************************************************************
*
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
@@ -93,17 +93,20 @@ struct pipe_winsys
/**
- * The buffer manager is modeled after the dri_bufmgr interface, which
- * in turn is modeled after the ARB_vertex_buffer_object extension,
- * but this is the subset that gallium cares about. Remember that
- * gallium gets to choose the interface it needs, and the window
- * systems must then implement that interface (rather than the
+ * Buffer management. Buffer attributes are mostly fixed over its lifetime.
+ *
+ * Remember that gallium gets to choose the interface it needs, and the
+ * window systems must then implement that interface (rather than the
* other way around...).
+ *
+ * usage is a bitmask of PIPE_BUFFER_USAGE_PIXEL/VERTEX/INDEX/CONSTANT. This
+ * usage argument is only an optimization hint, not a guarantee, therefore
+ * proper behavior must be observed in all circumstances.
*/
struct pipe_buffer_handle *(*buffer_create)( struct pipe_winsys *sws,
unsigned alignment,
- unsigned flags,
- unsigned hint );
+ unsigned usage,
+ unsigned size );
/** Create a buffer that wraps user-space data */
struct pipe_buffer_handle *(*user_buffer_create)(struct pipe_winsys *sws,
@@ -116,7 +119,7 @@ struct pipe_winsys
*/
void *(*buffer_map)( struct pipe_winsys *sws,
struct pipe_buffer_handle *buf,
- unsigned flags );
+ unsigned usage );
void (*buffer_unmap)( struct pipe_winsys *sws,
struct pipe_buffer_handle *buf );
@@ -126,44 +129,8 @@ struct pipe_winsys
struct pipe_buffer_handle **ptr,
struct pipe_buffer_handle *buf );
- /**
- * Create the data store of a buffer and optionally initialize it.
- *
- * usage is a bitmask of PIPE_BUFFER_USAGE_PIXEL/VERTEX/INDEX/CONSTANT. This
- * usage argument is only an optimization hint, not a guarantee, therefore
- * proper behavior must be observed in all circumstances.
- *
- * Returns zero on success.
- */
- int (*buffer_data)(struct pipe_winsys *sws,
- struct pipe_buffer_handle *buf,
- unsigned size, const void *data,
- unsigned usage);
- /**
- * Modify some or all of the data contained in a buffer's data store.
- *
- * Returns zero on success.
- */
- int (*buffer_subdata)(struct pipe_winsys *sws,
- struct pipe_buffer_handle *buf,
- unsigned long offset,
- unsigned long size,
- const void *data);
-
- /**
- * Query some or all of the data contained in a buffer's data store.
- *
- * Returns zero on success.
- */
- int (*buffer_get_subdata)(struct pipe_winsys *sws,
- struct pipe_buffer_handle *buf,
- unsigned long offset,
- unsigned long size,
- void *data);
-
-
- /** Set ptr = buf, with reference counting */
+ /** Set ptr = fence, with reference counting */
void (*fence_reference)( struct pipe_winsys *sws,
struct pipe_fence_handle **ptr,
struct pipe_fence_handle *fence );
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_handle.c b/src/mesa/pipe/pipebuffer/pb_buffer_handle.c
index 5a5eaee7ac..9aeff976f3 100644
--- a/src/mesa/pipe/pipebuffer/pb_buffer_handle.c
+++ b/src/mesa/pipe/pipebuffer/pb_buffer_handle.c
@@ -46,8 +46,8 @@
static struct pipe_buffer_handle *
buffer_handle_create(struct pipe_winsys *winsys,
unsigned alignment,
- unsigned flags,
- unsigned hint)
+ unsigned usage,
+ unsigned size)
{
struct pipe_buffer_handle *handle;
@@ -57,8 +57,8 @@ buffer_handle_create(struct pipe_winsys *winsys,
handle->refcount = 1;
handle->alignment = alignment;
- handle->flags = flags;
- handle->hint = hint;
+ handle->usage = usage;
+ handle->size = size;
handle->buf = &null_buffer;
@@ -73,7 +73,7 @@ buffer_handle_create_user(struct pipe_winsys *winsys,
struct pipe_buffer_handle *handle;
struct pipe_buffer *buf;
- handle = buffer_handle_create(winsys, 1, 0, 0);
+ handle = buffer_handle_create(winsys, 1, 0, size);
if(!handle)
return NULL;
@@ -129,46 +129,6 @@ buffer_handle_reference(struct pipe_winsys *winsys,
}
-static int
-buffer_handle_subdata(struct pipe_winsys *winsys,
- struct pipe_buffer_handle *handle,
- unsigned long offset,
- unsigned long size,
- const void *data)
-{
- void *map;
- assert(handle);
- assert(data);
- map = buffer_handle_map(winsys, handle, PIPE_BUFFER_FLAG_WRITE);
- if(map) {
- memcpy((char *)map + offset, data, size);
- buffer_handle_unmap(winsys, handle);
- return 0;
- }
- return -1;
-}
-
-
-static int
-buffer_handle_get_subdata(struct pipe_winsys *winsys,
- struct pipe_buffer_handle *handle,
- unsigned long offset,
- unsigned long size,
- void *data)
-{
- void *map;
- assert(handle);
- assert(data);
- map = buffer_handle_map(winsys, handle, PIPE_BUFFER_FLAG_READ);
- if(map) {
- memcpy(data, (char *)map + offset, size);
- buffer_handle_unmap(winsys, handle);
- return 0;
- }
- return -1;
-}
-
-
void
buffer_handle_init_winsys(struct pipe_winsys *winsys)
{
@@ -177,6 +137,4 @@ buffer_handle_init_winsys(struct pipe_winsys *winsys)
winsys->buffer_map = buffer_handle_map;
winsys->buffer_unmap = buffer_handle_unmap;
winsys->buffer_reference = buffer_handle_reference;
- winsys->buffer_subdata = buffer_handle_subdata;
- winsys->buffer_get_subdata = buffer_handle_get_subdata;
}
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_handle.h b/src/mesa/pipe/pipebuffer/pb_buffer_handle.h
index 076eec2fdc..34133c9fba 100644
--- a/src/mesa/pipe/pipebuffer/pb_buffer_handle.h
+++ b/src/mesa/pipe/pipebuffer/pb_buffer_handle.h
@@ -55,8 +55,8 @@ struct pipe_buffer_handle
/** Allocation characteristics */
unsigned alignment;
- unsigned flags;
- unsigned hint;
+ unsigned usage;
+ unsigned size;
/**
* The actual buffer.
diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c b/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c
index e9bc34b4a4..d174f24e32 100644
--- a/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c
+++ b/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c
@@ -241,7 +241,8 @@ mm_bufmgr_create_from_buffer(struct pipe_buffer *buffer,
mm->buffer = buffer;
mm->map = buffer_map(mm->buffer,
- PIPE_BUFFER_FLAG_READ | PIPE_BUFFER_FLAG_WRITE );
+ PIPE_BUFFER_USAGE_CPU_READ |
+ PIPE_BUFFER_USAGE_CPU_WRITE);
if(!mm->map)
goto failure;
diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c b/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c
index ee6fa62500..e6a8c78668 100644
--- a/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c
+++ b/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c
@@ -246,8 +246,8 @@ pool_bufmgr_create(struct buffer_manager *provider,
goto failure;
pool->map = buffer_map(pool->buffer,
- PIPE_BUFFER_FLAG_READ |
- PIPE_BUFFER_FLAG_WRITE );
+ PIPE_BUFFER_USAGE_CPU_READ |
+ PIPE_BUFFER_USAGE_CPU_WRITE);
if(!pool->map)
goto failure;
diff --git a/src/mesa/pipe/softpipe/sp_draw_arrays.c b/src/mesa/pipe/softpipe/sp_draw_arrays.c
index b7626f8a5f..8ee9177e5b 100644
--- a/src/mesa/pipe/softpipe/sp_draw_arrays.c
+++ b/src/mesa/pipe/softpipe/sp_draw_arrays.c
@@ -50,7 +50,7 @@ softpipe_map_constant_buffers(struct softpipe_context *sp)
for (i = 0; i < 2; i++) {
if (sp->constants[i].size)
sp->mapped_constants[i] = ws->buffer_map(ws, sp->constants[i].buffer,
- PIPE_BUFFER_FLAG_READ);
+ PIPE_BUFFER_USAGE_CPU_READ);
}
draw_set_mapped_constant_buffer(sp->draw,
@@ -122,7 +122,7 @@ softpipe_draw_elements(struct pipe_context *pipe,
void *buf
= pipe->winsys->buffer_map(pipe->winsys,
sp->vertex_buffer[i].buffer,
- PIPE_BUFFER_FLAG_READ);
+ PIPE_BUFFER_USAGE_CPU_READ);
draw_set_mapped_vertex_buffer(draw, i, buf);
}
}
@@ -130,7 +130,7 @@ softpipe_draw_elements(struct pipe_context *pipe,
if (indexBuffer) {
void *mapped_indexes
= pipe->winsys->buffer_map(pipe->winsys, indexBuffer,
- PIPE_BUFFER_FLAG_READ);
+ PIPE_BUFFER_USAGE_CPU_READ);
draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes);
}
else {
diff --git a/src/mesa/pipe/softpipe/sp_texture.c b/src/mesa/pipe/softpipe/sp_texture.c
index d43a6996e9..23e9c1b376 100644
--- a/src/mesa/pipe/softpipe/sp_texture.c
+++ b/src/mesa/pipe/softpipe/sp_texture.c
@@ -91,12 +91,9 @@ softpipe_texture_create(struct pipe_context *pipe, struct pipe_texture **pt)
softpipe_texture_layout(spt);
- spt->buffer = pipe->winsys->buffer_create(pipe->winsys, 32, 0, 0);
-
- if (spt->buffer) {
- pipe->winsys->buffer_data(pipe->winsys, spt->buffer, spt->buffer_size,
- NULL, PIPE_BUFFER_USAGE_PIXEL);
- }
+ spt->buffer = pipe->winsys->buffer_create(pipe->winsys, 32,
+ PIPE_BUFFER_USAGE_PIXEL,
+ spt->buffer_size);
if (!spt->buffer) {
FREE(spt);
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;