summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/nvc0/nvc0_state.c
diff options
context:
space:
mode:
authorChristoph Bumiller <[email protected]>2012-03-16 17:37:32 +0100
committerChristoph Bumiller <[email protected]>2012-04-14 06:14:21 +0200
commitedbfeed56f1ebd8517840ef48f8c87e24bb98157 (patch)
tree091d7e779b814713c0201813e9a3fed3153a9c6f /src/gallium/drivers/nvc0/nvc0_state.c
parent784f49e69624cba07616fd5a22ccb80ad3b5111b (diff)
nvc0: improve vertex state validation
Now updating vertex attribute format only when necessary.
Diffstat (limited to 'src/gallium/drivers/nvc0/nvc0_state.c')
-rw-r--r--src/gallium/drivers/nvc0/nvc0_state.c45
1 files changed, 35 insertions, 10 deletions
diff --git a/src/gallium/drivers/nvc0/nvc0_state.c b/src/gallium/drivers/nvc0/nvc0_state.c
index d493f6e7fa0..eb71e6b9853 100644
--- a/src/gallium/drivers/nvc0/nvc0_state.c
+++ b/src/gallium/drivers/nvc0/nvc0_state.c
@@ -746,19 +746,44 @@ nvc0_set_vertex_buffers(struct pipe_context *pipe,
const struct pipe_vertex_buffer *vb)
{
struct nvc0_context *nvc0 = nvc0_context(pipe);
+ uint32_t constant_vbos = 0;
unsigned i;
- for (i = 0; i < count; ++i)
- pipe_resource_reference(&nvc0->vtxbuf[i].buffer, vb[i].buffer);
- for (; i < nvc0->num_vtxbufs; ++i)
- pipe_resource_reference(&nvc0->vtxbuf[i].buffer, NULL);
-
- memcpy(nvc0->vtxbuf, vb, sizeof(*vb) * count);
- nvc0->num_vtxbufs = count;
-
- nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_VTX);
+ if (count != nvc0->num_vtxbufs) {
+ for (i = 0; i < count; ++i) {
+ pipe_resource_reference(&nvc0->vtxbuf[i].buffer, vb[i].buffer);
+ nvc0->vtxbuf[i].buffer_offset = vb[i].buffer_offset;
+ nvc0->vtxbuf[i].stride = vb[i].stride;
+ if (!vb[i].stride)
+ constant_vbos |= 1 << i;
+ }
+ for (; i < nvc0->num_vtxbufs; ++i)
+ pipe_resource_reference(&nvc0->vtxbuf[i].buffer, NULL);
+
+ nvc0->num_vtxbufs = count;
+ nvc0->dirty |= NVC0_NEW_ARRAYS;
+ } else {
+ for (i = 0; i < count; ++i) {
+ if (nvc0->vtxbuf[i].buffer == vb[i].buffer &&
+ nvc0->vtxbuf[i].buffer_offset == vb[i].buffer_offset &&
+ nvc0->vtxbuf[i].stride == vb[i].stride)
+ continue;
+ pipe_resource_reference(&nvc0->vtxbuf[i].buffer, vb[i].buffer);
+ nvc0->vtxbuf[i].buffer_offset = vb[i].buffer_offset;
+ nvc0->vtxbuf[i].stride = vb[i].stride;
+ if (likely(vb[i].stride))
+ nvc0->dirty |= NVC0_NEW_ARRAYS;
+ else
+ constant_vbos |= 1 << i;
+ }
+ }
+ if (constant_vbos != nvc0->constant_vbos) {
+ nvc0->constant_vbos = constant_vbos;
+ nvc0->dirty |= NVC0_NEW_ARRAYS;
+ }
- nvc0->dirty |= NVC0_NEW_ARRAYS;
+ if (nvc0->dirty & NVC0_NEW_ARRAYS)
+ nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_VTX);
}
static void