~ubuntu-branches/ubuntu/gutsy/vnc4/gutsy

« back to all changes in this revision

Viewing changes to unix/xc/extras/Mesa/src/tnl/t_context.h

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2006-05-15 20:35:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515203517-l4lre1ku942mn26k
Tags: 4.1.1+X4.3.0-10
* Correction of critical security issue. Thanks to Martin Kogler
  <e9925248@student.tuwien.ac.at> that informed me about the issue,
  and provided the patch.
  This flaw was originally found by Steve Wiseman of intelliadmin.com.
* Applied patch from Javier Kohen <jkohen@users.sourceforge.net> that
  inform the user that only 8 first characters of the password will
  actually be used when typing more than 8 characters, closes:
  #355619.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/*
 
3
 * Mesa 3-D graphics library
 
4
 * Version:  3.5
 
5
 *
 
6
 * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
 
7
 *
 
8
 * Permission is hereby granted, free of charge, to any person obtaining a
 
9
 * copy of this software and associated documentation files (the "Software"),
 
10
 * to deal in the Software without restriction, including without limitation
 
11
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 
12
 * and/or sell copies of the Software, and to permit persons to whom the
 
13
 * Software is furnished to do so, subject to the following conditions:
 
14
 *
 
15
 * The above copyright notice and this permission notice shall be included
 
16
 * in all copies or substantial portions 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 MERCHANTABILITY,
 
20
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 
21
 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 
22
 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
23
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
24
 *
 
25
 * Author:
 
26
 *    Keith Whitwell <keithw@valinux.com>
 
27
 */
 
28
 
 
29
#ifndef _T_CONTEXT_H
 
30
#define _T_CONTEXT_H
 
31
 
 
32
#include "glheader.h"
 
33
#include "mtypes.h"
 
34
 
 
35
#include "math/m_matrix.h"
 
36
#include "math/m_vector.h"
 
37
#include "math/m_xform.h"
 
38
 
 
39
 
 
40
#define MAX_PIPELINE_STAGES     30
 
41
 
 
42
 
 
43
/* Numbers for sizing immediate structs.
 
44
 */
 
45
#define IMM_MAX_COPIED_VERTS  3
 
46
#define IMM_MAXDATA          (216 + IMM_MAX_COPIED_VERTS)
 
47
#define IMM_SIZE             (IMM_MAXDATA + MAX_CLIPPED_VERTICES)
 
48
 
 
49
 
 
50
/* Values for IM->BeginState
 
51
 */
 
52
#define VERT_BEGIN_0    0x1        /* glBegin (if initially inside beg/end) */
 
53
#define VERT_BEGIN_1    0x2        /* glBegin (if initially outside beg/end) */
 
54
#define VERT_ERROR_0    0x4        /* invalid_operation in initial state 0 */
 
55
#define VERT_ERROR_1    0x8        /* invalid_operation in initial state 1 */
 
56
 
 
57
 
 
58
/* Flags to be added to the primitive enum in VB->Primitive.
 
59
 */
 
60
#define PRIM_MODE_MASK  0xff    /* Extract the actual primitive */
 
61
#define PRIM_BEGIN      0x100   /* The prim starts here (not wrapped) */
 
62
#define PRIM_END        0x200   /* The prim ends in this VB (does not wrap) */
 
63
#define PRIM_PARITY     0x400   /* The prim wrapped on an odd number of verts */
 
64
#define PRIM_LAST       0x800   /* No more prims in the VB */
 
65
 
 
66
 
 
67
/* Flags that describe the inputs and outputs of pipeline stages, and
 
68
 * the contents of a vertex-cassette.
 
69
 *
 
70
 * 5 spare flags, rearrangement of eval flags can secure at least 3
 
71
 * more.
 
72
 */
 
73
#define VERT_OBJ             _NEW_ARRAY_VERTEX
 
74
#define VERT_RGBA            _NEW_ARRAY_COLOR
 
75
#define VERT_NORM            _NEW_ARRAY_NORMAL
 
76
#define VERT_INDEX           _NEW_ARRAY_INDEX
 
77
#define VERT_EDGE            _NEW_ARRAY_EDGEFLAG
 
78
#define VERT_SPEC_RGB        _NEW_ARRAY_SECONDARYCOLOR
 
79
#define VERT_FOG_COORD       _NEW_ARRAY_FOGCOORD
 
80
#define VERT_TEX0            _NEW_ARRAY_TEXCOORD_0
 
81
#define VERT_TEX1            _NEW_ARRAY_TEXCOORD_1
 
82
#define VERT_TEX2            _NEW_ARRAY_TEXCOORD_2
 
83
#define VERT_TEX3            _NEW_ARRAY_TEXCOORD_3
 
84
#define VERT_TEX4            _NEW_ARRAY_TEXCOORD_4
 
85
#define VERT_TEX5            _NEW_ARRAY_TEXCOORD_5
 
86
#define VERT_TEX6            _NEW_ARRAY_TEXCOORD_6
 
87
#define VERT_TEX7            _NEW_ARRAY_TEXCOORD_7
 
88
#define VERT_EVAL_C1         0x8000     /* imm only */
 
89
#define VERT_EVAL_C2         0x10000    /* imm only */
 
90
#define VERT_EVAL_P1         0x20000    /* imm only */
 
91
#define VERT_EVAL_P2         0x40000    /* imm only */
 
92
#define VERT_OBJ_3           0x80000    /* imm only */
 
93
#define VERT_OBJ_4           0x100000   /* imm only */
 
94
#define VERT_MATERIAL        0x200000   /* imm only, but tested in vb code */
 
95
#define VERT_ELT             0x400000   /* imm only */
 
96
#define VERT_BEGIN           0x800000   /* imm only, but tested in vb code */
 
97
#define VERT_END             0x1000000  /* imm only, but tested in vb code */
 
98
#define VERT_END_VB          0x2000000  /* imm only, but tested in vb code */
 
99
#define VERT_POINT_SIZE      0x4000000  /* vb only, could reuse a bit */
 
100
#define VERT_EYE             VERT_BEGIN /* vb only, reuse imm bit */
 
101
#define VERT_CLIP            VERT_END   /* vb only, reuse imm bit*/
 
102
 
 
103
 
 
104
/* Flags for IM->TexCoordSize.  Enough flags for 16 units.
 
105
 */
 
106
#define TEX_0_SIZE_3          (GLuint) 0x1
 
107
#define TEX_0_SIZE_4          (GLuint) 0x1001
 
108
#define TEX_SIZE_3(unit)      (TEX_0_SIZE_3<<unit)
 
109
#define TEX_SIZE_4(unit)      (TEX_0_SIZE_4<<unit)
 
110
 
 
111
 
 
112
/* Shorthands.
 
113
 */
 
114
#define VERT_EVAL_ANY      (VERT_EVAL_C1|VERT_EVAL_P1|  \
 
115
                            VERT_EVAL_C2|VERT_EVAL_P2)
 
116
 
 
117
#define VERT_OBJ_23       (VERT_OBJ_3|VERT_OBJ)
 
118
#define VERT_OBJ_234      (VERT_OBJ_4|VERT_OBJ_23)
 
119
 
 
120
#define VERT_TEX0_SHIFT 11
 
121
 
 
122
#define VERT_TEX(i)        (VERT_TEX0 << i)
 
123
 
 
124
#define VERT_TEX_ANY       (VERT_TEX0 |         \
 
125
                            VERT_TEX1 |         \
 
126
                            VERT_TEX2 |         \
 
127
                            VERT_TEX3 |         \
 
128
                            VERT_TEX4 |         \
 
129
                            VERT_TEX5 |         \
 
130
                            VERT_TEX6 |         \
 
131
                            VERT_TEX7)
 
132
 
 
133
#define VERT_FIXUP        (VERT_TEX_ANY |       \
 
134
                           VERT_RGBA |          \
 
135
                           VERT_SPEC_RGB |      \
 
136
                           VERT_FOG_COORD |     \
 
137
                           VERT_INDEX |         \
 
138
                           VERT_EDGE |          \
 
139
                           VERT_NORM)
 
140
 
 
141
#define VERT_CURRENT_DATA  (VERT_FIXUP |        \
 
142
                            VERT_MATERIAL)
 
143
 
 
144
#define VERT_DATA          (VERT_TEX_ANY |      \
 
145
                            VERT_RGBA |         \
 
146
                            VERT_SPEC_RGB |     \
 
147
                            VERT_FOG_COORD |    \
 
148
                            VERT_INDEX |        \
 
149
                            VERT_EDGE |         \
 
150
                            VERT_NORM |         \
 
151
                            VERT_OBJ |  \
 
152
                            VERT_MATERIAL |     \
 
153
                            VERT_ELT |          \
 
154
                            VERT_EVAL_ANY)
 
155
 
 
156
 
 
157
/* KW: Represents everything that can take place between a begin and
 
158
 * end, and can represent multiple begin/end pairs.  Can be used to
 
159
 * losslessly encode this information in display lists.
 
160
 */
 
161
struct immediate
 
162
{
 
163
   struct __GLcontextRec *backref;
 
164
   GLuint id, ref_count;
 
165
 
 
166
   /* This must be saved when immediates are shared in display lists.
 
167
    */
 
168
   GLuint CopyStart, Start, Count;
 
169
   GLuint LastData;             /* count or count+1 */
 
170
   GLuint AndFlag, OrFlag;
 
171
   GLuint TexSize;              /* keep track of texcoord sizes */
 
172
   GLuint BeginState, SavedBeginState;
 
173
   GLuint LastPrimitive;
 
174
 
 
175
   GLuint ArrayEltFlags;        /* precalc'ed for glArrayElt */
 
176
   GLuint ArrayEltIncr;
 
177
   GLuint ArrayEltFlush;
 
178
 
 
179
#define FLUSH_ELT_EAGER 0x1
 
180
#define FLUSH_ELT_LAZY 0x2
 
181
   GLuint FlushElt;
 
182
 
 
183
   GLuint MaxTextureUnits;      /* precalc'ed for glMultiTexCoordARB */
 
184
 
 
185
   /* Temporary values created when vertices are copied into the
 
186
    * first 3 slots of the struct:
 
187
    */
 
188
   GLuint CopyOrFlag;
 
189
   GLuint CopyAndFlag;
 
190
   GLuint CopyTexSize;
 
191
   GLuint Evaluated;
 
192
 
 
193
 
 
194
   /* allocate storage for these on demand:
 
195
    */
 
196
   struct gl_material (*Material)[2];
 
197
   GLuint *MaterialMask;
 
198
   GLuint LastMaterial;
 
199
   GLuint MaterialOrMask;
 
200
   GLuint MaterialAndMask;
 
201
 
 
202
   GLfloat (*TexCoord[MAX_TEXTURE_UNITS])[4];
 
203
 
 
204
   GLuint  Primitive[IMM_SIZE];     /* BEGIN/END */
 
205
   GLuint  PrimitiveLength[IMM_SIZE]; /* BEGIN/END */
 
206
   GLuint  Flag[IMM_SIZE];          /* VERT_* flags */
 
207
   GLfloat Color[IMM_SIZE][4];
 
208
   GLfloat Obj[IMM_SIZE][4];
 
209
   GLfloat Normal[IMM_SIZE][3];
 
210
   GLfloat *NormalLengthPtr;
 
211
   GLfloat TexCoord0[IMM_SIZE][4];  /* just VERT_TEX0 */
 
212
   GLuint  Elt[IMM_SIZE];
 
213
   GLubyte EdgeFlag[IMM_SIZE];
 
214
   GLuint  Index[IMM_SIZE];
 
215
   GLfloat SecondaryColor[IMM_SIZE][4];
 
216
   GLfloat FogCoord[IMM_SIZE];
 
217
};
 
218
 
 
219
 
 
220
struct vertex_arrays
 
221
{
 
222
   GLvector4f  Obj;
 
223
   GLvector3f  Normal;
 
224
   struct gl_client_array Color;
 
225
   struct gl_client_array SecondaryColor;
 
226
   GLvector1ui Index;
 
227
   GLvector1ub EdgeFlag;
 
228
   GLvector4f  TexCoord[MAX_TEXTURE_UNITS];
 
229
   GLvector1ui Elt;
 
230
   GLvector1f  FogCoord;
 
231
};
 
232
 
 
233
 
 
234
typedef struct gl_material GLmaterial;
 
235
 
 
236
/* Contains the current state of a running pipeline.
 
237
 */
 
238
typedef struct vertex_buffer
 
239
{
 
240
   /* Constant over life of the vertex_buffer.
 
241
    */
 
242
   GLuint Size;
 
243
 
 
244
   /* Constant over the pipeline.
 
245
    */
 
246
   GLuint     Count;                            /* for everything except Elts */
 
247
   GLuint     FirstClipped;                     /* temp verts for clipping */
 
248
   GLuint     FirstPrimitive;                   /* usually zero */
 
249
 
 
250
   /* Pointers to current data.
 
251
    */
 
252
   GLuint      *Elts;                           /* VERT_ELT */
 
253
   GLvector4f  *ObjPtr;                         /* VERT_OBJ */
 
254
   GLvector4f  *EyePtr;                         /* VERT_EYE */
 
255
   GLvector4f  *ClipPtr;                        /* VERT_CLIP */
 
256
   GLvector4f  *ProjectedClipPtr;               /* VERT_CLIP (2) */
 
257
   GLubyte     ClipOrMask;                      /* VERT_CLIP (3) */
 
258
   GLubyte     *ClipMask;                       /* VERT_CLIP (4) */
 
259
   GLvector3f  *NormalPtr;                      /* VERT_NORM */
 
260
   GLfloat     *NormalLengthPtr;                /* VERT_NORM */
 
261
   GLboolean   *EdgeFlag;                       /* VERT_EDGE */
 
262
   GLvector4f  *TexCoordPtr[MAX_TEXTURE_UNITS]; /* VERT_TEX_0..n */
 
263
   GLvector1ui *IndexPtr[2];                    /* VERT_INDEX */
 
264
   struct gl_client_array *ColorPtr[2];                 /* VERT_RGBA */
 
265
   struct gl_client_array *SecondaryColorPtr[2];         /* VERT_SPEC_RGB */
 
266
   GLvector1f  *FogCoordPtr;                    /* VERT_FOG_COORD */
 
267
   GLvector1f  *PointSizePtr;                   /* VERT_POINT_SIZE */
 
268
   GLmaterial (*Material)[2];                   /* VERT_MATERIAL, optional */
 
269
   GLuint      *MaterialMask;                   /* VERT_MATERIAL, optional */
 
270
   GLuint      *Flag;                           /* VERT_* flags, optional */
 
271
   GLuint      *Primitive;                      /* GL_(mode)|PRIM_* flags */
 
272
   GLuint      *PrimitiveLength;                /* integers */
 
273
 
 
274
 
 
275
   GLuint importable_data;
 
276
   void *import_source;
 
277
   void (*import_data)( GLcontext *ctx, GLuint flags, GLuint vecflags );
 
278
   /* Callback to the provider of the untransformed input for the
 
279
    * render stage (or other stages) to call if they need to write into
 
280
    * write-protected arrays, or fixup the stride on input arrays.
 
281
    *
 
282
    * This is currently only necessary for client arrays that make it
 
283
    * as far down the pipeline as the render stage.
 
284
    */
 
285
 
 
286
   GLuint LastClipped;
 
287
   /* Private data from _tnl_render_stage that has no business being
 
288
    * in this struct.
 
289
    */
 
290
 
 
291
} TNLvertexbuffer;
 
292
 
 
293
 
 
294
 
 
295
/* Describes an individual operation on the pipeline.
 
296
 */
 
297
struct gl_pipeline_stage {
 
298
   const char *name;
 
299
   GLuint check_state;          /* All state referenced in check() --
 
300
                                 * When is the pipeline_stage struct
 
301
                                 * itself invalidated?  Must be
 
302
                                 * constant.
 
303
                                 */
 
304
 
 
305
   /* Usually constant or set by the 'check' callback:
 
306
    */
 
307
   GLuint run_state;            /* All state referenced in run() --
 
308
                                 * When is the cached output of the
 
309
                                 * stage invalidated?
 
310
                                 */
 
311
 
 
312
   GLboolean active;            /* True if runnable in current state */
 
313
   GLuint inputs;               /* VERT_* inputs to the stage */
 
314
   GLuint outputs;              /* VERT_* outputs of the stage */
 
315
 
 
316
   /* Set in _tnl_run_pipeline():
 
317
    */
 
318
   GLuint changed_inputs;       /* Generated value -- inputs to the
 
319
                                 * stage that have changed since last
 
320
                                 * call to 'run'.
 
321
                                 */
 
322
 
 
323
   /* Private data for the pipeline stage:
 
324
    */
 
325
   void *privatePtr;
 
326
 
 
327
   /* Free private data.  May not be null.
 
328
    */
 
329
   void (*destroy)( struct gl_pipeline_stage * );
 
330
 
 
331
   /* Called from _tnl_validate_pipeline().  Must update all fields in
 
332
    * the pipeline_stage struct for the current state.
 
333
    */
 
334
   void (*check)( GLcontext *ctx, struct gl_pipeline_stage * );
 
335
 
 
336
   /* Called from _tnl_run_pipeline().  The stage.changed_inputs value
 
337
    * encodes all inputs to thee struct which have changed.  If
 
338
    * non-zero, recompute all affected outputs of the stage, otherwise
 
339
    * execute any 'sideeffects' of the stage.
 
340
    *
 
341
    * Return value: GL_TRUE - keep going
 
342
    *               GL_FALSE - finished pipeline
 
343
    */
 
344
   GLboolean (*run)( GLcontext *ctx, struct gl_pipeline_stage * );
 
345
};
 
346
 
 
347
 
 
348
struct gl_pipeline {
 
349
   GLuint build_state_trigger;    /* state changes which require build */
 
350
   GLuint build_state_changes;    /* state changes since last build */
 
351
   GLuint run_state_changes;      /* state changes since last run */
 
352
   GLuint run_input_changes;      /* VERT_* changes since last run */
 
353
   GLuint inputs;                 /* VERT_* inputs to pipeline */
 
354
   struct gl_pipeline_stage stages[MAX_PIPELINE_STAGES+1];
 
355
   GLuint nr_stages;
 
356
};
 
357
 
 
358
 
 
359
struct tnl_eval_store {
 
360
   GLuint EvalMap1Flags;
 
361
   GLuint EvalMap2Flags;
 
362
   GLuint EvalNewState;
 
363
   struct immediate *im;        /* used for temporary data */
 
364
};
 
365
 
 
366
 
 
367
typedef void (*points_func)( GLcontext *ctx, GLuint first, GLuint last );
 
368
typedef void (*line_func)( GLcontext *ctx, GLuint v1, GLuint v2 );
 
369
typedef void (*triangle_func)( GLcontext *ctx,
 
370
                               GLuint v1, GLuint v2, GLuint v3 );
 
371
typedef void (*quad_func)( GLcontext *ctx, GLuint v1, GLuint v2,
 
372
                           GLuint v3, GLuint v4 );
 
373
typedef void (*render_func)( GLcontext *ctx, GLuint start, GLuint count,
 
374
                             GLuint flags );
 
375
typedef void (*interp_func)( GLcontext *ctx,
 
376
                             GLfloat t, GLuint dst, GLuint out, GLuint in,
 
377
                             GLboolean force_boundary );
 
378
typedef void (*copy_pv_func)( GLcontext *ctx, GLuint dst, GLuint src );
 
379
typedef void (*setup_func)( GLcontext *ctx,
 
380
                            GLuint start, GLuint end,
 
381
                            GLuint new_inputs);
 
382
 
 
383
 
 
384
struct tnl_device_driver {
 
385
   /***
 
386
    *** TNL Pipeline
 
387
    ***/
 
388
 
 
389
   void (*RunPipeline)(GLcontext *ctx);
 
390
   /* Replaces PipelineStart/PipelineFinish -- intended to allow
 
391
    * drivers to wrap _tnl_run_pipeline() with code to validate state
 
392
    * and grab/release hardware locks.  
 
393
    */
 
394
 
 
395
   void (*NotifyMaterialChange)(GLcontext *ctx);
 
396
   /* Alert tnl-aware drivers of changes to material.
 
397
    */
 
398
 
 
399
   GLboolean (*NotifyBegin)(GLcontext *ctx, GLenum p);
 
400
   /* Allow drivers to hook in optimized begin/end engines.
 
401
    * Return value:  GL_TRUE - driver handled the begin
 
402
    *                GL_FALSE - driver didn't handle the begin
 
403
    */
 
404
 
 
405
   /***
 
406
    *** Rendering -- These functions called only from t_vb_render.c
 
407
    ***/
 
408
   struct {
 
409
      void (*Start)(GLcontext *ctx);
 
410
      void (*Finish)(GLcontext *ctx);
 
411
      /* Called before and after all rendering operations, including DrawPixels,
 
412
       * ReadPixels, Bitmap, span functions, and CopyTexImage, etc commands.
 
413
       * These are a suitable place for grabbing/releasing hardware locks.
 
414
       */
 
415
 
 
416
      void (*PrimitiveNotify)(GLcontext *ctx, GLenum mode);
 
417
      /* Called between RenderStart() and RenderFinish() to indicate the
 
418
       * type of primitive we're about to draw.  Mode will be one of the
 
419
       * modes accepted by glBegin().
 
420
       */
 
421
 
 
422
      interp_func Interp;
 
423
      /* The interp function is called by the clipping routines when we need
 
424
       * to generate an interpolated vertex.  All pertinant vertex ancilliary
 
425
       * data should be computed by interpolating between the 'in' and 'out'
 
426
       * vertices.
 
427
       */
 
428
 
 
429
      copy_pv_func CopyPV;
 
430
      /* The copy function is used to make a copy of a vertex.  All pertinant
 
431
       * vertex attributes should be copied.
 
432
       */
 
433
 
 
434
      void (*ClippedPolygon)( GLcontext *ctx, const GLuint *elts, GLuint n );
 
435
      /* Render a polygon with <n> vertices whose indexes are in the <elts>
 
436
       * array.
 
437
       */
 
438
 
 
439
      void (*ClippedLine)( GLcontext *ctx, GLuint v0, GLuint v1 );
 
440
      /* Render a line between the two vertices given by indexes v0 and v1. */
 
441
 
 
442
      points_func           Points; /* must now respect vb->elts */
 
443
      line_func             Line;
 
444
      triangle_func         Triangle;
 
445
      quad_func             Quad;
 
446
      /* These functions are called in order to render points, lines,
 
447
       * triangles and quads.  These are only called via the T&L module.
 
448
       */
 
449
 
 
450
      render_func          *PrimTabVerts;
 
451
      render_func          *PrimTabElts;
 
452
      /* Render whole unclipped primitives (points, lines, linestrips,
 
453
       * lineloops, etc).  The tables are indexed by the GL enum of the
 
454
       * primitive to be rendered.  RenderTabVerts is used for non-indexed
 
455
       * arrays of vertices.  RenderTabElts is used for indexed arrays of
 
456
       * vertices.
 
457
       */
 
458
 
 
459
      void (*ResetLineStipple)( GLcontext *ctx );
 
460
      /* Reset the hardware's line stipple counter.
 
461
       */
 
462
 
 
463
      setup_func BuildVertices;
 
464
      /* This function is called whenever new vertices are required for
 
465
       * rendering.  The vertices in question are those n such that start
 
466
       * <= n < end.  The new_inputs parameter indicates those fields of
 
467
       * the vertex which need to be updated, if only a partial repair of
 
468
       * the vertex is required.
 
469
       *
 
470
       * This function is called only from _tnl_render_stage in tnl/t_render.c.
 
471
       */
 
472
      
 
473
 
 
474
      GLboolean (*Multipass)( GLcontext *ctx, GLuint passno );
 
475
      /* Driver may request additional render passes by returning GL_TRUE
 
476
       * when this function is called.  This function will be called
 
477
       * after the first pass, and passes will be made until the function
 
478
       * returns GL_FALSE.  If no function is registered, only one pass
 
479
       * is made.
 
480
       *
 
481
       * This function will be first invoked with passno == 1.
 
482
       */
 
483
   } Render;
 
484
};
 
485
   
 
486
 
 
487
typedef struct {
 
488
 
 
489
   /* Driver interface.
 
490
    */
 
491
   struct tnl_device_driver Driver;
 
492
 
 
493
   /* Track whether the module is active.
 
494
    */
 
495
   GLboolean bound_exec;
 
496
 
 
497
   /* Display list extensions
 
498
    */
 
499
   GLuint opcode_vertex_cassette;
 
500
 
 
501
   /* Pipeline
 
502
    */
 
503
   struct gl_pipeline pipeline;
 
504
   struct vertex_buffer vb;
 
505
 
 
506
   /* GLvectors for binding to vb:
 
507
    */
 
508
   struct vertex_arrays imm_inputs;
 
509
   struct vertex_arrays array_inputs;
 
510
   GLuint *tmp_primitive;
 
511
   GLuint *tmp_primitive_length;
 
512
 
 
513
   /* Set when executing an internally generated begin/end object.  If
 
514
    * such an object is encountered in a display list, it will be
 
515
    * replayed only if the list is outside any existing begin/end
 
516
    * objects.  
 
517
    */
 
518
   GLboolean ReplayHardBeginEnd;
 
519
 
 
520
   /* Note which vertices need copying over succesive immediates.
 
521
    * Will add save versions to precompute vertex copying where
 
522
    * possible.
 
523
    */
 
524
   struct immediate *ExecCopySource;
 
525
   GLuint ExecCopyCount;
 
526
   GLuint ExecCopyElts[IMM_MAX_COPIED_VERTS];
 
527
   GLuint ExecCopyTexSize;
 
528
   GLuint ExecParity;
 
529
 
 
530
   GLuint DlistPrimitive;
 
531
   GLuint DlistPrimitiveLength;
 
532
   GLuint DlistLastPrimitive;
 
533
 
 
534
   /* Cache a single free immediate (refcount == 0)
 
535
    */
 
536
   struct immediate *freed_immediate;   
 
537
 
 
538
   /* Probably need a better configuration mechanism:
 
539
    */
 
540
   GLboolean NeedProjCoords;
 
541
   GLboolean LoopbackDListCassettes;
 
542
   GLboolean CalcDListNormalLengths;
 
543
   GLboolean IsolateMaterials;
 
544
 
 
545
   /* Derived state and storage for _tnl_eval_vb:
 
546
    */
 
547
   struct tnl_eval_store eval;
 
548
 
 
549
   /* Functions to be plugged into dispatch when tnl is active.
 
550
    */
 
551
   GLvertexformat vtxfmt;
 
552
   GLvertexformat save_vtxfmt;
 
553
 
 
554
} TNLcontext;
 
555
 
 
556
 
 
557
 
 
558
#define TNL_CONTEXT(ctx) ((TNLcontext *)(ctx->swtnl_context))
 
559
#define TNL_CURRENT_IM(ctx) ((struct immediate *)(ctx->swtnl_im))
 
560
 
 
561
 
 
562
#define TYPE_IDX(t) ((t) & 0xf)
 
563
#define MAX_TYPES TYPE_IDX(GL_DOUBLE)+1      /* 0xa + 1 */
 
564
 
 
565
extern void _tnl_MakeCurrent( GLcontext *ctx,
 
566
                              GLframebuffer *drawBuffer,
 
567
                              GLframebuffer *readBuffer );
 
568
 
 
569
 
 
570
/*
 
571
 * Macros for fetching current input buffer.
 
572
 */
 
573
#ifdef THREADS
 
574
#define GET_IMMEDIATE  struct immediate *IM = TNL_CURRENT_IM(((GLcontext *) (_glapi_Context ? _glapi_Context : _glapi_get_context())))
 
575
#define SET_IMMEDIATE(ctx, im)  ctx->swtnl_im = (void *)im
 
576
#else
 
577
extern struct immediate *_tnl_CurrentInput;
 
578
#define GET_IMMEDIATE struct immediate *IM = _tnl_CurrentInput
 
579
#define SET_IMMEDIATE(ctx, im)                  \
 
580
do {                                            \
 
581
   ctx->swtnl_im = (void *)im;                  \
 
582
   _tnl_CurrentInput = im;                      \
 
583
} while (0)
 
584
#endif
 
585
 
 
586
 
 
587
#endif