1 /* $Id: fxtris.c,v 1.20 2002/10/24 23:57:23 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 * Keith Whitwell <keithw@valinux.com>
39 #include "swrast/swrast.h"
40 #include "swrast_setup/swrast_setup.h"
41 #include "tnl/t_context.h"
42 #include "tnl/t_pipeline.h"
48 * Subpixel offsets to adjust Mesa's (true) window coordinates to
49 * Glide coordinates. We need these to ensure precise rasterization.
50 * Otherwise, we'll fail a bunch of conformance tests.
52 #define TRI_X_OFFSET ( 0.0F)
53 #define TRI_Y_OFFSET ( 0.0F)
54 #define LINE_X_OFFSET ( 0.0F)
55 #define LINE_Y_OFFSET ( 0.125F)
56 #define PNT_X_OFFSET ( 0.375F)
57 #define PNT_Y_OFFSET ( 0.375F)
59 static void fxRasterPrimitive( GLcontext
*ctx
, GLenum prim
);
60 static void fxRenderPrimitive( GLcontext
*ctx
, GLenum prim
);
62 /***********************************************************************
63 * Macros for t_dd_tritmp.h to draw basic primitives *
64 ***********************************************************************/
66 #define TRI( a, b, c ) \
69 fxMesa->draw_tri( fxMesa, a, b, c ); \
71 grDrawTriangle( a, b, c ); \
74 #define QUAD( a, b, c, d ) \
77 fxMesa->draw_tri( fxMesa, a, b, d ); \
78 fxMesa->draw_tri( fxMesa, b, c, d ); \
80 grDrawTriangle( a, b, d ); \
81 grDrawTriangle( b, c, d ); \
85 #define LINE( v0, v1 ) \
88 fxMesa->draw_line( fxMesa, v0, v1 ); \
90 v0->x += LINE_X_OFFSET - TRI_X_OFFSET; \
91 v0->y += LINE_Y_OFFSET - TRI_Y_OFFSET; \
92 v1->x += LINE_X_OFFSET - TRI_X_OFFSET; \
93 v1->y += LINE_Y_OFFSET - TRI_Y_OFFSET; \
94 grDrawLine( v0, v1 ); \
95 v0->x -= LINE_X_OFFSET - TRI_X_OFFSET; \
96 v0->y -= LINE_Y_OFFSET - TRI_Y_OFFSET; \
97 v1->x -= LINE_X_OFFSET - TRI_X_OFFSET; \
98 v1->y -= LINE_Y_OFFSET - TRI_Y_OFFSET; \
102 #define POINT( v0 ) \
105 fxMesa->draw_point( fxMesa, v0 ); \
107 v0->x += PNT_X_OFFSET - TRI_X_OFFSET; \
108 v0->y += PNT_Y_OFFSET - TRI_Y_OFFSET; \
110 v0->x -= PNT_X_OFFSET - TRI_X_OFFSET; \
111 v0->y -= PNT_Y_OFFSET - TRI_Y_OFFSET; \
116 /***********************************************************************
117 * Fallback to swrast for basic primitives *
118 ***********************************************************************/
120 /* Build an SWvertex from a hardware vertex.
122 * This code is hit only when a mix of accelerated and unaccelerated
123 * primitives are being drawn, and only for the unaccelerated
127 fx_translate_vertex( GLcontext
*ctx
, const GrVertex
*src
, SWvertex
*dst
)
129 fxMesaContext fxMesa
= FX_CONTEXT(ctx
);
130 GLuint ts0
= fxMesa
->tmu_source
[0];
131 GLuint ts1
= fxMesa
->tmu_source
[1];
132 GLfloat w
= 1.0 / src
->oow
;
134 dst
->win
[0] = src
->x
;
135 dst
->win
[1] = src
->y
;
136 dst
->win
[2] = src
->ooz
;
137 dst
->win
[3] = src
->oow
;
139 dst
->color
[0] = (GLubyte
) src
->r
;
140 dst
->color
[1] = (GLubyte
) src
->g
;
141 dst
->color
[2] = (GLubyte
) src
->b
;
142 dst
->color
[3] = (GLubyte
) src
->a
;
144 dst
->texcoord
[ts0
][0] = fxMesa
->inv_s0scale
* src
->tmuvtx
[0].sow
* w
;
145 dst
->texcoord
[ts0
][1] = fxMesa
->inv_t0scale
* src
->tmuvtx
[0].tow
* w
;
147 if (fxMesa
->stw_hint_state
& GR_STWHINT_W_DIFF_TMU0
)
148 dst
->texcoord
[ts0
][3] = src
->tmuvtx
[0].oow
* w
;
150 dst
->texcoord
[ts0
][3] = 1.0;
152 if (fxMesa
->SetupIndex
& SETUP_TMU1
) {
153 dst
->texcoord
[ts1
][0] = fxMesa
->inv_s1scale
* src
->tmuvtx
[1].sow
* w
;
154 dst
->texcoord
[ts1
][1] = fxMesa
->inv_t1scale
* src
->tmuvtx
[1].tow
* w
;
156 if (fxMesa
->stw_hint_state
& GR_STWHINT_W_DIFF_TMU1
)
157 dst
->texcoord
[ts1
][3] = src
->tmuvtx
[1].oow
* w
;
159 dst
->texcoord
[ts1
][3] = 1.0;
162 dst
->pointSize
= ctx
->Point
._Size
;
167 fx_fallback_tri( fxMesaContext fxMesa
,
172 GLcontext
*ctx
= fxMesa
->glCtx
;
175 fx_translate_vertex( ctx
, v0
, &v
[0] );
176 fx_translate_vertex( ctx
, v1
, &v
[1] );
177 fx_translate_vertex( ctx
, v2
, &v
[2] );
178 _swrast_Triangle( ctx
, &v
[0], &v
[1], &v
[2] );
183 fx_fallback_line( fxMesaContext fxMesa
,
187 GLcontext
*ctx
= fxMesa
->glCtx
;
189 fx_translate_vertex( ctx
, v0
, &v
[0] );
190 fx_translate_vertex( ctx
, v1
, &v
[1] );
191 _swrast_Line( ctx
, &v
[0], &v
[1] );
196 fx_fallback_point( fxMesaContext fxMesa
,
199 GLcontext
*ctx
= fxMesa
->glCtx
;
201 fx_translate_vertex( ctx
, v0
, &v
[0] );
202 _swrast_Point( ctx
, &v
[0] );
205 /***********************************************************************
206 * Functions to draw basic primitives *
207 ***********************************************************************/
209 static void fx_print_vertex( GLcontext
*ctx
, const GrVertex
*v
)
211 fprintf(stderr
, "vertex at %p\n", (void *) v
);
213 fprintf(stderr
, "x %f y %f z %f oow %f\n",
214 v
->x
, v
->y
, v
->ooz
, v
->oow
);
215 fprintf(stderr
, "r %f g %f b %f a %f\n",
221 fprintf(stderr
, "\n");
224 #define DO_FALLBACK 0
226 /* Need to do clip loop at each triangle when mixing swrast and hw
227 * rendering. These functions are only used when mixed-mode rendering
230 static void fx_draw_quad( fxMesaContext fxMesa
,
236 QUAD( v0
, v1
, v2
, v3
);
239 static void fx_draw_triangle( fxMesaContext fxMesa
,
247 static void fx_draw_line( fxMesaContext fxMesa
,
251 /* No support for wide lines (avoid wide/aa line fallback).
256 static void fx_draw_point( fxMesaContext fxMesa
,
259 /* No support for wide points.
267 #define FX_UNFILLED_BIT 0x1
268 #define FX_OFFSET_BIT 0x2
269 #define FX_TWOSIDE_BIT 0x4
270 #define FX_FLAT_BIT 0x8
271 #define FX_FALLBACK_BIT 0x10
272 #define FX_MAX_TRIFUNC 0x20
277 triangle_func triangle
;
279 } rast_tab
[FX_MAX_TRIFUNC
];
281 #define DO_FALLBACK (IND & FX_FALLBACK_BIT)
282 #define DO_OFFSET (IND & FX_OFFSET_BIT)
283 #define DO_UNFILLED (IND & FX_UNFILLED_BIT)
284 #define DO_TWOSIDE (IND & FX_TWOSIDE_BIT)
285 #define DO_FLAT (IND & FX_FLAT_BIT)
290 #define DO_FULL_QUAD 1
294 #define HAVE_HW_FLATSHADE 0
295 #define HAVE_BACK_COLORS 0
296 #define VERTEX GrVertex
299 #define DEPTH_SCALE 1.0
300 #define UNFILLED_TRI unfilled_tri
301 #define UNFILLED_QUAD unfilled_quad
302 #define VERT_X(_v) _v->x
303 #define VERT_Y(_v) _v->y
304 #define VERT_Z(_v) _v->ooz
305 #define AREA_IS_CCW( a ) (a < 0)
306 #define GET_VERTEX(e) (fxMesa->verts + e)
308 #define VERT_SET_RGBA( dst, f ) \
310 dst->r = (GLfloat)f[0]; \
311 dst->g = (GLfloat)f[1]; \
312 dst->b = (GLfloat)f[2]; \
313 dst->a = (GLfloat)f[3]; \
316 #define VERT_COPY_RGBA( v0, v1 ) \
324 #define VERT_SAVE_RGBA( idx ) \
326 color[idx][0] = v[idx]->r; \
327 color[idx][1] = v[idx]->g; \
328 color[idx][2] = v[idx]->b; \
329 color[idx][3] = v[idx]->a; \
333 #define VERT_RESTORE_RGBA( idx ) \
335 v[idx]->r = color[idx][0]; \
336 v[idx]->g = color[idx][1]; \
337 v[idx]->b = color[idx][2]; \
338 v[idx]->a = color[idx][3]; \
342 #define LOCAL_VARS(n) \
343 fxMesaContext fxMesa = FX_CONTEXT(ctx); \
344 GLfloat color[n][4]; \
349 /***********************************************************************
350 * Functions to draw basic unfilled primitives *
351 ***********************************************************************/
353 #define RASTERIZE(x) if (fxMesa->raster_primitive != x) \
354 fxRasterPrimitive( ctx, x )
355 #define RENDER_PRIMITIVE fxMesa->render_primitive
356 #define IND FX_FALLBACK_BIT
358 #include "tnl_dd/t_dd_unfilled.h"
361 /***********************************************************************
362 * Functions to draw GL primitives *
363 ***********************************************************************/
367 #include "tnl_dd/t_dd_tritmp.h"
369 #define IND (FX_OFFSET_BIT)
370 #define TAG(x) x##_offset
371 #include "tnl_dd/t_dd_tritmp.h"
373 #define IND (FX_TWOSIDE_BIT)
374 #define TAG(x) x##_twoside
375 #include "tnl_dd/t_dd_tritmp.h"
377 #define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT)
378 #define TAG(x) x##_twoside_offset
379 #include "tnl_dd/t_dd_tritmp.h"
381 #define IND (FX_UNFILLED_BIT)
382 #define TAG(x) x##_unfilled
383 #include "tnl_dd/t_dd_tritmp.h"
385 #define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT)
386 #define TAG(x) x##_offset_unfilled
387 #include "tnl_dd/t_dd_tritmp.h"
389 #define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT)
390 #define TAG(x) x##_twoside_unfilled
391 #include "tnl_dd/t_dd_tritmp.h"
393 #define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT)
394 #define TAG(x) x##_twoside_offset_unfilled
395 #include "tnl_dd/t_dd_tritmp.h"
397 #define IND (FX_FALLBACK_BIT)
398 #define TAG(x) x##_fallback
399 #include "tnl_dd/t_dd_tritmp.h"
401 #define IND (FX_OFFSET_BIT|FX_FALLBACK_BIT)
402 #define TAG(x) x##_offset_fallback
403 #include "tnl_dd/t_dd_tritmp.h"
405 #define IND (FX_TWOSIDE_BIT|FX_FALLBACK_BIT)
406 #define TAG(x) x##_twoside_fallback
407 #include "tnl_dd/t_dd_tritmp.h"
409 #define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_FALLBACK_BIT)
410 #define TAG(x) x##_twoside_offset_fallback
411 #include "tnl_dd/t_dd_tritmp.h"
413 #define IND (FX_UNFILLED_BIT|FX_FALLBACK_BIT)
414 #define TAG(x) x##_unfilled_fallback
415 #include "tnl_dd/t_dd_tritmp.h"
417 #define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT)
418 #define TAG(x) x##_offset_unfilled_fallback
419 #include "tnl_dd/t_dd_tritmp.h"
421 #define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT)
422 #define TAG(x) x##_twoside_unfilled_fallback
423 #include "tnl_dd/t_dd_tritmp.h"
425 #define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT| \
427 #define TAG(x) x##_twoside_offset_unfilled_fallback
428 #include "tnl_dd/t_dd_tritmp.h"
431 /* Fx doesn't support provoking-vertex flat-shading?
433 #define IND (FX_FLAT_BIT)
434 #define TAG(x) x##_flat
435 #include "tnl_dd/t_dd_tritmp.h"
437 #define IND (FX_OFFSET_BIT|FX_FLAT_BIT)
438 #define TAG(x) x##_offset_flat
439 #include "tnl_dd/t_dd_tritmp.h"
441 #define IND (FX_TWOSIDE_BIT|FX_FLAT_BIT)
442 #define TAG(x) x##_twoside_flat
443 #include "tnl_dd/t_dd_tritmp.h"
445 #define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_FLAT_BIT)
446 #define TAG(x) x##_twoside_offset_flat
447 #include "tnl_dd/t_dd_tritmp.h"
449 #define IND (FX_UNFILLED_BIT|FX_FLAT_BIT)
450 #define TAG(x) x##_unfilled_flat
451 #include "tnl_dd/t_dd_tritmp.h"
453 #define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FLAT_BIT)
454 #define TAG(x) x##_offset_unfilled_flat
455 #include "tnl_dd/t_dd_tritmp.h"
457 #define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT|FX_FLAT_BIT)
458 #define TAG(x) x##_twoside_unfilled_flat
459 #include "tnl_dd/t_dd_tritmp.h"
461 #define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FLAT_BIT)
462 #define TAG(x) x##_twoside_offset_unfilled_flat
463 #include "tnl_dd/t_dd_tritmp.h"
465 #define IND (FX_FALLBACK_BIT|FX_FLAT_BIT)
466 #define TAG(x) x##_fallback_flat
467 #include "tnl_dd/t_dd_tritmp.h"
469 #define IND (FX_OFFSET_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT)
470 #define TAG(x) x##_offset_fallback_flat
471 #include "tnl_dd/t_dd_tritmp.h"
473 #define IND (FX_TWOSIDE_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT)
474 #define TAG(x) x##_twoside_fallback_flat
475 #include "tnl_dd/t_dd_tritmp.h"
477 #define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT)
478 #define TAG(x) x##_twoside_offset_fallback_flat
479 #include "tnl_dd/t_dd_tritmp.h"
481 #define IND (FX_UNFILLED_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT)
482 #define TAG(x) x##_unfilled_fallback_flat
483 #include "tnl_dd/t_dd_tritmp.h"
485 #define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT)
486 #define TAG(x) x##_offset_unfilled_fallback_flat
487 #include "tnl_dd/t_dd_tritmp.h"
489 #define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT)
490 #define TAG(x) x##_twoside_unfilled_fallback_flat
491 #include "tnl_dd/t_dd_tritmp.h"
493 #define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT| \
494 FX_FALLBACK_BIT|FX_FLAT_BIT)
495 #define TAG(x) x##_twoside_offset_unfilled_fallback_flat
496 #include "tnl_dd/t_dd_tritmp.h"
499 static void init_rast_tab( void )
504 init_twoside_offset();
506 init_offset_unfilled();
507 init_twoside_unfilled();
508 init_twoside_offset_unfilled();
510 init_offset_fallback();
511 init_twoside_fallback();
512 init_twoside_offset_fallback();
513 init_unfilled_fallback();
514 init_offset_unfilled_fallback();
515 init_twoside_unfilled_fallback();
516 init_twoside_offset_unfilled_fallback();
521 init_twoside_offset_flat();
522 init_unfilled_flat();
523 init_offset_unfilled_flat();
524 init_twoside_unfilled_flat();
525 init_twoside_offset_unfilled_flat();
526 init_fallback_flat();
527 init_offset_fallback_flat();
528 init_twoside_fallback_flat();
529 init_twoside_offset_fallback_flat();
530 init_unfilled_fallback_flat();
531 init_offset_unfilled_fallback_flat();
532 init_twoside_unfilled_fallback_flat();
533 init_twoside_offset_unfilled_fallback_flat();
538 /**********************************************************************/
539 /* Render whole (indexed) begin/end objects */
540 /**********************************************************************/
543 #define VERT(x) (vertptr + x)
545 #define RENDER_POINTS( start, count ) \
546 for ( ; start < count ; start++) \
547 grDrawPoint( VERT(ELT(start)) );
549 #define RENDER_LINE( v0, v1 ) \
550 grDrawLine( VERT(v0), VERT(v1) )
552 #define RENDER_TRI( v0, v1, v2 ) \
553 grDrawTriangle( VERT(v0), VERT(v1), VERT(v2) )
555 #define RENDER_QUAD( v0, v1, v2, v3 ) \
556 fx_draw_quad( fxMesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )
558 #define INIT(x) fxRenderPrimitive( ctx, x )
562 fxMesaContext fxMesa = FX_CONTEXT(ctx); \
563 GrVertex *vertptr = fxMesa->verts; \
564 const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
567 #define RESET_STIPPLE
568 #define RESET_OCCLUSION
569 #define PRESERVE_VB_DEFS
571 /* Elts, no clipping.
575 #define TAG(x) fx_##x##_elts
576 #define ELT(x) elt[x]
577 #include "tnl_dd/t_dd_rendertmp.h"
579 /* Verts, no clipping.
583 #define TAG(x) fx_##x##_verts
585 #include "tnl_dd/t_dd_rendertmp.h"
589 /**********************************************************************/
590 /* Render clipped primitives */
591 /**********************************************************************/
595 static void fxRenderClippedPoly( GLcontext
*ctx
, const GLuint
*elts
,
598 fxMesaContext fxMesa
= FX_CONTEXT(ctx
);
599 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
600 struct vertex_buffer
*VB
= &tnl
->vb
;
601 GLuint prim
= fxMesa
->render_primitive
;
603 /* Render the new vertices as an unclipped polygon.
606 GLuint
*tmp
= VB
->Elts
;
607 VB
->Elts
= (GLuint
*)elts
;
608 tnl
->Driver
.Render
.PrimTabElts
[GL_POLYGON
]( ctx
, 0, n
,
609 PRIM_BEGIN
|PRIM_END
);
613 /* Restore the render primitive
615 if (prim
!= GL_POLYGON
)
616 tnl
->Driver
.Render
.PrimitiveNotify( ctx
, prim
);
620 static void fxFastRenderClippedPoly( GLcontext
*ctx
, const GLuint
*elts
,
623 fxMesaContext fxMesa
= FX_CONTEXT( ctx
);
624 GrVertex
*vertptr
= fxMesa
->verts
;
625 const GrVertex
*start
= VERT(elts
[0]);
627 for (i
= 2 ; i
< n
; i
++) {
628 grDrawTriangle( start
, VERT(elts
[i
-1]), VERT(elts
[i
]) );
632 /**********************************************************************/
633 /* Choose render functions */
634 /**********************************************************************/
637 #define POINT_FALLBACK (DD_POINT_SMOOTH)
638 #define LINE_FALLBACK (DD_LINE_STIPPLE)
639 #define TRI_FALLBACK (DD_TRI_SMOOTH | DD_TRI_STIPPLE)
640 #define ANY_FALLBACK_FLAGS (POINT_FALLBACK | LINE_FALLBACK | TRI_FALLBACK)
641 #define ANY_RASTER_FLAGS (DD_FLATSHADE | DD_TRI_LIGHT_TWOSIDE | DD_TRI_OFFSET \
646 void fxDDChooseRenderState(GLcontext
*ctx
)
648 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
649 fxMesaContext fxMesa
= FX_CONTEXT(ctx
);
650 GLuint flags
= ctx
->_TriangleCaps
;
653 /* fprintf(stderr, "%s\n", __FUNCTION__); */
655 if (flags
& (ANY_FALLBACK_FLAGS
|ANY_RASTER_FLAGS
)) {
656 if (flags
& ANY_RASTER_FLAGS
) {
657 if (flags
& DD_TRI_LIGHT_TWOSIDE
) index
|= FX_TWOSIDE_BIT
;
658 if (flags
& DD_TRI_OFFSET
) index
|= FX_OFFSET_BIT
;
659 if (flags
& DD_TRI_UNFILLED
) index
|= FX_UNFILLED_BIT
;
660 if (flags
& DD_FLATSHADE
) index
|= FX_FLAT_BIT
;
663 fxMesa
->draw_point
= fx_draw_point
;
664 fxMesa
->draw_line
= fx_draw_line
;
665 fxMesa
->draw_tri
= fx_draw_triangle
;
667 /* Hook in fallbacks for specific primitives.
671 if (flags
& (POINT_FALLBACK
|
675 if (flags
& POINT_FALLBACK
)
676 fxMesa
->draw_point
= fx_fallback_point
;
678 if (flags
& LINE_FALLBACK
)
679 fxMesa
->draw_line
= fx_fallback_line
;
681 if (flags
& TRI_FALLBACK
) {
682 /* fprintf(stderr, "tri fallback\n"); */
683 fxMesa
->draw_tri
= fx_fallback_tri
;
686 index
|= FX_FALLBACK_BIT
;
690 /* fprintf(stderr, "render index %x\n", index); */
692 tnl
->Driver
.Render
.Points
= rast_tab
[index
].points
;
693 tnl
->Driver
.Render
.Line
= rast_tab
[index
].line
;
694 tnl
->Driver
.Render
.ClippedLine
= rast_tab
[index
].line
;
695 tnl
->Driver
.Render
.Triangle
= rast_tab
[index
].triangle
;
696 tnl
->Driver
.Render
.Quad
= rast_tab
[index
].quad
;
699 tnl
->Driver
.Render
.PrimTabVerts
= fx_render_tab_verts
;
700 tnl
->Driver
.Render
.PrimTabElts
= fx_render_tab_elts
;
701 tnl
->Driver
.Render
.ClippedPolygon
= fxFastRenderClippedPoly
;
703 tnl
->Driver
.Render
.ClippedPolygon
= fxRenderClippedPoly
;
706 tnl
->Driver
.Render
.PrimTabVerts
= _tnl_render_tab_verts
;
707 tnl
->Driver
.Render
.PrimTabElts
= _tnl_render_tab_elts
;
708 tnl
->Driver
.Render
.ClippedPolygon
= fxRenderClippedPoly
;
713 /**********************************************************************/
714 /* Runtime render state and callbacks */
715 /**********************************************************************/
718 static GLenum reduced_prim
[GL_POLYGON
+1] = {
733 /* Always called between RenderStart and RenderFinish --> We already
736 static void fxRasterPrimitive( GLcontext
*ctx
, GLenum prim
)
738 fxMesaContext fxMesa
= FX_CONTEXT( ctx
);
740 fxMesa
->raster_primitive
= prim
;
741 if (prim
== GL_TRIANGLES
)
742 grCullMode( fxMesa
->cullMode
);
744 grCullMode( GR_CULL_DISABLE
);
749 /* Determine the rasterized primitive when not drawing unfilled
752 static void fxRenderPrimitive( GLcontext
*ctx
, GLenum prim
)
754 fxMesaContext fxMesa
= FX_CONTEXT(ctx
);
755 GLuint rprim
= reduced_prim
[prim
];
757 fxMesa
->render_primitive
= prim
;
759 if (rprim
== GL_TRIANGLES
&& (ctx
->_TriangleCaps
& DD_TRI_UNFILLED
))
762 if (fxMesa
->raster_primitive
!= rprim
) {
763 fxRasterPrimitive( ctx
, rprim
);
769 /**********************************************************************/
770 /* Manage total rasterization fallbacks */
771 /**********************************************************************/
774 void fxCheckIsInHardware( GLcontext
*ctx
)
776 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
777 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
778 GLuint oldfallback
= !fxMesa
->is_in_hardware
;
781 fxMesa
->is_in_hardware
= fx_check_IsInHardware( ctx
);
782 newfallback
= !fxMesa
->is_in_hardware
;
785 if (oldfallback
== 0) {
786 /* fprintf(stderr, "goint to fallback\n"); */
787 _swsetup_Wakeup( ctx
);
792 /* fprintf(stderr, "leaving fallback\n"); */
793 _swrast_flush( ctx
);
794 tnl
->Driver
.Render
.Start
= fxCheckTexSizes
;
795 tnl
->Driver
.Render
.Finish
= _swrast_flush
;
796 tnl
->Driver
.Render
.PrimitiveNotify
= fxRenderPrimitive
;
797 tnl
->Driver
.Render
.ClippedPolygon
= _tnl_RenderClippedPolygon
;
798 tnl
->Driver
.Render
.ClippedLine
= _tnl_RenderClippedLine
;
799 tnl
->Driver
.Render
.PrimTabVerts
= _tnl_render_tab_verts
;
800 tnl
->Driver
.Render
.PrimTabElts
= _tnl_render_tab_elts
;
801 tnl
->Driver
.Render
.ResetLineStipple
= _swrast_ResetLineStipple
;
802 tnl
->Driver
.Render
.BuildVertices
= fxBuildVertices
;
803 tnl
->Driver
.Render
.Multipass
= 0;
804 fxChooseVertexState(ctx
);
805 fxDDChooseRenderState(ctx
);
810 void fxDDInitTriFuncs( GLcontext
*ctx
)
812 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
813 static int firsttime
= 1;
820 tnl
->Driver
.Render
.Start
= fxCheckTexSizes
;
821 tnl
->Driver
.Render
.Finish
= _swrast_flush
;
822 tnl
->Driver
.Render
.PrimitiveNotify
= fxRenderPrimitive
;
823 tnl
->Driver
.Render
.ClippedPolygon
= _tnl_RenderClippedPolygon
;
824 tnl
->Driver
.Render
.ClippedLine
= _tnl_RenderClippedLine
;
825 tnl
->Driver
.Render
.PrimTabVerts
= _tnl_render_tab_verts
;
826 tnl
->Driver
.Render
.PrimTabElts
= _tnl_render_tab_elts
;
827 tnl
->Driver
.Render
.ResetLineStipple
= _swrast_ResetLineStipple
;
828 tnl
->Driver
.Render
.BuildVertices
= fxBuildVertices
;
829 tnl
->Driver
.Render
.Multipass
= 0;
831 (void) fx_print_vertex
;
839 * Need this to provide at least one external definition.
842 extern int gl_fx_dummy_function_tris(void);
844 gl_fx_dummy_function_tris(void)