blob: 359a8b8a3db0fb633831bad99887eda0cba8af8b [file] [log] [blame]
Keith Whitwell8e4a95a2007-05-24 10:41:34 +01001/**************************************************************************
2 *
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
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:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
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 TUNGSTEN GRAPHICS 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.
25 *
26 **************************************************************************/
27
Brian279ffe32007-07-09 16:14:26 -060028/**
29 * Private data structures, etc for the draw module.
Keith Whitwell8e4a95a2007-05-24 10:41:34 +010030 */
31
Keith Whitwell8e4a95a2007-05-24 10:41:34 +010032
Brian279ffe32007-07-09 16:14:26 -060033/**
34 * Authors:
35 * Keith Whitwell <keith@tungstengraphics.com>
36 * Brian Paul
Keith Whitwell8e4a95a2007-05-24 10:41:34 +010037 */
Keith Whitwell8e4a95a2007-05-24 10:41:34 +010038
Brian279ffe32007-07-09 16:14:26 -060039
40#ifndef DRAW_PRIVATE_H
41#define DRAW_PRIVATE_H
42
43
Brian279ffe32007-07-09 16:14:26 -060044#include "pipe/p_state.h"
45#include "pipe/p_defines.h"
Brian766fa512007-08-20 17:02:07 -060046
José Fonsecaf430d952008-02-19 12:52:28 +090047#include "rtasm/rtasm_x86sse.h"
José Fonseca6acd63a2008-02-15 17:50:12 +090048#include "tgsi/exec/tgsi_exec.h"
Briancddeca52008-02-27 16:02:58 -070049#include "tgsi/util/tgsi_scan.h"
Brian0d13ade2007-10-02 11:46:11 -060050
Brian279ffe32007-07-09 16:14:26 -060051
Brianaceeb802008-02-18 16:19:05 -070052struct pipe_context;
Zack Rusin25b17b22007-10-29 08:27:32 -040053struct gallivm_prog;
54struct gallivm_cpu_engine;
José Fonsecac28fdf32007-11-07 12:08:19 +000055
Keith Whitwellf40357e2008-03-23 16:44:59 +000056struct draw_pt_middle_end;
57struct draw_pt_front_end;
58
Zack Rusinaadbb1d2008-04-12 15:45:28 -040059#define MAX_SHADER_VERTICES 128
60
Brian279ffe32007-07-09 16:14:26 -060061/**
62 * Basic vertex info.
63 * Carry some useful information around with the vertices in the prim pipe.
64 */
65struct vertex_header {
Brianfd0a6d62007-08-16 12:52:20 -060066 unsigned clipmask:12;
67 unsigned edgeflag:1;
Keith Whitwella37e0da2007-09-25 13:20:53 +010068 unsigned pad:3;
69 unsigned vertex_id:16;
Brian279ffe32007-07-09 16:14:26 -060070
Brianfd0a6d62007-08-16 12:52:20 -060071 float clip[4];
Brian279ffe32007-07-09 16:14:26 -060072
Brianfd0a6d62007-08-16 12:52:20 -060073 float data[][4]; /* Note variable size */
Brian279ffe32007-07-09 16:14:26 -060074};
75
José Fonsecac28fdf32007-11-07 12:08:19 +000076/* NOTE: It should match vertex_id size above */
77#define UNDEFINED_VERTEX_ID 0xffff
78
Briand8b16d42007-08-23 17:00:47 -060079/* XXX This is too large */
Brian08673452007-09-20 13:42:37 -060080#define MAX_VERTEX_SIZE ((2 + PIPE_MAX_SHADER_OUTPUTS) * 4 * sizeof(float))
Zack Rusine3309192008-04-14 12:27:24 -040081#define MAX_VERTEX_ALLOCATION ((MAX_VERTEX_SIZE + 0x0f) & ~0x0f)
Keith Whitwell4bb21342007-08-14 15:44:41 +010082
83
Brian279ffe32007-07-09 16:14:26 -060084
85/**
86 * Basic info for a point/line/triangle primitive.
87 */
88struct prim_header {
Brianfd0a6d62007-08-16 12:52:20 -060089 float det; /**< front/back face determinant */
90 unsigned reset_line_stipple:1;
91 unsigned edgeflags:3;
92 unsigned pad:28;
Brian279ffe32007-07-09 16:14:26 -060093 struct vertex_header *v[3]; /**< 1 to 3 vertex pointers */
94};
95
96
97
98struct draw_context;
99
100/**
101 * Base class for all primitive drawing stages.
102 */
Brianea470ee2007-07-12 13:32:31 -0600103struct draw_stage
Brian279ffe32007-07-09 16:14:26 -0600104{
105 struct draw_context *draw; /**< parent context */
106
Brianea470ee2007-07-12 13:32:31 -0600107 struct draw_stage *next; /**< next stage in pipeline */
Keith Whitwell8e4a95a2007-05-24 10:41:34 +0100108
Brian193c85e2007-11-09 07:54:46 -0700109 struct vertex_header **tmp; /**< temp vert storage, such as for clipping */
Brianfd0a6d62007-08-16 12:52:20 -0600110 unsigned nr_tmps;
Keith Whitwell8e4a95a2007-05-24 10:41:34 +0100111
Brianea470ee2007-07-12 13:32:31 -0600112 void (*point)( struct draw_stage *,
Keith Whitwell8e4a95a2007-05-24 10:41:34 +0100113 struct prim_header * );
114
Brianea470ee2007-07-12 13:32:31 -0600115 void (*line)( struct draw_stage *,
Keith Whitwell8e4a95a2007-05-24 10:41:34 +0100116 struct prim_header * );
117
Brianea470ee2007-07-12 13:32:31 -0600118 void (*tri)( struct draw_stage *,
Keith Whitwell8e4a95a2007-05-24 10:41:34 +0100119 struct prim_header * );
Zack Rusina1a989f2007-09-28 04:33:55 -0400120
Brian0bfd0852008-01-25 15:59:27 -0700121 void (*flush)( struct draw_stage *,
Brian1603a332008-01-25 17:21:05 -0700122 unsigned flags );
Brian0360b492007-07-25 15:48:09 -0600123
124 void (*reset_stipple_counter)( struct draw_stage * );
Michald7545482007-11-23 11:30:51 +0000125
126 void (*destroy)( struct draw_stage * );
Keith Whitwell8e4a95a2007-05-24 10:41:34 +0100127};
128
129
Keith Whitwell30479ef2008-02-15 18:56:41 +0000130#define PRIM_QUEUE_LENGTH 32
Keith Whitwell4bb21342007-08-14 15:44:41 +0100131#define VCACHE_SIZE 32
132#define VCACHE_OVERFLOW 4
133#define VS_QUEUE_LENGTH (VCACHE_SIZE + VCACHE_OVERFLOW + 1) /* can never fill up */
134
Zack Rusina1a989f2007-09-28 04:33:55 -0400135/**
136 * Private version of the compiled vertex_shader
137 */
138struct draw_vertex_shader {
Keith Whitwellb29d8d22008-02-15 13:37:01 +0000139
140 /* This member will disappear shortly:
141 */
Brian12ab5f92008-03-12 13:20:29 -0600142 struct pipe_shader_state state;
Keith Whitwellb29d8d22008-02-15 13:37:01 +0000143
Briancddeca52008-02-27 16:02:58 -0700144 struct tgsi_shader_info info;
145
Keith Whitwellb29d8d22008-02-15 13:37:01 +0000146 void (*prepare)( struct draw_vertex_shader *shader,
147 struct draw_context *draw );
148
149 /* Run the shader - this interface will get cleaned up in the
150 * future:
151 */
Zack Rusin808f9682008-04-11 19:58:22 -0400152 boolean (*run)( struct draw_vertex_shader *shader,
153 struct draw_context *draw,
154 const unsigned *elts,
155 unsigned count,
Zack Rusine3309192008-04-14 12:27:24 -0400156 void *out,
157 unsigned vertex_size);
Zack Rusin808f9682008-04-11 19:58:22 -0400158
Keith Whitwellb29d8d22008-02-15 13:37:01 +0000159
160 void (*delete)( struct draw_vertex_shader * );
Zack Rusina1a989f2007-09-28 04:33:55 -0400161};
Keith Whitwell4bb21342007-08-14 15:44:41 +0100162
Keith Whitwell027983f2008-01-24 11:19:06 +0000163
164/* Internal function for vertex fetch.
165 */
166typedef void (*fetch_func)(const void *ptr, float *attrib);
Keith Whitwelld2cb4ba2008-04-03 12:21:30 +0100167
168fetch_func draw_get_fetch_func( enum pipe_format format );
169
170
171
Keith Whitwell88858e02008-01-28 12:40:29 +0000172typedef void (*full_fetch_func)( struct draw_context *draw,
173 struct tgsi_exec_machine *machine,
174 const unsigned *elts,
175 unsigned count );
Keith Whitwell027983f2008-01-24 11:19:06 +0000176
Keith Whitwell297b3be2008-03-10 19:49:15 +0000177typedef void (*pt_fetch_func)( struct draw_context *draw,
178 float *out,
179 unsigned start,
180 unsigned count );
Keith Whitwell027983f2008-01-24 11:19:06 +0000181
182
Keith Whitwell297b3be2008-03-10 19:49:15 +0000183struct vbuf_render;
184
Keith Whitwella8582ef2008-04-16 10:03:18 +0100185
186#define PT_SHADE 0x1
187#define PT_CLIPTEST 0x2
188#define PT_PIPELINE 0x4
189#define PT_MAX_MIDDLE 0x8
190
Brian279ffe32007-07-09 16:14:26 -0600191/**
192 * Private context for the drawing module.
193 */
194struct draw_context
195{
Brianfd0a6d62007-08-16 12:52:20 -0600196 /** Drawing/primitive pipeline stages */
Brian279ffe32007-07-09 16:14:26 -0600197 struct {
Brianea470ee2007-07-12 13:32:31 -0600198 struct draw_stage *first; /**< one of the following */
Keith Whitwell8e4a95a2007-05-24 10:41:34 +0100199
Keith Whitwell08589f72007-09-26 11:56:17 +0100200 struct draw_stage *validate;
201
Brian279ffe32007-07-09 16:14:26 -0600202 /* stages (in logical order) */
Brianea470ee2007-07-12 13:32:31 -0600203 struct draw_stage *flatshade;
204 struct draw_stage *clip;
205 struct draw_stage *cull;
206 struct draw_stage *twoside;
207 struct draw_stage *offset;
208 struct draw_stage *unfilled;
Brian329a8472008-01-21 14:08:20 -0700209 struct draw_stage *stipple;
Brianeb4dc2d2008-02-21 16:18:05 -0700210 struct draw_stage *aapoint;
Brianaceeb802008-02-18 16:19:05 -0700211 struct draw_stage *aaline;
Brian446bfc32008-02-21 16:56:32 -0700212 struct draw_stage *pstipple;
Brian Paula1a13952008-02-28 17:49:22 -0700213 struct draw_stage *wide_line;
214 struct draw_stage *wide_point;
Zack Rusinde69fc12007-09-18 10:02:16 -0400215 struct draw_stage *rasterize;
Brian279ffe32007-07-09 16:14:26 -0600216 } pipeline;
217
Keith Whitwell297b3be2008-03-10 19:49:15 +0000218
219 struct vbuf_render *render;
220
221 /* Support prototype passthrough path:
222 */
223 struct {
Keith Whitwellf40357e2008-03-23 16:44:59 +0000224 unsigned prim; /* XXX: to be removed */
225 unsigned hw_vertex_size; /* XXX: to be removed */
226
227 struct {
Keith Whitwella8582ef2008-04-16 10:03:18 +0100228 struct draw_pt_middle_end *opt[PT_MAX_MIDDLE];
Keith Whitwellf40357e2008-03-23 16:44:59 +0000229 } middle;
230
231 struct {
Keith Whitwellf40357e2008-03-23 16:44:59 +0000232 struct draw_pt_front_end *vcache;
233 } front;
234
Keith Whitwell0b20d1b2008-04-04 13:18:09 +0100235 struct {
236 char *verts;
237 unsigned vertex_stride;
238 unsigned vertex_count;
239 } pipeline;
240
Keith Whitwell297b3be2008-03-10 19:49:15 +0000241 } pt;
242
Briandf1744c2008-03-27 15:33:47 -0600243 boolean flushing;
Keith Whitwell297b3be2008-03-10 19:49:15 +0000244
Brian279ffe32007-07-09 16:14:26 -0600245 /* pipe state that we need: */
Zack Rusin29440182007-09-17 12:59:50 -0400246 const struct pipe_rasterizer_state *rasterizer;
Brian279ffe32007-07-09 16:14:26 -0600247 struct pipe_viewport_state viewport;
Keith Whitwellc96d5652008-04-17 13:14:22 +0100248
Brian39038c12008-03-27 17:41:55 -0600249 struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
Keith Whitwellc96d5652008-04-17 13:14:22 +0100250 unsigned nr_vertex_buffers;
251
Brian39038c12008-03-27 17:41:55 -0600252 struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS];
Keith Whitwellb29d8d22008-02-15 13:37:01 +0000253 struct draw_vertex_shader *vertex_shader;
Brian3e2be1c2007-08-15 18:54:05 -0600254
Brian594dab42008-03-31 14:14:30 -0600255 boolean identity_viewport;
256
Briancd364362008-01-23 12:48:41 -0700257 uint num_vs_outputs; /**< convenience, from vertex_shader */
258
Brian64469862007-11-08 17:07:12 -0700259 /* user-space vertex data, buffers */
260 struct {
Keith Whitwell84501e62008-04-04 17:02:20 +0100261 const unsigned *edgeflag;
262
Brian64469862007-11-08 17:07:12 -0700263 /** vertex element/index buffer (ex: glDrawElements) */
264 const void *elts;
265 /** bytes per index (0, 1, 2 or 4) */
266 unsigned eltSize;
Brian3e2be1c2007-08-15 18:54:05 -0600267
Brian64469862007-11-08 17:07:12 -0700268 /** vertex arrays */
Brian39038c12008-03-27 17:41:55 -0600269 const void *vbuffer[PIPE_MAX_ATTRIBS];
Brian64469862007-11-08 17:07:12 -0700270
271 /** constant buffer (for vertex shader) */
272 const void *constants;
Brian64469862007-11-08 17:07:12 -0700273 } user;
Brian63a51ae2007-09-06 17:07:09 -0600274
Brian279ffe32007-07-09 16:14:26 -0600275 /* Clip derived state:
276 */
Brianfd0a6d62007-08-16 12:52:20 -0600277 float plane[12][4];
278 unsigned nr_planes;
Brian279ffe32007-07-09 16:14:26 -0600279
Brian5e29aab2008-02-26 14:29:35 -0700280 float wide_point_threshold; /**< convert pnts to tris if larger than this */
Brian Paula1a13952008-02-28 17:49:22 -0700281 float wide_line_threshold; /**< convert lines to tris if wider than this */
Brian8b8c9ac2008-03-13 14:33:57 -0600282 boolean line_stipple; /**< do line stipple? */
Brian5a09ad82008-03-14 16:13:35 -0600283 boolean point_sprite; /**< convert points to quads for sprites? */
Keith Whitwellb29d8d22008-02-15 13:37:01 +0000284 boolean use_sse;
Keith Whitwellcaf29332008-04-14 12:08:46 +0100285 boolean use_pt_shaders; /* temporary flag to switch on pt shader paths */
Brianf1fb69a2008-01-22 10:16:30 -0700286
Brianaceeb802008-02-18 16:19:05 -0700287 /* If a prim stage introduces new vertex attributes, they'll be stored here
288 */
289 struct {
290 uint semantic_name;
291 uint semantic_index;
292 int slot;
293 } extra_vp_outputs;
294
Brianfd0a6d62007-08-16 12:52:20 -0600295 unsigned reduced_prim;
296
Brian0d13ade2007-10-02 11:46:11 -0600297 /** TGSI program interpreter runtime state */
298 struct tgsi_exec_machine machine;
Keith Whitwell4bb21342007-08-14 15:44:41 +0100299
Keith Whitwell027983f2008-01-24 11:19:06 +0000300 /* Vertex fetch internal state
301 */
302 struct {
Brian39038c12008-03-27 17:41:55 -0600303 const ubyte *src_ptr[PIPE_MAX_ATTRIBS];
304 unsigned pitch[PIPE_MAX_ATTRIBS];
305 fetch_func fetch[PIPE_MAX_ATTRIBS];
Keith Whitwell027983f2008-01-24 11:19:06 +0000306 unsigned nr_attrs;
Keith Whitwell88858e02008-01-28 12:40:29 +0000307 full_fetch_func fetch_func;
Keith Whitwell297b3be2008-03-10 19:49:15 +0000308 pt_fetch_func pt_fetch;
Keith Whitwell027983f2008-01-24 11:19:06 +0000309 } vertex_fetch;
310
Keith Whitwell4bb21342007-08-14 15:44:41 +0100311 /* Post-tnl vertex cache:
312 */
313 struct {
Brian3df65af2007-10-23 15:02:02 -0600314 unsigned referenced; /**< bitfield */
Keith Whitwell30479ef2008-02-15 18:56:41 +0000315
316 struct {
317 unsigned in; /* client array element */
318 unsigned out; /* index in vs queue/array */
319 } idx[VCACHE_SIZE + VCACHE_OVERFLOW];
320
Brianfd0a6d62007-08-16 12:52:20 -0600321 unsigned overflow;
Keith Whitwell08589f72007-09-26 11:56:17 +0100322
Brian64469862007-11-08 17:07:12 -0700323 /** To find space in the vertex cache: */
Keith Whitwell08589f72007-09-26 11:56:17 +0100324 struct vertex_header *(*get_vertex)( struct draw_context *draw,
325 unsigned i );
Keith Whitwell4bb21342007-08-14 15:44:41 +0100326 } vcache;
327
328 /* Vertex shader queue:
329 */
330 struct {
Zack Rusin3f7a3dd2008-04-12 21:52:46 -0400331 unsigned elts[VS_QUEUE_LENGTH]; /**< index into the user's vertex arrays */
332 char *vertex_cache;
Brianfd0a6d62007-08-16 12:52:20 -0600333 unsigned queue_nr;
Keith Whitwell30479ef2008-02-15 18:56:41 +0000334 unsigned post_nr;
Keith Whitwell4bb21342007-08-14 15:44:41 +0100335 } vs;
336
Ian Romanick3d136052008-01-29 11:43:04 -0800337 /**
338 * Run the vertex shader on all vertices in the vertex queue.
339 */
340 void (*shader_queue_flush)(struct draw_context *draw);
341
Keith Whitwell4bb21342007-08-14 15:44:41 +0100342 /* Prim pipeline queue:
343 */
344 struct {
Keith Whitwell4bb21342007-08-14 15:44:41 +0100345 /* Need to queue up primitives until their vertices have been
346 * transformed by a vs queue flush.
347 */
348 struct prim_header queue[PRIM_QUEUE_LENGTH];
Brianfd0a6d62007-08-16 12:52:20 -0600349 unsigned queue_nr;
Keith Whitwell4bb21342007-08-14 15:44:41 +0100350 } pq;
Zack Rusin8731e392007-09-28 07:33:54 -0400351
Keith Whitwellb29d8d22008-02-15 13:37:01 +0000352
353 /* This (and the tgsi_exec_machine struct) probably need to be moved somewhere private.
354 */
355 struct gallivm_cpu_engine *engine;
Ian Romanicka89ee8a2008-01-30 20:10:45 -0800356 void *driver_private;
Brian279ffe32007-07-09 16:14:26 -0600357};
358
359
360
Brianea470ee2007-07-12 13:32:31 -0600361extern struct draw_stage *draw_unfilled_stage( struct draw_context *context );
362extern struct draw_stage *draw_twoside_stage( struct draw_context *context );
363extern struct draw_stage *draw_offset_stage( struct draw_context *context );
364extern struct draw_stage *draw_clip_stage( struct draw_context *context );
365extern struct draw_stage *draw_flatshade_stage( struct draw_context *context );
366extern struct draw_stage *draw_cull_stage( struct draw_context *context );
Brian329a8472008-01-21 14:08:20 -0700367extern struct draw_stage *draw_stipple_stage( struct draw_context *context );
Brian Paula1a13952008-02-28 17:49:22 -0700368extern struct draw_stage *draw_wide_line_stage( struct draw_context *context );
369extern struct draw_stage *draw_wide_point_stage( struct draw_context *context );
Keith Whitwell08589f72007-09-26 11:56:17 +0100370extern struct draw_stage *draw_validate_stage( struct draw_context *context );
Brian279ffe32007-07-09 16:14:26 -0600371
372
Brianb08102a2008-02-13 10:25:38 -0700373extern void draw_free_temp_verts( struct draw_stage *stage );
374
375extern void draw_alloc_temp_verts( struct draw_stage *stage, unsigned nr );
Brian279ffe32007-07-09 16:14:26 -0600376
José Fonseca3e221802007-11-07 13:07:20 +0000377extern void draw_reset_vertex_ids( struct draw_context *draw );
378
Brian279ffe32007-07-09 16:14:26 -0600379
Brian9a11a4a2007-08-31 11:28:31 -0600380extern int draw_vertex_cache_check_space( struct draw_context *draw,
381 unsigned nr_verts );
382
Brian9a11a4a2007-08-31 11:28:31 -0600383extern void draw_vertex_cache_invalidate( struct draw_context *draw );
384extern void draw_vertex_cache_unreference( struct draw_context *draw );
Keith Whitwella37e0da2007-09-25 13:20:53 +0100385extern void draw_vertex_cache_reset_vertex_ids( struct draw_context *draw );
386
Brian9a11a4a2007-08-31 11:28:31 -0600387extern void draw_vertex_shader_queue_flush( struct draw_context *draw );
388
Keith Whitwell027983f2008-01-24 11:19:06 +0000389extern void draw_update_vertex_fetch( struct draw_context *draw );
Brian9a11a4a2007-08-31 11:28:31 -0600390
Keith Whitwell4505acf2008-03-25 15:17:53 +0000391extern boolean draw_need_pipeline(const struct draw_context *draw,
392 unsigned prim );
Brian8b8c9ac2008-03-13 14:33:57 -0600393
Brian279ffe32007-07-09 16:14:26 -0600394
Keith Whitwellf40357e2008-03-23 16:44:59 +0000395/* Passthrough mode (second attempt):
396 */
397boolean draw_pt_init( struct draw_context *draw );
398void draw_pt_destroy( struct draw_context *draw );
399boolean draw_pt_arrays( struct draw_context *draw,
400 unsigned prim,
401 unsigned start,
402 unsigned count );
403
Keith Whitwell0b20d1b2008-04-04 13:18:09 +0100404void draw_pt_reset_vertex_ids( struct draw_context *draw );
405void draw_pt_run_pipeline( struct draw_context *draw,
406 unsigned prim,
407 char *verts,
408 unsigned vertex_stride,
409 unsigned vertex_count,
410 const ushort *elts,
411 unsigned count );
Keith Whitwellf40357e2008-03-23 16:44:59 +0000412
413
Brian1603a332008-01-25 17:21:05 -0700414#define DRAW_FLUSH_SHADER_QUEUE 0x1 /* sized not to overflow, never raised */
415#define DRAW_FLUSH_PRIM_QUEUE 0x2
416#define DRAW_FLUSH_VERTEX_CACHE 0x4
417#define DRAW_FLUSH_STATE_CHANGE 0x8
418#define DRAW_FLUSH_BACKEND 0x10
Keith Whitwell08589f72007-09-26 11:56:17 +0100419
420
Brian1603a332008-01-25 17:21:05 -0700421void draw_do_flush( struct draw_context *draw, unsigned flags );
Keith Whitwell08589f72007-09-26 11:56:17 +0100422
Keith Whitwell84501e62008-04-04 17:02:20 +0100423boolean draw_get_edgeflag( struct draw_context *draw,
424 unsigned idx );
Keith Whitwell08589f72007-09-26 11:56:17 +0100425
426
Brian279ffe32007-07-09 16:14:26 -0600427/**
428 * Get a writeable copy of a vertex.
429 * \param stage drawing stage info
430 * \param vert the vertex to copy (source)
431 * \param idx index into stage's tmp[] array to put the copy (dest)
432 * \return pointer to the copied vertex
Keith Whitwell8e4a95a2007-05-24 10:41:34 +0100433 */
434static INLINE struct vertex_header *
Brianea470ee2007-07-12 13:32:31 -0600435dup_vert( struct draw_stage *stage,
Keith Whitwell8e4a95a2007-05-24 10:41:34 +0100436 const struct vertex_header *vert,
Brianfd0a6d62007-08-16 12:52:20 -0600437 unsigned idx )
Keith Whitwell8e4a95a2007-05-24 10:41:34 +0100438{
439 struct vertex_header *tmp = stage->tmp[idx];
Briancd364362008-01-23 12:48:41 -0700440 const uint vsize = sizeof(struct vertex_header)
441 + stage->draw->num_vs_outputs * 4 * sizeof(float);
442 memcpy(tmp, vert, vsize);
José Fonsecac28fdf32007-11-07 12:08:19 +0000443 tmp->vertex_id = UNDEFINED_VERTEX_ID;
Keith Whitwell8e4a95a2007-05-24 10:41:34 +0100444 return tmp;
445}
446
Zack Rusinb46926c2007-10-03 10:31:42 -0400447static INLINE float
448dot4(const float *a, const float *b)
449{
450 float result = (a[0]*b[0] +
451 a[1]*b[1] +
452 a[2]*b[2] +
453 a[3]*b[3]);
454
455 return result;
456}
Keith Whitwell8e4a95a2007-05-24 10:41:34 +0100457
Zack Rusin3f7a3dd2008-04-12 21:52:46 -0400458static INLINE struct vertex_header *
Zack Rusine3309192008-04-14 12:27:24 -0400459draw_header_from_block(char *block, int size, int num)
Zack Rusin3f7a3dd2008-04-12 21:52:46 -0400460{
Zack Rusin3f7a3dd2008-04-12 21:52:46 -0400461 return (struct vertex_header*)(block + num * size);
462}
463
Brian279ffe32007-07-09 16:14:26 -0600464#endif /* DRAW_PRIVATE_H */