#ifndef LP_RAST_H
#define LP_RAST_H
+#include "lp_jit.h"
+
/* Initially create and program a single rasterizer directly. Later
* will want multiple of these, one or two per core. At that stage
* will probably pass command buffers into the rasterizers rather than
*/
struct lp_rasterizer;
+#define TILESIZE 64
+
+
struct lp_rast_state {
/* State for the shader:
*/
*/
const struct lp_rast_state *state;
- /* Attribute interpolation:
+ /* Attribute interpolation: FIXME: reduce memory waste!
*/
- struct tgsi_interp_coef position_coef;
- struct tgsi_interp_coef *coef;
+ float a0[PIPE_MAX_ATTRIBS][4];
+ float dadx[PIPE_MAX_ATTRIBS][4];
+ float dady[PIPE_MAX_ATTRIBS][4];
};
* lp_setup_flush().
*/
-#include "lp_setup.h"
+#include "lp_setup_context.h"
#include "util/u_math.h"
#include "util/u_memory.h"
static void reset_context( struct setup_context *setup )
{
+ unsigned i, j;
+
for (i = 0; i < setup->tiles_x; i++) {
for (j = 0; j < setup->tiles_y; j++) {
- struct cmd_block_list *list = scene->tile[i][j];
+ struct cmd_block_list *list = &setup->tile[i][j];
struct cmd_block *block;
struct cmd_block *tmp;
- for (block = list->first; block != list->tail; block = tmp) {
+ for (block = list->head; block != list->tail; block = tmp) {
tmp = block->next;
FREE(block);
}
- list->first = list->tail;
+ list->head = list->tail;
}
}
{
- struct data_block_list *list = &scene->data;
+ struct data_block_list *list = &setup->data;
struct data_block *block, *tmp;
- for (block = list->first; block != list->tail; block = tmp) {
+ for (block = list->head; block != list->tail; block = tmp) {
tmp = block->next;
FREE(block);
}
- list->first = list->tail;
+ list->head = list->tail;
}
}
/* Add a command to all active bins.
*/
static void bin_everywhere( struct setup_context *setup,
- bin_cmd cmd,
+ lp_rast_cmd cmd,
const union lp_rast_cmd_arg *arg )
{
unsigned i, j;
for (i = 0; i < setup->tiles_x; i++)
for (j = 0; j < setup->tiles_y; j++)
- bin_cmd( setup, &setup->tile[i][j], cmd, arg );
+ bin_cmd( &setup->tile[i][j], cmd, arg );
}
static void
rasterize_bins( struct setup_context *setup,
- struct lp_rast *rast,
boolean write_depth )
{
+ struct lp_rasterizer *rast = setup->rast;
+ struct cmd_block *block;
+ unsigned i,j,k;
+
lp_rast_bind_color( rast,
- scene->fb.color,
+ setup->fb.color,
TRUE ); /* WRITE */
lp_rast_bind_depth( rast,
- scene->fb.depth,
+ setup->fb.zstencil,
write_depth ); /* WRITE */
- for (i = 0; i < scene->tiles_x; i++) {
- for (j = 0; j < scene->tiles_y; j++) {
+ for (i = 0; i < setup->tiles_x; i++) {
+ for (j = 0; j < setup->tiles_y; j++) {
lp_rast_start_tile( rast,
i * TILESIZE,
j * TILESIZE );
- for (block = scene->tile[i][j].first; block; block = block->next) {
- for (k = 0; k < block->nr_cmds; k++) {
- block->cmd[k].func( rast, block->cmd[k].arg );
+ for (block = setup->tile[i][j].head; block; block = block->next) {
+ for (k = 0; k < block->count; k++) {
+ block->cmd[k]( rast, block->arg[k] );
}
}
}
}
- lp_setup_free_data( setup );
+ reset_context( setup );
}
#ifndef LP_SETUP_CONTEXT_H
#define LP_SETUP_CONTEXT_H
+#include "lp_setup.h"
+#include "lp_rast.h"
#define CMD_BLOCK_MAX 128
#define DATA_BLOCK_SIZE (16 * 1024 - sizeof(unsigned) - sizeof(void *))
/* switch to a non-pointer value for this:
*/
-typedef void (*lp_rast_cmd)( struct lp_rast *, const union lp_rast_cmd_arg * );
+typedef void (*lp_rast_cmd)( struct lp_rasterizer *, const union lp_rast_cmd_arg * );
struct cmd_block {
- union lp_rast_arg *arg[CMD_BLOCK_MAX];
lp_rast_cmd cmd[CMD_BLOCK_MAX];
+ const union lp_rast_cmd_arg *arg[CMD_BLOCK_MAX];
unsigned count;
struct cmd_block *next;
};
struct data_block {
- ubyte data[DATA_BLOCK_SZ];
+ ubyte data[DATA_BLOCK_SIZE];
unsigned used;
struct data_block *next;
};
struct setup_context {
+ struct lp_rasterizer *rast;
+
/* When there are multiple threads, will want to double-buffer the
* bin arrays:
*/
- struct cmd_block_list bin[MAXHEIGHT / TILESIZE][MAXWIDTH / TILESIZE];
+ struct cmd_block_list tile[MAXHEIGHT / TILESIZE][MAXWIDTH / TILESIZE];
struct data_block_list data;
unsigned tiles_x;
void (*triangle)( struct setup_context *,
const float (*v0)[4],
const float (*v1)[4],
- const float (*v1)[4]);
+ const float (*v2)[4]);
};
+void lp_setup_new_data_block( struct data_block_list *list );
+void lp_setup_new_cmd_block( struct cmd_block_list *list );
+
static INLINE void *get_data( struct data_block_list *list,
unsigned size)
{
{
struct data_block *tail = list->tail;
- char *data = tail->data + tail->used;
+ ubyte *data = tail->data + tail->used;
tail->used += size;
return data;
}
/* Add a command to a given bin.
*/
static INLINE void bin_cmd( struct cmd_block_list *list,
- bin_cmd cmd,
+ lp_rast_cmd cmd,
const union lp_rast_cmd_arg *arg )
{
- if (list->tail.count == CMD_BLOCK_MAX) {
- lp_setup_new_cmd_block( list )
+ if (list->tail->count == CMD_BLOCK_MAX) {
+ lp_setup_new_cmd_block( list );
}
{
+#endif