diff options
author | Brian <brian.paul@tungstengraphics.com> | 2007-07-27 10:21:34 -0600 |
---|---|---|
committer | Brian <brian.paul@tungstengraphics.com> | 2007-07-27 10:21:34 -0600 |
commit | a0c1d591ab8d19377c7ab784a0472fac00f9fcd3 (patch) | |
tree | 1c0b32d0f8b456f9a6abdece3c65dbc6822668a0 /src/mesa/pipe/softpipe/sp_state_derived.c | |
parent | 78ea9cee0d7fd424238ec25f9939d2c955694c0a (diff) |
Maintain cliprect (scissor) info in sp_state_derived.c.
The cliprect depends on the scissor rect (if enabled), otherwise the drawing
surface bounds.
Diffstat (limited to 'src/mesa/pipe/softpipe/sp_state_derived.c')
-rw-r--r-- | src/mesa/pipe/softpipe/sp_state_derived.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c index 26083c2962..9572890afe 100644 --- a/src/mesa/pipe/softpipe/sp_state_derived.c +++ b/src/mesa/pipe/softpipe/sp_state_derived.c @@ -163,6 +163,41 @@ static void calculate_vertex_layout( struct softpipe_context *softpipe ) } +/** + * Recompute cliprect from scissor bounds, scissor enable and surface size. + */ +static void +compute_cliprect(struct softpipe_context *sp) +{ + GLint surfWidth, surfHeight; + + if (sp->framebuffer.num_cbufs > 0) { + surfWidth = sp->framebuffer.cbufs[0]->width; + surfHeight = sp->framebuffer.cbufs[0]->height; + } + else { + /* no surface? */ + surfWidth = sp->scissor.maxx; + surfHeight = sp->scissor.maxy; + } + + if (sp->setup.scissor) { + /* clip to scissor rect */ + sp->cliprect.minx = MAX2(sp->scissor.minx, 0); + sp->cliprect.miny = MAX2(sp->scissor.miny, 0); + sp->cliprect.maxx = MIN2(sp->scissor.maxx, surfWidth - 1); + sp->cliprect.maxy = MIN2(sp->scissor.maxy, surfHeight - 1); + } + else { + /* clip to surface bounds */ + sp->cliprect.minx = 0; + sp->cliprect.miny = 0; + sp->cliprect.maxx = surfWidth - 1; + sp->cliprect.maxy = surfHeight - 1; + } +} + + /* Hopefully this will remain quite simple, otherwise need to pull in * something like the state tracker mechanism. */ @@ -171,6 +206,11 @@ void softpipe_update_derived( struct softpipe_context *softpipe ) if (softpipe->dirty & (SP_NEW_SETUP | SP_NEW_FS)) calculate_vertex_layout( softpipe ); + if (softpipe->dirty & (SP_NEW_SCISSOR | + SP_NEW_STENCIL | + SP_NEW_FRAMEBUFFER)) + compute_cliprect(softpipe); + if (softpipe->dirty & (SP_NEW_BLEND | SP_NEW_DEPTH_TEST | SP_NEW_ALPHA_TEST | |