Re-commit t_vertex.[ch] changes to fd.o server.
[mesa.git] / src / mesa / tnl / t_context.h
1 /*
2 * mesa 3-D graphics library
3 * Version: 5.1
4 *
5 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 /**
26 * \file t_context.h
27 * \brief TnL module datatypes and definitions.
28 * \author Keith Whitwell
29 */
30
31
32 /**
33 * \mainpage The TNL-module
34 *
35 * TNL stands for "transform and lighting", i.e. this module implements
36 * a pipeline that receives as input a buffer of vertices and does all
37 * necessary transformations (rotations, clipping, vertex shader etc.)
38 * and passes then the output to the rasterizer.
39 *
40 * The tnl_pipeline contains the array of all stages, which should be
41 * applied. Each stage is a black-box, which is described by an
42 * tnl_pipeline_stage. The function ::_tnl_run_pipeline applies all the
43 * stages to the vertex_buffer TNLcontext::vb, where the vertex data
44 * is stored. The last stage in the pipeline is the rasterizer.
45 *
46 * The initial vertex_buffer data may either come from an ::immediate
47 * structure or client vertex_arrays or display lists:
48 *
49 *
50 * - The ::immediate structure records all the GL commands issued between
51 * glBegin and glEnd. \n
52 * The structure accumulates data, until it is either full or it is
53 * flushed (usually by a state change). Before starting then the pipeline,
54 * the collected vertex data in ::immediate has to be pushed into
55 * TNLcontext::vb.
56 * This happens in ::_tnl_vb_bind_immediate. The pipeline is then run by
57 * calling tnl_device_driver::RunPipeline = ::_tnl_run_pipeline, which
58 * is stored in TNLcontext::Driver. \n
59 * An ::immediate does (for performance reasons) usually not finish with a
60 * glEnd, and hence it also does not need to start with a glBegin.
61 * This means that the last vertices of one ::immediate may need to be
62 * saved for the next one.
63 *
64 *
65 * - NOT SURE ABOUT THIS: The vertex_arrays structure is used to handle
66 * glDrawArrays etc. \n
67 * Here, the data of the vertex_arrays is copied by ::_tnl_vb_bind_arrays
68 * into TNLcontext::vb, so that the pipeline can be started.
69 */
70
71
72 #ifndef _T_CONTEXT_H
73 #define _T_CONTEXT_H
74
75 #include "glheader.h"
76 #include "mtypes.h"
77
78 #include "math/m_matrix.h"
79 #include "math/m_vector.h"
80 #include "math/m_xform.h"
81
82
83 #define MAX_PIPELINE_STAGES 30
84
85
86 /*
87 * Note: The first attributes match the VERT_ATTRIB_* definitions
88 * in mtypes.h. However, the tnl module has additional attributes
89 * for materials, color indexes, edge flags, etc.
90 */
91 enum {
92 _TNL_ATTRIB_POS = 0,
93 _TNL_ATTRIB_WEIGHT = 1,
94 _TNL_ATTRIB_NORMAL = 2,
95 _TNL_ATTRIB_COLOR0 = 3,
96 _TNL_ATTRIB_COLOR1 = 4,
97 _TNL_ATTRIB_FOG = 5,
98 _TNL_ATTRIB_SIX = 6,
99 _TNL_ATTRIB_SEVEN = 7,
100 _TNL_ATTRIB_TEX0 = 8,
101 _TNL_ATTRIB_TEX1 = 9,
102 _TNL_ATTRIB_TEX2 = 10,
103 _TNL_ATTRIB_TEX3 = 11,
104 _TNL_ATTRIB_TEX4 = 12,
105 _TNL_ATTRIB_TEX5 = 13,
106 _TNL_ATTRIB_TEX6 = 14,
107 _TNL_ATTRIB_TEX7 = 15,
108 _TNL_ATTRIB_MAT_FRONT_AMBIENT = 16,
109 _TNL_ATTRIB_MAT_BACK_AMBIENT = 17,
110 _TNL_ATTRIB_MAT_FRONT_DIFFUSE = 18,
111 _TNL_ATTRIB_MAT_BACK_DIFFUSE = 19,
112 _TNL_ATTRIB_MAT_FRONT_SPECULAR = 20,
113 _TNL_ATTRIB_MAT_BACK_SPECULAR = 21,
114 _TNL_ATTRIB_MAT_FRONT_EMISSION = 22,
115 _TNL_ATTRIB_MAT_BACK_EMISSION = 23,
116 _TNL_ATTRIB_MAT_FRONT_SHININESS = 24,
117 _TNL_ATTRIB_MAT_BACK_SHININESS = 25,
118 _TNL_ATTRIB_MAT_FRONT_INDEXES = 26,
119 _TNL_ATTRIB_MAT_BACK_INDEXES = 27,
120 _TNL_ATTRIB_INDEX = 28,
121 _TNL_ATTRIB_EDGEFLAG = 29,
122 _TNL_ATTRIB_MAX = 30
123 } ;
124
125 /* Will probably have to revise this scheme fairly shortly, eg. by
126 * compacting all the MAT flags down to one bit, or by using two
127 * dwords to store the flags.
128 */
129 #define _TNL_BIT_POS (1<<0)
130 #define _TNL_BIT_WEIGHT (1<<1)
131 #define _TNL_BIT_NORMAL (1<<2)
132 #define _TNL_BIT_COLOR0 (1<<3)
133 #define _TNL_BIT_COLOR1 (1<<4)
134 #define _TNL_BIT_FOG (1<<5)
135 #define _TNL_BIT_SIX (1<<6)
136 #define _TNL_BIT_SEVEN (1<<7)
137 #define _TNL_BIT_TEX0 (1<<8)
138 #define _TNL_BIT_TEX1 (1<<9)
139 #define _TNL_BIT_TEX2 (1<<10)
140 #define _TNL_BIT_TEX3 (1<<11)
141 #define _TNL_BIT_TEX4 (1<<12)
142 #define _TNL_BIT_TEX5 (1<<13)
143 #define _TNL_BIT_TEX6 (1<<14)
144 #define _TNL_BIT_TEX7 (1<<15)
145 #define _TNL_BIT_MAT_FRONT_AMBIENT (1<<16)
146 #define _TNL_BIT_MAT_BACK_AMBIENT (1<<17)
147 #define _TNL_BIT_MAT_FRONT_DIFFUSE (1<<18)
148 #define _TNL_BIT_MAT_BACK_DIFFUSE (1<<19)
149 #define _TNL_BIT_MAT_FRONT_SPECULAR (1<<20)
150 #define _TNL_BIT_MAT_BACK_SPECULAR (1<<21)
151 #define _TNL_BIT_MAT_FRONT_EMISSION (1<<22)
152 #define _TNL_BIT_MAT_BACK_EMISSION (1<<23)
153 #define _TNL_BIT_MAT_FRONT_SHININESS (1<<24)
154 #define _TNL_BIT_MAT_BACK_SHININESS (1<<25)
155 #define _TNL_BIT_MAT_FRONT_INDEXES (1<<26)
156 #define _TNL_BIT_MAT_BACK_INDEXES (1<<27)
157 #define _TNL_BIT_INDEX (1<<28)
158 #define _TNL_BIT_EDGEFLAG (1<<29)
159
160 #define _TNL_BIT_TEX(u) (1 << (_TNL_ATTRIB_TEX0 + (u)))
161
162
163
164 #define _TNL_BITS_MAT_ANY (_TNL_BIT_MAT_FRONT_AMBIENT | \
165 _TNL_BIT_MAT_BACK_AMBIENT | \
166 _TNL_BIT_MAT_FRONT_DIFFUSE | \
167 _TNL_BIT_MAT_BACK_DIFFUSE | \
168 _TNL_BIT_MAT_FRONT_SPECULAR | \
169 _TNL_BIT_MAT_BACK_SPECULAR | \
170 _TNL_BIT_MAT_FRONT_EMISSION | \
171 _TNL_BIT_MAT_BACK_EMISSION | \
172 _TNL_BIT_MAT_FRONT_SHININESS | \
173 _TNL_BIT_MAT_BACK_SHININESS | \
174 _TNL_BIT_MAT_FRONT_INDEXES | \
175 _TNL_BIT_MAT_BACK_INDEXES)
176
177
178 #define _TNL_BITS_TEX_ANY (_TNL_BIT_TEX0 | \
179 _TNL_BIT_TEX1 | \
180 _TNL_BIT_TEX2 | \
181 _TNL_BIT_TEX3 | \
182 _TNL_BIT_TEX4 | \
183 _TNL_BIT_TEX5 | \
184 _TNL_BIT_TEX6 | \
185 _TNL_BIT_TEX7)
186
187
188 #define _TNL_BITS_PROG_ANY (_TNL_BIT_POS | \
189 _TNL_BIT_WEIGHT | \
190 _TNL_BIT_NORMAL | \
191 _TNL_BIT_COLOR0 | \
192 _TNL_BIT_COLOR1 | \
193 _TNL_BIT_FOG | \
194 _TNL_BIT_SIX | \
195 _TNL_BIT_SEVEN | \
196 _TNL_BITS_TEX_ANY)
197
198
199
200 #define PRIM_BEGIN 0x10
201 #define PRIM_END 0x20
202 #define PRIM_WEAK 0x40
203 #define PRIM_MODE_MASK 0x0f
204
205 /*
206 */
207 struct tnl_prim {
208 GLuint mode;
209 GLuint start;
210 GLuint count;
211 };
212
213
214
215 struct tnl_eval1_map {
216 struct gl_1d_map *map;
217 GLuint sz;
218 };
219
220 struct tnl_eval2_map {
221 struct gl_2d_map *map;
222 GLuint sz;
223 };
224
225 struct tnl_eval {
226 GLuint new_state;
227 struct tnl_eval1_map map1[_TNL_ATTRIB_INDEX + 1];
228 struct tnl_eval2_map map2[_TNL_ATTRIB_INDEX + 1];
229 };
230
231
232 #define TNL_MAX_PRIM 16
233 #define TNL_MAX_COPIED_VERTS 3
234
235 struct tnl_copied_vtx {
236 GLfloat buffer[_TNL_ATTRIB_MAX * 4 * TNL_MAX_COPIED_VERTS];
237 GLuint nr;
238 };
239
240 #define VERT_BUFFER_SIZE 2048 /* 8kbytes */
241
242 typedef void (*attrfv_func)( const GLfloat * );
243
244 /* The assembly of vertices in immediate mode is separated from
245 * display list compilation. This allows a simpler immediate mode
246 * treatment and a display list compiler better suited to
247 * hardware-acceleration.
248 */
249 struct tnl_vtx {
250 GLfloat buffer[VERT_BUFFER_SIZE];
251 GLubyte attrsz[_TNL_ATTRIB_MAX];
252 GLuint vertex_size;
253 struct tnl_prim prim[TNL_MAX_PRIM];
254 GLuint prim_count;
255 GLfloat *vbptr; /* cursor, points into buffer */
256 GLfloat vertex[_TNL_ATTRIB_MAX*4]; /* current vertex */
257 GLfloat *attrptr[_TNL_ATTRIB_MAX]; /* points into vertex */
258 GLfloat *current[_TNL_ATTRIB_MAX]; /* points into ctx->Current, etc */
259 GLuint counter, initial_counter;
260 struct tnl_copied_vtx copied;
261 attrfv_func tabfv[_TNL_ATTRIB_MAX][4];
262 struct tnl_eval eval;
263 GLboolean *edgeflag_tmp;
264 GLboolean have_materials;
265 };
266
267
268
269
270 /* For display lists, this structure holds a run of vertices of the
271 * same format, and a strictly well-formed set of begin/end pairs,
272 * starting on the first vertex and ending at the last. Vertex
273 * copying on buffer breaks is precomputed according to these
274 * primitives, though there are situations where the copying will need
275 * correction at execute-time, perhaps by replaying the list as
276 * immediate mode commands.
277 *
278 * On executing this list, the 'current' values may be updated with
279 * the values of the final vertex, and often no fixup of the start of
280 * the vertex list is required.
281 *
282 * Eval and other commands that don't fit into these vertex lists are
283 * compiled using the fallback opcode mechanism provided by dlist.c.
284 */
285 struct tnl_vertex_list {
286 GLubyte attrsz[_TNL_ATTRIB_MAX];
287 GLuint vertex_size;
288
289 GLfloat *buffer;
290 GLuint count;
291 GLuint wrap_count; /* number of copied vertices at start */
292 GLboolean have_materials; /* bit of a hack - quick check for materials */
293 GLboolean dangling_attr_ref; /* current attr implicitly referenced
294 outside the list */
295
296 GLfloat *normal_lengths;
297 struct tnl_prim *prim;
298 GLuint prim_count;
299
300 struct tnl_vertex_store *vertex_store;
301 struct tnl_primitive_store *prim_store;
302 };
303
304 /* These buffers should be a reasonable size to support upload to
305 * hardware? Maybe drivers should stitch them back together, or
306 * specify a desired size?
307 */
308 #define SAVE_BUFFER_SIZE (16*1024)
309 #define SAVE_PRIM_SIZE 128
310
311 /* Storage to be shared among several vertex_lists.
312 */
313 struct tnl_vertex_store {
314 GLfloat buffer[SAVE_BUFFER_SIZE];
315 GLuint used;
316 GLuint refcount;
317 };
318
319 struct tnl_primitive_store {
320 struct tnl_prim buffer[SAVE_PRIM_SIZE];
321 GLuint used;
322 GLuint refcount;
323 };
324
325
326 struct tnl_save {
327 GLubyte attrsz[_TNL_ATTRIB_MAX];
328 GLuint vertex_size;
329
330 GLfloat *buffer;
331 GLuint count;
332 GLuint wrap_count;
333
334 struct tnl_prim *prim;
335 GLuint prim_count, prim_max;
336
337 struct tnl_vertex_store *vertex_store;
338 struct tnl_primitive_store *prim_store;
339
340 GLfloat *vbptr; /* cursor, points into buffer */
341 GLfloat vertex[_TNL_ATTRIB_MAX*4]; /* current values */
342 GLfloat *attrptr[_TNL_ATTRIB_MAX];
343 GLuint counter, initial_counter;
344 GLboolean dangling_attr_ref;
345 GLboolean have_materials;
346
347 GLuint opcode_vertex_list;
348
349 struct tnl_copied_vtx copied;
350
351 GLfloat *current[_TNL_ATTRIB_MAX]; /* points into ctx->ListState */
352 GLubyte *currentsz[_TNL_ATTRIB_MAX];
353
354 void (*tabfv[_TNL_ATTRIB_MAX][4])( const GLfloat * );
355 };
356
357
358
359
360
361
362
363 struct tnl_vertex_arrays
364 {
365 /* Conventional vertex attribute arrays */
366 GLvector4f Obj;
367 GLvector4f Normal;
368 GLvector4f Color;
369 GLvector4f SecondaryColor;
370 GLvector4f FogCoord;
371 GLvector4f TexCoord[MAX_TEXTURE_COORD_UNITS];
372 GLvector4f Index;
373
374 GLubyte *EdgeFlag;
375 GLuint *Elt;
376
377 /* These attributes don't alias with the conventional attributes.
378 * The GL_NV_vertex_program extension defines 16 extra sets of vertex
379 * arrays which have precedent over the conventional arrays when enabled.
380 */
381 GLvector4f Attribs[_TNL_ATTRIB_MAX];
382 };
383
384
385 /**
386 * Contains the current state of a running pipeline.
387 */
388 struct vertex_buffer
389 {
390 /* Constant over life of the vertex_buffer.
391 */
392 GLuint Size;
393
394 /* Constant over the pipeline.
395 */
396 GLuint Count; /* for everything except Elts */
397
398 /* Pointers to current data.
399 */
400 GLuint *Elts;
401 GLvector4f *ObjPtr; /* _TNL_BIT_POS */
402 GLvector4f *EyePtr; /* _TNL_BIT_POS */
403 GLvector4f *ClipPtr; /* _TNL_BIT_POS */
404 GLvector4f *NdcPtr; /* _TNL_BIT_POS */
405 GLubyte ClipOrMask; /* _TNL_BIT_POS */
406 GLubyte *ClipMask; /* _TNL_BIT_POS */
407 GLvector4f *NormalPtr; /* _TNL_BIT_NORMAL */
408 GLfloat *NormalLengthPtr; /* _TNL_BIT_NORMAL */
409 GLboolean *EdgeFlag; /* _TNL_BIT_EDGEFLAG */
410 GLvector4f *TexCoordPtr[MAX_TEXTURE_COORD_UNITS]; /* VERT_TEX_0..n */
411 GLvector4f *IndexPtr[2]; /* _TNL_BIT_INDEX */
412 GLvector4f *ColorPtr[2]; /* _TNL_BIT_COLOR0 */
413 GLvector4f *SecondaryColorPtr[2]; /* _TNL_BIT_COLOR1 */
414 GLvector4f *PointSizePtr; /* _TNL_BIT_POS */
415 GLvector4f *FogCoordPtr; /* _TNL_BIT_FOG */
416
417 struct tnl_prim *Primitive;
418 GLuint PrimitiveCount;
419
420 /* Inputs to the vertex program stage */
421 GLvector4f *AttribPtr[_TNL_ATTRIB_MAX]; /* GL_NV_vertex_program */
422
423 GLuint LastClipped;
424 /* Private data from _tnl_render_stage that has no business being
425 * in this struct.
426 */
427
428 };
429
430
431
432 /** Describes an individual operation on the pipeline.
433 */
434 struct tnl_pipeline_stage {
435 const char *name;
436 GLuint check_state; /* All state referenced in check() --
437 * When is the pipeline_stage struct
438 * itself invalidated? Must be
439 * constant.
440 */
441
442 /* Usually constant or set by the 'check' callback:
443 */
444 GLuint run_state; /* All state referenced in run() --
445 * When is the cached output of the
446 * stage invalidated?
447 */
448
449 GLboolean active; /* True if runnable in current state */
450 GLuint inputs; /* VERT_* inputs to the stage */
451 GLuint outputs; /* VERT_* outputs of the stage */
452
453 /* Set in _tnl_run_pipeline():
454 */
455 GLuint changed_inputs; /* Generated value -- inputs to the
456 * stage that have changed since last
457 * call to 'run'.
458 */
459
460
461 /* Private data for the pipeline stage:
462 */
463 void *privatePtr;
464
465 /* Free private data. May not be null.
466 */
467 void (*destroy)( struct tnl_pipeline_stage * );
468
469 /* Called from _tnl_validate_pipeline(). Must update all fields in
470 * the pipeline_stage struct for the current state.
471 */
472 void (*check)( GLcontext *ctx, struct tnl_pipeline_stage * );
473
474 /* Called from _tnl_run_pipeline(). The stage.changed_inputs value
475 * encodes all inputs to thee struct which have changed. If
476 * non-zero, recompute all affected outputs of the stage, otherwise
477 * execute any 'sideeffects' of the stage.
478 *
479 * Return value: GL_TRUE - keep going
480 * GL_FALSE - finished pipeline
481 */
482 GLboolean (*run)( GLcontext *ctx, struct tnl_pipeline_stage * );
483 };
484
485 /** Contains the array of all pipeline stages.
486 * The default values are defined at the end of t_pipeline.c */
487 struct tnl_pipeline {
488 GLuint build_state_trigger; /**< state changes which require build */
489 GLuint build_state_changes; /**< state changes since last build */
490 GLuint run_state_changes; /**< state changes since last run */
491 GLuint run_input_changes; /**< VERT_* changes since last run */
492 GLuint inputs; /**< VERT_* inputs to pipeline */
493 /** This array has to end with a NULL-pointer. */
494 struct tnl_pipeline_stage stages[MAX_PIPELINE_STAGES+1];
495 GLuint nr_stages;
496 };
497
498
499 struct tnl_clipspace_attr {
500 int attrib;
501 int vertoffset;
502 int vertattrsize;
503 GLfloat *inputptr;
504 int inputstride;
505
506 void (*insert)( const struct tnl_clipspace_attr *a,
507 char *v, const GLfloat *input );
508
509 void (*extract)( const struct tnl_clipspace_attr *a,
510 GLfloat *output, const char *v );
511
512 const GLfloat *vp;
513 };
514
515
516
517 typedef void (*points_func)( GLcontext *ctx, GLuint first, GLuint last );
518 typedef void (*line_func)( GLcontext *ctx, GLuint v1, GLuint v2 );
519 typedef void (*triangle_func)( GLcontext *ctx,
520 GLuint v1, GLuint v2, GLuint v3 );
521 typedef void (*quad_func)( GLcontext *ctx, GLuint v1, GLuint v2,
522 GLuint v3, GLuint v4 );
523 typedef void (*render_func)( GLcontext *ctx, GLuint start, GLuint count,
524 GLuint flags );
525 typedef void (*interp_func)( GLcontext *ctx,
526 GLfloat t, GLuint dst, GLuint out, GLuint in,
527 GLboolean force_boundary );
528 typedef void (*copy_pv_func)( GLcontext *ctx, GLuint dst, GLuint src );
529 typedef void (*setup_func)( GLcontext *ctx,
530 GLuint start, GLuint end,
531 GLuint new_inputs);
532
533
534
535
536 struct tnl_clipspace {
537 GLboolean need_extras;
538
539 GLuint new_inputs;
540
541 GLubyte *vertex_buf;
542 GLuint vertex_size;
543 GLuint max_vertex_size;
544
545 struct tnl_clipspace_attr attr[_TNL_ATTRIB_MAX];
546 GLuint attr_count;
547
548 void (*emit)( GLcontext *ctx, GLuint start, GLuint end, void *dest );
549 interp_func interp;
550 copy_pv_func copy_pv;
551 };
552
553
554 struct tnl_device_driver {
555 /***
556 *** TNL Pipeline
557 ***/
558
559 void (*RunPipeline)(GLcontext *ctx);
560 /* Replaces PipelineStart/PipelineFinish -- intended to allow
561 * drivers to wrap _tnl_run_pipeline() with code to validate state
562 * and grab/release hardware locks.
563 */
564
565 void (*NotifyMaterialChange)(GLcontext *ctx);
566 /* Alert tnl-aware drivers of changes to material.
567 */
568
569 GLboolean (*NotifyBegin)(GLcontext *ctx, GLenum p);
570 /* Allow drivers to hook in optimized begin/end engines.
571 * Return value: GL_TRUE - driver handled the begin
572 * GL_FALSE - driver didn't handle the begin
573 */
574
575 /***
576 *** Rendering -- These functions called only from t_vb_render.c
577 ***/
578 struct {
579 void (*Start)(GLcontext *ctx);
580 void (*Finish)(GLcontext *ctx);
581 /* Called before and after all rendering operations, including DrawPixels,
582 * ReadPixels, Bitmap, span functions, and CopyTexImage, etc commands.
583 * These are a suitable place for grabbing/releasing hardware locks.
584 */
585
586 void (*PrimitiveNotify)(GLcontext *ctx, GLenum mode);
587 /* Called between RenderStart() and RenderFinish() to indicate the
588 * type of primitive we're about to draw. Mode will be one of the
589 * modes accepted by glBegin().
590 */
591
592 interp_func Interp;
593 /* The interp function is called by the clipping routines when we need
594 * to generate an interpolated vertex. All pertinant vertex ancilliary
595 * data should be computed by interpolating between the 'in' and 'out'
596 * vertices.
597 */
598
599 copy_pv_func CopyPV;
600 /* The copy function is used to make a copy of a vertex. All pertinant
601 * vertex attributes should be copied.
602 */
603
604 void (*ClippedPolygon)( GLcontext *ctx, const GLuint *elts, GLuint n );
605 /* Render a polygon with <n> vertices whose indexes are in the <elts>
606 * array.
607 */
608
609 void (*ClippedLine)( GLcontext *ctx, GLuint v0, GLuint v1 );
610 /* Render a line between the two vertices given by indexes v0 and v1. */
611
612 points_func Points; /* must now respect vb->elts */
613 line_func Line;
614 triangle_func Triangle;
615 quad_func Quad;
616 /* These functions are called in order to render points, lines,
617 * triangles and quads. These are only called via the T&L module.
618 */
619
620 render_func *PrimTabVerts;
621 render_func *PrimTabElts;
622 /* Render whole unclipped primitives (points, lines, linestrips,
623 * lineloops, etc). The tables are indexed by the GL enum of the
624 * primitive to be rendered. RenderTabVerts is used for non-indexed
625 * arrays of vertices. RenderTabElts is used for indexed arrays of
626 * vertices.
627 */
628
629 void (*ResetLineStipple)( GLcontext *ctx );
630 /* Reset the hardware's line stipple counter.
631 */
632
633 setup_func BuildVertices;
634 /* This function is called whenever new vertices are required for
635 * rendering. The vertices in question are those n such that start
636 * <= n < end. The new_inputs parameter indicates those fields of
637 * the vertex which need to be updated, if only a partial repair of
638 * the vertex is required.
639 *
640 * This function is called only from _tnl_render_stage in tnl/t_render.c.
641 */
642
643
644 GLboolean (*Multipass)( GLcontext *ctx, GLuint passno );
645 /* Driver may request additional render passes by returning GL_TRUE
646 * when this function is called. This function will be called
647 * after the first pass, and passes will be made until the function
648 * returns GL_FALSE. If no function is registered, only one pass
649 * is made.
650 *
651 * This function will be first invoked with passno == 1.
652 */
653 } Render;
654 };
655
656
657 typedef struct {
658
659 /* Driver interface.
660 */
661 struct tnl_device_driver Driver;
662
663 /* Execute:
664 */
665 struct tnl_vtx vtx;
666
667 /* Compile:
668 */
669 struct tnl_save save;
670
671 /* Pipeline
672 */
673 struct tnl_pipeline pipeline;
674 struct vertex_buffer vb;
675
676 /* GLvectors for binding to vb:
677 */
678 struct tnl_vertex_arrays vtx_inputs;
679 struct tnl_vertex_arrays save_inputs;
680 struct tnl_vertex_arrays current;
681 struct tnl_vertex_arrays array_inputs;
682
683
684 /* Clipspace/ndc/window vertex managment:
685 */
686 struct tnl_clipspace clipspace;
687
688
689 /* Probably need a better configuration mechanism:
690 */
691 GLboolean NeedNdcCoords;
692 GLboolean LoopbackDListCassettes;
693 GLboolean CalcDListNormalLengths;
694 GLboolean IsolateMaterials;
695
696 /*
697 */
698 GLuint render_inputs;
699
700
701 GLvertexformat exec_vtxfmt;
702 GLvertexformat save_vtxfmt;
703
704 } TNLcontext;
705
706
707
708 #define TNL_CONTEXT(ctx) ((TNLcontext *)(ctx->swtnl_context))
709
710
711 #define TYPE_IDX(t) ((t) & 0xf)
712 #define MAX_TYPES TYPE_IDX(GL_DOUBLE)+1 /* 0xa + 1 */
713
714 extern void _tnl_MakeCurrent( GLcontext *ctx,
715 GLframebuffer *drawBuffer,
716 GLframebuffer *readBuffer );
717
718
719
720
721 #endif