diff options
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_context.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_rast.c | 120 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_rast.h | 21 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_rast_priv.h | 11 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_setup.c | 16 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_setup.h | 3 |
6 files changed, 92 insertions, 81 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_context.c b/src/gallium/drivers/llvmpipe/lp_context.c index 7f7b04412c..06aa032540 100644 --- a/src/gallium/drivers/llvmpipe/lp_context.c +++ b/src/gallium/drivers/llvmpipe/lp_context.c @@ -179,7 +179,7 @@ llvmpipe_create( struct pipe_screen *screen ) if (debug_get_bool_option( "LP_NO_RAST", FALSE )) llvmpipe->no_rast = TRUE; - llvmpipe->setup = lp_setup_create(); + llvmpipe->setup = lp_setup_create( screen ); if (!llvmpipe->setup) goto fail; diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index beb149ef18..977f35c46c 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -35,7 +35,7 @@ #define RAST_DEBUG debug_printf -struct lp_rasterizer *lp_rast_create( void ) +struct lp_rasterizer *lp_rast_create( struct pipe_screen *screen ) { struct lp_rasterizer *rast; @@ -43,6 +43,7 @@ struct lp_rasterizer *lp_rast_create( void ) if(!rast) return NULL; + rast->screen = screen; rast->tile.color = align_malloc( TILE_SIZE*TILE_SIZE*4, 16 ); rast->tile.depth = align_malloc( TILE_SIZE*TILE_SIZE*4, 16 ); @@ -50,39 +51,75 @@ struct lp_rasterizer *lp_rast_create( void ) } -void lp_rast_begin( struct lp_rasterizer *rast, - unsigned width, - unsigned height ) +boolean lp_rast_begin( struct lp_rasterizer *rast, + struct pipe_surface *cbuf, + struct pipe_surface *zsbuf, + boolean write_color, + boolean write_zstencil, + unsigned width, + unsigned height ) { + struct pipe_screen *screen = rast->screen; + RAST_DEBUG("%s %dx%d\n", __FUNCTION__, width, height); + pipe_surface_reference(&rast->state.cbuf, cbuf); + pipe_surface_reference(&rast->state.zsbuf, zsbuf); + rast->width = width; rast->height = height; + rast->state.write_zstencil = write_zstencil; + rast->state.write_color = write_color; + 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 ) -{ - RAST_DEBUG("%s\n", __FUNCTION__); + if (cbuf) { + rast->cbuf_transfer = screen->get_tex_transfer(rast->screen, + cbuf->texture, + cbuf->face, + cbuf->level, + cbuf->zslice, + PIPE_TRANSFER_READ_WRITE, + 0, 0, width, height); + if (!rast->cbuf_transfer) + return FALSE; + + rast->cbuf_map = screen->transfer_map(rast->screen, + rast->cbuf_transfer); + if (!rast->cbuf_map) + return FALSE; + } - pipe_surface_reference(&rast->state.cbuf, cbuf); - rast->state.write_color = write_color; + return TRUE; } -void lp_rast_bind_zstencil( struct lp_rasterizer *rast, - struct pipe_surface *zsbuf, - boolean write_zstencil ) + +void lp_rast_end( struct lp_rasterizer *rast ) { - RAST_DEBUG("%s\n", __FUNCTION__); + struct pipe_screen *screen = rast->screen; - pipe_surface_reference(&rast->state.zsbuf, zsbuf); - rast->state.write_zstencil = write_zstencil; + if (rast->cbuf_map) + screen->transfer_unmap(screen, rast->cbuf_transfer); + + if (rast->zsbuf_map) + screen->transfer_unmap(screen, rast->zsbuf_transfer); + + if (rast->cbuf_transfer) + screen->tex_transfer_destroy(rast->cbuf_transfer); + + if (rast->zsbuf_transfer) + screen->tex_transfer_destroy(rast->cbuf_transfer); + + rast->cbuf_transfer = NULL; + rast->zsbuf_transfer = NULL; + rast->cbuf_map = NULL; + rast->zsbuf_map = NULL; } + + /* Begining of each tile: */ void lp_rast_start_tile( struct lp_rasterizer *rast, @@ -233,50 +270,17 @@ void lp_rast_shade_quads( struct lp_rasterizer *rast, static void lp_rast_store_color( struct lp_rasterizer *rast ) { - struct pipe_surface *surface; - struct pipe_screen *screen; - struct pipe_transfer *transfer; const unsigned x = rast->x; const unsigned y = rast->y; - unsigned w = TILE_SIZE; - unsigned h = TILE_SIZE; - void *map; - - RAST_DEBUG("%s %d,%d %dx%d\n", __FUNCTION__, x, y, w, h); - - surface = rast->state.cbuf; - if(!surface) - return; - - screen = surface->texture->screen; - - 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, - surface->face, - surface->level, - surface->zslice, - PIPE_TRANSFER_READ_WRITE, - x, y, w, h); - if(!transfer) - return; - - map = screen->transfer_map(screen, transfer); - if(map) { - lp_tile_write_4ub(transfer->format, - rast->tile.color, - map, transfer->stride, - x, y, w, h); - - screen->transfer_unmap(screen, transfer); - } - screen->tex_transfer_destroy(transfer); + RAST_DEBUG("%s %d,%d\n", __FUNCTION__, x, y); + lp_tile_write_4ub(rast->cbuf_transfer->format, + rast->tile.color, + rast->cbuf_map, + rast->cbuf_transfer->stride, + x, y, + TILESIZE, TILESIZE); } diff --git a/src/gallium/drivers/llvmpipe/lp_rast.h b/src/gallium/drivers/llvmpipe/lp_rast.h index 72f897503d..9dfdf25cda 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.h +++ b/src/gallium/drivers/llvmpipe/lp_rast.h @@ -37,6 +37,7 @@ * individual function calls like this. */ struct lp_rasterizer; +struct pipe_screen; #define TILESIZE 64 @@ -118,19 +119,17 @@ struct lp_rast_triangle { -struct lp_rasterizer *lp_rast_create( void ); +struct lp_rasterizer *lp_rast_create( struct pipe_screen *screen ); -void lp_rast_begin( struct lp_rasterizer *, - unsigned width, - unsigned height); +boolean lp_rast_begin( struct lp_rasterizer *rast, + struct pipe_surface *cbuf, + struct pipe_surface *zsbuf, + boolean write_color, + boolean write_zstencil, + unsigned width, + unsigned height ); -void lp_rast_bind_color( struct lp_rasterizer *, - struct pipe_surface *cbuf, - boolean write_when_done ); - -void lp_rast_bind_zstencil( struct lp_rasterizer *, - struct pipe_surface *zsbuf, - boolean write_when_done ); +void lp_rast_end( struct lp_rasterizer * ); /* 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 f5a6699ed4..eae8138aaf 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast_priv.h +++ b/src/gallium/drivers/llvmpipe/lp_rast_priv.h @@ -30,6 +30,8 @@ #include "lp_rast.h" +struct pipe_transfer; +struct pipe_screen; /* We can choose whatever layout for the internal tile storage we * prefer: @@ -49,7 +51,6 @@ struct lp_rasterizer { */ struct lp_rast_tile tile; - unsigned x; unsigned y; boolean clipped_tile; @@ -57,7 +58,13 @@ struct lp_rasterizer { boolean check_for_clipped_tiles; unsigned width; unsigned height; - + + struct pipe_screen *screen; + struct pipe_transfer *cbuf_transfer; + struct pipe_transfer *zsbuf_transfer; + void *cbuf_map; + void *zsbuf_map; + struct { struct pipe_surface *cbuf; struct pipe_surface *zsbuf; diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index ec1027bb40..ba9d801032 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -165,16 +165,14 @@ rasterize_bins( struct setup_context *setup, unsigned i,j,k; lp_rast_begin( rast, + setup->fb.cbuf, + setup->fb.zsbuf, + setup->fb.cbuf != NULL, + setup->fb.zsbuf != NULL && write_depth, setup->fb.width, setup->fb.height ); - lp_rast_bind_color( rast, - setup->fb.cbuf, - setup->fb.cbuf != NULL ); - 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,6 +191,8 @@ rasterize_bins( struct setup_context *setup, } } + lp_rast_end( rast ); + reset_context( setup ); } @@ -528,12 +528,12 @@ lp_setup_destroy( struct setup_context *setup ) * rasterizer to use with it. */ struct setup_context * -lp_setup_create( void ) +lp_setup_create( struct pipe_screen *screen ) { struct setup_context *setup = CALLOC_STRUCT(setup_context); unsigned i, j; - setup->rast = lp_rast_create(); + setup->rast = lp_rast_create( screen ); if (!setup->rast) goto fail; diff --git a/src/gallium/drivers/llvmpipe/lp_setup.h b/src/gallium/drivers/llvmpipe/lp_setup.h index 0dedc9e9fe..1edd7410fc 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.h +++ b/src/gallium/drivers/llvmpipe/lp_setup.h @@ -52,12 +52,13 @@ struct pipe_texture; struct pipe_surface; struct pipe_buffer; struct pipe_blend_color; +struct pipe_screen; struct setup_context; struct lp_fragment_shader; struct lp_jit_context; struct setup_context * -lp_setup_create( void ); +lp_setup_create( struct pipe_screen *screen ); void lp_setup_clear(struct setup_context *setup, |