From: Keith Whitwell Date: Fri, 9 Oct 2009 09:24:19 +0000 (+0100) Subject: llvmpipe: calculate overall width and height, pass to rasterizer X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=84ab7dcf48e87350c0622c533e51aa495f7256c2;p=mesa.git llvmpipe: calculate overall width and height, pass to rasterizer --- diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index 695ddc089a4..6ac44feb4c7 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -48,6 +48,17 @@ struct lp_rasterizer *lp_rast_create( void ) return rast; } + +void lp_rast_begin( struct lp_rasterizer *rast, + unsigned width, + unsigned height ) +{ + rast->width = width; + rast->height = height; + rast->check_for_clipped_tiles = (width % TILESIZE != 0 || + height % TILESIZE != 0); +} + void lp_rast_bind_color( struct lp_rasterizer *rast, struct pipe_surface *cbuf, boolean write_color ) @@ -195,8 +206,7 @@ void lp_rast_shade_quads( struct lp_rasterizer *rast, */ -void lp_rast_end_tile( struct lp_rasterizer *rast, - boolean write_depth ) +void lp_rast_end_tile( struct lp_rasterizer *rast ) { struct pipe_surface *surface; struct pipe_screen *screen; @@ -213,10 +223,10 @@ void lp_rast_end_tile( struct lp_rasterizer *rast, screen = surface->texture->screen; - if(x + w > surface->width) - w = surface->width - x; - if(y + h > surface->height) - h = surface->height - y; + if(x + w > rast->width) + w = rast->width - x; + if(y + h > rast->height) + h = rast->height - y; transfer = screen->get_tex_transfer(screen, surface->texture, @@ -240,7 +250,7 @@ void lp_rast_end_tile( struct lp_rasterizer *rast, screen->tex_transfer_destroy(transfer); - if (write_depth) { + if (0) { /* FIXME: call u_tile func to store depth/stencil to surface */ } } diff --git a/src/gallium/drivers/llvmpipe/lp_rast.h b/src/gallium/drivers/llvmpipe/lp_rast.h index 64d668f9983..26d057beb29 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.h +++ b/src/gallium/drivers/llvmpipe/lp_rast.h @@ -97,6 +97,11 @@ struct lp_rast_triangle { float dx23; float dx31; + /* XXX: these are only used inside lp_setup_tri.c, don't really + * need to bin them: + */ + float oneoverarea; + /* inputs for the shader */ struct lp_rast_shader_inputs inputs; }; @@ -105,13 +110,17 @@ struct lp_rast_triangle { struct lp_rasterizer *lp_rast_create( void ); +void lp_rast_begin( struct lp_rasterizer *, + unsigned width, + unsigned height); + void lp_rast_bind_color( struct lp_rasterizer *, struct pipe_surface *cbuf, boolean write_when_done ); -void lp_rast_bind_depth( struct lp_rasterizer *, - struct pipe_surface *zsbuf, - boolean write_when_done ); +void lp_rast_bind_zstencil( struct lp_rasterizer *, + struct pipe_surface *zsbuf, + boolean write_when_done ); /* Begining of each tile: */ diff --git a/src/gallium/drivers/llvmpipe/lp_rast_priv.h b/src/gallium/drivers/llvmpipe/lp_rast_priv.h index 29e4c8fd800..d7a8b9c257d 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast_priv.h +++ b/src/gallium/drivers/llvmpipe/lp_rast_priv.h @@ -52,7 +52,11 @@ struct lp_rasterizer { unsigned x; unsigned y; + boolean clipped_tile; + boolean check_for_clipped_tiles; + unsigned width; + unsigned height; struct { struct pipe_surface *cbuf; diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index 9f1b3d21f09..4f100808165 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -160,13 +160,23 @@ rasterize_bins( struct setup_context *setup, struct cmd_block *block; unsigned i,j,k; + if (setup->state != SETUP_ACTIVE) { + /* this can happen, not a big deal */ + debug_printf("%s called when not binning\n", __FUNCTION__); + return; + } + + lp_rast_begin( rast, + setup->fb.width, + setup->fb.height ); + lp_rast_bind_color( rast, setup->fb.cbuf, - TRUE ); /* WRITE */ + setup->fb.cbuf != NULL ); - lp_rast_bind_depth( rast, - setup->fb.zsbuf, - write_depth ); /* WRITE */ + lp_rast_bind_zstencil( rast, + setup->fb.zsbuf, + setup->fb.zsbuf != NULL && write_depth ); for (i = 0; i < setup->tiles_x; i++) { for (j = 0; j < setup->tiles_y; j++) { @@ -193,15 +203,38 @@ rasterize_bins( struct setup_context *setup, static void begin_binning( struct setup_context *setup ) { + if (!setup->fb.cbuf && !setup->fb.zsbuf) { + setup->fb.width = 0; + setup->fb.height = 0; + } + else if (!setup->fb.zsbuf) { + setup->fb.width = setup->fb.cbuf->width; + setup->fb.height = setup->fb.cbuf->height; + } + else if (!setup->fb.cbuf) { + setup->fb.width = setup->fb.zsbuf->width; + setup->fb.height = setup->fb.zsbuf->height; + } + else { + /* XXX: not sure what we're really supposed to do for + * mis-matched color & depth buffer sizes. + */ + setup->fb.width = MIN2(setup->fb.cbuf->width, + setup->fb.zsbuf->width); + setup->fb.height = MIN2(setup->fb.cbuf->height, + setup->fb.zsbuf->height); + } + + setup->tiles_x = align(setup->fb.width, TILESIZE); + setup->tiles_y = align(setup->fb.height, TILESIZE); + if (setup->fb.cbuf) { if (setup->clear.flags & PIPE_CLEAR_COLOR) bin_everywhere( setup, lp_rast_clear_color, &setup->clear.color ); else - bin_everywhere( setup, - lp_rast_load_color, - NULL ); + bin_everywhere( setup, lp_rast_load_color, NULL ); } if (setup->fb.zsbuf) { @@ -210,9 +243,7 @@ begin_binning( struct setup_context *setup ) lp_rast_clear_zstencil, &setup->clear.zstencil ); else - bin_everywhere( setup, - lp_rast_load_zstencil, - NULL ); + bin_everywhere( setup, lp_rast_load_zstencil, NULL ); } } diff --git a/src/gallium/drivers/llvmpipe/lp_setup.h b/src/gallium/drivers/llvmpipe/lp_setup.h index 04f9f878926..bd439fa8578 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.h +++ b/src/gallium/drivers/llvmpipe/lp_setup.h @@ -37,9 +37,15 @@ enum lp_interp { LP_INTERP_FACING }; +/* Describes how to generate all the fragment shader inputs from the + * the vertices passed into our triangle/line/point functions. + * + * Vertices are treated as an array of float[4] values, indexed by + * src_index. + */ struct lp_shader_input { - enum lp_interp interp; - unsigned vs_output; + enum lp_interp interp; /* how to interpolate values */ + unsigned src_index; /* where to find values in incoming vertices */ }; struct pipe_texture; diff --git a/src/gallium/drivers/llvmpipe/lp_setup_context.h b/src/gallium/drivers/llvmpipe/lp_setup_context.h index 37caeed85fd..7410ac70b81 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup_context.h +++ b/src/gallium/drivers/llvmpipe/lp_setup_context.h @@ -87,6 +87,8 @@ struct setup_context { struct { struct pipe_surface *cbuf; struct pipe_surface *zsbuf; + unsigned width; + unsigned height; } fb; struct {