*/
static void intel_buffer_data(struct pipe_winsys *sws,
struct pipe_buffer_handle *buf,
- unsigned size, const void *data )
+ unsigned size, const void *data,
+ unsigned usage )
{
struct intel_context *intel = intel_pipe_winsys(sws)->intel;
winsys->buffer_data( winsys,
region->buffer,
pitch * cpp * height,
- NULL );
+ NULL,
+ PIPE_BUFFER_USAGE_PIXEL );
return region;
}
static void
xm_buffer_data(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
- unsigned size, const void *data )
+ unsigned size, const void *data, unsigned usage)
{
struct xm_buffer *xm_buf = xm_bo(buf);
assert(!xm_buf->userBuffer);
winsys->buffer_data( winsys,
region->buffer,
region->pitch * cpp * height,
- NULL );
+ NULL,
+ PIPE_BUFFER_USAGE_PIXEL );
return region;
}
/* FIXME: handle failure */
if(!vbuf->buf)
vbuf->buf = winsys->buffer_create(winsys, 64);
- winsys->buffer_data(winsys, vbuf->buf, VBUF_SIZE, NULL);
+ winsys->buffer_data( winsys, vbuf->buf,
+ VBUF_SIZE, NULL,
+ PIPE_BUFFER_USAGE_VERTEX );
vbuf->vertex_map = winsys->buffer_map(winsys,
vbuf->buf,
PIPE_BUFFER_FLAG_WRITE );
/**
- * Buffer flags
+ * Buffer access flags
*/
#define PIPE_BUFFER_FLAG_READ 0x1
#define PIPE_BUFFER_FLAG_WRITE 0x2
-#define PIPE_BUFFER_USE_TEXTURE 0x1
-#define PIPE_BUFFER_USE_VERTEX_BUFFER 0x2
-#define PIPE_BUFFER_USE_INDEX_BUFFER 0x4
-#define PIPE_BUFFER_USE_RENDER_TARGET 0x8
+
+/**
+ * Buffer usage flags
+ */
+#define PIPE_BUFFER_USAGE_PIXEL 0x1
+#define PIPE_BUFFER_USAGE_VERTEX 0x2
+#define PIPE_BUFFER_USAGE_INDEX 0x4
+#define PIPE_BUFFER_USAGE_CONSTANT 0x8
/**
struct pipe_buffer_handle **ptr,
struct pipe_buffer_handle *buf );
- /** Create the data store of a buffer and optionally initialize it */
+ /**
+ * 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.
+ */
void (*buffer_data)(struct pipe_winsys *sws,
struct pipe_buffer_handle *buf,
- unsigned size, const void *data );
+ unsigned size, const void *data,
+ unsigned usage);
/** Modify some or all of the data contained in a buffer's data store */
void (*buffer_subdata)(struct pipe_winsys *sws,
static void
xm_buffer_data(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
- unsigned size, const void *data )
+ unsigned size, const void *data, unsigned usage )
{
struct xm_buffer *xm_buf = xm_bo(buf);
assert(!xm_buf->userBuffer);
winsys->buffer_data( winsys,
region->buffer,
region->pitch * cpp * height,
- NULL );
+ NULL,
+ PIPE_BUFFER_USAGE_PIXEL );
return region;
}
}
/* load Mesa constants into the constant buffer */
- ws->buffer_data(ws, cbuf->buffer, paramBytes, params->ParameterValues);
+ ws->buffer_data(ws, cbuf->buffer, paramBytes, params->ParameterValues,
+ PIPE_BUFFER_USAGE_CONSTANT);
cbuf->size = paramBytes;
{
struct pipe_context *pipe = st_context(ctx)->pipe;
struct st_buffer_object *st_obj = st_buffer_object(obj);
+ unsigned buffer_usage;
st_obj->Base.Size = size;
st_obj->Base.Usage = usage;
+
+ switch(target) {
+ case GL_PIXEL_PACK_BUFFER_ARB:
+ case GL_PIXEL_UNPACK_BUFFER_ARB:
+ buffer_usage = PIPE_BUFFER_USAGE_PIXEL;
+ break;
+ case GL_ARRAY_BUFFER_ARB:
+ buffer_usage = PIPE_BUFFER_USAGE_VERTEX;
+ break;
+ case GL_ELEMENT_ARRAY_BUFFER_ARB:
+ buffer_usage = PIPE_BUFFER_USAGE_INDEX;
+ break;
+ default:
+ buffer_usage = 0;
+ }
- pipe->winsys->buffer_data( pipe->winsys, st_obj->buffer, size, data );
+ pipe->winsys->buffer_data( pipe->winsys, st_obj->buffer,
+ size, data,
+ buffer_usage );
}
const unsigned size = sizeof(ctx->Current.Attrib);
const void *data = ctx->Current.Attrib;
/* colors, texcoords, etc */
- pipe->winsys->buffer_data(pipe->winsys, buf, size, data);
+ pipe->winsys->buffer_data(pipe->winsys, buf,
+ size, data,
+ PIPE_BUFFER_USAGE_VERTEX);
/* position */
pipe->winsys->buffer_subdata(pipe->winsys, buf,
0, /* offset */
fb_buf.start_offset = 0;
pipe->winsys->buffer_data(pipe->winsys, fb_buf.buffer,
fb_buf.size,
- NULL); /* data */
+ NULL, /* data */
+ PIPE_BUFFER_USAGE_VERTEX);
if (pipe->set_feedback_buffer)
pipe->set_feedback_buffer(pipe, 0, &fb_buf);
}
/* XXX create one-time */
vbuf = pipe->winsys->buffer_create(pipe->winsys, 32);
- pipe->winsys->buffer_data(pipe->winsys, vbuf, vertex_bytes, verts);
+ pipe->winsys->buffer_data(pipe->winsys, vbuf,
+ vertex_bytes, verts,
+ PIPE_BUFFER_USAGE_VERTEX);
/* tell pipe about the vertex buffer */
vbuffer.buffer = vbuf;