summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZack Rusin <zackr@vmware.com>2009-01-26 15:22:53 -0500
committerZack Rusin <zackr@vmware.com>2009-01-27 12:20:26 -0500
commit4f5308bdcb9e62f678975a77783a48096f6dfdc6 (patch)
tree3895687d86bdff430155b850b663d252f867dfdc /src
parentd6888e811d24eaa7e8d9093be606394f00435c05 (diff)
gallium: remove redundant size from the constant buffer
reuse the size of the actual buffer
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/i915simple/i915_state.c6
-rw-r--r--src/gallium/drivers/i965simple/brw_curbe.c6
-rw-r--r--src/gallium/drivers/nv10/nv10_state.c7
-rw-r--r--src/gallium/drivers/nv20/nv20_state.c7
-rw-r--r--src/gallium/drivers/nv30/nv30_state.c2
-rw-r--r--src/gallium/drivers/nv40/nv40_state.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_draw_arrays.c6
-rw-r--r--src/gallium/drivers/softpipe/sp_state_fs.c1
-rw-r--r--src/gallium/drivers/trace/tr_state.c1
-rw-r--r--src/gallium/include/pipe/p_state.h1
-rw-r--r--src/mesa/state_tracker/st_atom_constbuf.c2
11 files changed, 19 insertions, 22 deletions
diff --git a/src/gallium/drivers/i915simple/i915_state.c b/src/gallium/drivers/i915simple/i915_state.c
index f46e46eb22..19f194c027 100644
--- a/src/gallium/drivers/i915simple/i915_state.c
+++ b/src/gallium/drivers/i915simple/i915_state.c
@@ -535,13 +535,13 @@ static void i915_set_constant_buffer(struct pipe_context *pipe,
*/
if (buf) {
void *mapped;
- if (buf->size &&
+ if (buf->buffer && buf->buffer->size &&
(mapped = ws->buffer_map(ws, buf->buffer,
PIPE_BUFFER_USAGE_CPU_READ))) {
- memcpy(i915->current.constants[shader], mapped, buf->size);
+ memcpy(i915->current.constants[shader], mapped, buf->buffer->size);
ws->buffer_unmap(ws, buf->buffer);
i915->current.num_user_constants[shader]
- = buf->size / (4 * sizeof(float));
+ = buf->buffer->size / (4 * sizeof(float));
}
else {
i915->current.num_user_constants[shader] = 0;
diff --git a/src/gallium/drivers/i965simple/brw_curbe.c b/src/gallium/drivers/i965simple/brw_curbe.c
index 824ee7fd6d..5e1cce7530 100644
--- a/src/gallium/drivers/i965simple/brw_curbe.c
+++ b/src/gallium/drivers/i965simple/brw_curbe.c
@@ -257,13 +257,13 @@ static void upload_constant_buffer(struct brw_context *brw)
if (brw->vs.prog_data->num_consts) {
/* map the vertex constant buffer and copy to curbe: */
void *data = ws->buffer_map(ws, cbuffer->buffer, 0);
- /* FIXME: this is wrong. the cbuffer->size currently
+ /* FIXME: this is wrong. the cbuffer->buffer->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 */
- memcpy(&buf[offset], data, cbuffer->size);
+ memcpy(&buf[offset], data, cbuffer->buffer->size);
ws->buffer_unmap(ws, cbuffer->buffer);
- offset += cbuffer->size;
+ offset += cbuffer->buffer->size;
}
/*immediates*/
if (brw->vs.prog_data->num_imm) {
diff --git a/src/gallium/drivers/nv10/nv10_state.c b/src/gallium/drivers/nv10/nv10_state.c
index 622bcdf22e..119af66dfd 100644
--- a/src/gallium/drivers/nv10/nv10_state.c
+++ b/src/gallium/drivers/nv10/nv10_state.c
@@ -467,11 +467,12 @@ nv10_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
if (buf) {
void *mapped;
- if (buf->size && (mapped = ws->buffer_map(ws, buf->buffer, PIPE_BUFFER_USAGE_CPU_READ)))
+ if (buf->buffer && buf->buffer->size &&
+ (mapped = ws->buffer_map(ws, buf->buffer, PIPE_BUFFER_USAGE_CPU_READ)))
{
- memcpy(nv10->constbuf[shader], mapped, buf->size);
+ memcpy(nv10->constbuf[shader], mapped, buf->buffer->size);
nv10->constbuf_nr[shader] =
- buf->size / (4 * sizeof(float));
+ buf->buffer->size / (4 * sizeof(float));
ws->buffer_unmap(ws, buf->buffer);
}
}
diff --git a/src/gallium/drivers/nv20/nv20_state.c b/src/gallium/drivers/nv20/nv20_state.c
index e8dc9665e8..ecec4f49a0 100644
--- a/src/gallium/drivers/nv20/nv20_state.c
+++ b/src/gallium/drivers/nv20/nv20_state.c
@@ -460,11 +460,12 @@ nv20_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
if (buf) {
void *mapped;
- if (buf->size && (mapped = ws->buffer_map(ws, buf->buffer, PIPE_BUFFER_USAGE_CPU_READ)))
+ if (buf->buffer && buf->buffer->size &&
+ (mapped = ws->buffer_map(ws, buf->buffer, PIPE_BUFFER_USAGE_CPU_READ)))
{
- memcpy(nv20->constbuf[shader], mapped, buf->size);
+ memcpy(nv20->constbuf[shader], mapped, buf->buffer->size);
nv20->constbuf_nr[shader] =
- buf->size / (4 * sizeof(float));
+ buf->buffer->size / (4 * sizeof(float));
ws->buffer_unmap(ws, buf->buffer);
}
}
diff --git a/src/gallium/drivers/nv30/nv30_state.c b/src/gallium/drivers/nv30/nv30_state.c
index 63f5303166..26147565a5 100644
--- a/src/gallium/drivers/nv30/nv30_state.c
+++ b/src/gallium/drivers/nv30/nv30_state.c
@@ -592,7 +592,7 @@ nv30_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
struct nv30_context *nv30 = nv30_context(pipe);
nv30->constbuf[shader] = buf->buffer;
- nv30->constbuf_nr[shader] = buf->size / (4 * sizeof(float));
+ nv30->constbuf_nr[shader] = buf->buffer->size / (4 * sizeof(float));
if (shader == PIPE_SHADER_VERTEX) {
nv30->dirty |= NV30_NEW_VERTPROG;
diff --git a/src/gallium/drivers/nv40/nv40_state.c b/src/gallium/drivers/nv40/nv40_state.c
index d5d81b1371..2eff25aa83 100644
--- a/src/gallium/drivers/nv40/nv40_state.c
+++ b/src/gallium/drivers/nv40/nv40_state.c
@@ -607,7 +607,7 @@ nv40_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
struct nv40_context *nv40 = nv40_context(pipe);
nv40->constbuf[shader] = buf->buffer;
- nv40->constbuf_nr[shader] = buf->size / (4 * sizeof(float));
+ nv40->constbuf_nr[shader] = buf->buffer->size / (4 * sizeof(float));
if (shader == PIPE_SHADER_VERTEX) {
nv40->dirty |= NV40_NEW_VERTPROG;
diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c
index 424bd56846..ed3e8f95ae 100644
--- a/src/gallium/drivers/softpipe/sp_draw_arrays.c
+++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c
@@ -49,14 +49,14 @@ softpipe_map_constant_buffers(struct softpipe_context *sp)
struct pipe_winsys *ws = sp->pipe.winsys;
uint i;
for (i = 0; i < PIPE_SHADER_TYPES; i++) {
- if (sp->constants[i].size)
+ if (sp->constants[i].buffer && sp->constants[i].buffer->size)
sp->mapped_constants[i] = ws->buffer_map(ws, sp->constants[i].buffer,
PIPE_BUFFER_USAGE_CPU_READ);
}
draw_set_mapped_constant_buffer(sp->draw,
sp->mapped_constants[PIPE_SHADER_VERTEX],
- sp->constants[PIPE_SHADER_VERTEX].size);
+ sp->constants[PIPE_SHADER_VERTEX].buffer->size);
}
static void
@@ -73,7 +73,7 @@ softpipe_unmap_constant_buffers(struct softpipe_context *sp)
draw_set_mapped_constant_buffer(sp->draw, NULL, 0);
for (i = 0; i < 2; i++) {
- if (sp->constants[i].size)
+ if (sp->constants[i].buffer && sp->constants[i].buffer->size)
ws->buffer_unmap(ws, sp->constants[i].buffer);
sp->mapped_constants[i] = NULL;
}
diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c
index e5b609cf6c..15815160ed 100644
--- a/src/gallium/drivers/softpipe/sp_state_fs.c
+++ b/src/gallium/drivers/softpipe/sp_state_fs.c
@@ -155,7 +155,6 @@ softpipe_set_constant_buffer(struct pipe_context *pipe,
winsys_buffer_reference(ws,
&softpipe->constants[shader].buffer,
buf ? buf->buffer : NULL);
- softpipe->constants[shader].size = buf ? buf->size : 0;
softpipe->dirty |= SP_NEW_CONSTANTS;
}
diff --git a/src/gallium/drivers/trace/tr_state.c b/src/gallium/drivers/trace/tr_state.c
index 095b054bb5..b23ccc1a3d 100644
--- a/src/gallium/drivers/trace/tr_state.c
+++ b/src/gallium/drivers/trace/tr_state.c
@@ -223,7 +223,6 @@ void trace_dump_constant_buffer(const struct pipe_constant_buffer *state)
trace_dump_struct_begin("pipe_constant_buffer");
trace_dump_member(ptr, state, buffer);
- trace_dump_member(uint, state, size);
trace_dump_struct_end();
}
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index 866c8a82dc..13fa9ba848 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -162,7 +162,6 @@ struct pipe_clip_state
struct pipe_constant_buffer
{
struct pipe_buffer *buffer;
- unsigned size; /** in bytes (XXX: redundant!) */
};
diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c
index d02e51cb9a..514b10cd02 100644
--- a/src/mesa/state_tracker/st_atom_constbuf.c
+++ b/src/mesa/state_tracker/st_atom_constbuf.c
@@ -92,8 +92,6 @@ void st_upload_constants( struct st_context *st,
pipe_buffer_unmap(pipe->screen, cbuf->buffer);
}
- cbuf->size = paramBytes;
-
st->pipe->set_constant_buffer(st->pipe, id, 0, cbuf);
}
else {