diff options
author | Brian <brian.paul@tungstengraphics.com> | 2008-01-25 15:59:27 -0700 |
---|---|---|
committer | Brian <brian.paul@tungstengraphics.com> | 2008-01-25 17:22:56 -0700 |
commit | 0bfd085e2866fbbd40209dcee23f0e6240583fe8 (patch) | |
tree | 5cefec02084d42517848529161b734d73557059a /src/mesa/pipe/draw/draw_flatshade.c | |
parent | bd8bf60b6f2402895e7159a4df644f8a4a307cf5 (diff) |
gallium: replace prim pipeline begin/end() functions with flush()
This is basically half of Keith's draw/flush patch.
The stage->point/line/tri() functions are now self-validating, the validator
functions are installed by the flush() function.
There were excessive calls to validate_pipeline(), however. This was caused
by draw_prim_queue_flush() keeping a local 'first' variable that always pointed
to the validate functions. Replaced 'first' with 'draw->pipeline.first'.
Performance in gears is up just slightly with this patch.
Diffstat (limited to 'src/mesa/pipe/draw/draw_flatshade.c')
-rw-r--r-- | src/mesa/pipe/draw/draw_flatshade.c | 67 |
1 files changed, 42 insertions, 25 deletions
diff --git a/src/mesa/pipe/draw/draw_flatshade.c b/src/mesa/pipe/draw/draw_flatshade.c index 8444c53310..1419f287d2 100644 --- a/src/mesa/pipe/draw/draw_flatshade.c +++ b/src/mesa/pipe/draw/draw_flatshade.c @@ -50,25 +50,6 @@ flat_stage(struct draw_stage *stage) } -static void flatshade_begin( struct draw_stage *stage ) -{ - struct flat_stage *flat = flat_stage(stage); - const struct pipe_shader_state *vs = stage->draw->vertex_shader->state; - uint i; - - /* Find which vertex shader outputs are colors, make a list */ - flat->num_color_attribs = 0; - for (i = 0; i < vs->num_outputs; i++) { - if (vs->output_semantic_name[i] == TGSI_SEMANTIC_COLOR || - vs->output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) { - flat->color_attribs[flat->num_color_attribs++] = i; - } - } - - stage->next->begin( stage->next ); -} - - /** Copy all the color attributes from 'src' vertex to 'dst' vertex */ static INLINE void copy_colors( struct draw_stage *stage, struct vertex_header *dst, @@ -144,9 +125,46 @@ static void flatshade_point( struct draw_stage *stage, } -static void flatshade_end( struct draw_stage *stage ) +static void flatshade_init_state( struct draw_stage *stage ) +{ + struct flat_stage *flat = flat_stage(stage); + const struct pipe_shader_state *vs = stage->draw->vertex_shader->state; + uint i; + + /* Find which vertex shader outputs are colors, make a list */ + flat->num_color_attribs = 0; + for (i = 0; i < vs->num_outputs; i++) { + if (vs->output_semantic_name[i] == TGSI_SEMANTIC_COLOR || + vs->output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) { + flat->color_attribs[flat->num_color_attribs++] = i; + } + } + + stage->line = flatshade_line; + stage->tri = flatshade_tri; +} + +static void flatshade_first_tri( struct draw_stage *stage, + struct prim_header *header ) +{ + flatshade_init_state( stage ); + stage->tri( stage, header ); +} + +static void flatshade_first_line( struct draw_stage *stage, + struct prim_header *header ) +{ + flatshade_init_state( stage ); + stage->line( stage, header ); +} + + +static void flatshade_flush( struct draw_stage *stage, + unsigned flags ) { - stage->next->end( stage->next ); + stage->tri = flatshade_first_tri; + stage->line = flatshade_first_line; + stage->next->flush( stage->next, flags ); } @@ -174,11 +192,10 @@ struct draw_stage *draw_flatshade_stage( struct draw_context *draw ) flatshade->stage.draw = draw; flatshade->stage.next = NULL; - flatshade->stage.begin = flatshade_begin; flatshade->stage.point = flatshade_point; - flatshade->stage.line = flatshade_line; - flatshade->stage.tri = flatshade_tri; - flatshade->stage.end = flatshade_end; + flatshade->stage.line = flatshade_first_line; + flatshade->stage.tri = flatshade_first_tri; + flatshade->stage.flush = flatshade_flush; flatshade->stage.reset_stipple_counter = flatshade_reset_stipple_counter; flatshade->stage.destroy = flatshade_destroy; |