diff options
author | José Fonseca <jrfonseca@tungstengraphics.com> | 2008-01-28 14:51:14 +0900 |
---|---|---|
committer | José Fonseca <jrfonseca@tungstengraphics.com> | 2008-01-28 14:51:14 +0900 |
commit | 3b93c74a8d6e36039b79ddf38c11e27aa0bd3b9b (patch) | |
tree | 6f9a49ec2c486affaed3decea579b626a6969790 | |
parent | dac124081d4bbc9d7527661e4a96aa78077b9f52 (diff) |
Cache the vinfo in vbuf_stage.
-rw-r--r-- | src/mesa/pipe/draw/draw_vbuf.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/mesa/pipe/draw/draw_vbuf.c b/src/mesa/pipe/draw/draw_vbuf.c index aea5b4aeee..60ad93133c 100644 --- a/src/mesa/pipe/draw/draw_vbuf.c +++ b/src/mesa/pipe/draw/draw_vbuf.c @@ -50,6 +50,8 @@ struct vbuf_stage { struct vbuf_render *render; + const struct vertex_info *vinfo; + /** Vertex size in bytes */ unsigned vertex_size; @@ -84,8 +86,7 @@ vbuf_stage( struct draw_stage *stage ) static void vbuf_flush_indices( struct draw_stage *stage ); static void vbuf_flush_vertices( struct draw_stage *stage ); -static void vbuf_alloc_vertices( struct draw_stage *stage, - unsigned new_vertex_size ); +static void vbuf_alloc_vertices( struct draw_stage *stage ); static INLINE boolean @@ -101,7 +102,7 @@ check_space( struct vbuf_stage *vbuf, unsigned nr ) { if (vbuf->nr_vertices + nr > vbuf->max_vertices ) { vbuf_flush_vertices(&vbuf->stage); - vbuf_alloc_vertices(&vbuf->stage, vbuf->vertex_size); + vbuf_alloc_vertices(&vbuf->stage); } if (vbuf->nr_indices + nr > vbuf->max_indices ) @@ -120,10 +121,12 @@ static INLINE void emit_vertex( struct vbuf_stage *vbuf, struct vertex_header *vertex ) { - const struct vertex_info *vinfo = vbuf->render->get_vertex_info(vbuf->render); + const struct vertex_info *vinfo = vbuf->vinfo; uint i; uint count = 0; /* for debug/sanity */ + + assert(vinfo == vbuf->render->get_vertex_info(vbuf->render)); // fprintf(stderr, "emit vertex %d to %p\n", // vbuf->nr_vertices, vbuf->vertex_ptr); @@ -265,8 +268,11 @@ vbuf_set_prim( struct draw_stage *stage, uint newprim ) if (vertex_size != vbuf->vertex_size) vbuf_flush_vertices(stage); + vbuf->vinfo = vinfo; + vbuf->vertex_size = vertex_size; + if (!vbuf->vertices) - vbuf_alloc_vertices(stage, vertex_size); + vbuf_alloc_vertices(stage); } @@ -364,7 +370,7 @@ vbuf_flush_vertices( struct draw_stage *stage ) vbuf->vertices, vbuf->vertex_size, vbuf->nr_vertices); - vbuf->nr_vertices = 0; + vbuf->max_vertices = vbuf->nr_vertices = 0; vbuf->vertex_ptr = vbuf->vertices = NULL; } @@ -372,8 +378,7 @@ vbuf_flush_vertices( struct draw_stage *stage ) static void -vbuf_alloc_vertices( struct draw_stage *stage, - unsigned new_vertex_size ) +vbuf_alloc_vertices( struct draw_stage *stage ) { struct vbuf_stage *vbuf = vbuf_stage( stage ); @@ -381,7 +386,6 @@ vbuf_alloc_vertices( struct draw_stage *stage, assert(!vbuf->vertices); /* Allocate a new vertex buffer */ - vbuf->vertex_size = new_vertex_size; vbuf->max_vertices = vbuf->render->max_vertex_buffer_bytes / vbuf->vertex_size; vbuf->vertices = (uint *) vbuf->render->allocate_vertices(vbuf->render, (ushort) vbuf->vertex_size, |