diff options
author | Ben Skeggs <skeggsb@gmail.com> | 2008-01-27 12:35:33 +1100 |
---|---|---|
committer | Ben Skeggs <skeggsb@gmail.com> | 2008-01-27 12:35:33 +1100 |
commit | a556034514582dc8e1b8b65f56020031d513331b (patch) | |
tree | 182aaf4be24733e2943f9e39cfb86bc22f942efb /src/mesa/pipe/draw/draw_prim.c | |
parent | 9043323f1437f9c6791845b3ddbb9af912b45110 (diff) | |
parent | b717de3238a028a3fdfbaf13eb02dbde262f03e7 (diff) |
Merge branch 'upstream-gallium-0.1' into darktama-gallium-0.1
Diffstat (limited to 'src/mesa/pipe/draw/draw_prim.c')
-rw-r--r-- | src/mesa/pipe/draw/draw_prim.c | 104 |
1 files changed, 42 insertions, 62 deletions
diff --git a/src/mesa/pipe/draw/draw_prim.c b/src/mesa/pipe/draw/draw_prim.c index f8fc23b510..243381aec0 100644 --- a/src/mesa/pipe/draw/draw_prim.c +++ b/src/mesa/pipe/draw/draw_prim.c @@ -57,39 +57,40 @@ static unsigned reduced_prim[PIPE_PRIM_POLYGON + 1] = { static void draw_prim_queue_flush( struct draw_context *draw ) { - struct draw_stage *first = draw->pipeline.first; unsigned i; if (0) fprintf(stdout,"Flushing with %d prims, %d verts\n", draw->pq.queue_nr, draw->vs.queue_nr); - /* Make sure all vertices are available/shaded: - */ - if (draw->vs.queue_nr) - draw_vertex_shader_queue_flush(draw); + if (draw->pq.queue_nr == 0) + return; + /* NOTE: we cannot save draw->pipeline->first in a local var because + * draw->pipeline->first is often changed by the first call to tri(), + * line(), etc. + */ switch (draw->reduced_prim) { case RP_TRI: for (i = 0; i < draw->pq.queue_nr; i++) { if (draw->pq.queue[i].reset_line_stipple) - first->reset_stipple_counter( first ); + draw->pipeline.first->reset_stipple_counter( draw->pipeline.first ); - first->tri( first, &draw->pq.queue[i] ); + draw->pipeline.first->tri( draw->pipeline.first, &draw->pq.queue[i] ); } break; case RP_LINE: for (i = 0; i < draw->pq.queue_nr; i++) { if (draw->pq.queue[i].reset_line_stipple) - first->reset_stipple_counter( first ); + draw->pipeline.first->reset_stipple_counter( draw->pipeline.first ); - first->line( first, &draw->pq.queue[i] ); + draw->pipeline.first->line( draw->pipeline.first, &draw->pq.queue[i] ); } break; case RP_POINT: - first->reset_stipple_counter( first ); + draw->pipeline.first->reset_stipple_counter( draw->pipeline.first ); for (i = 0; i < draw->pq.queue_nr; i++) - first->point( first, &draw->pq.queue[i] ); + draw->pipeline.first->point( draw->pipeline.first, &draw->pq.queue[i] ); break; } @@ -98,33 +99,32 @@ static void draw_prim_queue_flush( struct draw_context *draw ) } -void draw_do_flush( struct draw_context *draw, - unsigned flush ) + +void draw_do_flush( struct draw_context *draw, unsigned flags ) { - if ((flush & (DRAW_FLUSH_PRIM_QUEUE | - DRAW_FLUSH_VERTEX_CACHE_INVALIDATE | - DRAW_FLUSH_DRAW)) && - draw->pq.queue_nr) - { - draw_prim_queue_flush(draw); - } + if (0) + fprintf(stdout,"Flushing with %d verts, %d prims\n", + draw->vs.queue_nr, + draw->pq.queue_nr ); - if ((flush & (DRAW_FLUSH_VERTEX_CACHE_INVALIDATE | - DRAW_FLUSH_DRAW)) && - draw->drawing) - { - draw_vertex_cache_invalidate(draw); - } - if ((flush & DRAW_FLUSH_DRAW) && - draw->drawing) - { - draw->pipeline.first->end( draw->pipeline.first ); - draw->drawing = FALSE; - draw->prim = ~0; - draw->pipeline.first = draw->pipeline.validate; - } + if (flags >= DRAW_FLUSH_SHADER_QUEUE) { + draw_vertex_shader_queue_flush(draw); + + if (flags >= DRAW_FLUSH_PRIM_QUEUE) { + draw_prim_queue_flush(draw); + if (flags >= DRAW_FLUSH_VERTEX_CACHE) { + draw_vertex_cache_invalidate(draw); + + if (flags >= DRAW_FLUSH_STATE_CHANGE) { + draw->pipeline.first->flush( draw->pipeline.first, flags ); + draw->pipeline.first = draw->pipeline.validate; + draw->reduced_prim = ~0; + } + } + } + } } @@ -139,7 +139,7 @@ static struct prim_header *get_queued_prim( struct draw_context *draw, { if (!draw_vertex_cache_check_space( draw, nr_verts )) { // fprintf(stderr, "v"); - draw_do_flush( draw, DRAW_FLUSH_VERTEX_CACHE_INVALIDATE ); + draw_do_flush( draw, DRAW_FLUSH_VERTEX_CACHE ); } else if (draw->pq.queue_nr == PRIM_QUEUE_LENGTH) { // fprintf(stderr, "p"); @@ -247,13 +247,14 @@ static void do_quad( struct draw_context *draw, * Main entrypoint to draw some number of points/lines/triangles */ static void -draw_prim( struct draw_context *draw, unsigned start, unsigned count ) +draw_prim( struct draw_context *draw, + unsigned prim, unsigned start, unsigned count ) { unsigned i; // _mesa_printf("%s (%d) %d/%d\n", __FUNCTION__, draw->prim, start, count ); - switch (draw->prim) { + switch (prim) { case PIPE_PRIM_POINTS: for (i = 0; i < count; i ++) { do_point( draw, @@ -385,21 +386,6 @@ draw_prim( struct draw_context *draw, unsigned start, unsigned count ) } -static void -draw_set_prim( struct draw_context *draw, unsigned prim ) -{ - assert(prim >= PIPE_PRIM_POINTS); - assert(prim <= PIPE_PRIM_POLYGON); - - if (reduced_prim[prim] != draw->reduced_prim) { - draw_do_flush( draw, DRAW_FLUSH_PRIM_QUEUE ); - draw->reduced_prim = reduced_prim[prim]; - } - - draw->prim = prim; -} - - /** @@ -413,19 +399,13 @@ void draw_arrays(struct draw_context *draw, unsigned prim, unsigned start, unsigned count) { - if (!draw->drawing) { - draw->drawing = TRUE; - - /* tell drawing pipeline we're beginning drawing */ - draw->pipeline.first->begin( draw->pipeline.first ); - } - - if (draw->prim != prim) { - draw_set_prim( draw, prim ); + if (reduced_prim[prim] != draw->reduced_prim) { + draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE ); + draw->reduced_prim = reduced_prim[prim]; } /* drawing done here: */ - draw_prim(draw, start, count); + draw_prim(draw, prim, start, count); } |