diff options
author | José Fonseca <[email protected]> | 2009-02-24 11:30:25 +0000 |
---|---|---|
committer | José Fonseca <[email protected]> | 2009-02-24 11:30:25 +0000 |
commit | 693fac8ae2e5812265222b1335695bd33b90bd8a (patch) | |
tree | df1bf997bcec57a8b9db1451c8fb40c488221ef0 /src/mesa | |
parent | c5dd8634c8d3487a171cd129c2b7ac6e205e72a7 (diff) |
gallium: Add pipe_buffer_write/read inlines.
Saves code, and will simplify future interface changes.
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/state_tracker/st_atom_constbuf.c | 10 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_bitmap.c | 16 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_bufferobjects.c | 10 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_clear.c | 12 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_drawpixels.c | 5 |
5 files changed, 16 insertions, 37 deletions
diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c index 514b10cd022..2df6fef210e 100644 --- a/src/mesa/state_tracker/st_atom_constbuf.c +++ b/src/mesa/state_tracker/st_atom_constbuf.c @@ -85,12 +85,10 @@ void st_upload_constants( struct st_context *st, } /* load Mesa constants into the constant buffer */ - if (cbuf->buffer) { - void *map = pipe_buffer_map(pipe->screen, cbuf->buffer, - PIPE_BUFFER_USAGE_CPU_WRITE); - memcpy(map, params->ParameterValues, paramBytes); - pipe_buffer_unmap(pipe->screen, cbuf->buffer); - } + if (cbuf->buffer) + pipe_buffer_write(pipe->screen, cbuf->buffer, + 0, paramBytes, + params->ParameterValues); st->pipe->set_constant_buffer(st->pipe, id, 0, cbuf); } diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index ef44a08859c..66d7cbf8e6a 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -417,17 +417,11 @@ setup_bitmap_vertex_data(struct st_context *st, } /* put vertex data into vbuf */ - { - char *buf = pipe_buffer_map(pipe->screen, - st->bitmap.vbuf, - PIPE_BUFFER_USAGE_CPU_WRITE); - - memcpy(buf + st->bitmap.vbuf_slot * sizeof st->bitmap.vertices, - st->bitmap.vertices, - sizeof st->bitmap.vertices); - - pipe_buffer_unmap(pipe->screen, st->bitmap.vbuf); - } + pipe_buffer_write(pipe->screen, + st->bitmap.vbuf, + st->bitmap.vbuf_slot * sizeof st->bitmap.vertices, + sizeof st->bitmap.vertices, + st->bitmap.vertices); return st->bitmap.vbuf_slot++ * sizeof st->bitmap.vertices; } diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c index aba1cda9323..562ac6c65c5 100644 --- a/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -100,14 +100,11 @@ st_bufferobj_subdata(GLcontext *ctx, { 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_buffer_map(pipe->screen, st_obj->buffer, PIPE_BUFFER_USAGE_CPU_WRITE); - memcpy(map + offset, data, size); - pipe_buffer_unmap(pipe->screen, st_obj->buffer); + pipe_buffer_write(pipe->screen, st_obj->buffer, offset, size, data); } @@ -123,14 +120,11 @@ st_bufferobj_get_subdata(GLcontext *ctx, { 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_buffer_map(pipe->screen, st_obj->buffer, PIPE_BUFFER_USAGE_CPU_READ); - memcpy(data, map + offset, size); - pipe_buffer_unmap(pipe->screen, st_obj->buffer); + pipe_buffer_read(pipe->screen, st_obj->buffer, offset, size, data); } diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 20eaaa4ae73..c6fc7cec27c 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -150,7 +150,6 @@ draw_quad(GLcontext *ctx, struct pipe_context *pipe = st->pipe; const GLuint max_slots = 1024 / sizeof(st->clear.vertices); GLuint i; - void *buf; if (st->clear.vbuf_slot >= max_slots) { pipe_buffer_reference(pipe->screen, &st->clear.vbuf, NULL); @@ -186,13 +185,10 @@ draw_quad(GLcontext *ctx, } /* put vertex data into vbuf */ - buf = pipe_buffer_map(pipe->screen, st->clear.vbuf, PIPE_BUFFER_USAGE_CPU_WRITE); - - memcpy((char *)buf + st->clear.vbuf_slot * sizeof(st->clear.vertices), - st->clear.vertices, - sizeof(st->clear.vertices)); - - pipe_buffer_unmap(pipe->screen, st->clear.vbuf); + pipe_buffer_write(pipe->screen, st->clear.vbuf, + st->clear.vbuf_slot * sizeof(st->clear.vertices), + sizeof(st->clear.vertices), + st->clear.vertices); /* draw */ util_draw_vertex_buffer(pipe, diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 13307fc2c12..c73d0080cac 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -485,14 +485,11 @@ draw_quad(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z, { struct pipe_buffer *buf; - ubyte *map; /* allocate/load buffer object with vertex data */ buf = pipe_buffer_create(pipe->screen, 32, PIPE_BUFFER_USAGE_VERTEX, sizeof(verts)); - map = pipe_buffer_map(pipe->screen, buf, PIPE_BUFFER_USAGE_CPU_WRITE); - memcpy(map, verts, sizeof(verts)); - pipe_buffer_unmap(pipe->screen, buf); + pipe_buffer_write(pipe->screen, buf, 0, sizeof(verts), verts); util_draw_vertex_buffer(pipe, buf, 0, PIPE_PRIM_QUADS, |