1 /* -*- mode: c; c-basic-offset: 3 -*-
3 * Copyright 2000 VA Linux Systems Inc., Fremont, California.
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 (including the next
15 * paragraph) shall be included in all copies or substantial portions of the
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * VA LINUX SYSTEMS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
23 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 /* $XFree86: xc/lib/GL/mesa/src/drv/fx/fxtris.c,v 1.5 2000/09/24 13:51:04 alanh Exp $ */
29 * Keith Whitwell <keithw@valinux.com>
42 #include "swrast/swrast.h"
43 #include "swrast_setup/swrast_setup.h"
44 #include "tnl/t_context.h"
45 #include "tnl/t_pipeline.h"
51 * Subpixel offsets to adjust Mesa's (true) window coordinates to
52 * Glide coordinates. We need these to ensure precise rasterization.
53 * Otherwise, we'll fail a bunch of conformance tests.
55 #define TRI_X_OFFSET ( 0.0F)
56 #define TRI_Y_OFFSET ( 0.0F)
57 #define LINE_X_OFFSET ( 0.0F)
58 #define LINE_Y_OFFSET ( 0.125F)
59 #define PNT_X_OFFSET ( 0.375F)
60 #define PNT_Y_OFFSET ( 0.375F)
62 static void fxRasterPrimitive( GLcontext
*ctx
, GLenum prim
);
63 static void fxRenderPrimitive( GLcontext
*ctx
, GLenum prim
);
65 /***********************************************************************
66 * Macros for t_dd_tritmp.h to draw basic primitives *
67 ***********************************************************************/
69 #define TRI( a, b, c ) \
72 fxMesa->draw_tri( fxMesa, a, b, c ); \
74 grDrawTriangle( a, b, c ); \
77 #define QUAD( a, b, c, d ) \
80 fxMesa->draw_tri( fxMesa, a, b, d ); \
81 fxMesa->draw_tri( fxMesa, b, c, d ); \
83 grDrawTriangle( a, b, d ); \
84 grDrawTriangle( b, c, d ); \
88 #define LINE( v0, v1 ) \
91 fxMesa->draw_line( fxMesa, v0, v1 ); \
93 v0->x += LINE_X_OFFSET - TRI_X_OFFSET; \
94 v0->y += LINE_Y_OFFSET - TRI_Y_OFFSET; \
95 v1->x += LINE_X_OFFSET - TRI_X_OFFSET; \
96 v1->y += LINE_Y_OFFSET - TRI_Y_OFFSET; \
97 grDrawLine( v0, v1 ); \
98 v0->x -= LINE_X_OFFSET - TRI_X_OFFSET; \
99 v0->y -= LINE_Y_OFFSET - TRI_Y_OFFSET; \
100 v1->x -= LINE_X_OFFSET - TRI_X_OFFSET; \
101 v1->y -= LINE_Y_OFFSET - TRI_Y_OFFSET; \
105 #define POINT( v0 ) \
108 fxMesa->draw_point( fxMesa, v0 ); \
110 v0->x += PNT_X_OFFSET - TRI_X_OFFSET; \
111 v0->y += PNT_Y_OFFSET - TRI_Y_OFFSET; \
113 v0->x -= PNT_X_OFFSET - TRI_X_OFFSET; \
114 v0->y -= PNT_Y_OFFSET - TRI_Y_OFFSET; \
119 /***********************************************************************
120 * Fallback to swrast for basic primitives *
121 ***********************************************************************/
123 /* Build an SWvertex from a hardware vertex.
125 * This code is hit only when a mix of accelerated and unaccelerated
126 * primitives are being drawn, and only for the unaccelerated
130 fx_translate_vertex( GLcontext
*ctx
, const GrVertex
*src
, SWvertex
*dst
)
132 fxMesaContext fxMesa
= FX_CONTEXT(ctx
);
133 GLuint ts0
= fxMesa
->tmu_source
[0];
134 GLuint ts1
= fxMesa
->tmu_source
[1];
135 GLfloat w
= 1.0 / src
->oow
;
137 dst
->win
[0] = src
->x
;
138 dst
->win
[1] = src
->y
;
139 dst
->win
[2] = src
->ooz
;
140 dst
->win
[3] = src
->oow
;
142 dst
->color
[0] = (GLubyte
) src
->r
;
143 dst
->color
[1] = (GLubyte
) src
->g
;
144 dst
->color
[2] = (GLubyte
) src
->b
;
145 dst
->color
[3] = (GLubyte
) src
->a
;
147 dst
->texcoord
[ts0
][0] = fxMesa
->inv_s0scale
* src
->tmuvtx
[0].sow
* w
;
148 dst
->texcoord
[ts0
][1] = fxMesa
->inv_t0scale
* src
->tmuvtx
[0].tow
* w
;
150 if (fxMesa
->stw_hint_state
& GR_STWHINT_W_DIFF_TMU0
)
151 dst
->texcoord
[ts0
][3] = src
->tmuvtx
[0].oow
* w
;
153 dst
->texcoord
[ts0
][3] = 1.0;
155 if (fxMesa
->SetupIndex
& SETUP_TMU1
) {
156 dst
->texcoord
[ts1
][0] = fxMesa
->inv_s1scale
* src
->tmuvtx
[1].sow
* w
;
157 dst
->texcoord
[ts1
][1] = fxMesa
->inv_t1scale
* src
->tmuvtx
[1].tow
* w
;
159 if (fxMesa
->stw_hint_state
& GR_STWHINT_W_DIFF_TMU1
)
160 dst
->texcoord
[ts1
][3] = src
->tmuvtx
[1].oow
* w
;
162 dst
->texcoord
[ts1
][3] = 1.0;
165 dst
->pointSize
= ctx
->Point
._Size
;
170 fx_fallback_tri( fxMesaContext fxMesa
,
175 GLcontext
*ctx
= fxMesa
->glCtx
;
177 fx_translate_vertex( ctx
, v0
, &v
[0] );
178 fx_translate_vertex( ctx
, v1
, &v
[1] );
179 fx_translate_vertex( ctx
, v2
, &v
[2] );
180 _swrast_Triangle( ctx
, &v
[0], &v
[1], &v
[2] );
185 fx_fallback_line( fxMesaContext fxMesa
,
189 GLcontext
*ctx
= fxMesa
->glCtx
;
191 fx_translate_vertex( ctx
, v0
, &v
[0] );
192 fx_translate_vertex( ctx
, v1
, &v
[1] );
193 _swrast_Line( ctx
, &v
[0], &v
[1] );
198 fx_fallback_point( fxMesaContext fxMesa
,
201 GLcontext
*ctx
= fxMesa
->glCtx
;
203 fx_translate_vertex( ctx
, v0
, &v
[0] );
204 _swrast_Point( ctx
, &v
[0] );
207 /***********************************************************************
208 * Functions to draw basic primitives *
209 ***********************************************************************/
211 static void fx_print_vertex( GLcontext
*ctx
, const GrVertex
*v
)
213 fprintf(stderr
, "vertex at %p\n", v
);
215 fprintf(stderr
, "x %f y %f z %f oow %f\n",
216 v
->x
, v
->y
, v
->ooz
, v
->oow
);
217 fprintf(stderr
, "r %f g %f b %f a %f\n",
223 fprintf(stderr
, "\n");
226 #define DO_FALLBACK 0
228 /* Need to do clip loop at each triangle when mixing swrast and hw
229 * rendering. These functions are only used when mixed-mode rendering
232 static void fx_draw_quad( fxMesaContext fxMesa
,
238 QUAD( v0
, v1
, v2
, v3
);
241 static void fx_draw_triangle( fxMesaContext fxMesa
,
249 static void fx_draw_line( fxMesaContext fxMesa
,
253 /* No support for wide lines (avoid wide/aa line fallback).
258 static void fx_draw_point( fxMesaContext fxMesa
,
261 /* No support for wide points.
269 #define FX_UNFILLED_BIT 0x1
270 #define FX_OFFSET_BIT 0x2
271 #define FX_TWOSIDE_BIT 0x4
272 #define FX_FLAT_BIT 0x8
273 #define FX_FALLBACK_BIT 0x10
274 #define FX_MAX_TRIFUNC 0x20
279 triangle_func triangle
;
281 } rast_tab
[FX_MAX_TRIFUNC
];
283 #define DO_FALLBACK (IND & FX_FALLBACK_BIT)
284 #define DO_OFFSET (IND & FX_OFFSET_BIT)
285 #define DO_UNFILLED (IND & FX_UNFILLED_BIT)
286 #define DO_TWOSIDE (IND & FX_TWOSIDE_BIT)
287 #define DO_FLAT (IND & FX_FLAT_BIT)
292 #define DO_FULL_QUAD 1
296 #define HAVE_HW_FLATSHADE 0
297 #define HAVE_BACK_COLORS 0
298 #define VERTEX GrVertex
301 #define DEPTH_SCALE 1.0
302 #define UNFILLED_TRI unfilled_tri
303 #define UNFILLED_QUAD unfilled_quad
304 #define VERT_X(_v) _v->x
305 #define VERT_Y(_v) _v->y
306 #define VERT_Z(_v) _v->ooz
307 #define AREA_IS_CCW( a ) (a < 0)
308 #define GET_VERTEX(e) (fxMesa->verts + e)
310 #define VERT_SET_RGBA( dst, f ) \
312 dst->r = (GLfloat)f[0]; \
313 dst->g = (GLfloat)f[1]; \
314 dst->b = (GLfloat)f[2]; \
315 dst->a = (GLfloat)f[3]; \
318 #define VERT_COPY_RGBA( v0, v1 ) \
326 #define VERT_SAVE_RGBA( idx ) \
328 color[idx][0] = v[idx]->r; \
329 color[idx][1] = v[idx]->g; \
330 color[idx][1] = v[idx]->b; \
331 color[idx][3] = v[idx]->a; \
335 #define VERT_RESTORE_RGBA( idx ) \
337 v[idx]->r = color[idx][0]; \
338 v[idx]->g = color[idx][1]; \
339 v[idx]->b = color[idx][2]; \
340 v[idx]->a = color[idx][3]; \
344 #define LOCAL_VARS(n) \
345 fxMesaContext fxMesa = FX_CONTEXT(ctx); \
346 GLfloat color[n][4]; \
351 /***********************************************************************
352 * Functions to draw basic unfilled primitives *
353 ***********************************************************************/
355 #define RASTERIZE(x) if (fxMesa->raster_primitive != x) \
356 fxRasterPrimitive( ctx, x )
357 #define RENDER_PRIMITIVE fxMesa->render_primitive
358 #define IND FX_FALLBACK_BIT
360 #include "tnl_dd/t_dd_unfilled.h"
363 /***********************************************************************
364 * Functions to draw GL primitives *
365 ***********************************************************************/
369 #include "tnl_dd/t_dd_tritmp.h"
371 #define IND (FX_OFFSET_BIT)
372 #define TAG(x) x##_offset
373 #include "tnl_dd/t_dd_tritmp.h"
375 #define IND (FX_TWOSIDE_BIT)
376 #define TAG(x) x##_twoside
377 #include "tnl_dd/t_dd_tritmp.h"
379 #define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT)
380 #define TAG(x) x##_twoside_offset
381 #include "tnl_dd/t_dd_tritmp.h"
383 #define IND (FX_UNFILLED_BIT)
384 #define TAG(x) x##_unfilled
385 #include "tnl_dd/t_dd_tritmp.h"
387 #define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT)
388 #define TAG(x) x##_offset_unfilled
389 #include "tnl_dd/t_dd_tritmp.h"
391 #define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT)
392 #define TAG(x) x##_twoside_unfilled
393 #include "tnl_dd/t_dd_tritmp.h"
395 #define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT)
396 #define TAG(x) x##_twoside_offset_unfilled
397 #include "tnl_dd/t_dd_tritmp.h"
399 #define IND (FX_FALLBACK_BIT)
400 #define TAG(x) x##_fallback
401 #include "tnl_dd/t_dd_tritmp.h"
403 #define IND (FX_OFFSET_BIT|FX_FALLBACK_BIT)
404 #define TAG(x) x##_offset_fallback
405 #include "tnl_dd/t_dd_tritmp.h"
407 #define IND (FX_TWOSIDE_BIT|FX_FALLBACK_BIT)
408 #define TAG(x) x##_twoside_fallback
409 #include "tnl_dd/t_dd_tritmp.h"
411 #define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_FALLBACK_BIT)
412 #define TAG(x) x##_twoside_offset_fallback
413 #include "tnl_dd/t_dd_tritmp.h"
415 #define IND (FX_UNFILLED_BIT|FX_FALLBACK_BIT)
416 #define TAG(x) x##_unfilled_fallback
417 #include "tnl_dd/t_dd_tritmp.h"
419 #define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT)
420 #define TAG(x) x##_offset_unfilled_fallback
421 #include "tnl_dd/t_dd_tritmp.h"
423 #define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT)
424 #define TAG(x) x##_twoside_unfilled_fallback
425 #include "tnl_dd/t_dd_tritmp.h"
427 #define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT| \
429 #define TAG(x) x##_twoside_offset_unfilled_fallback
430 #include "tnl_dd/t_dd_tritmp.h"
433 /* Fx doesn't support provoking-vertex flat-shading?
435 #define IND (FX_FLAT_BIT)
436 #define TAG(x) x##_flat
437 #include "tnl_dd/t_dd_tritmp.h"
439 #define IND (FX_OFFSET_BIT|FX_FLAT_BIT)
440 #define TAG(x) x##_offset_flat
441 #include "tnl_dd/t_dd_tritmp.h"
443 #define IND (FX_TWOSIDE_BIT|FX_FLAT_BIT)
444 #define TAG(x) x##_twoside_flat
445 #include "tnl_dd/t_dd_tritmp.h"
447 #define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_FLAT_BIT)
448 #define TAG(x) x##_twoside_offset_flat
449 #include "tnl_dd/t_dd_tritmp.h"
451 #define IND (FX_UNFILLED_BIT|FX_FLAT_BIT)
452 #define TAG(x) x##_unfilled_flat
453 #include "tnl_dd/t_dd_tritmp.h"
455 #define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FLAT_BIT)
456 #define TAG(x) x##_offset_unfilled_flat
457 #include "tnl_dd/t_dd_tritmp.h"
459 #define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT|FX_FLAT_BIT)
460 #define TAG(x) x##_twoside_unfilled_flat
461 #include "tnl_dd/t_dd_tritmp.h"
463 #define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FLAT_BIT)
464 #define TAG(x) x##_twoside_offset_unfilled_flat
465 #include "tnl_dd/t_dd_tritmp.h"
467 #define IND (FX_FALLBACK_BIT|FX_FLAT_BIT)
468 #define TAG(x) x##_fallback_flat
469 #include "tnl_dd/t_dd_tritmp.h"
471 #define IND (FX_OFFSET_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT)
472 #define TAG(x) x##_offset_fallback_flat
473 #include "tnl_dd/t_dd_tritmp.h"
475 #define IND (FX_TWOSIDE_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT)
476 #define TAG(x) x##_twoside_fallback_flat
477 #include "tnl_dd/t_dd_tritmp.h"
479 #define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT)
480 #define TAG(x) x##_twoside_offset_fallback_flat
481 #include "tnl_dd/t_dd_tritmp.h"
483 #define IND (FX_UNFILLED_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT)
484 #define TAG(x) x##_unfilled_fallback_flat
485 #include "tnl_dd/t_dd_tritmp.h"
487 #define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT)
488 #define TAG(x) x##_offset_unfilled_fallback_flat
489 #include "tnl_dd/t_dd_tritmp.h"
491 #define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT)
492 #define TAG(x) x##_twoside_unfilled_fallback_flat
493 #include "tnl_dd/t_dd_tritmp.h"
495 #define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT| \
496 FX_FALLBACK_BIT|FX_FLAT_BIT)
497 #define TAG(x) x##_twoside_offset_unfilled_fallback_flat
498 #include "tnl_dd/t_dd_tritmp.h"
501 static void init_rast_tab( void )
506 init_twoside_offset();
508 init_offset_unfilled();
509 init_twoside_unfilled();
510 init_twoside_offset_unfilled();
512 init_offset_fallback();
513 init_twoside_fallback();
514 init_twoside_offset_fallback();
515 init_unfilled_fallback();
516 init_offset_unfilled_fallback();
517 init_twoside_unfilled_fallback();
518 init_twoside_offset_unfilled_fallback();
523 init_twoside_offset_flat();
524 init_unfilled_flat();
525 init_offset_unfilled_flat();
526 init_twoside_unfilled_flat();
527 init_twoside_offset_unfilled_flat();
528 init_fallback_flat();
529 init_offset_fallback_flat();
530 init_twoside_fallback_flat();
531 init_twoside_offset_fallback_flat();
532 init_unfilled_fallback_flat();
533 init_offset_unfilled_fallback_flat();
534 init_twoside_unfilled_fallback_flat();
535 init_twoside_offset_unfilled_fallback_flat();
540 /**********************************************************************/
541 /* Render whole (indexed) begin/end objects */
542 /**********************************************************************/
545 #define VERT(x) (vertptr + x)
547 #define RENDER_POINTS( start, count ) \
548 for ( ; start < count ; start++) \
549 grDrawPoint( VERT(ELT(start)) );
551 #define RENDER_LINE( v0, v1 ) \
552 grDrawLine( VERT(v0), VERT(v1) )
554 #define RENDER_TRI( v0, v1, v2 ) \
555 grDrawTriangle( VERT(v0), VERT(v1), VERT(v2) )
557 #define RENDER_QUAD( v0, v1, v2, v3 ) \
558 fx_draw_quad( fxMesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )
560 #define INIT(x) fxRenderPrimitive( ctx, x )
564 fxMesaContext fxMesa = FX_CONTEXT(ctx); \
565 GrVertex *vertptr = fxMesa->verts; \
566 const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
569 #define RESET_STIPPLE
570 #define RESET_OCCLUSION
571 #define PRESERVE_VB_DEFS
573 /* Elts, no clipping.
577 #define TAG(x) fx_##x##_elts
578 #define ELT(x) elt[x]
579 #include "tnl_dd/t_dd_rendertmp.h"
581 /* Verts, no clipping.
585 #define TAG(x) fx_##x##_verts
587 #include "tnl_dd/t_dd_rendertmp.h"
591 /**********************************************************************/
592 /* Render clipped primitives */
593 /**********************************************************************/
597 static void fxRenderClippedPoly( GLcontext
*ctx
, const GLuint
*elts
,
600 fxMesaContext fxMesa
= FX_CONTEXT(ctx
);
601 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
602 struct vertex_buffer
*VB
= &tnl
->vb
;
603 GLuint prim
= fxMesa
->render_primitive
;
605 /* Render the new vertices as an unclipped polygon.
608 GLuint
*tmp
= VB
->Elts
;
609 VB
->Elts
= (GLuint
*)elts
;
610 tnl
->Driver
.Render
.PrimTabElts
[GL_POLYGON
]( ctx
, 0, n
,
611 PRIM_BEGIN
|PRIM_END
);
615 /* Restore the render primitive
617 if (prim
!= GL_POLYGON
)
618 tnl
->Driver
.Render
.PrimitiveNotify( ctx
, prim
);
622 static void fxFastRenderClippedPoly( GLcontext
*ctx
, const GLuint
*elts
,
625 fxMesaContext fxMesa
= FX_CONTEXT( ctx
);
626 GrVertex
*vertptr
= fxMesa
->verts
;
627 const GrVertex
*start
= VERT(elts
[0]);
630 for (i
= 2 ; i
< n
; i
++) {
631 grDrawTriangle( start
, VERT(elts
[i
-1]), VERT(elts
[i
]) );
635 /**********************************************************************/
636 /* Choose render functions */
637 /**********************************************************************/
640 #define POINT_FALLBACK (DD_POINT_SMOOTH)
641 #define LINE_FALLBACK (DD_LINE_STIPPLE)
642 #define TRI_FALLBACK (DD_TRI_SMOOTH)
643 #define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK|DD_TRI_STIPPLE)
644 #define ANY_RASTER_FLAGS (DD_FLATSHADE|DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET| \
649 static void fxChooseRenderState(GLcontext
*ctx
)
651 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
652 fxMesaContext fxMesa
= FX_CONTEXT(ctx
);
653 GLuint flags
= ctx
->_TriangleCaps
;
656 /* fprintf(stderr, "%s\n", __FUNCTION__); */
658 if (flags
& (ANY_FALLBACK_FLAGS
|ANY_RASTER_FLAGS
)) {
659 if (flags
& ANY_RASTER_FLAGS
) {
660 if (flags
& DD_TRI_LIGHT_TWOSIDE
) index
|= FX_TWOSIDE_BIT
;
661 if (flags
& DD_TRI_OFFSET
) index
|= FX_OFFSET_BIT
;
662 if (flags
& DD_TRI_UNFILLED
) index
|= FX_UNFILLED_BIT
;
663 if (flags
& DD_FLATSHADE
) index
|= FX_FLAT_BIT
;
666 fxMesa
->draw_point
= fx_draw_point
;
667 fxMesa
->draw_line
= fx_draw_line
;
668 fxMesa
->draw_tri
= fx_draw_triangle
;
670 /* Hook in fallbacks for specific primitives.
674 if (flags
& (POINT_FALLBACK
|
678 if (flags
& POINT_FALLBACK
)
679 fxMesa
->draw_point
= fx_fallback_point
;
681 if (flags
& LINE_FALLBACK
)
682 fxMesa
->draw_line
= fx_fallback_line
;
684 if (flags
& TRI_FALLBACK
)
685 fxMesa
->draw_tri
= fx_fallback_tri
;
687 index
|= FX_FALLBACK_BIT
;
691 tnl
->Driver
.Render
.Points
= rast_tab
[index
].points
;
692 tnl
->Driver
.Render
.Line
= rast_tab
[index
].line
;
693 tnl
->Driver
.Render
.ClippedLine
= rast_tab
[index
].line
;
694 tnl
->Driver
.Render
.Triangle
= rast_tab
[index
].triangle
;
695 tnl
->Driver
.Render
.Quad
= rast_tab
[index
].quad
;
698 tnl
->Driver
.Render
.PrimTabVerts
= fx_render_tab_verts
;
699 tnl
->Driver
.Render
.PrimTabElts
= fx_render_tab_elts
;
700 tnl
->Driver
.Render
.ClippedPolygon
= fxFastRenderClippedPoly
;
702 tnl
->Driver
.Render
.PrimTabVerts
= _tnl_render_tab_verts
;
703 tnl
->Driver
.Render
.PrimTabElts
= _tnl_render_tab_elts
;
704 tnl
->Driver
.Render
.ClippedPolygon
= fxRenderClippedPoly
;
708 /**********************************************************************/
709 /* Runtime render state and callbacks */
710 /**********************************************************************/
713 static GLenum reduced_prim
[GL_POLYGON
+1] = {
728 /* Always called between RenderStart and RenderFinish --> We already
731 static void fxRasterPrimitive( GLcontext
*ctx
, GLenum prim
)
733 fxMesaContext fxMesa
= FX_CONTEXT( ctx
);
735 fxMesa
->raster_primitive
= prim
;
736 if (prim
== GL_TRIANGLES
)
737 grCullMode( fxMesa
->cullMode
);
739 grCullMode( GR_CULL_DISABLE
);
744 /* Determine the rasterized primitive when not drawing unfilled
747 static void fxRenderPrimitive( GLcontext
*ctx
, GLenum prim
)
749 fxMesaContext fxMesa
= FX_CONTEXT(ctx
);
750 GLuint rprim
= reduced_prim
[prim
];
752 fxMesa
->render_primitive
= prim
;
754 if (rprim
== GL_TRIANGLES
&& (ctx
->_TriangleCaps
& DD_TRI_UNFILLED
))
757 if (fxMesa
->raster_primitive
!= rprim
) {
758 fxRasterPrimitive( ctx
, rprim
);
764 /**********************************************************************/
765 /* Manage total rasterization fallbacks */
766 /**********************************************************************/
769 void fxCheckIsInHardware( GLcontext
*ctx
)
771 fxMesaContext fxMesa
= (fxMesaContext
) ctx
->DriverCtx
;
772 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
773 GLuint oldfallback
= !fxMesa
->is_in_hardware
;
776 fxMesa
->is_in_hardware
= check_IsInHardware( ctx
);
777 newfallback
= !fxMesa
->is_in_hardware
;
780 if (oldfallback
== 0) {
781 _swsetup_Wakeup( ctx
);
786 _swrast_flush( ctx
);
787 tnl
->Driver
.Render
.Start
= fxCheckTexSizes
;
788 tnl
->Driver
.Render
.Finish
= _swrast_flush
;
789 tnl
->Driver
.Render
.PrimitiveNotify
= fxRenderPrimitive
;
790 tnl
->Driver
.Render
.ClippedPolygon
= _tnl_RenderClippedPolygon
;
791 tnl
->Driver
.Render
.ClippedLine
= _tnl_RenderClippedLine
;
792 tnl
->Driver
.Render
.PrimTabVerts
= _tnl_render_tab_verts
;
793 tnl
->Driver
.Render
.PrimTabElts
= _tnl_render_tab_elts
;
794 tnl
->Driver
.Render
.ResetLineStipple
= _swrast_ResetLineStipple
;
795 tnl
->Driver
.Render
.BuildVertices
= fxBuildVertices
;
796 tnl
->Driver
.Render
.Multipass
= 0;
797 fxDDChooseSetupState(ctx
);
798 fxDDChooseRenderState(ctx
);
803 void fxDDInitTriFuncs( GLcontext
*ctx
)
805 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
806 fxMesaContext fxMesa
= FX_CONTEXT(ctx
);
807 static int firsttime
= 1;
814 tnl
->Driver
.Render
.Start
= fxCheckTexSizes
;
815 tnl
->Driver
.Render
.Finish
= _swrast_flush
;
816 tnl
->Driver
.Render
.PrimitiveNotify
= fxRenderPrimitive
;
817 tnl
->Driver
.Render
.ClippedPolygon
= _tnl_RenderClippedPolygon
;
818 tnl
->Driver
.Render
.ClippedLine
= _tnl_RenderClippedLine
;
819 tnl
->Driver
.Render
.PrimTabVerts
= _tnl_render_tab_verts
;
820 tnl
->Driver
.Render
.PrimTabElts
= _tnl_render_tab_elts
;
821 tnl
->Driver
.Render
.ResetLineStipple
= _swrast_ResetLineStipple
;
822 tnl
->Driver
.Render
.BuildVertices
= fxBuildVertices
;
823 tnl
->Driver
.Render
.Multipass
= 0;
825 (void) fx_print_vertex
;
832 * Need this to provide at least one external definition.
835 extern int gl_fx_dummy_function_tris(void);
837 gl_fx_dummy_function_tris(void)