mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-26 05:40:33 +01:00
llvmpipe: trivial/clear works
This commit is contained in:
parent
295aea0489
commit
e0e2008f1d
6 changed files with 92 additions and 81 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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,37 +51,73 @@ 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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void lp_rast_bind_color( struct lp_rasterizer *rast,
|
||||
struct pipe_surface *cbuf,
|
||||
boolean write_color )
|
||||
|
||||
void lp_rast_end( struct lp_rasterizer *rast )
|
||||
{
|
||||
RAST_DEBUG("%s\n", __FUNCTION__);
|
||||
struct pipe_screen *screen = rast->screen;
|
||||
|
||||
pipe_surface_reference(&rast->state.cbuf, cbuf);
|
||||
rast->state.write_color = write_color;
|
||||
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;
|
||||
}
|
||||
|
||||
void lp_rast_bind_zstencil( struct lp_rasterizer *rast,
|
||||
struct pipe_surface *zsbuf,
|
||||
boolean write_zstencil )
|
||||
{
|
||||
RAST_DEBUG("%s\n", __FUNCTION__);
|
||||
|
||||
pipe_surface_reference(&rast->state.zsbuf, zsbuf);
|
||||
rast->state.write_zstencil = write_zstencil;
|
||||
}
|
||||
|
||||
|
||||
/* Begining of each tile:
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue