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>
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 *(GLuint
*)&dst
->r
= *(GLuint
*)&src
->r
;
62 *(GLuint
*)&dst
->g
= *(GLuint
*)&src
->g
;
63 *(GLuint
*)&dst
->b
= *(GLuint
*)&src
->b
;
64 *(GLuint
*)&dst
->a
= *(GLuint
*)&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 *(GLuint
*)&dst
->r
= *(GLuint
*)&src
->r
;
79 *(GLuint
*)&dst
->g
= *(GLuint
*)&src
->g
;
80 *(GLuint
*)&dst
->b
= *(GLuint
*)&src
->b
;
81 *(GLuint
*)&dst
->a
= *(GLuint
*)&src
->a
;
82 *(GLuint
*)&dst
->r1
= *(GLuint
*)&src
->r1
;
83 *(GLuint
*)&dst
->g1
= *(GLuint
*)&src
->g1
;
84 *(GLuint
*)&dst
->b1
= *(GLuint
*)&src
->b1
;
85 #endif /* !FX_PACKEDCOLOR */
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 assert(VB
->ColorPtr
[1]->stride
== 4 * sizeof(GLfloat
));
111 GET_COLOR(VB
->ColorPtr
[1], dst
),
112 GET_COLOR(VB
->ColorPtr
[1], out
),
113 GET_COLOR(VB
->ColorPtr
[1], in
) );
115 if (VB
->SecondaryColorPtr
[1]) {
117 GET_COLOR(VB
->SecondaryColorPtr
[1], dst
),
118 GET_COLOR(VB
->SecondaryColorPtr
[1], out
),
119 GET_COLOR(VB
->SecondaryColorPtr
[1], in
) );
124 VB
->EdgeFlag
[dst
] = VB
->EdgeFlag
[out
] || force_boundary
;
127 setup_tab
[FX_CONTEXT(ctx
)->SetupIndex
].interp(ctx
, t
, dst
, out
, in
,
131 static void copy_pv_extras( GLcontext
*ctx
, GLuint dst
, GLuint src
)
133 struct vertex_buffer
*VB
= &TNL_CONTEXT(ctx
)->vb
;
135 if (VB
->ColorPtr
[1]) {
136 COPY_4FV( GET_COLOR(VB
->ColorPtr
[1], dst
),
137 GET_COLOR(VB
->ColorPtr
[1], src
) );
139 if (VB
->SecondaryColorPtr
[1]) {
140 COPY_3FV( GET_COLOR(VB
->SecondaryColorPtr
[1], dst
),
141 GET_COLOR(VB
->SecondaryColorPtr
[1], src
) );
145 setup_tab
[FX_CONTEXT(ctx
)->SetupIndex
].copy_pv(ctx
, dst
, src
);
149 #define IND (SETUP_XYZW|SETUP_RGBA)
150 #define TAG(x) x##_wg
153 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0)
154 #define TAG(x) x##_wgt0
157 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1)
158 #define TAG(x) x##_wgt0t1
161 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX)
162 #define TAG(x) x##_wgpt0
165 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\
167 #define TAG(x) x##_wgpt0t1
170 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_PSIZ)
171 #define TAG(x) x##_wga
174 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ)
175 #define TAG(x) x##_wgt0a
178 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ)
179 #define TAG(x) x##_wgt0t1a
182 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ)
183 #define TAG(x) x##_wgpt0a
186 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\
187 SETUP_PTEX|SETUP_PSIZ)
188 #define TAG(x) x##_wgpt0t1a
192 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC)
193 #define TAG(x) x##_2wg
196 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0)
197 #define TAG(x) x##_2wgt0
200 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1)
201 #define TAG(x) x##_2wgt0t1
204 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX)
205 #define TAG(x) x##_2wgpt0
208 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|\
210 #define TAG(x) x##_2wgpt0t1
213 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ)
214 #define TAG(x) x##_2wga
217 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ)
218 #define TAG(x) x##_2wgt0a
221 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ)
222 #define TAG(x) x##_2wgt0t1a
225 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ)
226 #define TAG(x) x##_2wgpt0a
229 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|\
230 SETUP_PTEX|SETUP_PSIZ)
231 #define TAG(x) x##_2wgpt0t1a
235 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_FOGC)
236 #define TAG(x) x##_wgf
239 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_FOGC)
240 #define TAG(x) x##_wgt0f
243 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|SETUP_FOGC)
244 #define TAG(x) x##_wgt0t1f
247 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX|SETUP_FOGC)
248 #define TAG(x) x##_wgpt0f
251 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\
252 SETUP_PTEX|SETUP_FOGC)
253 #define TAG(x) x##_wgpt0t1f
256 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_PSIZ|SETUP_FOGC)
257 #define TAG(x) x##_wgaf
260 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC)
261 #define TAG(x) x##_wgt0af
264 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ|SETUP_FOGC)
265 #define TAG(x) x##_wgt0t1af
268 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
269 #define TAG(x) x##_wgpt0af
272 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\
273 SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
274 #define TAG(x) x##_wgpt0t1af
278 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_FOGC)
279 #define TAG(x) x##_2wgf
282 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_FOGC)
283 #define TAG(x) x##_2wgt0f
286 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|SETUP_FOGC)
287 #define TAG(x) x##_2wgt0t1f
290 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX|SETUP_FOGC)
291 #define TAG(x) x##_2wgpt0f
294 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|\
295 SETUP_PTEX|SETUP_FOGC)
296 #define TAG(x) x##_2wgpt0t1f
299 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ|SETUP_FOGC)
300 #define TAG(x) x##_2wgaf
303 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC)
304 #define TAG(x) x##_2wgt0af
307 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ|SETUP_FOGC)
308 #define TAG(x) x##_2wgt0t1af
311 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
312 #define TAG(x) x##_2wgpt0af
315 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|\
316 SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
317 #define TAG(x) x##_2wgpt0t1af
322 /* Snapping for voodoo-1
324 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA)
325 #define TAG(x) x##_wsg
328 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0)
329 #define TAG(x) x##_wsgt0
332 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
334 #define TAG(x) x##_wsgt0t1
337 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
339 #define TAG(x) x##_wsgpt0
342 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
343 SETUP_TMU1|SETUP_PTEX)
344 #define TAG(x) x##_wsgpt0t1
347 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_PSIZ)
348 #define TAG(x) x##_wsga
351 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ)
352 #define TAG(x) x##_wsgt0a
355 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
356 SETUP_TMU1|SETUP_PSIZ)
357 #define TAG(x) x##_wsgt0t1a
360 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
361 SETUP_PTEX|SETUP_PSIZ)
362 #define TAG(x) x##_wsgpt0a
365 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
366 SETUP_TMU1|SETUP_PTEX|SETUP_PSIZ)
367 #define TAG(x) x##_wsgpt0t1a
371 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC)
372 #define TAG(x) x##_2wsg
375 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0)
376 #define TAG(x) x##_2wsgt0
379 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
381 #define TAG(x) x##_2wsgt0t1
384 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
386 #define TAG(x) x##_2wsgpt0
389 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
390 SETUP_TMU1|SETUP_PTEX)
391 #define TAG(x) x##_2wsgpt0t1
394 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ)
395 #define TAG(x) x##_2wsga
398 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ)
399 #define TAG(x) x##_2wsgt0a
402 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
403 SETUP_TMU1|SETUP_PSIZ)
404 #define TAG(x) x##_2wsgt0t1a
407 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
408 SETUP_PTEX|SETUP_PSIZ)
409 #define TAG(x) x##_2wsgpt0a
412 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
413 SETUP_TMU1|SETUP_PTEX|SETUP_PSIZ)
414 #define TAG(x) x##_2wsgpt0t1a
418 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_FOGC)
419 #define TAG(x) x##_wsgf
422 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|SETUP_FOGC)
423 #define TAG(x) x##_wsgt0f
426 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
427 SETUP_TMU1|SETUP_FOGC)
428 #define TAG(x) x##_wsgt0t1f
431 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
432 SETUP_PTEX|SETUP_FOGC)
433 #define TAG(x) x##_wsgpt0f
436 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
437 SETUP_TMU1|SETUP_PTEX|SETUP_FOGC)
438 #define TAG(x) x##_wsgpt0t1f
441 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_PSIZ|SETUP_FOGC)
442 #define TAG(x) x##_wsgaf
445 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC)
446 #define TAG(x) x##_wsgt0af
449 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
450 SETUP_TMU1|SETUP_PSIZ|SETUP_FOGC)
451 #define TAG(x) x##_wsgt0t1af
454 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
455 SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
456 #define TAG(x) x##_wsgpt0af
459 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
460 SETUP_TMU1|SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
461 #define TAG(x) x##_wsgpt0t1af
465 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_FOGC)
466 #define TAG(x) x##_2wsgf
469 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_FOGC)
470 #define TAG(x) x##_2wsgt0f
473 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
474 SETUP_TMU1|SETUP_FOGC)
475 #define TAG(x) x##_2wsgt0t1f
478 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
479 SETUP_PTEX|SETUP_FOGC)
480 #define TAG(x) x##_2wsgpt0f
483 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
484 SETUP_TMU1|SETUP_PTEX|SETUP_FOGC)
485 #define TAG(x) x##_2wsgpt0t1f
488 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ|SETUP_FOGC)
489 #define TAG(x) x##_2wsgaf
492 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC)
493 #define TAG(x) x##_2wsgt0af
496 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
497 SETUP_TMU1|SETUP_PSIZ|SETUP_FOGC)
498 #define TAG(x) x##_2wsgt0t1af
501 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
502 SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
503 #define TAG(x) x##_2wsgpt0af
506 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
507 SETUP_TMU1|SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
508 #define TAG(x) x##_2wsgpt0t1af
513 /* Vertex repair (multipass rendering)
515 #define IND (SETUP_RGBA)
519 #define IND (SETUP_TMU0)
520 #define TAG(x) x##_t0
523 #define IND (SETUP_TMU0|SETUP_TMU1)
524 #define TAG(x) x##_t0t1
527 #define IND (SETUP_RGBA|SETUP_TMU0)
528 #define TAG(x) x##_gt0
531 #define IND (SETUP_RGBA|SETUP_TMU0|SETUP_TMU1)
532 #define TAG(x) x##_gt0t1
536 #define IND (SETUP_RGBA|SETUP_SPEC)
537 #define TAG(x) x##_2g
540 #define IND (SETUP_TMU0|SETUP_SPEC)
541 #define TAG(x) x##_2t0
544 #define IND (SETUP_TMU0|SETUP_SPEC|SETUP_TMU1)
545 #define TAG(x) x##_2t0t1
548 #define IND (SETUP_RGBA|SETUP_SPEC|SETUP_TMU0)
549 #define TAG(x) x##_2gt0
552 #define IND (SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1)
553 #define TAG(x) x##_2gt0t1
558 static void init_setup_tab( void )
655 void fxPrintSetupFlags(char *msg
, GLuint flags
)
657 fprintf(stderr
, "%s(%x): %s%s%s%s%s%s%s%s\n",
660 (flags
& SETUP_XYZW
) ? " xyzw," : "",
661 (flags
& SETUP_SNAP
) ? " snap," : "",
662 (flags
& SETUP_RGBA
) ? " rgba," : "",
663 (flags
& SETUP_TMU0
) ? " tex-0," : "",
664 (flags
& SETUP_TMU1
) ? " tex-1," : "",
665 (flags
& SETUP_PSIZ
) ? " psiz," : "",
666 (flags
& SETUP_SPEC
) ? " spec," : "",
667 (flags
& SETUP_FOGC
) ? " fog," : "");
672 void fxCheckTexSizes( GLcontext
*ctx
)
674 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
675 fxMesaContext fxMesa
= FX_CONTEXT( ctx
);
677 if (!setup_tab
[fxMesa
->SetupIndex
].check_tex_sizes(ctx
)) {
678 GLuint ind
= fxMesa
->SetupIndex
|= (SETUP_PTEX
|SETUP_RGBA
);
680 /* Tdfx handles projective textures nicely; just have to change
681 * up to the new vertex format.
683 if (setup_tab
[ind
].vertex_format
!= fxMesa
->stw_hint_state
) {
685 fxMesa
->stw_hint_state
= setup_tab
[ind
].vertex_format
;
686 FX_grHints(GR_HINT_STWHINT
, fxMesa
->stw_hint_state
);
688 /* This is required as we have just changed the vertex
689 * format, so the interp routines must also change.
690 * In the unfilled and twosided cases we are using the
691 * Extras ones anyway, so leave them in place.
693 if (!(ctx
->_TriangleCaps
& (DD_TRI_LIGHT_TWOSIDE
|DD_TRI_UNFILLED
))) {
694 tnl
->Driver
.Render
.Interp
= setup_tab
[fxMesa
->SetupIndex
].interp
;
701 void fxBuildVertices( GLcontext
*ctx
, GLuint start
, GLuint count
,
704 fxMesaContext fxMesa
= FX_CONTEXT( ctx
);
705 GrVertex
*v
= (fxMesa
->verts
+ start
);
710 if (newinputs
& VERT_BIT_POS
) {
711 setup_tab
[fxMesa
->SetupIndex
].emit( ctx
, start
, count
, v
);
715 if (newinputs
& VERT_BIT_COLOR0
)
718 if (newinputs
& VERT_BIT_COLOR1
)
721 if (newinputs
& VERT_BIT_FOG
)
724 if (newinputs
& VERT_BIT_TEX0
)
727 if (newinputs
& VERT_BIT_TEX1
)
728 ind
|= SETUP_TMU0
|SETUP_TMU1
;
730 if (fxMesa
->SetupIndex
& SETUP_PTEX
)
733 ind
&= fxMesa
->SetupIndex
;
736 setup_tab
[ind
].emit( ctx
, start
, count
, v
);
742 void fxChooseVertexState( GLcontext
*ctx
)
744 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
745 fxMesaContext fxMesa
= FX_CONTEXT( ctx
);
746 GLuint ind
= SETUP_XYZW
|SETUP_RGBA
;
748 if (fxMesa
->snapVertices
)
751 fxMesa
->tmu_source
[0] = 0;
752 fxMesa
->tmu_source
[1] = 1;
754 if (ctx
->Texture
._EnabledUnits
& 0x2) {
755 if (ctx
->Texture
._EnabledUnits
& 0x1) {
759 fxMesa
->tmu_source
[0] = 1;
760 fxMesa
->tmu_source
[1] = 0;
762 else if (ctx
->Texture
._EnabledUnits
& 0x1) {
766 if (ctx
->_TriangleCaps
& DD_POINT_ATTEN
) {
770 if (ctx
->_TriangleCaps
& DD_SEPARATE_SPECULAR
) {
774 if (ctx
->Fog
.FogCoordinateSource
== GL_FOG_COORDINATE_EXT
) {
778 fxMesa
->SetupIndex
= ind
;
780 if (ctx
->_TriangleCaps
& (DD_TRI_LIGHT_TWOSIDE
|DD_TRI_UNFILLED
)) {
781 tnl
->Driver
.Render
.Interp
= interp_extras
;
782 tnl
->Driver
.Render
.CopyPV
= copy_pv_extras
;
784 tnl
->Driver
.Render
.Interp
= setup_tab
[ind
].interp
;
785 tnl
->Driver
.Render
.CopyPV
= setup_tab
[ind
].copy_pv
;
788 if (setup_tab
[ind
].vertex_format
!= fxMesa
->stw_hint_state
) {
789 fxMesa
->stw_hint_state
= setup_tab
[ind
].vertex_format
;
790 FX_grHints(GR_HINT_STWHINT
, fxMesa
->stw_hint_state
);
796 void fxAllocVB( GLcontext
*ctx
)
798 fxMesaContext fxMesa
= FX_CONTEXT(ctx
);
799 GLuint size
= TNL_CONTEXT(ctx
)->vb
.Size
;
800 static int firsttime
= 1;
806 fxMesa
->verts
= (GrVertex
*)ALIGN_MALLOC(size
* sizeof(GrVertex
), 32);
807 fxMesa
->SetupIndex
= SETUP_XYZW
|SETUP_RGBA
;
811 void fxFreeVB( GLcontext
*ctx
)
813 fxMesaContext fxMesa
= FX_CONTEXT(ctx
);
815 ALIGN_FREE(fxMesa
->verts
);
823 * Need this to provide at least one external definition.
826 extern int gl_fx_dummy_function_vb(void);
828 gl_fx_dummy_function_vb(void)