2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
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:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
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.
27 * Keith Whitwell <keith@tungstengraphics.com>
28 * Daniel Borca <dborca@users.sourceforge.net>
37 #include "main/glheader.h"
38 #include "main/mtypes.h"
39 #include "main/imports.h"
40 #include "main/macros.h"
41 #include "main/colormac.h"
43 #include "math/m_translate.h"
44 #include "swrast_setup/swrast_setup.h"
47 #include "tnl/t_context.h"
52 static void copy_pv( GLcontext
*ctx
, GLuint edst
, GLuint esrc
)
54 fxMesaContext fxMesa
= FX_CONTEXT( ctx
);
55 GrVertex
*dst
= fxMesa
->verts
+ edst
;
56 GrVertex
*src
= fxMesa
->verts
+ esrc
;
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 */
68 static void copy_pv2( GLcontext
*ctx
, GLuint edst
, GLuint esrc
)
70 fxMesaContext fxMesa
= FX_CONTEXT( ctx
);
71 GrVertex
*dst
= fxMesa
->verts
+ edst
;
72 GrVertex
*src
= fxMesa
->verts
+ esrc
;
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 */
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
);
94 } setup_tab
[MAX_SETUP
];
97 #define GET_COLOR(ptr, idx) ((ptr)->data[idx])
100 static void interp_extras( GLcontext
*ctx
,
102 GLuint dst
, GLuint out
, GLuint in
,
103 GLboolean force_boundary
)
105 struct vertex_buffer
*VB
= &TNL_CONTEXT(ctx
)->vb
;
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
112 if (VB
->ColorPtr
[1]->stride
) {
113 assert(VB
->ColorPtr
[1]->stride
== 4 * sizeof(GLfloat
));
115 GET_COLOR(VB
->ColorPtr
[1], dst
),
116 GET_COLOR(VB
->ColorPtr
[1], out
),
117 GET_COLOR(VB
->ColorPtr
[1], in
) );
120 if (VB
->SecondaryColorPtr
[1]) {
122 GET_COLOR(VB
->SecondaryColorPtr
[1], dst
),
123 GET_COLOR(VB
->SecondaryColorPtr
[1], out
),
124 GET_COLOR(VB
->SecondaryColorPtr
[1], in
) );
129 VB
->EdgeFlag
[dst
] = VB
->EdgeFlag
[out
] || force_boundary
;
132 setup_tab
[FX_CONTEXT(ctx
)->SetupIndex
].interp(ctx
, t
, dst
, out
, in
,
136 static void copy_pv_extras( GLcontext
*ctx
, GLuint dst
, GLuint src
)
138 struct vertex_buffer
*VB
= &TNL_CONTEXT(ctx
)->vb
;
140 if (VB
->ColorPtr
[1]) {
141 COPY_4FV( GET_COLOR(VB
->ColorPtr
[1], dst
),
142 GET_COLOR(VB
->ColorPtr
[1], src
) );
144 if (VB
->SecondaryColorPtr
[1]) {
145 COPY_3FV( GET_COLOR(VB
->SecondaryColorPtr
[1], dst
),
146 GET_COLOR(VB
->SecondaryColorPtr
[1], src
) );
150 setup_tab
[FX_CONTEXT(ctx
)->SetupIndex
].copy_pv(ctx
, dst
, src
);
154 #define IND (SETUP_XYZW|SETUP_RGBA)
155 #define TAG(x) x##_wg
158 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0)
159 #define TAG(x) x##_wgt0
162 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1)
163 #define TAG(x) x##_wgt0t1
166 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX)
167 #define TAG(x) x##_wgpt0
170 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\
172 #define TAG(x) x##_wgpt0t1
175 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_PSIZ)
176 #define TAG(x) x##_wga
179 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ)
180 #define TAG(x) x##_wgt0a
183 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ)
184 #define TAG(x) x##_wgt0t1a
187 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ)
188 #define TAG(x) x##_wgpt0a
191 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\
192 SETUP_PTEX|SETUP_PSIZ)
193 #define TAG(x) x##_wgpt0t1a
197 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC)
198 #define TAG(x) x##_2wg
201 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0)
202 #define TAG(x) x##_2wgt0
205 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1)
206 #define TAG(x) x##_2wgt0t1
209 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX)
210 #define TAG(x) x##_2wgpt0
213 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|\
215 #define TAG(x) x##_2wgpt0t1
218 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ)
219 #define TAG(x) x##_2wga
222 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ)
223 #define TAG(x) x##_2wgt0a
226 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ)
227 #define TAG(x) x##_2wgt0t1a
230 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ)
231 #define TAG(x) x##_2wgpt0a
234 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|\
235 SETUP_PTEX|SETUP_PSIZ)
236 #define TAG(x) x##_2wgpt0t1a
240 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_FOGC)
241 #define TAG(x) x##_wgf
244 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_FOGC)
245 #define TAG(x) x##_wgt0f
248 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|SETUP_FOGC)
249 #define TAG(x) x##_wgt0t1f
252 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX|SETUP_FOGC)
253 #define TAG(x) x##_wgpt0f
256 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\
257 SETUP_PTEX|SETUP_FOGC)
258 #define TAG(x) x##_wgpt0t1f
261 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_PSIZ|SETUP_FOGC)
262 #define TAG(x) x##_wgaf
265 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC)
266 #define TAG(x) x##_wgt0af
269 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ|SETUP_FOGC)
270 #define TAG(x) x##_wgt0t1af
273 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
274 #define TAG(x) x##_wgpt0af
277 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\
278 SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
279 #define TAG(x) x##_wgpt0t1af
283 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_FOGC)
284 #define TAG(x) x##_2wgf
287 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_FOGC)
288 #define TAG(x) x##_2wgt0f
291 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|SETUP_FOGC)
292 #define TAG(x) x##_2wgt0t1f
295 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX|SETUP_FOGC)
296 #define TAG(x) x##_2wgpt0f
299 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|\
300 SETUP_PTEX|SETUP_FOGC)
301 #define TAG(x) x##_2wgpt0t1f
304 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ|SETUP_FOGC)
305 #define TAG(x) x##_2wgaf
308 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC)
309 #define TAG(x) x##_2wgt0af
312 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ|SETUP_FOGC)
313 #define TAG(x) x##_2wgt0t1af
316 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
317 #define TAG(x) x##_2wgpt0af
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
327 /* Snapping for voodoo-1
329 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA)
330 #define TAG(x) x##_wsg
333 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0)
334 #define TAG(x) x##_wsgt0
337 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
339 #define TAG(x) x##_wsgt0t1
342 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
344 #define TAG(x) x##_wsgpt0
347 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
348 SETUP_TMU1|SETUP_PTEX)
349 #define TAG(x) x##_wsgpt0t1
352 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_PSIZ)
353 #define TAG(x) x##_wsga
356 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ)
357 #define TAG(x) x##_wsgt0a
360 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
361 SETUP_TMU1|SETUP_PSIZ)
362 #define TAG(x) x##_wsgt0t1a
365 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
366 SETUP_PTEX|SETUP_PSIZ)
367 #define TAG(x) x##_wsgpt0a
370 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
371 SETUP_TMU1|SETUP_PTEX|SETUP_PSIZ)
372 #define TAG(x) x##_wsgpt0t1a
376 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC)
377 #define TAG(x) x##_2wsg
380 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0)
381 #define TAG(x) x##_2wsgt0
384 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
386 #define TAG(x) x##_2wsgt0t1
389 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
391 #define TAG(x) x##_2wsgpt0
394 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
395 SETUP_TMU1|SETUP_PTEX)
396 #define TAG(x) x##_2wsgpt0t1
399 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ)
400 #define TAG(x) x##_2wsga
403 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ)
404 #define TAG(x) x##_2wsgt0a
407 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
408 SETUP_TMU1|SETUP_PSIZ)
409 #define TAG(x) x##_2wsgt0t1a
412 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
413 SETUP_PTEX|SETUP_PSIZ)
414 #define TAG(x) x##_2wsgpt0a
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
423 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_FOGC)
424 #define TAG(x) x##_wsgf
427 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|SETUP_FOGC)
428 #define TAG(x) x##_wsgt0f
431 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
432 SETUP_TMU1|SETUP_FOGC)
433 #define TAG(x) x##_wsgt0t1f
436 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
437 SETUP_PTEX|SETUP_FOGC)
438 #define TAG(x) x##_wsgpt0f
441 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
442 SETUP_TMU1|SETUP_PTEX|SETUP_FOGC)
443 #define TAG(x) x##_wsgpt0t1f
446 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_PSIZ|SETUP_FOGC)
447 #define TAG(x) x##_wsgaf
450 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC)
451 #define TAG(x) x##_wsgt0af
454 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
455 SETUP_TMU1|SETUP_PSIZ|SETUP_FOGC)
456 #define TAG(x) x##_wsgt0t1af
459 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
460 SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
461 #define TAG(x) x##_wsgpt0af
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
470 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_FOGC)
471 #define TAG(x) x##_2wsgf
474 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_FOGC)
475 #define TAG(x) x##_2wsgt0f
478 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
479 SETUP_TMU1|SETUP_FOGC)
480 #define TAG(x) x##_2wsgt0t1f
483 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
484 SETUP_PTEX|SETUP_FOGC)
485 #define TAG(x) x##_2wsgpt0f
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
493 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ|SETUP_FOGC)
494 #define TAG(x) x##_2wsgaf
497 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC)
498 #define TAG(x) x##_2wsgt0af
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
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
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
518 /* Vertex repair (multipass rendering)
520 #define IND (SETUP_RGBA)
524 #define IND (SETUP_TMU0)
525 #define TAG(x) x##_t0
528 #define IND (SETUP_TMU0|SETUP_TMU1)
529 #define TAG(x) x##_t0t1
532 #define IND (SETUP_RGBA|SETUP_TMU0)
533 #define TAG(x) x##_gt0
536 #define IND (SETUP_RGBA|SETUP_TMU0|SETUP_TMU1)
537 #define TAG(x) x##_gt0t1
541 #define IND (SETUP_RGBA|SETUP_SPEC)
542 #define TAG(x) x##_2g
545 #define IND (SETUP_TMU0|SETUP_SPEC)
546 #define TAG(x) x##_2t0
549 #define IND (SETUP_TMU0|SETUP_SPEC|SETUP_TMU1)
550 #define TAG(x) x##_2t0t1
553 #define IND (SETUP_RGBA|SETUP_SPEC|SETUP_TMU0)
554 #define TAG(x) x##_2gt0
557 #define IND (SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1)
558 #define TAG(x) x##_2gt0t1
563 static void init_setup_tab( void )
660 void fxPrintSetupFlags(char *msg
, GLuint flags
)
662 fprintf(stderr
, "%s(%x): %s%s%s%s%s%s%s%s\n",
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," : "");
677 void fxCheckTexSizes( GLcontext
*ctx
)
679 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
680 fxMesaContext fxMesa
= FX_CONTEXT( ctx
);
682 if (!setup_tab
[fxMesa
->SetupIndex
].check_tex_sizes(ctx
)) {
683 GLuint ind
= fxMesa
->SetupIndex
|= (SETUP_PTEX
|SETUP_RGBA
);
685 /* Tdfx handles projective textures nicely; just have to change
686 * up to the new vertex format.
688 if (setup_tab
[ind
].vertex_format
!= fxMesa
->stw_hint_state
) {
690 fxMesa
->stw_hint_state
= setup_tab
[ind
].vertex_format
;
691 FX_grHints(GR_HINT_STWHINT
, fxMesa
->stw_hint_state
);
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.
698 if (!(ctx
->_TriangleCaps
& (DD_TRI_LIGHT_TWOSIDE
|DD_TRI_UNFILLED
))) {
699 tnl
->Driver
.Render
.Interp
= setup_tab
[fxMesa
->SetupIndex
].interp
;
706 void fxBuildVertices( GLcontext
*ctx
, GLuint start
, GLuint end
,
709 fxMesaContext fxMesa
= FX_CONTEXT( ctx
);
710 GrVertex
*v
= (fxMesa
->verts
+ start
);
715 if (newinputs
& VERT_BIT_POS
) {
716 setup_tab
[fxMesa
->SetupIndex
].emit( ctx
, start
, end
, v
);
720 if (newinputs
& VERT_BIT_COLOR0
)
723 if (newinputs
& VERT_BIT_COLOR1
)
726 if (newinputs
& VERT_BIT_FOG
)
729 if (newinputs
& VERT_BIT_TEX0
)
732 if (newinputs
& VERT_BIT_TEX1
)
733 ind
|= SETUP_TMU0
|SETUP_TMU1
;
735 if (fxMesa
->SetupIndex
& SETUP_PTEX
)
738 ind
&= fxMesa
->SetupIndex
;
741 setup_tab
[ind
].emit( ctx
, start
, end
, v
);
747 void fxChooseVertexState( GLcontext
*ctx
)
749 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
750 fxMesaContext fxMesa
= FX_CONTEXT( ctx
);
751 GLuint ind
= SETUP_XYZW
|SETUP_RGBA
;
753 if (fxMesa
->snapVertices
)
756 fxMesa
->tmu_source
[0] = 0;
757 fxMesa
->tmu_source
[1] = 1;
759 if (ctx
->Texture
._EnabledUnits
& 0x2) {
760 if (ctx
->Texture
._EnabledUnits
& 0x1) {
764 fxMesa
->tmu_source
[0] = 1;
765 fxMesa
->tmu_source
[1] = 0;
767 else if (ctx
->Texture
._EnabledUnits
& 0x1) {
771 if (ctx
->_TriangleCaps
& DD_POINT_ATTEN
) {
775 if (ctx
->_TriangleCaps
& DD_SEPARATE_SPECULAR
) {
779 if (ctx
->Fog
.FogCoordinateSource
== GL_FOG_COORDINATE_EXT
) {
783 fxMesa
->SetupIndex
= ind
;
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
;
789 tnl
->Driver
.Render
.Interp
= setup_tab
[ind
].interp
;
790 tnl
->Driver
.Render
.CopyPV
= setup_tab
[ind
].copy_pv
;
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
);
801 void fxAllocVB( GLcontext
*ctx
)
803 fxMesaContext fxMesa
= FX_CONTEXT(ctx
);
804 GLuint size
= TNL_CONTEXT(ctx
)->vb
.Size
;
805 static int firsttime
= 1;
811 fxMesa
->verts
= (GrVertex
*)ALIGN_MALLOC(size
* sizeof(GrVertex
), 32);
812 fxMesa
->SetupIndex
= SETUP_XYZW
|SETUP_RGBA
;
816 void fxFreeVB( GLcontext
*ctx
)
818 fxMesaContext fxMesa
= FX_CONTEXT(ctx
);
820 ALIGN_FREE(fxMesa
->verts
);
828 * Need this to provide at least one external definition.
831 extern int gl_fx_dummy_function_vb(void);
833 gl_fx_dummy_function_vb(void)