diff options
author | Brian <[email protected]> | 2008-01-16 10:57:53 -0700 |
---|---|---|
committer | Brian <[email protected]> | 2008-01-16 10:57:53 -0700 |
commit | d11fd189ff84ec24df0fb988e5c3e1a9260e038c (patch) | |
tree | ddd3e318de012bf025776425e87d68a986e96855 /src/mesa/pipe/draw | |
parent | 0e6b78c7eb7ebee9074489664416be489a27c742 (diff) |
vbuf updates/fixes (KeithW)
Plus, update i915 and Cell drivers for latest vbuf->draw() params.
Diffstat (limited to 'src/mesa/pipe/draw')
-rw-r--r-- | src/mesa/pipe/draw/draw_vbuf.c | 63 | ||||
-rw-r--r-- | src/mesa/pipe/draw/draw_vbuf.h | 6 |
2 files changed, 37 insertions, 32 deletions
diff --git a/src/mesa/pipe/draw/draw_vbuf.c b/src/mesa/pipe/draw/draw_vbuf.c index 4f59b1b25da..6cda122c3af 100644 --- a/src/mesa/pipe/draw/draw_vbuf.c +++ b/src/mesa/pipe/draw/draw_vbuf.c @@ -83,7 +83,8 @@ 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_flush_vertices( struct draw_stage *stage ); +static void vbuf_alloc_vertices( struct draw_stage *stage, unsigned new_vertex_size ); @@ -98,8 +99,10 @@ overflow( void *map, void *ptr, unsigned bytes, unsigned bufsz ) static INLINE void check_space( struct vbuf_stage *vbuf, unsigned nr ) { - if (vbuf->nr_vertices + nr > vbuf->max_vertices ) - vbuf_flush_vertices(&vbuf->stage, vbuf->vertex_size ); + if (vbuf->nr_vertices + nr > vbuf->max_vertices ) { + vbuf_flush_vertices(&vbuf->stage); + vbuf_alloc_vertices(&vbuf->stage, vbuf->vertex_size); + } if (vbuf->nr_indices + nr > vbuf->max_indices ) vbuf_flush_indices(&vbuf->stage); @@ -232,10 +235,12 @@ vbuf_first_tri( struct draw_stage *stage, struct vbuf_stage *vbuf = vbuf_stage( stage ); vbuf_flush_indices( stage ); + stage->tri = vbuf_tri; - stage->tri( stage, prim ); vbuf->prim = PIPE_PRIM_TRIANGLES; vbuf->render->set_primitive(vbuf->render, PIPE_PRIM_TRIANGLES); + + stage->tri( stage, prim ); } @@ -247,9 +252,10 @@ vbuf_first_line( struct draw_stage *stage, vbuf_flush_indices( stage ); stage->line = vbuf_line; - stage->line( stage, prim ); vbuf->prim = PIPE_PRIM_LINES; vbuf->render->set_primitive(vbuf->render, PIPE_PRIM_LINES); + + stage->line( stage, prim ); } @@ -260,10 +266,12 @@ vbuf_first_point( struct draw_stage *stage, struct vbuf_stage *vbuf = vbuf_stage( stage ); vbuf_flush_indices( stage ); + stage->point = vbuf_point; - stage->point( stage, prim ); vbuf->prim = PIPE_PRIM_POINTS; vbuf->render->set_primitive(vbuf->render, PIPE_PRIM_POINTS); + + stage->point( stage, prim ); } @@ -291,15 +299,13 @@ vbuf_flush_indices( struct draw_stage *stage ) assert(0); } - vbuf->render->draw( vbuf->render, - vbuf->prim, - vbuf->indices, - vbuf->nr_indices, - vbuf->vertices, - vbuf->nr_vertices, - vbuf->vertex_size ); - + vbuf->render->draw(vbuf->render, vbuf->indices, vbuf->nr_indices); + vbuf->nr_indices = 0; + + stage->point = vbuf_first_point; + stage->line = vbuf_first_line; + stage->tri = vbuf_first_tri; } @@ -311,8 +317,7 @@ vbuf_flush_indices( struct draw_stage *stage ) * we flush. */ static void -vbuf_flush_vertices( struct draw_stage *stage, - unsigned new_vertex_size ) +vbuf_flush_vertices( struct draw_stage *stage ) { struct vbuf_stage *vbuf = vbuf_stage( stage ); @@ -332,15 +337,24 @@ vbuf_flush_vertices( struct draw_stage *stage, vbuf->vertex_ptr = vbuf->vertices = NULL; } +} + +static void +vbuf_alloc_vertices( struct draw_stage *stage, + unsigned new_vertex_size ) +{ + struct vbuf_stage *vbuf = vbuf_stage( stage ); + assert(!vbuf->nr_indices); + 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 = vbuf->render->allocate_vertices(vbuf->render, - vbuf->vertex_size, - vbuf->max_vertices) ; + (ushort) vbuf->vertex_size, + (ushort) vbuf->max_vertices); vbuf->vertex_ptr = vbuf->vertices; } @@ -352,22 +366,17 @@ vbuf_begin( struct draw_stage *stage ) const struct vertex_info *vinfo = vbuf->render->get_vertex_info(vbuf->render); unsigned vertex_size = vinfo->size * sizeof(float); - if(vbuf->vertex_size != vertex_size) - vbuf_flush_vertices(&vbuf->stage, vertex_size); + /* XXX: Overkill */ + vbuf_alloc_vertices(&vbuf->stage, vertex_size); } static void vbuf_end( struct draw_stage *stage ) { -#if 0 +// vbuf_flush_indices( stage ); /* XXX: Overkill */ - vbuf_flush_indices( stage ); -#else - /* By flushing vertices we avoid having the vertex buffer grow and grow */ - struct vbuf_stage *vbuf = vbuf_stage(stage); - vbuf_flush_vertices( stage, vbuf->vertex_size ); -#endif + vbuf_flush_vertices( stage ); stage->point = vbuf_first_point; stage->line = vbuf_first_line; diff --git a/src/mesa/pipe/draw/draw_vbuf.h b/src/mesa/pipe/draw/draw_vbuf.h index be4c4ab77bc..cfd2b9820c1 100644 --- a/src/mesa/pipe/draw/draw_vbuf.h +++ b/src/mesa/pipe/draw/draw_vbuf.h @@ -82,12 +82,8 @@ struct vbuf_render { * DrawElements, note indices are ushort: */ void (*draw)( struct vbuf_render *, - uint prim, const ushort *indices, - uint nr_indices, - const void *vertices, - uint nr_vertices, - uint vertex_bytes); + uint nr_indices ); /** * Called when vbuf is done with this set of vertices: |