summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c82
-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
-rw-r--r--src/mesa/state_tracker/st_atom_constbuf.c16
-rw-r--r--src/mesa/state_tracker/st_cb_bufferobjects.c106
-rw-r--r--src/mesa/state_tracker/st_cb_bufferobjects.h1
-rw-r--r--src/mesa/state_tracker/st_context.h7
-rw-r--r--src/mesa/state_tracker/st_draw.c45
26 files changed, 228 insertions, 456 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 340fa2fb85..43ed0602a4 100644
--- a/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c
+++ b/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c
@@ -70,10 +70,10 @@ static void *intel_buffer_map(struct pipe_winsys *winsys,
{
unsigned drm_flags = 0;
- if (flags & PIPE_BUFFER_FLAG_WRITE)
+ if (flags & PIPE_BUFFER_USAGE_CPU_WRITE)
drm_flags |= DRM_BO_FLAG_WRITE;
- if (flags & PIPE_BUFFER_FLAG_READ)
+ if (flags & PIPE_BUFFER_USAGE_CPU_READ)
drm_flags |= DRM_BO_FLAG_READ;
return driBOMap( dri_bo(buf), drm_flags, 0 );
@@ -103,50 +103,48 @@ intel_buffer_reference(struct pipe_winsys *winsys,
}
-/* Grabs the hardware lock!
- */
-static int intel_buffer_data(struct pipe_winsys *winsys,
- struct pipe_buffer_handle *buf,
- unsigned size, const void *data,
- unsigned usage )
-{
- driBOData( dri_bo(buf), size, data, 0 );
- return 0;
-}
-
-static int intel_buffer_subdata(struct pipe_winsys *winsys,
- struct pipe_buffer_handle *buf,
- unsigned long offset,
- unsigned long size,
- const void *data)
-{
- driBOSubData( dri_bo(buf), offset, size, data );
- return 0;
-}
-
-static int intel_buffer_get_subdata(struct pipe_winsys *winsys,
- struct pipe_buffer_handle *buf,
- unsigned long offset,
- unsigned long size,
- void *data)
-{
- driBOGetSubData( dri_bo(buf), offset, size, data );
- return 0;
-}
-
/* Pipe has no concept of pools. We choose the tex/region pool
* for all buffers.
+ * Grabs the hardware lock!
*/
static struct pipe_buffer_handle *
intel_buffer_create(struct pipe_winsys *winsys,
unsigned alignment,
- unsigned flags,
- unsigned hint )
+ unsigned usage,
+ unsigned size )
{
struct _DriBufferObject *buffer;
struct intel_pipe_winsys *iws = intel_pipe_winsys(winsys);
+ unsigned flags = 0;
+
+ if (usage & (PIPE_BUFFER_USAGE_VERTEX /*| IWS_BUFFER_USAGE_LOCAL*/)) {
+ flags |= DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_CACHED;
+ } else {
+ flags |= DRM_BO_FLAG_MEM_VRAM | DRM_BO_FLAG_MEM_TT;
+ }
+
+ if (usage & PIPE_BUFFER_USAGE_GPU_READ)
+ flags |= DRM_BO_FLAG_READ;
+
+ if (usage & PIPE_BUFFER_USAGE_GPU_WRITE)
+ flags |= DRM_BO_FLAG_WRITE;
+
+ /* drm complains if we don't set any read/write flags.
+ */
+ if ((flags & (DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE)) == 0)
+ flags |= DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE;
+
+#if 0
+ if (flags & IWS_BUFFER_USAGE_EXE)
+ flags |= DRM_BO_FLAG_EXE;
+
+ if (usage & IWS_BUFFER_USAGE_CACHED)
+ flags |= DRM_BO_FLAG_CACHED;
+#endif
+
driGenBuffers( iws->regionPool,
- "pipe buffer", 1, &buffer, alignment, flags, hint );
+ "pipe buffer", 1, &buffer, alignment, flags, 0 );
+ driBOData( buffer, size, NULL, 0 );
return pipe_bo(buffer);
}
@@ -219,15 +217,12 @@ intel_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,
- PIPE_BUFFER_USAGE_PIXEL);
if(ret) {
winsys->buffer_reference(winsys, &surf->buffer, NULL);
return ret;
@@ -285,9 +280,6 @@ intel_create_pipe_winsys( int fd )
iws->winsys.buffer_map = intel_buffer_map;
iws->winsys.buffer_unmap = intel_buffer_unmap;
iws->winsys.buffer_reference = intel_buffer_reference;
- iws->winsys.buffer_data = intel_buffer_data;
- iws->winsys.buffer_subdata = intel_buffer_subdata;
- iws->winsys.buffer_get_subdata = intel_buffer_get_subdata;
iws->winsys.flush_frontbuffer = intel_flush_frontbuffer;
iws->winsys.printf = intel_printf;
iws->winsys.get_name = intel_get_name;
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;
diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c
index 57f5ec68d2..c9d63136b5 100644
--- a/src/mesa/state_tracker/st_atom_constbuf.c
+++ b/src/mesa/state_tracker/st_atom_constbuf.c
@@ -69,8 +69,13 @@ void st_upload_constants( struct st_context *st,
_mesa_load_state_parameters(st->ctx, params);
- if (!cbuf->buffer)
- cbuf->buffer = ws->buffer_create(ws, 1, 0, 0);
+ if (cbuf->buffer && cbuf->size != paramBytes)
+ ws->buffer_reference( ws, &cbuf->buffer, NULL );
+
+ if (!cbuf->buffer) {
+ cbuf->buffer = ws->buffer_create(ws, 1, PIPE_BUFFER_USAGE_CONSTANT,
+ paramBytes);
+ }
if (0)
{
@@ -80,8 +85,11 @@ void st_upload_constants( struct st_context *st,
}
/* load Mesa constants into the constant buffer */
- ws->buffer_data(ws, cbuf->buffer, paramBytes, params->ParameterValues,
- PIPE_BUFFER_USAGE_CONSTANT);
+ if (cbuf->buffer) {
+ memcpy(ws->buffer_map(ws, cbuf->buffer, PIPE_BUFFER_USAGE_CPU_WRITE),
+ params->ParameterValues, paramBytes);
+ ws->buffer_unmap(ws, cbuf->buffer);
+ }
cbuf->size = paramBytes;
diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c
index 872248cdb5..60bd1d5f0d 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -55,7 +55,6 @@
static struct gl_buffer_object *
st_bufferobj_alloc(GLcontext *ctx, GLuint name, GLenum target)
{
- struct st_context *st = st_context(ctx);
struct st_buffer_object *st_obj = CALLOC_STRUCT(st_buffer_object);
if (!st_obj)
@@ -63,8 +62,6 @@ st_bufferobj_alloc(GLcontext *ctx, GLuint name, GLenum target)
_mesa_initialize_buffer_object(&st_obj->Base, name, target);
- st_obj->buffer = st->pipe->winsys->buffer_create( st->pipe->winsys, 32, 0, 0 );
-
return &st_obj->Base;
}
@@ -89,6 +86,57 @@ st_bufferobj_free(GLcontext *ctx, struct gl_buffer_object *obj)
/**
+ * Replace data in a subrange of buffer object. If the data range
+ * specified by size + offset extends beyond the end of the buffer or
+ * if data is NULL, no copy is performed.
+ * Called via glBufferSubDataARB().
+ */
+static void
+st_bufferobj_subdata(GLcontext *ctx,
+ GLenum target,
+ GLintptrARB offset,
+ GLsizeiptrARB size,
+ const GLvoid * data, struct gl_buffer_object *obj)
+{
+ struct pipe_context *pipe = st_context(ctx)->pipe;
+ struct st_buffer_object *st_obj = st_buffer_object(obj);
+ char *map;
+
+ if (offset >= st_obj->size || size > (st_obj->size - offset))
+ return;
+
+ map = pipe->winsys->buffer_map(pipe->winsys, st_obj->buffer,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
+ memcpy(map + offset, data, size);
+ pipe->winsys->buffer_unmap(pipe->winsys, st_obj->buffer);
+}
+
+
+/**
+ * Called via glGetBufferSubDataARB().
+ */
+static void
+st_bufferobj_get_subdata(GLcontext *ctx,
+ GLenum target,
+ GLintptrARB offset,
+ GLsizeiptrARB size,
+ GLvoid * data, struct gl_buffer_object *obj)
+{
+ struct pipe_context *pipe = st_context(ctx)->pipe;
+ struct st_buffer_object *st_obj = st_buffer_object(obj);
+ char *map;
+
+ if (offset >= st_obj->size || size > (st_obj->size - offset))
+ return;
+
+ map = pipe->winsys->buffer_map(pipe->winsys, st_obj->buffer,
+ PIPE_BUFFER_USAGE_CPU_READ);
+ memcpy(data, map + offset, size);
+ pipe->winsys->buffer_unmap(pipe->winsys, st_obj->buffer);
+}
+
+
+/**
* Allocate space for and store data in a buffer object. Any data that was
* previously stored in the buffer object is lost. If data is NULL,
* memory will be allocated, but no copy will occur.
@@ -102,7 +150,8 @@ st_bufferobj_data(GLcontext *ctx,
GLenum usage,
struct gl_buffer_object *obj)
{
- struct pipe_context *pipe = st_context(ctx)->pipe;
+ struct st_context *st = st_context(ctx);
+ struct pipe_context *pipe = st->pipe;
struct st_buffer_object *st_obj = st_buffer_object(obj);
unsigned buffer_usage;
@@ -124,46 +173,15 @@ st_bufferobj_data(GLcontext *ctx,
buffer_usage = 0;
}
- pipe->winsys->buffer_data( pipe->winsys, st_obj->buffer,
- size, data,
- buffer_usage );
-}
+ pipe->winsys->buffer_reference( pipe->winsys, &st_obj->buffer, NULL );
+ st_obj->buffer = pipe->winsys->buffer_create( pipe->winsys, 32, buffer_usage,
+ size );
-/**
- * Replace data in a subrange of buffer object. If the data range
- * specified by size + offset extends beyond the end of the buffer or
- * if data is NULL, no copy is performed.
- * Called via glBufferSubDataARB().
- */
-static void
-st_bufferobj_subdata(GLcontext *ctx,
- GLenum target,
- GLintptrARB offset,
- GLsizeiptrARB size,
- const GLvoid * data, struct gl_buffer_object *obj)
-{
- struct pipe_context *pipe = st_context(ctx)->pipe;
- struct st_buffer_object *st_obj = st_buffer_object(obj);
-
- pipe->winsys->buffer_subdata(pipe->winsys, st_obj->buffer, offset, size, data);
-}
-
-
-/**
- * Called via glGetBufferSubDataARB().
- */
-static void
-st_bufferobj_get_subdata(GLcontext *ctx,
- GLenum target,
- GLintptrARB offset,
- GLsizeiptrARB size,
- GLvoid * data, struct gl_buffer_object *obj)
-{
- struct pipe_context *pipe = st_context(ctx)->pipe;
- struct st_buffer_object *st_obj = st_buffer_object(obj);
+ st_obj->size = size;
- pipe->winsys->buffer_get_subdata(pipe->winsys, st_obj->buffer, offset, size, data);
+ if (data)
+ st_bufferobj_subdata(ctx, target, 0, size, data, obj);
}
@@ -180,15 +198,15 @@ st_bufferobj_map(GLcontext *ctx, GLenum target, GLenum access,
switch (access) {
case GL_WRITE_ONLY:
- flags = PIPE_BUFFER_FLAG_WRITE;
+ flags = PIPE_BUFFER_USAGE_CPU_WRITE;
break;
case GL_READ_ONLY:
- flags = PIPE_BUFFER_FLAG_READ;
+ flags = PIPE_BUFFER_USAGE_CPU_READ;
break;
case GL_READ_WRITE:
/* fall-through */
default:
- flags = PIPE_BUFFER_FLAG_READ | PIPE_BUFFER_FLAG_WRITE;
+ flags = PIPE_BUFFER_USAGE_CPU_READ | PIPE_BUFFER_USAGE_CPU_WRITE;
break;
}
diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.h b/src/mesa/state_tracker/st_cb_bufferobjects.h
index 2090a743e0..15003ae15d 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.h
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.h
@@ -40,6 +40,7 @@ struct st_buffer_object
{
struct gl_buffer_object Base;
struct pipe_buffer_handle *buffer;
+ GLsizeiptrARB size;
};
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 5ae21c93f9..2b6f8743f3 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -164,13 +164,6 @@ struct st_context
struct st_fragment_program *combined_prog;
} bitmap;
- /**
- * Buffer object which stores the ctx->Current.Attrib[] values.
- * Used for vertex array drawing when we we need an attribute for
- * which there's no enabled array.
- */
- struct pipe_buffer_handle *default_attrib_buffer;
-
struct cso_cache *cache;
};
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 71acf6e862..371d4e7966 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -191,29 +191,6 @@ pipe_vertex_format(GLenum type, GLuint size, GLboolean normalized)
/**
- * The default attribute buffer is basically a copy of the
- * ctx->Current.Attrib[] array. It's used when the vertex program
- * references an attribute for which we don't have a VBO/array.
- */
-static void
-create_default_attribs_buffer(struct st_context *st)
-{
- struct pipe_context *pipe = st->pipe;
- /* XXX don't hardcode magic 32 here */
- st->default_attrib_buffer = pipe->winsys->buffer_create( pipe->winsys, 32, 0, 0 );
-}
-
-
-static void
-destroy_default_attribs_buffer(struct st_context *st)
-{
- struct pipe_context *pipe = st->pipe;
- pipe->winsys->buffer_reference(pipe->winsys,
- &st->default_attrib_buffer, NULL);
-}
-
-
-/**
* This function gets plugged into the VBO module and is called when
* we have something to render.
* Basically, translate the information into the format expected by pipe.
@@ -399,10 +376,14 @@ st_draw_vertices(GLcontext *ctx, unsigned prim,
}
/* XXX create one-time */
- vbuf = pipe->winsys->buffer_create(pipe->winsys, 32, 0, 0);
- pipe->winsys->buffer_data(pipe->winsys, vbuf,
- vertex_bytes, verts,
- PIPE_BUFFER_USAGE_VERTEX);
+ vbuf = pipe->winsys->buffer_create(pipe->winsys, 32,
+ PIPE_BUFFER_USAGE_VERTEX, vertex_bytes);
+ assert(vbuf);
+
+ memcpy(pipe->winsys->buffer_map(pipe->winsys, vbuf,
+ PIPE_BUFFER_USAGE_CPU_WRITE),
+ verts, vertex_bytes);
+ pipe->winsys->buffer_unmap(pipe->winsys, vbuf);
/* tell pipe about the vertex buffer */
vbuffer.buffer = vbuf;
@@ -568,7 +549,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
/* map the attrib buffer */
map = pipe->winsys->buffer_map(pipe->winsys,
vbuffer[attr].buffer,
- PIPE_BUFFER_FLAG_READ);
+ PIPE_BUFFER_USAGE_CPU_READ);
draw_set_mapped_vertex_buffer(draw, attr, map);
}
@@ -592,7 +573,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
map = pipe->winsys->buffer_map(pipe->winsys,
index_buffer_handle,
- PIPE_BUFFER_FLAG_READ);
+ PIPE_BUFFER_USAGE_CPU_READ);
draw_set_mapped_element_buffer(draw, indexSize, map);
}
else {
@@ -604,7 +585,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
/* map constant buffers */
mapped_constants = winsys->buffer_map(winsys,
st->state.constants[PIPE_SHADER_VERTEX].buffer,
- PIPE_BUFFER_FLAG_READ);
+ PIPE_BUFFER_USAGE_CPU_READ);
draw_set_mapped_constant_buffer(st->draw, mapped_constants);
@@ -640,16 +621,12 @@ void st_init_draw( struct st_context *st )
{
GLcontext *ctx = st->ctx;
- /* actually, not used here, but elsewhere */
- create_default_attribs_buffer(st);
-
vbo_set_draw_func(ctx, st_draw_vbo);
}
void st_destroy_draw( struct st_context *st )
{
- destroy_default_attribs_buffer(st);
}