whitespace changes and new comments
[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 #define _TNL_BITS_MAT_ANY (_TNL_BIT_MAT_FRONT_AMBIENT | \
164 _TNL_BIT_MAT_BACK_AMBIENT | \
165 _TNL_BIT_MAT_FRONT_DIFFUSE | \
166 _TNL_BIT_MAT_BACK_DIFFUSE | \
167 _TNL_BIT_MAT_FRONT_SPECULAR | \
168 _TNL_BIT_MAT_BACK_SPECULAR | \
169 _TNL_BIT_MAT_FRONT_EMISSION | \
170 _TNL_BIT_MAT_BACK_EMISSION | \
171 _TNL_BIT_MAT_FRONT_SHININESS | \
172 _TNL_BIT_MAT_BACK_SHININESS | \
173 _TNL_BIT_MAT_FRONT_INDEXES | \
174 _TNL_BIT_MAT_BACK_INDEXES)
175
176
177 #define _TNL_BITS_TEX_ANY (_TNL_BIT_TEX0 | \
178 _TNL_BIT_TEX1 | \
179 _TNL_BIT_TEX2 | \
180 _TNL_BIT_TEX3 | \
181 _TNL_BIT_TEX4 | \
182 _TNL_BIT_TEX5 | \
183 _TNL_BIT_TEX6 | \
184 _TNL_BIT_TEX7)
185
186
187 #define _TNL_BITS_PROG_ANY (_TNL_BIT_POS | \
188 _TNL_BIT_WEIGHT | \
189 _TNL_BIT_NORMAL | \
190 _TNL_BIT_COLOR0 | \
191 _TNL_BIT_COLOR1 | \
192 _TNL_BIT_FOG | \
193 _TNL_BIT_SIX | \
194 _TNL_BIT_SEVEN | \
195 _TNL_BITS_TEX_ANY)
196
197
198
199 #define PRIM_BEGIN 0x10
200 #define PRIM_END 0x20
201 #define PRIM_WEAK 0x40
202 #define PRIM_MODE_MASK 0x0f
203
204 /*
205 */
206 struct tnl_prim {
207 GLuint mode;
208 GLuint start;
209 GLuint count;
210 };
211
212
213
214 struct tnl_eval1_map {
215 struct gl_1d_map *map;
216 GLuint sz;
217 };
218
219 struct tnl_eval2_map {
220 struct gl_2d_map *map;
221 GLuint sz;
222 };
223
224 struct tnl_eval {
225 GLuint new_state;
226 struct tnl_eval1_map map1[_TNL_ATTRIB_INDEX + 1];
227 struct tnl_eval2_map map2[_TNL_ATTRIB_INDEX + 1];
228 };
229
230
231 #define TNL_MAX_PRIM 16
232 #define TNL_MAX_COPIED_VERTS 3
233
234 struct tnl_copied_vtx {
235 GLfloat buffer[_TNL_ATTRIB_MAX * 4 * TNL_MAX_COPIED_VERTS];
236 GLuint nr;
237 };
238
239 #define VERT_BUFFER_SIZE 2048 /* 8kbytes */
240
241 typedef void (*attrfv_func)( const GLfloat * );
242
243 /* The assembly of vertices in immediate mode is separated from
244 * display list compilation. This allows a simpler immediate mode
245 * treatment and a display list compiler better suited to
246 * hardware-acceleration.
247 */
248 struct tnl_vtx {
249 GLfloat buffer[VERT_BUFFER_SIZE];
250 GLubyte attrsz[_TNL_ATTRIB_MAX];
251 GLuint vertex_size;
252 struct tnl_prim prim[TNL_MAX_PRIM];
253 GLuint prim_count;
254 GLfloat *vbptr; /* cursor, points into buffer */
255 GLfloat vertex[_TNL_ATTRIB_MAX*4]; /* current vertex */
256 GLfloat *attrptr[_TNL_ATTRIB_MAX]; /* points into vertex */
257 GLfloat *current[_TNL_ATTRIB_MAX]; /* points into ctx->Current, etc */
258 GLuint counter, initial_counter;
259 struct tnl_copied_vtx copied;
260 attrfv_func tabfv[_TNL_ATTRIB_MAX][4];
261 struct tnl_eval eval;
262 GLboolean *edgeflag_tmp;
263 GLboolean have_materials;
264 };
265
266
267
268
269 /* For display lists, this structure holds a run of vertices of the
270 * same format, and a strictly well-formed set of begin/end pairs,
271 * starting on the first vertex and ending at the last. Vertex
272 * copying on buffer breaks is precomputed according to these
273 * primitives, though there are situations where the copying will need
274 * correction at execute-time, perhaps by replaying the list as
275 * immediate mode commands.
276 *
277 * On executing this list, the 'current' values may be updated with
278 * the values of the final vertex, and often no fixup of the start of
279 * the vertex list is required.
280 *
281 * Eval and other commands that don't fit into these vertex lists are
282 * compiled using the fallback opcode mechanism provided by dlist.c.
283 */
284 struct tnl_vertex_list {
285 GLubyte attrsz[_TNL_ATTRIB_MAX];
286 GLuint vertex_size;
287
288 GLfloat *buffer;
289 GLuint count;
290 GLuint wrap_count; /* number of copied vertices at start */
291 GLboolean have_materials; /* bit of a hack - quick check for materials */
292 GLboolean dangling_attr_ref; /* current attr implicitly referenced
293 outside the list */
294
295 GLfloat *normal_lengths;
296 struct tnl_prim *prim;
297 GLuint prim_count;
298
299 struct tnl_vertex_store *vertex_store;
300 struct tnl_primitive_store *prim_store;
301 };
302
303 /* These buffers should be a reasonable size to support upload to
304 * hardware? Maybe drivers should stitch them back together, or
305 * specify a desired size?
306 */
307 #define SAVE_BUFFER_SIZE (16*1024)
308 #define SAVE_PRIM_SIZE 128
309
310 /* Storage to be shared among several vertex_lists.
311 */
312 struct tnl_vertex_store {
313 GLfloat buffer[SAVE_BUFFER_SIZE];
314 GLuint used;
315 GLuint refcount;
316 };
317
318 struct tnl_primitive_store {
319 struct tnl_prim buffer[SAVE_PRIM_SIZE];
320 GLuint used;
321 GLuint refcount;
322 };
323
324
325 struct tnl_save {
326 GLubyte attrsz[_TNL_ATTRIB_MAX];
327 GLuint vertex_size;
328
329 GLfloat *buffer;
330 GLuint count;
331 GLuint wrap_count;
332
333 struct tnl_prim *prim;
334 GLuint prim_count, prim_max;
335
336 struct tnl_vertex_store *vertex_store;
337 struct tnl_primitive_store *prim_store;
338
339 GLfloat *vbptr; /* cursor, points into buffer */
340 GLfloat vertex[_TNL_ATTRIB_MAX*4]; /* current values */
341 GLfloat *attrptr[_TNL_ATTRIB_MAX];
342 GLuint counter, initial_counter;
343 GLboolean dangling_attr_ref;
344 GLboolean have_materials;
345
346 GLuint opcode_vertex_list;
347
348 struct tnl_copied_vtx copied;
349
350 GLfloat *current[_TNL_ATTRIB_MAX]; /* points into ctx->ListState */
351 GLubyte *currentsz[_TNL_ATTRIB_MAX];
352
353 void (*tabfv[_TNL_ATTRIB_MAX][4])( const GLfloat * );
354 };
355
356
357
358
359
360
361
362 struct tnl_vertex_arrays
363 {
364 /* Conventional vertex attribute arrays */
365 GLvector4f Obj;
366 GLvector4f Normal;
367 GLvector4f Color;
368 GLvector4f SecondaryColor;
369 GLvector4f FogCoord;
370 GLvector4f TexCoord[MAX_TEXTURE_COORD_UNITS];
371 GLvector4f Index;
372
373 GLubyte *EdgeFlag;
374 GLuint *Elt;
375
376 /* These attributes don't alias with the conventional attributes.
377 * The GL_NV_vertex_program extension defines 16 extra sets of vertex
378 * arrays which have precedent over the conventional arrays when enabled.
379 */
380 GLvector4f Attribs[_TNL_ATTRIB_MAX];
381 };
382
383
384 /**
385 * Contains the current state of a running pipeline.
386 */
387 struct vertex_buffer
388 {
389 /* Constant over life of the vertex_buffer.
390 */
391 GLuint Size;
392
393 /* Constant over the pipeline.
394 */
395 GLuint Count; /* for everything except Elts */
396
397 /* Pointers to current data.
398 */
399 GLuint *Elts;
400 GLvector4f *ObjPtr; /* _TNL_BIT_POS */
401 GLvector4f *EyePtr; /* _TNL_BIT_POS */
402 GLvector4f *ClipPtr; /* _TNL_BIT_POS */
403 GLvector4f *NdcPtr; /* _TNL_BIT_POS */
404 GLubyte ClipOrMask; /* _TNL_BIT_POS */
405 GLubyte *ClipMask; /* _TNL_BIT_POS */
406 GLvector4f *NormalPtr; /* _TNL_BIT_NORMAL */
407 GLfloat *NormalLengthPtr; /* _TNL_BIT_NORMAL */
408 GLboolean *EdgeFlag; /* _TNL_BIT_EDGEFLAG */
409 GLvector4f *TexCoordPtr[MAX_TEXTURE_COORD_UNITS]; /* VERT_TEX_0..n */
410 GLvector4f *IndexPtr[2]; /* _TNL_BIT_INDEX */
411 GLvector4f *ColorPtr[2]; /* _TNL_BIT_COLOR0 */
412 GLvector4f *SecondaryColorPtr[2]; /* _TNL_BIT_COLOR1 */
413 GLvector4f *PointSizePtr; /* _TNL_BIT_POS */
414 GLvector4f *FogCoordPtr; /* _TNL_BIT_FOG */
415
416 struct tnl_prim *Primitive;
417 GLuint PrimitiveCount;
418
419 /* Inputs to the vertex program stage */
420 GLvector4f *AttribPtr[_TNL_ATTRIB_MAX]; /* GL_NV_vertex_program */
421
422 GLuint LastClipped;
423 /* Private data from _tnl_render_stage that has no business being
424 * in this struct.
425 */
426
427 };
428
429
430
431 /** Describes an individual operation on the pipeline.
432 */
433 struct tnl_pipeline_stage {
434 const char *name;
435 GLuint check_state; /* All state referenced in check() --
436 * When is the pipeline_stage struct
437 * itself invalidated? Must be
438 * constant.
439 */
440
441 /* Usually constant or set by the 'check' callback:
442 */
443 GLuint run_state; /* All state referenced in run() --
444 * When is the cached output of the
445 * stage invalidated?
446 */
447
448 GLboolean active; /* True if runnable in current state */
449 GLuint inputs; /* VERT_* inputs to the stage */
450 GLuint outputs; /* VERT_* outputs of the stage */
451
452 /* Set in _tnl_run_pipeline():
453 */
454 GLuint changed_inputs; /* Generated value -- inputs to the
455 * stage that have changed since last
456 * call to 'run'.
457 */
458
459 /* Private data for the pipeline stage:
460 */
461 void *privatePtr;
462
463 /* Free private data. May not be null.
464 */
465 void (*destroy)( struct tnl_pipeline_stage * );
466
467 /* Called from _tnl_validate_pipeline(). Must update all fields in
468 * the pipeline_stage struct for the current state.
469 */
470 void (*check)( GLcontext *ctx, struct tnl_pipeline_stage * );
471
472 /* Called from _tnl_run_pipeline(). The stage.changed_inputs value
473 * encodes all inputs to thee struct which have changed. If
474 * non-zero, recompute all affected outputs of the stage, otherwise
475 * execute any 'sideeffects' of the stage.
476 *
477 * Return value: GL_TRUE - keep going
478 * GL_FALSE - finished pipeline
479 */
480 GLboolean (*run)( GLcontext *ctx, struct tnl_pipeline_stage * );
481 };
482
483 /** Contains the array of all pipeline stages.
484 * The default values are defined at the end of t_pipeline.c */
485 struct tnl_pipeline {
486 GLuint build_state_trigger; /**< state changes which require build */
487 GLuint build_state_changes; /**< state changes since last build */
488 GLuint run_state_changes; /**< state changes since last run */
489 GLuint run_input_changes; /**< VERT_* changes since last run */
490 GLuint inputs; /**< VERT_* inputs to pipeline */
491 /** This array has to end with a NULL-pointer. */
492 struct tnl_pipeline_stage stages[MAX_PIPELINE_STAGES+1];
493 GLuint nr_stages;
494 };
495
496
497
498
499 typedef void (*points_func)( GLcontext *ctx, GLuint first, GLuint last );
500 typedef void (*line_func)( GLcontext *ctx, GLuint v1, GLuint v2 );
501 typedef void (*triangle_func)( GLcontext *ctx,
502 GLuint v1, GLuint v2, GLuint v3 );
503 typedef void (*quad_func)( GLcontext *ctx, GLuint v1, GLuint v2,
504 GLuint v3, GLuint v4 );
505 typedef void (*render_func)( GLcontext *ctx, GLuint start, GLuint count,
506 GLuint flags );
507 typedef void (*interp_func)( GLcontext *ctx,
508 GLfloat t, GLuint dst, GLuint out, GLuint in,
509 GLboolean force_boundary );
510 typedef void (*copy_pv_func)( GLcontext *ctx, GLuint dst, GLuint src );
511 typedef void (*setup_func)( GLcontext *ctx,
512 GLuint start, GLuint end,
513 GLuint new_inputs);
514
515
516 struct tnl_device_driver {
517 /***
518 *** TNL Pipeline
519 ***/
520
521 void (*RunPipeline)(GLcontext *ctx);
522 /* Replaces PipelineStart/PipelineFinish -- intended to allow
523 * drivers to wrap _tnl_run_pipeline() with code to validate state
524 * and grab/release hardware locks.
525 */
526
527 void (*NotifyMaterialChange)(GLcontext *ctx);
528 /* Alert tnl-aware drivers of changes to material.
529 */
530
531 GLboolean (*NotifyBegin)(GLcontext *ctx, GLenum p);
532 /* Allow drivers to hook in optimized begin/end engines.
533 * Return value: GL_TRUE - driver handled the begin
534 * GL_FALSE - driver didn't handle the begin
535 */
536
537 /***
538 *** Rendering -- These functions called only from t_vb_render.c
539 ***/
540 struct {
541 void (*Start)(GLcontext *ctx);
542 void (*Finish)(GLcontext *ctx);
543 /* Called before and after all rendering operations, including DrawPixels,
544 * ReadPixels, Bitmap, span functions, and CopyTexImage, etc commands.
545 * These are a suitable place for grabbing/releasing hardware locks.
546 */
547
548 void (*PrimitiveNotify)(GLcontext *ctx, GLenum mode);
549 /* Called between RenderStart() and RenderFinish() to indicate the
550 * type of primitive we're about to draw. Mode will be one of the
551 * modes accepted by glBegin().
552 */
553
554 interp_func Interp;
555 /* The interp function is called by the clipping routines when we need
556 * to generate an interpolated vertex. All pertinant vertex ancilliary
557 * data should be computed by interpolating between the 'in' and 'out'
558 * vertices.
559 */
560
561 copy_pv_func CopyPV;
562 /* The copy function is used to make a copy of a vertex. All pertinant
563 * vertex attributes should be copied.
564 */
565
566 void (*ClippedPolygon)( GLcontext *ctx, const GLuint *elts, GLuint n );
567 /* Render a polygon with <n> vertices whose indexes are in the <elts>
568 * array.
569 */
570
571 void (*ClippedLine)( GLcontext *ctx, GLuint v0, GLuint v1 );
572 /* Render a line between the two vertices given by indexes v0 and v1. */
573
574 points_func Points; /* must now respect vb->elts */
575 line_func Line;
576 triangle_func Triangle;
577 quad_func Quad;
578 /* These functions are called in order to render points, lines,
579 * triangles and quads. These are only called via the T&L module.
580 */
581
582 render_func *PrimTabVerts;
583 render_func *PrimTabElts;
584 /* Render whole unclipped primitives (points, lines, linestrips,
585 * lineloops, etc). The tables are indexed by the GL enum of the
586 * primitive to be rendered. RenderTabVerts is used for non-indexed
587 * arrays of vertices. RenderTabElts is used for indexed arrays of
588 * vertices.
589 */
590
591 void (*ResetLineStipple)( GLcontext *ctx );
592 /* Reset the hardware's line stipple counter.
593 */
594
595 setup_func BuildVertices;
596 /* This function is called whenever new vertices are required for
597 * rendering. The vertices in question are those n such that start
598 * <= n < end. The new_inputs parameter indicates those fields of
599 * the vertex which need to be updated, if only a partial repair of
600 * the vertex is required.
601 *
602 * This function is called only from _tnl_render_stage in tnl/t_render.c.
603 */
604
605
606 GLboolean (*Multipass)( GLcontext *ctx, GLuint passno );
607 /* Driver may request additional render passes by returning GL_TRUE
608 * when this function is called. This function will be called
609 * after the first pass, and passes will be made until the function
610 * returns GL_FALSE. If no function is registered, only one pass
611 * is made.
612 *
613 * This function will be first invoked with passno == 1.
614 */
615 } Render;
616 };
617
618
619 typedef struct {
620
621 /* Driver interface.
622 */
623 struct tnl_device_driver Driver;
624
625 /* Execute:
626 */
627 struct tnl_vtx vtx;
628
629 /* Compile:
630 */
631 struct tnl_save save;
632
633 /* Pipeline
634 */
635 struct tnl_pipeline pipeline;
636 struct vertex_buffer vb;
637
638 /* GLvectors for binding to vb:
639 */
640 struct tnl_vertex_arrays vtx_inputs;
641 struct tnl_vertex_arrays save_inputs;
642 struct tnl_vertex_arrays current;
643 struct tnl_vertex_arrays array_inputs;
644
645
646 /* Probably need a better configuration mechanism:
647 */
648 GLboolean NeedNdcCoords;
649 GLboolean LoopbackDListCassettes;
650 GLboolean CalcDListNormalLengths;
651 GLboolean IsolateMaterials;
652
653
654 GLvertexformat exec_vtxfmt;
655 GLvertexformat save_vtxfmt;
656
657 } TNLcontext;
658
659
660
661 #define TNL_CONTEXT(ctx) ((TNLcontext *)(ctx->swtnl_context))
662
663
664 #define TYPE_IDX(t) ((t) & 0xf)
665 #define MAX_TYPES TYPE_IDX(GL_DOUBLE)+1 /* 0xa + 1 */
666
667 extern void _tnl_MakeCurrent( GLcontext *ctx,
668 GLframebuffer *drawBuffer,
669 GLframebuffer *readBuffer );
670
671
672
673
674 #endif