}
+/**
+ * Begin the rasterization phase.
+ * Map the framebuffer surfaces. Initialize the 'rast' state.
+ */
boolean lp_rast_begin( struct lp_rasterizer *rast,
struct pipe_surface *cbuf,
struct pipe_surface *zsbuf,
}
+/**
+ * Finish the rasterization phase.
+ * Unmap framebuffer surfaces.
+ */
void lp_rast_end( struct lp_rasterizer *rast )
{
struct pipe_screen *screen = rast->screen;
-/* Begining of each tile:
+/**
+ * Begining rasterization of a tile.
+ * \param x window X position of the tile, in pixels
+ * \param y window Y position of the tile, in pixels
*/
void lp_rast_start_tile( struct lp_rasterizer *rast,
unsigned x,
rast->y = y;
}
+
+/**
+ * Clear the rasterizer's current color tile.
+ */
void lp_rast_clear_color( struct lp_rasterizer *rast,
const union lp_rast_cmd_arg arg )
{
}
}
+
+/**
+ * Clear the rasterizer's current z/stencil tile.
+ */
void lp_rast_clear_zstencil( struct lp_rasterizer *rast,
const union lp_rast_cmd_arg arg)
{
*/
+/**
+ * Write the rasterizer's color tile to the framebuffer.
+ */
static void lp_rast_store_color( struct lp_rasterizer *rast )
{
const unsigned x = rast->x;
}
+/**
+ * Write the rasterizer's z/stencil tile to the framebuffer.
+ */
static void lp_rast_store_zstencil( struct lp_rasterizer *rast )
{
RAST_DEBUG("%s\n", __FUNCTION__);
}
+/**
+ * Write the rasterizer's tiles to the framebuffer.
+ */
void lp_rast_end_tile( struct lp_rasterizer *rast )
{
RAST_DEBUG("%s\n", __FUNCTION__);
* plus inputs to run the shader:
*/
struct lp_rast_triangle {
+ /* bounding box of tri (in pixels) */
int minx;
int maxx;
int miny;
int eo2;
int eo3;
- /* y deltas for vertex pairs */
+ /* y deltas for vertex pairs (in fixed pt) */
int dy12;
int dy23;
int dy31;
- /* x deltas for vertex pairs */
+ /* x deltas for vertex pairs (in fixed pt) */
int dx12;
int dx23;
int dx31;
struct cmd_block_list tile[TILES_X][TILES_Y];
struct data_block_list data;
+ /* size of framebuffer, in tiles */
unsigned tiles_x;
unsigned tiles_y;
void lp_setup_new_data_block( struct data_block_list *list );
void lp_setup_new_cmd_block( struct cmd_block_list *list );
+
+/**
+ * Allocate space for a command/data in the given block list.
+ * Grow the block list if needed.
+ */
static INLINE void *get_data( struct data_block_list *list,
unsigned size)
{
#define MIN3(a,b,c) MIN2(MIN2(a,b),c)
#define MAX3(a,b,c) MAX2(MAX2(a,b),c)
+/**
+ * Do basic setup for triangle rasterization and determine which
+ * framebuffer tiles are touched. Put the triangle in the bins for the
+ * tiles which we overlap.
+ */
static void
do_triangle_ccw(struct setup_context *setup,
const float (*v1)[4],
const float (*v3)[4],
boolean frontfacing )
{
-
+ /* x/y positions in fixed point */
+ const int x1 = subpixel_snap(v1[0][0]);
+ const int x2 = subpixel_snap(v2[0][0]);
+ const int x3 = subpixel_snap(v3[0][0]);
const int y1 = subpixel_snap(v1[0][1]);
const int y2 = subpixel_snap(v2[0][1]);
const int y3 = subpixel_snap(v3[0][1]);
- const int x1 = subpixel_snap(v1[0][0]);
- const int x2 = subpixel_snap(v2[0][0]);
- const int x3 = subpixel_snap(v3[0][0]);
-
struct lp_rast_triangle *tri = get_data( &setup->data, sizeof *tri );
float area;
int minx, maxx, miny, maxy;
return;
}
- // Bounding rectangle
+ /* Bounding rectangle (in pixels) */
tri->minx = (MIN3(x1, x2, x3) + 0xf) >> FIXED_ORDER;
tri->maxx = (MAX3(x1, x2, x3) + 0xf) >> FIXED_ORDER;
tri->miny = (MIN3(y1, y2, y3) + 0xf) >> FIXED_ORDER;
}
}
+ /* Convert to tile coordinates:
+ */
minx = tri->minx / TILE_SIZE;
miny = tri->miny / TILE_SIZE;
maxx = tri->maxx / TILE_SIZE;
maxy = tri->maxy / TILE_SIZE;
-
- /* Convert to tile coordinates:
+ /* Determine which tile(s) intersect the triangle's bounding box
*/
if (miny == maxy && minx == maxx)
{
cx3 + ei3 > 0)
{
in = 1;
- /* shade whole tile */
- bin_command( &setup->tile[x][y], lp_rast_shade_tile,
+ /* triangle covers the whole tile- shade whole tile */
+ bin_command( &setup->tile[x][y],
+ lp_rast_shade_tile,
lp_rast_arg_inputs(&tri->inputs) );
}
else