struct lp_rasterizer *lp_rast_create( struct pipe_screen *screen )
{
struct lp_rasterizer *rast;
+ unsigned i;
rast = CALLOC_STRUCT(lp_rasterizer);
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 );
+
+ for (i = 0; i < Elements(rast->tasks); i++) {
+ rast->tasks[i].tile.color = align_malloc( TILE_SIZE*TILE_SIZE*4, 16 );
+ rast->tasks[i].tile.depth = align_malloc( TILE_SIZE*TILE_SIZE*4, 16 );
+ }
return rast;
}
*/
static void
lp_rast_start_tile( struct lp_rasterizer *rast,
+ unsigned thread_index,
unsigned x, unsigned y )
{
LP_DBG(DEBUG_RAST, "%s %d,%d\n", __FUNCTION__, x, y);
- rast->x = x;
- rast->y = y;
+ rast->tasks[thread_index].x = x;
+ rast->tasks[thread_index].y = y;
}
* This is a bin command called during bin processing.
*/
void lp_rast_clear_color( struct lp_rasterizer *rast,
+ unsigned thread_index,
const union lp_rast_cmd_arg arg )
{
const uint8_t *clear_color = arg.clear_color;
+ uint8_t *color_tile = rast->tasks[thread_index].tile.color;
LP_DBG(DEBUG_RAST, "%s 0x%x,0x%x,0x%x,0x%x\n", __FUNCTION__,
clear_color[0],
if (clear_color[0] == clear_color[1] &&
clear_color[1] == clear_color[2] &&
clear_color[2] == clear_color[3]) {
- memset(rast->tile.color, clear_color[0], TILE_SIZE * TILE_SIZE * 4);
+ memset(color_tile, clear_color[0], TILE_SIZE * TILE_SIZE * 4);
}
else {
unsigned x, y, chan;
for (y = 0; y < TILE_SIZE; y++)
for (x = 0; x < TILE_SIZE; x++)
for (chan = 0; chan < 4; ++chan)
- TILE_PIXEL(rast->tile.color, x, y, chan) = clear_color[chan];
+ TILE_PIXEL(color_tile, x, y, chan) = clear_color[chan];
}
}
* This is a bin command called during bin processing.
*/
void lp_rast_clear_zstencil( struct lp_rasterizer *rast,
+ unsigned thread_index,
const union lp_rast_cmd_arg arg)
{
unsigned i, j;
+ uint32_t *depth_tile = rast->tasks[thread_index].tile.depth;
LP_DBG(DEBUG_RAST, "%s 0x%x\n", __FUNCTION__, arg.clear_zstencil);
for (i = 0; i < TILE_SIZE; i++)
for (j = 0; j < TILE_SIZE; j++)
- rast->tile.depth[i*TILE_SIZE + j] = arg.clear_zstencil;
+ depth_tile[i*TILE_SIZE + j] = arg.clear_zstencil;
}
* This is a bin command called during bin processing.
*/
void lp_rast_load_color( struct lp_rasterizer *rast,
+ unsigned thread_index,
const union lp_rast_cmd_arg arg)
{
LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__);
* This is a bin command called during bin processing.
*/
void lp_rast_load_zstencil( struct lp_rasterizer *rast,
+ unsigned thread_index,
const union lp_rast_cmd_arg arg )
{
LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__);
void lp_rast_set_state( struct lp_rasterizer *rast,
+ unsigned thread_index,
const union lp_rast_cmd_arg arg )
{
const struct lp_rast_state *state = arg.set_state;
LP_DBG(DEBUG_RAST, "%s %p\n", __FUNCTION__, (void *) state);
/* just set the current state pointer for this rasterizer */
- rast->current_state = state;
+ rast->tasks[thread_index].current_state = state;
}
* This is a bin command called during bin processing.
*/
void lp_rast_shade_tile( struct lp_rasterizer *rast,
+ unsigned thread_index,
const union lp_rast_cmd_arg arg )
{
const struct lp_rast_shader_inputs *inputs = arg.shade_tile;
+ const unsigned tile_x = rast->tasks[thread_index].x;
+ const unsigned tile_y = rast->tasks[thread_index].y;
const unsigned mask = ~0;
unsigned x, y;
*/
for (y = 0; y < TILE_SIZE; y += 4)
for (x = 0; x < TILE_SIZE; x += 4)
- lp_rast_shade_quads( rast, inputs, rast->x + x, rast->y + y, mask);
+ lp_rast_shade_quads( rast,
+ thread_index,
+ inputs,
+ tile_x + x,
+ tile_y + y,
+ mask);
}
* This is a bin command called during bin processing.
*/
void lp_rast_shade_quads( struct lp_rasterizer *rast,
+ unsigned thread_index,
const struct lp_rast_shader_inputs *inputs,
unsigned x, unsigned y,
unsigned mask)
{
#if 1
- const struct lp_rast_state *state = rast->current_state;
- struct lp_rast_tile *tile = &rast->tile;
+ const struct lp_rast_state *state = rast->tasks[thread_index].current_state;
+ struct lp_rast_tile *tile = &rast->tasks[thread_index].tile;
void *color;
void *depth;
uint32_t ALIGN16_ATTRIB masks[2][2][2][2];
/**
* Write the rasterizer's color tile to the framebuffer.
*/
-static void lp_rast_store_color( struct lp_rasterizer *rast )
+static void lp_rast_store_color( struct lp_rasterizer *rast,
+ unsigned thread_index)
{
- const unsigned x = rast->x;
- const unsigned y = rast->y;
+ const unsigned x = rast->tasks[thread_index].x;
+ const unsigned y = rast->tasks[thread_index].y;
unsigned w = TILE_SIZE;
unsigned h = TILE_SIZE;
LP_DBG(DEBUG_RAST, "%s %d,%d %dx%d\n", __FUNCTION__, x, y, w, h);
lp_tile_write_4ub(rast->cbuf_transfer->format,
- rast->tile.color,
+ rast->tasks[thread_index].tile.color,
rast->cbuf_map,
rast->cbuf_transfer->stride,
x, y,
/**
* Write the rasterizer's z/stencil tile to the framebuffer.
*/
-static void lp_rast_store_zstencil( struct lp_rasterizer *rast )
+static void lp_rast_store_zstencil( struct lp_rasterizer *rast,
+ unsigned thread_index )
{
- const unsigned x = rast->x;
- const unsigned y = rast->y;
+ const unsigned x = rast->tasks[thread_index].x;
+ const unsigned y = rast->tasks[thread_index].y;
unsigned w = TILE_SIZE;
unsigned h = TILE_SIZE;
LP_DBG(DEBUG_RAST, "%s %d,%d %dx%d\n", __FUNCTION__, x, y, w, h);
assert(rast->zsbuf_transfer->format == PIPE_FORMAT_Z32_UNORM);
- lp_tile_write_z32(rast->tile.depth,
+ lp_tile_write_z32(rast->tasks[thread_index].tile.depth,
rast->zsbuf_map,
rast->zsbuf_transfer->stride,
x, y, w, h);
* Write the rasterizer's tiles to the framebuffer.
*/
static void
-lp_rast_end_tile( struct lp_rasterizer *rast )
+lp_rast_end_tile( struct lp_rasterizer *rast,
+ unsigned thread_index )
{
LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__);
if (rast->state.write_color)
- lp_rast_store_color(rast);
+ lp_rast_store_color(rast, thread_index);
if (rast->state.write_zstencil)
- lp_rast_store_zstencil(rast);
+ lp_rast_store_zstencil(rast, thread_index);
}
*/
static void
rasterize_bin( struct lp_rasterizer *rast,
+ unsigned thread_index,
const struct cmd_bin *bin,
int x, int y)
{
struct cmd_block *block;
unsigned k;
- lp_rast_start_tile( rast, x, y );
+ lp_rast_start_tile( rast, thread_index, x, y );
/* simply execute each of the commands in the block list */
for (block = commands->head; block; block = block->next) {
for (k = 0; k < block->count; k++) {
- block->cmd[k]( rast, block->arg[k] );
+ block->cmd[k]( rast, 0, block->arg[k] );
}
}
- lp_rast_end_tile( rast );
+ lp_rast_end_tile( rast, thread_index );
}
for (i = 0; i < bins->tiles_x; i++) {
for (j = 0; j < bins->tiles_y; j++) {
struct cmd_bin *bin = lp_get_bin(bins, i, j);
- rasterize_bin( rast, bin, i * TILE_SIZE, j * TILE_SIZE );
+ rasterize_bin( rast, 0, bin, i * TILE_SIZE, j * TILE_SIZE );
}
}
}
lp_bin_iter_begin( bins );
while ((bin = lp_bin_iter_next(bins, &x, &y))) {
- rasterize_bin( rast, bin, x * TILE_SIZE, y * TILE_SIZE);
+ rasterize_bin( rast, 0, bin, x * TILE_SIZE, y * TILE_SIZE);
}
}
#endif
*/
void lp_rast_destroy( struct lp_rasterizer *rast )
{
+ unsigned i;
+
pipe_surface_reference(&rast->state.cbuf, NULL);
pipe_surface_reference(&rast->state.zsbuf, NULL);
- align_free(rast->tile.depth);
- align_free(rast->tile.color);
+
+ for (i = 0; i < Elements(rast->tasks); i++) {
+ align_free(rast->tasks[i].tile.depth);
+ align_free(rast->tasks[i].tile.color);
+ }
+
FREE(rast);
}
* All pixels are known to be inside the triangle's bounds.
*/
static void
-block_full_4( struct lp_rasterizer *rast, int x, int y )
+block_full_4( struct lp_rasterizer_task *rast_task, int x, int y )
{
- const unsigned i = rast->nr_blocks;
+ const unsigned i = rast_task->nr_blocks;
assert(x % 4 == 0);
assert(y % 4 == 0);
- rast->blocks[i].x = x;
- rast->blocks[i].y = y;
- rast->blocks[i].mask = ~0;
- rast->nr_blocks++;
+ rast_task->blocks[i].x = x;
+ rast_task->blocks[i].y = y;
+ rast_task->blocks[i].mask = ~0;
+ rast_task->nr_blocks++;
}
* All pixels are known to be inside the triangle's bounds.
*/
static void
-block_full_16( struct lp_rasterizer *rast, int x, int y )
+block_full_16( struct lp_rasterizer_task *rast_task, int x, int y )
{
unsigned ix, iy;
assert(x % 16 == 0);
assert(y % 16 == 0);
for (iy = 0; iy < 16; iy += 4)
for (ix = 0; ix < 16; ix += 4)
- block_full_4(rast, x + ix, y + iy);
+ block_full_4(rast_task, x + ix, y + iy);
}
* Generate a mask of in/out flags and add the block to the blocks list.
*/
static void
-do_block_4( struct lp_rasterizer *rast,
+do_block_4( struct lp_rasterizer_task *rast_task,
const struct lp_rast_triangle *tri,
int x, int y,
int c1,
/* As we do trivial reject already, masks should rarely be all zero:
*/
if (mask) {
- const unsigned i = rast->nr_blocks;
- rast->blocks[i].x = x;
- rast->blocks[i].y = y;
- rast->blocks[i].mask = mask;
- rast->nr_blocks++;
+ const unsigned i = rast_task->nr_blocks;
+ rast_task->blocks[i].x = x;
+ rast_task->blocks[i].y = y;
+ rast_task->blocks[i].mask = mask;
+ rast_task->nr_blocks++;
}
}
* of the triangle's bounds.
*/
static void
-do_block_16( struct lp_rasterizer *rast,
+do_block_16( struct lp_rasterizer_task *rast_task,
const struct lp_rast_triangle *tri,
int x, int y,
int c1,
cx2 + ei2 > 0 &&
cx3 + ei3 > 0) {
/* the block is completely inside the triangle */
- block_full_4(rast, x+ix, y+iy);
+ block_full_4(rast_task, x+ix, y+iy);
}
else {
/* the block is partially in/out of the triangle */
- do_block_4(rast, tri, x+ix, y+iy, cx1, cx2, cx3);
+ do_block_4(rast_task, tri, x+ix, y+iy, cx1, cx2, cx3);
}
}
}
*/
void
lp_rast_triangle( struct lp_rasterizer *rast,
+ unsigned thread_index,
const union lp_rast_cmd_arg arg )
{
+ struct lp_rasterizer_task *rast_task = &rast->tasks[thread_index];
const struct lp_rast_triangle *tri = arg.triangle;
- int x = rast->x;
- int y = rast->y;
+ int x = rast_task->x;
+ int y = rast_task->y;
int ix, iy;
unsigned i = 0;
int eo2 = tri->eo2 * 16;
int eo3 = tri->eo3 * 16;
- assert(Elements(rast->blocks) == (TILE_SIZE * TILE_SIZE) / (4*4));
+ assert(Elements(rast_task->blocks) == (TILE_SIZE * TILE_SIZE) / (4*4));
LP_DBG(DEBUG_RAST, "lp_rast_triangle\n");
- rast->nr_blocks = 0;
+ rast_task->nr_blocks = 0;
/* Walk over the tile to build a list of 4x4 pixel blocks which will
* be filled/shaded. We do this at two granularities: 16x16 blocks
cx2 + ei2 > 0 &&
cx3 + ei3 > 0) {
/* the block is completely inside the triangle */
- block_full_16(rast, x+ix, y+iy);
+ block_full_16(rast_task, x+ix, y+iy);
}
else {
/* the block is partially in/out of the triangle */
- do_block_16(rast, tri, x+ix, y+iy, cx1, cx2, cx3);
+ do_block_16(rast_task, tri, x+ix, y+iy, cx1, cx2, cx3);
}
}
}
- assert(rast->nr_blocks <= Elements(rast->blocks));
+ assert(rast_task->nr_blocks <= Elements(rast_task->blocks));
/* Shade the 4x4 pixel blocks */
- for (i = 0; i < rast->nr_blocks; i++)
- lp_rast_shade_quads(rast, &tri->inputs,
- rast->blocks[i].x,
- rast->blocks[i].y,
- rast->blocks[i].mask);
+ for (i = 0; i < rast_task->nr_blocks; i++)
+ lp_rast_shade_quads(rast,
+ thread_index,
+ &tri->inputs,
+ rast_task->blocks[i].x,
+ rast_task->blocks[i].y,
+ rast_task->blocks[i].mask);
}