summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker/st_atom_constbuf.c
diff options
context:
space:
mode:
authorMichel Dänzer <[email protected]>2008-01-25 17:01:01 +0100
committerMichel Dänzer <[email protected]>2008-01-25 17:01:01 +0100
commit756d52ec12c41ee90ee9598dc9028cc134806bd2 (patch)
treea112f0b2a933faccb8e759c3b039f8b492daa8ed /src/mesa/state_tracker/st_atom_constbuf.c
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/state_tracker/st_atom_constbuf.c')
-rw-r--r--src/mesa/state_tracker/st_atom_constbuf.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c
index 57f5ec68d20..c9d63136b5f 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;