diff options
author | Brian <brian.paul@tungstengraphics.com> | 2008-01-25 17:21:05 -0700 |
---|---|---|
committer | Brian <brian.paul@tungstengraphics.com> | 2008-01-25 17:22:56 -0700 |
commit | 1603a33fb276d7e78a2e872dfa05aa0093d1329a (patch) | |
tree | d293a1e1dbd7b05b80828a8f3303607567b59664 /src/mesa/pipe/draw/draw_validate.c | |
parent | 0bfd085e2866fbbd40209dcee23f0e6240583fe8 (diff) |
gallium: better flush logic in draw module
This is the other half of Keith's draw/flush patch.
There are now 5 flush flags to control what's flushed (post-xform vertex
cache, prim cache, vbuf, etc).
The gears slow-down in this part of the patch was due to the cull stage not
getting invoked. It was unconditional before, but is now gated by 'need_det'.
But it also needs to be gated by draw->rasterizer->cull_mode. Gears uses
back-face culling.
Diffstat (limited to 'src/mesa/pipe/draw/draw_validate.c')
-rw-r--r-- | src/mesa/pipe/draw/draw_validate.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/mesa/pipe/draw/draw_validate.c b/src/mesa/pipe/draw/draw_validate.c index a626fb1fba..86d5a5f814 100644 --- a/src/mesa/pipe/draw/draw_validate.c +++ b/src/mesa/pipe/draw/draw_validate.c @@ -43,6 +43,13 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage ) { struct draw_context *draw = stage->draw; struct draw_stage *next = draw->pipeline.rasterize; + int need_det = 0; + int precalc_flat = 0; + + /* Set the validate's next stage to the rasterize stage, so that it + * can be found later if needed for flushing. + */ + stage->next = next; /* * NOTE: we build up the pipeline in end-to-start order. @@ -61,29 +68,38 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage ) if (draw->rasterizer->line_stipple_enable) { draw->pipeline.stipple->next = next; next = draw->pipeline.stipple; + precalc_flat = 1; /* only needed for lines really */ } if (draw->rasterizer->fill_cw != PIPE_POLYGON_MODE_FILL || draw->rasterizer->fill_ccw != PIPE_POLYGON_MODE_FILL) { draw->pipeline.unfilled->next = next; next = draw->pipeline.unfilled; + precalc_flat = 1; /* only needed for triangles really */ + need_det = 1; } if (draw->rasterizer->offset_cw || draw->rasterizer->offset_ccw) { draw->pipeline.offset->next = next; next = draw->pipeline.offset; + need_det = 1; } if (draw->rasterizer->light_twoside) { draw->pipeline.twoside->next = next; next = draw->pipeline.twoside; + need_det = 1; } /* Always run the cull stage as we calculate determinant there - * also. Fix this.. + * also. + * + * This can actually be a win as culling out the triangles can lead + * to less work emitting vertices, smaller vertex buffers, etc. + * It's difficult to say whether this will be true in general. */ - { + if (need_det || draw->rasterizer->cull_mode) { draw->pipeline.cull->next = next; next = draw->pipeline.cull; } @@ -94,23 +110,18 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage ) { draw->pipeline.clip->next = next; next = draw->pipeline.clip; + precalc_flat = 1; /* XXX: FIX ME! Only needed for clipped prims */ } - /* Do software flatshading prior to clipping. XXX: should only do - * this for clipped primitives, ie it is a part of the clip - * routine. - */ - if (draw->rasterizer->flatshade) { + if (draw->rasterizer->flatshade && precalc_flat) { draw->pipeline.flatshade->next = next; next = draw->pipeline.flatshade; } - + draw->pipeline.first = next; - //BP draw->pipeline.first->begin( draw->pipeline.first ); return next; } - static void validate_tri( struct draw_stage *stage, struct prim_header *header ) { @@ -162,7 +173,6 @@ struct draw_stage *draw_validate_stage( struct draw_context *draw ) struct draw_stage *stage = CALLOC_STRUCT(draw_stage); stage->draw = draw; - stage->next = NULL; stage->point = validate_point; stage->line = validate_line; |