~ubuntu-branches/ubuntu/quantal/mesa-glw/quantal

« back to all changes in this revision

Viewing changes to src/mesa/drivers/glide/fxvb.c

  • Committer: Bazaar Package Importer
  • Author(s): Morten Kjeldgaard
  • Date: 2008-05-06 16:19:15 UTC
  • Revision ID: james.westby@ubuntu.com-20080506161915-uynz7nftmfixu6bq
Tags: upstream-7.0.3
ImportĀ upstreamĀ versionĀ 7.0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
 
21
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 
22
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
 
23
 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
24
 */
 
25
 
 
26
/* Authors:
 
27
 *    Keith Whitwell <keith@tungstengraphics.com>
 
28
 *    Daniel Borca <dborca@users.sourceforge.net>
 
29
 */
 
30
 
 
31
#ifdef HAVE_CONFIG_H
 
32
#include "conf.h"
 
33
#endif
 
34
 
 
35
#ifdef FX
 
36
 
 
37
#include "glheader.h"
 
38
#include "mtypes.h"
 
39
#include "imports.h"
 
40
#include "macros.h"
 
41
#include "colormac.h"
 
42
 
 
43
#include "math/m_translate.h"
 
44
#include "swrast_setup/swrast_setup.h"
 
45
 
 
46
#include "tnl/tnl.h"
 
47
#include "tnl/t_context.h"
 
48
 
 
49
#include "fxdrv.h"
 
50
 
 
51
 
 
52
static void copy_pv( GLcontext *ctx, GLuint edst, GLuint esrc )
 
53
{
 
54
   fxMesaContext fxMesa = FX_CONTEXT( ctx );
 
55
   GrVertex *dst = fxMesa->verts + edst;
 
56
   GrVertex *src = fxMesa->verts + esrc;
 
57
 
 
58
#if FX_PACKEDCOLOR
 
59
   *(GLuint *)&dst->pargb = *(GLuint *)&src->pargb;
 
60
#else  /* !FX_PACKEDCOLOR */
 
61
   COPY_FLOAT(dst->r, src->r);
 
62
   COPY_FLOAT(dst->g, src->g);
 
63
   COPY_FLOAT(dst->b, src->b);
 
64
   COPY_FLOAT(dst->a, src->a);
 
65
#endif /* !FX_PACKEDCOLOR */
 
66
}
 
67
 
 
68
static void copy_pv2( GLcontext *ctx, GLuint edst, GLuint esrc )
 
69
{
 
70
   fxMesaContext fxMesa = FX_CONTEXT( ctx );
 
71
   GrVertex *dst = fxMesa->verts + edst;
 
72
   GrVertex *src = fxMesa->verts + esrc;
 
73
 
 
74
#if FX_PACKEDCOLOR
 
75
   *(GLuint *)&dst->pargb = *(GLuint *)&src->pargb;
 
76
   *(GLuint *)&dst->pspec = *(GLuint *)&src->pspec;
 
77
#else  /* !FX_PACKEDCOLOR */
 
78
   COPY_FLOAT(dst->r, src->r);
 
79
   COPY_FLOAT(dst->g, src->g);
 
80
   COPY_FLOAT(dst->b, src->b);
 
81
   COPY_FLOAT(dst->a, src->a);
 
82
   COPY_FLOAT(dst->r1, src->r1);
 
83
   COPY_FLOAT(dst->g1, src->g1);
 
84
   COPY_FLOAT(dst->b1, src->b1);
 
85
#endif /* !FX_PACKEDCOLOR */
 
86
}
 
87
 
 
88
static struct {
 
89
   void               (*emit) (GLcontext *ctx, GLuint start, GLuint end, void *dest);
 
90
   tnl_copy_pv_func     copy_pv;
 
91
   tnl_interp_func      interp;
 
92
   GLboolean          (*check_tex_sizes) (GLcontext *ctx);
 
93
   GLuint               vertex_format;
 
94
} setup_tab[MAX_SETUP];
 
95
 
 
96
 
 
97
#define GET_COLOR(ptr, idx) ((ptr)->data[idx])
 
98
 
 
99
 
 
100
static void interp_extras( GLcontext *ctx,
 
101
                           GLfloat t,
 
102
                           GLuint dst, GLuint out, GLuint in,
 
103
                           GLboolean force_boundary )
 
104
{
 
105
   struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
 
106
 
 
107
   if (VB->ColorPtr[1]) {
 
108
      /* If stride is zero, ColorPtr[1] is constant across the VB, so
 
109
       * there is no point interpolating between two values as they will
 
110
       * be identical.  This case is handled in t_dd_tritmp.h
 
111
       */
 
112
      if (VB->ColorPtr[1]->stride) {
 
113
         assert(VB->ColorPtr[1]->stride == 4 * sizeof(GLfloat));
 
114
         INTERP_4F( t,
 
115
                    GET_COLOR(VB->ColorPtr[1], dst),
 
116
                    GET_COLOR(VB->ColorPtr[1], out),
 
117
                    GET_COLOR(VB->ColorPtr[1], in) );
 
118
      }
 
119
 
 
120
      if (VB->SecondaryColorPtr[1]) {
 
121
         INTERP_3F( t,
 
122
                    GET_COLOR(VB->SecondaryColorPtr[1], dst),
 
123
                    GET_COLOR(VB->SecondaryColorPtr[1], out),
 
124
                    GET_COLOR(VB->SecondaryColorPtr[1], in) );
 
125
      }
 
126
   }
 
127
 
 
128
   if (VB->EdgeFlag) {
 
129
      VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary;
 
130
   }
 
131
 
 
132
   setup_tab[FX_CONTEXT(ctx)->SetupIndex].interp(ctx, t, dst, out, in,
 
133
                                                   force_boundary);
 
134
}
 
135
 
 
136
static void copy_pv_extras( GLcontext *ctx, GLuint dst, GLuint src )
 
137
{
 
138
   struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
 
139
 
 
140
   if (VB->ColorPtr[1]) {
 
141
         COPY_4FV( GET_COLOR(VB->ColorPtr[1], dst),
 
142
                   GET_COLOR(VB->ColorPtr[1], src) );
 
143
 
 
144
         if (VB->SecondaryColorPtr[1]) {
 
145
            COPY_3FV( GET_COLOR(VB->SecondaryColorPtr[1], dst),
 
146
                      GET_COLOR(VB->SecondaryColorPtr[1], src) );
 
147
         }
 
148
   }
 
149
 
 
150
   setup_tab[FX_CONTEXT(ctx)->SetupIndex].copy_pv(ctx, dst, src);
 
151
}
 
152
 
 
153
 
 
154
#define IND (SETUP_XYZW|SETUP_RGBA)
 
155
#define TAG(x) x##_wg
 
156
#include "fxvbtmp.h"
 
157
 
 
158
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0)
 
159
#define TAG(x) x##_wgt0
 
160
#include "fxvbtmp.h"
 
161
 
 
162
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1)
 
163
#define TAG(x) x##_wgt0t1
 
164
#include "fxvbtmp.h"
 
165
 
 
166
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX)
 
167
#define TAG(x) x##_wgpt0
 
168
#include "fxvbtmp.h"
 
169
 
 
170
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\
 
171
             SETUP_PTEX)
 
172
#define TAG(x) x##_wgpt0t1
 
173
#include "fxvbtmp.h"
 
174
 
 
175
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_PSIZ)
 
176
#define TAG(x) x##_wga
 
177
#include "fxvbtmp.h"
 
178
 
 
179
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ)
 
180
#define TAG(x) x##_wgt0a
 
181
#include "fxvbtmp.h"
 
182
 
 
183
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ)
 
184
#define TAG(x) x##_wgt0t1a
 
185
#include "fxvbtmp.h"
 
186
 
 
187
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ)
 
188
#define TAG(x) x##_wgpt0a
 
189
#include "fxvbtmp.h"
 
190
 
 
191
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\
 
192
             SETUP_PTEX|SETUP_PSIZ)
 
193
#define TAG(x) x##_wgpt0t1a
 
194
#include "fxvbtmp.h"
 
195
 
 
196
 
 
197
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC)
 
198
#define TAG(x) x##_2wg
 
199
#include "fxvbtmp.h"
 
200
 
 
201
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0)
 
202
#define TAG(x) x##_2wgt0
 
203
#include "fxvbtmp.h"
 
204
 
 
205
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1)
 
206
#define TAG(x) x##_2wgt0t1
 
207
#include "fxvbtmp.h"
 
208
 
 
209
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX)
 
210
#define TAG(x) x##_2wgpt0
 
211
#include "fxvbtmp.h"
 
212
 
 
213
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|\
 
214
             SETUP_PTEX)
 
215
#define TAG(x) x##_2wgpt0t1
 
216
#include "fxvbtmp.h"
 
217
 
 
218
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ)
 
219
#define TAG(x) x##_2wga
 
220
#include "fxvbtmp.h"
 
221
 
 
222
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ)
 
223
#define TAG(x) x##_2wgt0a
 
224
#include "fxvbtmp.h"
 
225
 
 
226
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ)
 
227
#define TAG(x) x##_2wgt0t1a
 
228
#include "fxvbtmp.h"
 
229
 
 
230
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ)
 
231
#define TAG(x) x##_2wgpt0a
 
232
#include "fxvbtmp.h"
 
233
 
 
234
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|\
 
235
             SETUP_PTEX|SETUP_PSIZ)
 
236
#define TAG(x) x##_2wgpt0t1a
 
237
#include "fxvbtmp.h"
 
238
 
 
239
/* fog { */
 
240
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_FOGC)
 
241
#define TAG(x) x##_wgf
 
242
#include "fxvbtmp.h"
 
243
 
 
244
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_FOGC)
 
245
#define TAG(x) x##_wgt0f
 
246
#include "fxvbtmp.h"
 
247
 
 
248
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|SETUP_FOGC)
 
249
#define TAG(x) x##_wgt0t1f
 
250
#include "fxvbtmp.h"
 
251
 
 
252
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX|SETUP_FOGC)
 
253
#define TAG(x) x##_wgpt0f
 
254
#include "fxvbtmp.h"
 
255
 
 
256
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\
 
257
             SETUP_PTEX|SETUP_FOGC)
 
258
#define TAG(x) x##_wgpt0t1f
 
259
#include "fxvbtmp.h"
 
260
 
 
261
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_PSIZ|SETUP_FOGC)
 
262
#define TAG(x) x##_wgaf
 
263
#include "fxvbtmp.h"
 
264
 
 
265
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC)
 
266
#define TAG(x) x##_wgt0af
 
267
#include "fxvbtmp.h"
 
268
 
 
269
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ|SETUP_FOGC)
 
270
#define TAG(x) x##_wgt0t1af
 
271
#include "fxvbtmp.h"
 
272
 
 
273
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
 
274
#define TAG(x) x##_wgpt0af
 
275
#include "fxvbtmp.h"
 
276
 
 
277
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\
 
278
             SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
 
279
#define TAG(x) x##_wgpt0t1af
 
280
#include "fxvbtmp.h"
 
281
 
 
282
 
 
283
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_FOGC)
 
284
#define TAG(x) x##_2wgf
 
285
#include "fxvbtmp.h"
 
286
 
 
287
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_FOGC)
 
288
#define TAG(x) x##_2wgt0f
 
289
#include "fxvbtmp.h"
 
290
 
 
291
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|SETUP_FOGC)
 
292
#define TAG(x) x##_2wgt0t1f
 
293
#include "fxvbtmp.h"
 
294
 
 
295
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX|SETUP_FOGC)
 
296
#define TAG(x) x##_2wgpt0f
 
297
#include "fxvbtmp.h"
 
298
 
 
299
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|\
 
300
             SETUP_PTEX|SETUP_FOGC)
 
301
#define TAG(x) x##_2wgpt0t1f
 
302
#include "fxvbtmp.h"
 
303
 
 
304
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ|SETUP_FOGC)
 
305
#define TAG(x) x##_2wgaf
 
306
#include "fxvbtmp.h"
 
307
 
 
308
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC)
 
309
#define TAG(x) x##_2wgt0af
 
310
#include "fxvbtmp.h"
 
311
 
 
312
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ|SETUP_FOGC)
 
313
#define TAG(x) x##_2wgt0t1af
 
314
#include "fxvbtmp.h"
 
315
 
 
316
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
 
317
#define TAG(x) x##_2wgpt0af
 
318
#include "fxvbtmp.h"
 
319
 
 
320
#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|\
 
321
             SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
 
322
#define TAG(x) x##_2wgpt0t1af
 
323
#include "fxvbtmp.h"
 
324
/* fog } */
 
325
 
 
326
 
 
327
/* Snapping for voodoo-1
 
328
 */
 
329
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA)
 
330
#define TAG(x) x##_wsg
 
331
#include "fxvbtmp.h"
 
332
 
 
333
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0)
 
334
#define TAG(x) x##_wsgt0
 
335
#include "fxvbtmp.h"
 
336
 
 
337
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
 
338
             SETUP_TMU1)
 
339
#define TAG(x) x##_wsgt0t1
 
340
#include "fxvbtmp.h"
 
341
 
 
342
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
 
343
             SETUP_PTEX)
 
344
#define TAG(x) x##_wsgpt0
 
345
#include "fxvbtmp.h"
 
346
 
 
347
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
 
348
             SETUP_TMU1|SETUP_PTEX)
 
349
#define TAG(x) x##_wsgpt0t1
 
350
#include "fxvbtmp.h"
 
351
 
 
352
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_PSIZ)
 
353
#define TAG(x) x##_wsga
 
354
#include "fxvbtmp.h"
 
355
 
 
356
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ)
 
357
#define TAG(x) x##_wsgt0a
 
358
#include "fxvbtmp.h"
 
359
 
 
360
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
 
361
             SETUP_TMU1|SETUP_PSIZ)
 
362
#define TAG(x) x##_wsgt0t1a
 
363
#include "fxvbtmp.h"
 
364
 
 
365
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
 
366
             SETUP_PTEX|SETUP_PSIZ)
 
367
#define TAG(x) x##_wsgpt0a
 
368
#include "fxvbtmp.h"
 
369
 
 
370
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
 
371
             SETUP_TMU1|SETUP_PTEX|SETUP_PSIZ)
 
372
#define TAG(x) x##_wsgpt0t1a
 
373
#include "fxvbtmp.h"
 
374
 
 
375
 
 
376
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC)
 
377
#define TAG(x) x##_2wsg
 
378
#include "fxvbtmp.h"
 
379
 
 
380
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0)
 
381
#define TAG(x) x##_2wsgt0
 
382
#include "fxvbtmp.h"
 
383
 
 
384
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
 
385
             SETUP_TMU1)
 
386
#define TAG(x) x##_2wsgt0t1
 
387
#include "fxvbtmp.h"
 
388
 
 
389
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
 
390
             SETUP_PTEX)
 
391
#define TAG(x) x##_2wsgpt0
 
392
#include "fxvbtmp.h"
 
393
 
 
394
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
 
395
             SETUP_TMU1|SETUP_PTEX)
 
396
#define TAG(x) x##_2wsgpt0t1
 
397
#include "fxvbtmp.h"
 
398
 
 
399
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ)
 
400
#define TAG(x) x##_2wsga
 
401
#include "fxvbtmp.h"
 
402
 
 
403
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ)
 
404
#define TAG(x) x##_2wsgt0a
 
405
#include "fxvbtmp.h"
 
406
 
 
407
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
 
408
             SETUP_TMU1|SETUP_PSIZ)
 
409
#define TAG(x) x##_2wsgt0t1a
 
410
#include "fxvbtmp.h"
 
411
 
 
412
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
 
413
             SETUP_PTEX|SETUP_PSIZ)
 
414
#define TAG(x) x##_2wsgpt0a
 
415
#include "fxvbtmp.h"
 
416
 
 
417
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
 
418
             SETUP_TMU1|SETUP_PTEX|SETUP_PSIZ)
 
419
#define TAG(x) x##_2wsgpt0t1a
 
420
#include "fxvbtmp.h"
 
421
 
 
422
/* fog { */
 
423
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_FOGC)
 
424
#define TAG(x) x##_wsgf
 
425
#include "fxvbtmp.h"
 
426
 
 
427
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|SETUP_FOGC)
 
428
#define TAG(x) x##_wsgt0f
 
429
#include "fxvbtmp.h"
 
430
 
 
431
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
 
432
             SETUP_TMU1|SETUP_FOGC)
 
433
#define TAG(x) x##_wsgt0t1f
 
434
#include "fxvbtmp.h"
 
435
 
 
436
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
 
437
             SETUP_PTEX|SETUP_FOGC)
 
438
#define TAG(x) x##_wsgpt0f
 
439
#include "fxvbtmp.h"
 
440
 
 
441
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
 
442
             SETUP_TMU1|SETUP_PTEX|SETUP_FOGC)
 
443
#define TAG(x) x##_wsgpt0t1f
 
444
#include "fxvbtmp.h"
 
445
 
 
446
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_PSIZ|SETUP_FOGC)
 
447
#define TAG(x) x##_wsgaf
 
448
#include "fxvbtmp.h"
 
449
 
 
450
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC)
 
451
#define TAG(x) x##_wsgt0af
 
452
#include "fxvbtmp.h"
 
453
 
 
454
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
 
455
             SETUP_TMU1|SETUP_PSIZ|SETUP_FOGC)
 
456
#define TAG(x) x##_wsgt0t1af
 
457
#include "fxvbtmp.h"
 
458
 
 
459
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
 
460
             SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
 
461
#define TAG(x) x##_wsgpt0af
 
462
#include "fxvbtmp.h"
 
463
 
 
464
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
 
465
             SETUP_TMU1|SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
 
466
#define TAG(x) x##_wsgpt0t1af
 
467
#include "fxvbtmp.h"
 
468
 
 
469
 
 
470
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_FOGC)
 
471
#define TAG(x) x##_2wsgf
 
472
#include "fxvbtmp.h"
 
473
 
 
474
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_FOGC)
 
475
#define TAG(x) x##_2wsgt0f
 
476
#include "fxvbtmp.h"
 
477
 
 
478
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
 
479
             SETUP_TMU1|SETUP_FOGC)
 
480
#define TAG(x) x##_2wsgt0t1f
 
481
#include "fxvbtmp.h"
 
482
 
 
483
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
 
484
             SETUP_PTEX|SETUP_FOGC)
 
485
#define TAG(x) x##_2wsgpt0f
 
486
#include "fxvbtmp.h"
 
487
 
 
488
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
 
489
             SETUP_TMU1|SETUP_PTEX|SETUP_FOGC)
 
490
#define TAG(x) x##_2wsgpt0t1f
 
491
#include "fxvbtmp.h"
 
492
 
 
493
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ|SETUP_FOGC)
 
494
#define TAG(x) x##_2wsgaf
 
495
#include "fxvbtmp.h"
 
496
 
 
497
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC)
 
498
#define TAG(x) x##_2wsgt0af
 
499
#include "fxvbtmp.h"
 
500
 
 
501
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
 
502
             SETUP_TMU1|SETUP_PSIZ|SETUP_FOGC)
 
503
#define TAG(x) x##_2wsgt0t1af
 
504
#include "fxvbtmp.h"
 
505
 
 
506
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
 
507
             SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
 
508
#define TAG(x) x##_2wsgpt0af
 
509
#include "fxvbtmp.h"
 
510
 
 
511
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
 
512
             SETUP_TMU1|SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
 
513
#define TAG(x) x##_2wsgpt0t1af
 
514
#include "fxvbtmp.h"
 
515
/* fog } */
 
516
 
 
517
 
 
518
/* Vertex repair (multipass rendering)
 
519
 */
 
520
#define IND (SETUP_RGBA)
 
521
#define TAG(x) x##_g
 
522
#include "fxvbtmp.h"
 
523
 
 
524
#define IND (SETUP_TMU0)
 
525
#define TAG(x) x##_t0
 
526
#include "fxvbtmp.h"
 
527
 
 
528
#define IND (SETUP_TMU0|SETUP_TMU1)
 
529
#define TAG(x) x##_t0t1
 
530
#include "fxvbtmp.h"
 
531
 
 
532
#define IND (SETUP_RGBA|SETUP_TMU0)
 
533
#define TAG(x) x##_gt0
 
534
#include "fxvbtmp.h"
 
535
 
 
536
#define IND (SETUP_RGBA|SETUP_TMU0|SETUP_TMU1)
 
537
#define TAG(x) x##_gt0t1
 
538
#include "fxvbtmp.h"
 
539
 
 
540
 
 
541
#define IND (SETUP_RGBA|SETUP_SPEC)
 
542
#define TAG(x) x##_2g
 
543
#include "fxvbtmp.h"
 
544
 
 
545
#define IND (SETUP_TMU0|SETUP_SPEC)
 
546
#define TAG(x) x##_2t0
 
547
#include "fxvbtmp.h"
 
548
 
 
549
#define IND (SETUP_TMU0|SETUP_SPEC|SETUP_TMU1)
 
550
#define TAG(x) x##_2t0t1
 
551
#include "fxvbtmp.h"
 
552
 
 
553
#define IND (SETUP_RGBA|SETUP_SPEC|SETUP_TMU0)
 
554
#define TAG(x) x##_2gt0
 
555
#include "fxvbtmp.h"
 
556
 
 
557
#define IND (SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1)
 
558
#define TAG(x) x##_2gt0t1
 
559
#include "fxvbtmp.h"
 
560
 
 
561
 
 
562
 
 
563
static void init_setup_tab( void )
 
564
{
 
565
   init_wg();
 
566
   init_wgt0();
 
567
   init_wgt0t1();
 
568
   init_wgpt0();
 
569
   init_wgpt0t1();
 
570
   init_wga();
 
571
   init_wgt0a();
 
572
   init_wgt0t1a();
 
573
   init_wgpt0a();
 
574
   init_wgpt0t1a();
 
575
    init_2wg();
 
576
    init_2wgt0();
 
577
    init_2wgt0t1();
 
578
    init_2wgpt0();
 
579
    init_2wgpt0t1();
 
580
    init_2wga();
 
581
    init_2wgt0a();
 
582
    init_2wgt0t1a();
 
583
    init_2wgpt0a();
 
584
    init_2wgpt0t1a();
 
585
   init_wgf();
 
586
   init_wgt0f();
 
587
   init_wgt0t1f();
 
588
   init_wgpt0f();
 
589
   init_wgpt0t1f();
 
590
   init_wgaf();
 
591
   init_wgt0af();
 
592
   init_wgt0t1af();
 
593
   init_wgpt0af();
 
594
   init_wgpt0t1af();
 
595
    init_2wgf();
 
596
    init_2wgt0f();
 
597
    init_2wgt0t1f();
 
598
    init_2wgpt0f();
 
599
    init_2wgpt0t1f();
 
600
    init_2wgaf();
 
601
    init_2wgt0af();
 
602
    init_2wgt0t1af();
 
603
    init_2wgpt0af();
 
604
    init_2wgpt0t1af();
 
605
 
 
606
   init_wsg();
 
607
   init_wsgt0();
 
608
   init_wsgt0t1();
 
609
   init_wsgpt0();
 
610
   init_wsgpt0t1();
 
611
   init_wsga();
 
612
   init_wsgt0a();
 
613
   init_wsgt0t1a();
 
614
   init_wsgpt0a();
 
615
   init_wsgpt0t1a();
 
616
    init_2wsg();
 
617
    init_2wsgt0();
 
618
    init_2wsgt0t1();
 
619
    init_2wsgpt0();
 
620
    init_2wsgpt0t1();
 
621
    init_2wsga();
 
622
    init_2wsgt0a();
 
623
    init_2wsgt0t1a();
 
624
    init_2wsgpt0a();
 
625
    init_2wsgpt0t1a();
 
626
   init_wsgf();
 
627
   init_wsgt0f();
 
628
   init_wsgt0t1f();
 
629
   init_wsgpt0f();
 
630
   init_wsgpt0t1f();
 
631
   init_wsgaf();
 
632
   init_wsgt0af();
 
633
   init_wsgt0t1af();
 
634
   init_wsgpt0af();
 
635
   init_wsgpt0t1af();
 
636
    init_2wsgf();
 
637
    init_2wsgt0f();
 
638
    init_2wsgt0t1f();
 
639
    init_2wsgpt0f();
 
640
    init_2wsgpt0t1f();
 
641
    init_2wsgaf();
 
642
    init_2wsgt0af();
 
643
    init_2wsgt0t1af();
 
644
    init_2wsgpt0af();
 
645
    init_2wsgpt0t1af();
 
646
 
 
647
   init_g();
 
648
   init_t0();
 
649
   init_t0t1();
 
650
   init_gt0();
 
651
   init_gt0t1();
 
652
    init_2g();
 
653
    init_2t0();
 
654
    init_2t0t1();
 
655
    init_2gt0();
 
656
    init_2gt0t1();
 
657
}
 
658
 
 
659
 
 
660
void fxPrintSetupFlags(char *msg, GLuint flags )
 
661
{
 
662
   fprintf(stderr, "%s(%x): %s%s%s%s%s%s%s%s\n",
 
663
           msg,
 
664
           (int)flags,
 
665
           (flags & SETUP_XYZW)     ? " xyzw," : "",
 
666
           (flags & SETUP_SNAP)     ? " snap," : "",
 
667
           (flags & SETUP_RGBA)     ? " rgba," : "",
 
668
           (flags & SETUP_TMU0)     ? " tex-0," : "",
 
669
           (flags & SETUP_TMU1)     ? " tex-1," : "",
 
670
           (flags & SETUP_PSIZ)     ? " psiz," : "",
 
671
           (flags & SETUP_SPEC)     ? " spec," : "",
 
672
           (flags & SETUP_FOGC)     ? " fog," : "");
 
673
}
 
674
 
 
675
 
 
676
 
 
677
void fxCheckTexSizes( GLcontext *ctx )
 
678
{
 
679
   TNLcontext *tnl = TNL_CONTEXT(ctx);
 
680
   fxMesaContext fxMesa = FX_CONTEXT( ctx );
 
681
 
 
682
   if (!setup_tab[fxMesa->SetupIndex].check_tex_sizes(ctx)) {
 
683
      GLuint ind = fxMesa->SetupIndex |= (SETUP_PTEX|SETUP_RGBA);
 
684
 
 
685
      /* Tdfx handles projective textures nicely; just have to change
 
686
       * up to the new vertex format.
 
687
       */
 
688
      if (setup_tab[ind].vertex_format != fxMesa->stw_hint_state) {
 
689
 
 
690
         fxMesa->stw_hint_state = setup_tab[ind].vertex_format;
 
691
         FX_grHints(GR_HINT_STWHINT, fxMesa->stw_hint_state);
 
692
 
 
693
         /* This is required as we have just changed the vertex
 
694
          * format, so the interp routines must also change.
 
695
          * In the unfilled and twosided cases we are using the
 
696
          * Extras ones anyway, so leave them in place.
 
697
          */
 
698
         if (!(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
 
699
            tnl->Driver.Render.Interp = setup_tab[fxMesa->SetupIndex].interp;
 
700
         }
 
701
      }
 
702
   }
 
703
}
 
704
 
 
705
 
 
706
void fxBuildVertices( GLcontext *ctx, GLuint start, GLuint end,
 
707
                        GLuint newinputs )
 
708
{
 
709
   fxMesaContext fxMesa = FX_CONTEXT( ctx );
 
710
   GrVertex *v = (fxMesa->verts + start);
 
711
 
 
712
   if (!newinputs)
 
713
      return;
 
714
 
 
715
   if (newinputs & VERT_BIT_POS) {
 
716
      setup_tab[fxMesa->SetupIndex].emit( ctx, start, end, v );
 
717
   } else {
 
718
      GLuint ind = 0;
 
719
 
 
720
      if (newinputs & VERT_BIT_COLOR0)
 
721
         ind |= SETUP_RGBA;
 
722
 
 
723
      if (newinputs & VERT_BIT_COLOR1)
 
724
         ind |= SETUP_SPEC;
 
725
 
 
726
      if (newinputs & VERT_BIT_FOG)
 
727
         ind |= SETUP_FOGC;
 
728
 
 
729
      if (newinputs & VERT_BIT_TEX0)
 
730
         ind |= SETUP_TMU0;
 
731
 
 
732
      if (newinputs & VERT_BIT_TEX1)
 
733
         ind |= SETUP_TMU0|SETUP_TMU1;
 
734
 
 
735
      if (fxMesa->SetupIndex & SETUP_PTEX)
 
736
         ind = ~0;
 
737
 
 
738
      ind &= fxMesa->SetupIndex;
 
739
 
 
740
      if (ind) {
 
741
         setup_tab[ind].emit( ctx, start, end, v );
 
742
      }
 
743
   }
 
744
}
 
745
 
 
746
 
 
747
void fxChooseVertexState( GLcontext *ctx )
 
748
{
 
749
   TNLcontext *tnl = TNL_CONTEXT(ctx);
 
750
   fxMesaContext fxMesa = FX_CONTEXT( ctx );
 
751
   GLuint ind = SETUP_XYZW|SETUP_RGBA;
 
752
 
 
753
   if (fxMesa->snapVertices)
 
754
      ind |= SETUP_SNAP;
 
755
 
 
756
   fxMesa->tmu_source[0] = 0;
 
757
   fxMesa->tmu_source[1] = 1;
 
758
 
 
759
   if (ctx->Texture._EnabledUnits & 0x2) {
 
760
      if (ctx->Texture._EnabledUnits & 0x1) {
 
761
         ind |= SETUP_TMU1;
 
762
      }
 
763
      ind |= SETUP_TMU0;
 
764
      fxMesa->tmu_source[0] = 1;
 
765
      fxMesa->tmu_source[1] = 0;
 
766
   }
 
767
   else if (ctx->Texture._EnabledUnits & 0x1) {
 
768
      ind |= SETUP_TMU0;
 
769
   }
 
770
 
 
771
   if (ctx->_TriangleCaps & DD_POINT_ATTEN) {
 
772
      ind |= SETUP_PSIZ;
 
773
   }
 
774
 
 
775
   if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) {
 
776
      ind |= SETUP_SPEC;
 
777
   }
 
778
 
 
779
   if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) {
 
780
      ind |= SETUP_FOGC;
 
781
   }
 
782
 
 
783
   fxMesa->SetupIndex = ind;
 
784
 
 
785
   if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
 
786
      tnl->Driver.Render.Interp = interp_extras;
 
787
      tnl->Driver.Render.CopyPV = copy_pv_extras;
 
788
   } else {
 
789
      tnl->Driver.Render.Interp = setup_tab[ind].interp;
 
790
      tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv;
 
791
   }
 
792
 
 
793
   if (setup_tab[ind].vertex_format != fxMesa->stw_hint_state) {
 
794
      fxMesa->stw_hint_state = setup_tab[ind].vertex_format;
 
795
      FX_grHints(GR_HINT_STWHINT, fxMesa->stw_hint_state);
 
796
   }
 
797
}
 
798
 
 
799
 
 
800
 
 
801
void fxAllocVB( GLcontext *ctx )
 
802
{
 
803
   fxMesaContext fxMesa = FX_CONTEXT(ctx);
 
804
   GLuint size = TNL_CONTEXT(ctx)->vb.Size;
 
805
   static int firsttime = 1;
 
806
   if (firsttime) {
 
807
      init_setup_tab();
 
808
      firsttime = 0;
 
809
   }
 
810
 
 
811
   fxMesa->verts = (GrVertex *)ALIGN_MALLOC(size * sizeof(GrVertex), 32);
 
812
   fxMesa->SetupIndex = SETUP_XYZW|SETUP_RGBA;
 
813
}
 
814
 
 
815
 
 
816
void fxFreeVB( GLcontext *ctx )
 
817
{
 
818
   fxMesaContext fxMesa = FX_CONTEXT(ctx);
 
819
   if (fxMesa->verts) {
 
820
      ALIGN_FREE(fxMesa->verts);
 
821
      fxMesa->verts = 0;
 
822
   }
 
823
}
 
824
#else
 
825
 
 
826
 
 
827
/*
 
828
 * Need this to provide at least one external definition.
 
829
 */
 
830
 
 
831
extern int gl_fx_dummy_function_vb(void);
 
832
int
 
833
gl_fx_dummy_function_vb(void)
 
834
{
 
835
   return 0;
 
836
}
 
837
 
 
838
#endif /* FX */