37caeed85fda5b8575243210920b3a623bc1febd
1 /**************************************************************************
3 * Copyright 2007-2009 VMware, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
28 #ifndef LP_SETUP_CONTEXT_H
29 #define LP_SETUP_CONTEXT_H
34 /* We're limited to 2K by 2K for 32bit fixed point rasterization.
35 * Will need a 64-bit version for larger framebuffers.
37 #define MAXHEIGHT 2048
39 #define TILES_X (MAXWIDTH / TILESIZE)
40 #define TILES_Y (MAXHEIGHT / TILESIZE)
42 #define CMD_BLOCK_MAX 128
43 #define DATA_BLOCK_SIZE (16 * 1024 - sizeof(unsigned) - sizeof(void *))
46 /* switch to a non-pointer value for this:
48 typedef void (*lp_rast_cmd
)( struct lp_rasterizer
*, const union lp_rast_cmd_arg
* );
51 lp_rast_cmd cmd
[CMD_BLOCK_MAX
];
52 const union lp_rast_cmd_arg
*arg
[CMD_BLOCK_MAX
];
54 struct cmd_block
*next
;
58 ubyte data
[DATA_BLOCK_SIZE
];
60 struct data_block
*next
;
63 struct cmd_block_list
{
64 struct cmd_block
*head
;
65 struct cmd_block
*tail
;
68 struct data_block_list
{
69 struct data_block
*head
;
70 struct data_block
*tail
;
74 struct setup_context
{
76 struct lp_rasterizer
*rast
;
78 /* When there are multiple threads, will want to double-buffer the
81 struct cmd_block_list tile
[TILES_X
][TILES_Y
];
82 struct data_block_list data
;
88 struct pipe_surface
*cbuf
;
89 struct pipe_surface
*zsbuf
;
94 union lp_rast_cmd_arg color
;
95 union lp_rast_cmd_arg zstencil
;
105 struct lp_shader_input input
[PIPE_MAX_ATTRIBS
];
109 void (*point
)( struct setup_context
*,
110 const float (*v0
)[4]);
112 void (*line
)( struct setup_context
*,
113 const float (*v0
)[4],
114 const float (*v1
)[4]);
116 void (*triangle
)( struct setup_context
*,
117 const float (*v0
)[4],
118 const float (*v1
)[4],
119 const float (*v2
)[4]);
122 void lp_setup_choose_triangle( struct setup_context
*setup
);
123 void lp_setup_choose_line( struct setup_context
*setup
);
124 void lp_setup_choose_point( struct setup_context
*setup
);
127 void lp_setup_new_data_block( struct data_block_list
*list
);
128 void lp_setup_new_cmd_block( struct cmd_block_list
*list
);
130 static INLINE
void *get_data( struct data_block_list
*list
,
134 if (list
->tail
->used
+ size
> DATA_BLOCK_SIZE
) {
135 lp_setup_new_data_block( list
);
139 struct data_block
*tail
= list
->tail
;
140 ubyte
*data
= tail
->data
+ tail
->used
;
146 /* Add a command to a given bin.
148 static INLINE
void bin_cmd( struct cmd_block_list
*list
,
150 const union lp_rast_cmd_arg
*arg
)
152 if (list
->tail
->count
== CMD_BLOCK_MAX
) {
153 lp_setup_new_cmd_block( list
);
157 struct cmd_block
*tail
= list
->tail
;
158 unsigned i
= tail
->count
;