2 * Author: Max Lingua <sunmax@libero.it>
10 #include "s3v_context.h"
14 #include "main/glheader.h"
15 #include "main/mtypes.h"
16 #include "main/macros.h"
17 #include "main/colormac.h"
19 #include "swrast/swrast.h"
20 #include "swrast_setup/swrast_setup.h"
22 #include "tnl/t_context.h"
23 #include "tnl/t_pipeline.h"
26 /***********************************************************************
27 * Build hardware rasterization functions *
28 ***********************************************************************/
33 #define HAVE_BACK_COLORS 0
34 #define HAVE_HW_FLATSHADE 1
35 #define VERTEX s3vVertex
38 #define VERT_SET_RGBA( v, c ) \
40 UNCLAMPED_FLOAT_TO_RGBA_CHAN( v->ub4[4], c); \
41 /* *(v->ub4[4]) = c; \ */ \
43 #define VERT_COPY_RGBA( v0, v1 ) v0->ui[4] = v1->ui[4]
45 #define VERT_COPY_RGBA1( v0, v1 ) v0->ui[4] = v1->ui[4]
47 #define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[4]
48 #define VERT_RESTORE_RGBA( idx ) v[idx]->ui[4] = color[idx]
50 #define S3V_OFFSET_BIT 0x01
51 #define S3V_TWOSIDE_BIT 0x02
52 #define S3V_UNFILLED_BIT 0x04
53 #define S3V_FALLBACK_BIT 0x08
54 #define S3V_MAX_TRIFUNC 0x10
58 tnl_points_func points
;
60 tnl_triangle_func triangle
;
62 } rast_tab
[S3V_MAX_TRIFUNC
];
64 #define S3V_RAST_CULL_BIT 0x01
65 #define S3V_RAST_FLAT_BIT 0x02
66 #define S3V_RAST_TEX_BIT 0x04
68 static s3v_point_func s3v_point_tab
[0x8];
69 static s3v_line_func s3v_line_tab
[0x8];
70 static s3v_tri_func s3v_tri_tab
[0x8];
71 static s3v_quad_func s3v_quad_tab
[0x8];
75 #include "s3v_tritmp.h"
77 #define IND (S3V_RAST_CULL_BIT)
78 #define TAG(x) x##_cull
79 #include "s3v_tritmp.h"
81 #define IND (S3V_RAST_FLAT_BIT)
82 #define TAG(x) x##_flat
83 #include "s3v_tritmp.h"
85 #define IND (S3V_RAST_CULL_BIT|S3V_RAST_FLAT_BIT)
86 #define TAG(x) x##_cull_flat
87 #include "s3v_tritmp.h"
89 #define IND (S3V_RAST_TEX_BIT)
90 #define TAG(x) x##_tex
91 #include "s3v_tritmp.h"
93 #define IND (S3V_RAST_CULL_BIT|S3V_RAST_TEX_BIT)
94 #define TAG(x) x##_cull_tex
95 #include "s3v_tritmp.h"
97 #define IND (S3V_RAST_FLAT_BIT|S3V_RAST_TEX_BIT)
98 #define TAG(x) x##_flat_tex
99 #include "s3v_tritmp.h"
101 #define IND (S3V_RAST_CULL_BIT|S3V_RAST_FLAT_BIT|S3V_RAST_TEX_BIT)
102 #define TAG(x) x##_cull_flat_tex
103 #include "s3v_tritmp.h"
105 static void init_rast_tab( void )
107 DEBUG(("*** init_rast_tab ***\n"));
112 s3v_init_cull_flat();
116 s3v_init_cull_flat_tex();
119 /***********************************************************************
120 * Rasterization fallback helpers *
121 ***********************************************************************/
124 /* This code is hit only when a mix of accelerated and unaccelerated
125 * primitives are being drawn, and only for the unaccelerated
131 s3v_fallback_quad( s3vContextPtr vmesa
,
135 const s3vVertex
*v3
)
137 GLcontext
*ctx
= vmesa
->glCtx
;
139 s3v_translate_vertex( ctx
, v0
, &v
[0] );
140 s3v_translate_vertex( ctx
, v1
, &v
[1] );
141 s3v_translate_vertex( ctx
, v2
, &v
[2] );
142 s3v_translate_vertex( ctx
, v3
, &v
[3] );
143 DEBUG(("s3v_fallback_quad\n"));
144 /* _swrast_Quad( ctx, &v[0], &v[1], &v[2], &v[3] ); */
148 s3v_fallback_tri( s3vContextPtr vmesa
,
151 const s3vVertex
*v2
)
153 GLcontext
*ctx
= vmesa
->glCtx
;
155 s3v_translate_vertex( ctx
, v0
, &v
[0] );
156 s3v_translate_vertex( ctx
, v1
, &v
[1] );
157 s3v_translate_vertex( ctx
, v2
, &v
[2] );
158 DEBUG(("s3v_fallback_tri\n"));
159 /* _swrast_Triangle( ctx, &v[0], &v[1], &v[2] ); */
163 s3v_fallback_line( s3vContextPtr vmesa
,
165 const s3vVertex
*v1
)
167 GLcontext
*ctx
= vmesa
->glCtx
;
169 s3v_translate_vertex( ctx
, v0
, &v
[0] );
170 s3v_translate_vertex( ctx
, v1
, &v
[1] );
171 DEBUG(("s3v_fallback_line\n"));
172 _swrast_Line( ctx
, &v
[0], &v
[1] );
177 s3v_fallback_point( s3vContextPtr vmesa,
178 const s3vVertex *v0 )
180 GLcontext *ctx = vmesa->glCtx;
182 s3v_translate_vertex( ctx, v0, &v[0] );
183 _swrast_Point( ctx, &v[0] );
188 /***********************************************************************
189 * Choose rasterization functions *
190 ***********************************************************************/
192 #define _S3V_NEW_RASTER_STATE (_NEW_FOG | \
194 _DD_NEW_TRI_SMOOTH | \
195 _DD_NEW_LINE_SMOOTH | \
196 _DD_NEW_POINT_SMOOTH | \
197 _DD_NEW_TRI_STIPPLE | \
198 _DD_NEW_LINE_STIPPLE)
200 #define LINE_FALLBACK (0)
201 #define TRI_FALLBACK (0)
203 static void s3v_nodraw_triangle(GLcontext
*ctx
, s3vVertex
*v0
,
204 s3vVertex
*v1
, s3vVertex
*v2
)
206 (void) (ctx
&& v0
&& v1
&& v2
);
209 static void s3v_nodraw_quad(GLcontext
*ctx
,
210 s3vVertex
*v0
, s3vVertex
*v1
,
211 s3vVertex
*v2
, s3vVertex
*v3
)
213 (void) (ctx
&& v0
&& v1
&& v2
&& v3
);
216 void s3vChooseRasterState(GLcontext
*ctx
);
218 void s3vChooseRasterState(GLcontext
*ctx
)
220 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
221 GLuint flags
= ctx
->_TriangleCaps
;
224 DEBUG(("*** s3vChooseRasterState ***\n"));
226 if (ctx
->Polygon
.CullFlag
) {
227 if (ctx
->Polygon
.CullFaceMode
== GL_FRONT_AND_BACK
) {
228 vmesa
->draw_tri
= (s3v_tri_func
)s3v_nodraw_triangle
;
229 vmesa
->draw_quad
= (s3v_quad_func
)s3v_nodraw_quad
;
232 ind
|= S3V_RAST_CULL_BIT
;
233 /* s3v_update_cullsign(ctx); */
234 } /* else vmesa->backface_sign = 0; */
236 if ( flags
& DD_FLATSHADE
)
237 ind
|= S3V_RAST_FLAT_BIT
;
239 if ( ctx
->Texture
.Unit
[0]._ReallyEnabled
) {
240 ind
|= S3V_RAST_TEX_BIT
;
243 DEBUG(("ind = %i\n", ind
));
245 vmesa
->draw_line
= s3v_line_tab
[ind
];
246 vmesa
->draw_tri
= s3v_tri_tab
[ind
];
247 vmesa
->draw_quad
= s3v_quad_tab
[ind
];
248 vmesa
->draw_point
= s3v_point_tab
[ind
];
251 /* Hook in fallbacks for specific primitives. CURRENTLY DISABLED
254 if (flags
& LINE_FALLBACK
)
255 vmesa
->draw_line
= s3v_fallback_line
;
257 if (flags
& TRI_FALLBACK
) {
258 DEBUG(("TRI_FALLBACK\n"));
259 vmesa
->draw_tri
= s3v_fallback_tri
;
260 vmesa
->draw_quad
= s3v_fallback_quad
;
268 /***********************************************************************
269 * Macros for t_dd_tritmp.h to draw basic primitives *
270 ***********************************************************************/
272 #define TRI( v0, v1, v2 ) \
276 vmesa->draw_tri( vmesa, v0, v1, v2 ); \
278 DEBUG(("TRI: max was here\n")); /* \
279 s3v_draw_tex_triangle( vmesa, v0, v1, v2 ); */ \
280 vmesa->draw_tri( vmesa, v0, v1, v2 ); \
283 #define QUAD( v0, v1, v2, v3 ) \
285 DEBUG(("QUAD: max was here\n")); \
286 vmesa->draw_quad( vmesa, v0, v1, v2, v3 ); \
289 #define LINE( v0, v1 ) \
291 DEBUG(("LINE: max was here\n")); \
292 vmesa->draw_line( vmesa, v0, v1 ); \
295 #define POINT( v0 ) \
297 vmesa->draw_point( vmesa, v0 ); \
301 /***********************************************************************
302 * Build render functions from dd templates *
303 ***********************************************************************/
306 #define S3V_OFFSET_BIT 0x01
307 #define S3V_TWOSIDE_BIT 0x02
308 #define S3V_UNFILLED_BIT 0x04
309 #define S3V_FALLBACK_BIT 0x08
310 #define S3V_MAX_TRIFUNC 0x10
316 triangle_func triangle;
318 } rast_tab[S3V_MAX_TRIFUNC];
321 #define DO_FALLBACK (IND & S3V_FALLBACK_BIT)
322 #define DO_OFFSET (IND & S3V_OFFSET_BIT)
323 #define DO_UNFILLED (IND & S3V_UNFILLED_BIT)
324 #define DO_TWOSIDE (IND & S3V_TWOSIDE_BIT)
330 #define DO_FULL_QUAD 1
334 #define HAVE_BACK_COLORS 0
335 #define HAVE_HW_FLATSHADE 1
336 #define VERTEX s3vVertex
339 #define DEPTH_SCALE 1.0
340 #define UNFILLED_TRI unfilled_tri
341 #define UNFILLED_QUAD unfilled_quad
342 #define VERT_X(_v) _v->v.x
343 #define VERT_Y(_v) _v->v.y
344 #define VERT_Z(_v) _v->v.z
345 #define AREA_IS_CCW( a ) (a > 0)
346 #define GET_VERTEX(e) (vmesa->verts + (e<<vmesa->vertex_stride_shift))
349 #define VERT_SET_RGBA( v, c ) \
351 /* UNCLAMPED_FLOAT_TO_RGBA_CHAN( v->ub4[4], c) */ \
354 #define VERT_COPY_RGBA( v0, v1 ) v0->ui[4] = v1->ui[4]
356 #define VERT_COPY_RGBA1( v0, v1 ) v0->ui[4] = v1->ui[4]
358 #define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[4]
359 #define VERT_RESTORE_RGBA( idx ) v[idx]->ui[4] = color[idx]
362 #define LOCAL_VARS(n) \
363 s3vContextPtr vmesa = S3V_CONTEXT(ctx); \
368 /***********************************************************************
369 * Helpers for rendering unfilled primitives *
370 ***********************************************************************/
372 static const GLuint hw_prim
[GL_POLYGON
+1] = {
385 static void s3vResetLineStipple( GLcontext
*ctx
);
386 static void s3vRasterPrimitive( GLcontext
*ctx
, GLuint hwprim
);
387 static void s3vRenderPrimitive( GLcontext
*ctx
, GLenum prim
);
389 extern static void s3v_lines_emit(GLcontext *ctx, GLuint start, GLuint end);
390 extern static void s3v_tris_emit(GLcontext *ctx, GLuint start, GLuint end);
392 #define RASTERIZE(x) if (vmesa->hw_primitive != hw_prim[x]) \
393 s3vRasterPrimitive( ctx, hw_prim[x] )
394 #define RENDER_PRIMITIVE vmesa->render_primitive
396 #define IND S3V_FALLBACK_BIT
397 #include "tnl_dd/t_dd_unfilled.h"
400 /***********************************************************************
401 * Generate GL render functions *
402 ***********************************************************************/
406 #include "tnl_dd/t_dd_tritmp.h"
408 #define IND (S3V_OFFSET_BIT)
409 #define TAG(x) x##_offset
410 #include "tnl_dd/t_dd_tritmp.h"
412 #define IND (S3V_TWOSIDE_BIT)
413 #define TAG(x) x##_twoside
414 #include "tnl_dd/t_dd_tritmp.h"
416 #define IND (S3V_TWOSIDE_BIT|S3V_OFFSET_BIT)
417 #define TAG(x) x##_twoside_offset
418 #include "tnl_dd/t_dd_tritmp.h"
420 #define IND (S3V_UNFILLED_BIT)
421 #define TAG(x) x##_unfilled
422 #include "tnl_dd/t_dd_tritmp.h"
424 #define IND (S3V_OFFSET_BIT|S3V_UNFILLED_BIT)
425 #define TAG(x) x##_offset_unfilled
426 #include "tnl_dd/t_dd_tritmp.h"
428 #define IND (S3V_TWOSIDE_BIT|S3V_UNFILLED_BIT)
429 #define TAG(x) x##_twoside_unfilled
430 #include "tnl_dd/t_dd_tritmp.h"
432 #define IND (S3V_TWOSIDE_BIT|S3V_OFFSET_BIT|S3V_UNFILLED_BIT)
433 #define TAG(x) x##_twoside_offset_unfilled
434 #include "tnl_dd/t_dd_tritmp.h"
437 static void init_render_tab( void )
439 DEBUG(("*** init_render_tab ***\n"));
444 init_twoside_offset();
446 init_offset_unfilled();
447 init_twoside_unfilled();
448 init_twoside_offset_unfilled();
452 /**********************************************************************/
453 /* Render unclipped begin/end objects */
454 /**********************************************************************/
456 #define VERT(x) (s3vVertex *)(s3vverts + (x << shift))
458 #define RENDER_POINTS( start, count ) \
459 DEBUG(("RENDER_POINTS...(ok)\n")); \
460 for ( ; start < count ; start++) \
461 vmesa->draw_line( vmesa, VERT(start), VERT(start) )
462 /* vmesa->draw_point( vmesa, VERT(start) ) */
464 #define RENDER_LINE( v0, v1 ) \
465 /* DEBUG(("RENDER_LINE...(ok)\n")); \ */ \
466 vmesa->draw_line( vmesa, VERT(v0), VERT(v1) ); \
467 DEBUG(("RENDER_LINE...(ok)\n"))
469 #define RENDER_TRI( v0, v1, v2 ) \
470 DEBUG(("RENDER_TRI...(ok)\n")); \
471 vmesa->draw_tri( vmesa, VERT(v0), VERT(v1), VERT(v2) )
473 #define RENDER_QUAD( v0, v1, v2, v3 ) \
474 DEBUG(("RENDER_QUAD...(ok)\n")); \
475 /* s3v_draw_quad( vmesa, VERT(v0), VERT(v1), VERT(v2),VERT(v3) ) */\
476 /* s3v_draw_triangle( vmesa, VERT(v0), VERT(v1), VERT(v2) ); \
477 s3v_draw_triangle( vmesa, VERT(v0), VERT(v2), VERT(v3) ) */ \
478 vmesa->draw_quad( vmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )
480 #define INIT(x) s3vRenderPrimitive( ctx, x );
483 s3vContextPtr vmesa = S3V_CONTEXT(ctx); \
484 const GLuint shift = vmesa->vertex_stride_shift; \
485 const char *s3vverts = (char *)vmesa->verts; \
486 const GLboolean stipple = ctx->Line.StippleFlag; \
488 #define RESET_STIPPLE if ( stipple ) s3vResetLineStipple( ctx );
489 #define RESET_OCCLUSION
490 #define PRESERVE_VB_DEFS
492 #define TAG(x) s3v_##x##_verts
493 #include "tnl_dd/t_dd_rendertmp.h"
496 /**********************************************************************/
497 /* Render clipped primitives */
498 /**********************************************************************/
500 static void s3vRenderClippedPoly( GLcontext
*ctx
, const GLuint
*elts
,
503 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
504 struct vertex_buffer
*VB
= &TNL_CONTEXT(ctx
)->vb
;
505 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
506 GLuint prim
= vmesa
->render_primitive
;
508 DEBUG(("I AM in: s3vRenderClippedPoly\n"));
510 /* Render the new vertices as an unclipped polygon.
514 GLuint
*tmp
= VB
->Elts
;
515 VB
->Elts
= (GLuint
*)elts
;
516 tnl
->Driver
.Render
.PrimTabElts
[GL_POLYGON
]
517 ( ctx
, 0, n
, PRIM_BEGIN
|PRIM_END
);
522 /* Restore the render primitive
525 if (prim
!= GL_POLYGON
) {
526 DEBUG(("and prim != GL_POLYGON\n"));
527 tnl
->Driver
.Render
.PrimitiveNotify( ctx
, prim
);
533 static void s3vRenderClippedLine( GLcontext
*ctx
, GLuint ii
, GLuint jj
)
535 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
536 /*tnl->Driver.LineFunc = s3v_line_tab[2];*/ /* _swsetup_Line; */
538 DEBUG(("I AM in: s3vRenderClippedLine\n"));
539 tnl
->Driver
.Render
.Line( ctx
, ii
, jj
);
543 /**********************************************************************/
544 /* Choose render functions */
545 /**********************************************************************/
549 #define _S3V_NEW_RENDERSTATE (_DD_NEW_TRI_UNFILLED | \
550 _DD_NEW_TRI_LIGHT_TWOSIDE | \
553 #define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)
555 static void s3vChooseRenderState(GLcontext
*ctx
)
557 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
558 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
559 GLuint flags
= ctx
->_TriangleCaps
;
562 DEBUG(("s3vChooseRenderState\n"));
564 if (flags
& ANY_RASTER_FLAGS
) {
565 if (flags
& DD_TRI_LIGHT_TWOSIDE
) index
|= S3V_TWOSIDE_BIT
;
566 if (flags
& DD_TRI_OFFSET
) index
|= S3V_OFFSET_BIT
;
567 if (flags
& DD_TRI_UNFILLED
) index
|= S3V_UNFILLED_BIT
;
570 DEBUG(("vmesa->RenderIndex = %i\n", vmesa
->RenderIndex
));
571 DEBUG(("index = %i\n", index
));
573 if (vmesa
->RenderIndex
!= index
) {
574 vmesa
->RenderIndex
= index
;
576 tnl
->Driver
.Render
.Points
= rast_tab
[index
].points
;
577 tnl
->Driver
.Render
.Line
= rast_tab
[index
].line
;
578 tnl
->Driver
.Render
.Triangle
= rast_tab
[index
].triangle
;
579 tnl
->Driver
.Render
.Quad
= rast_tab
[index
].quad
;
581 if (vmesa
->RenderIndex
== 0)
582 tnl
->Driver
.Render
.PrimTabVerts
= s3v_render_tab_verts
;
584 tnl
->Driver
.Render
.PrimTabVerts
= _tnl_render_tab_verts
;
585 tnl
->Driver
.Render
.PrimTabElts
= _tnl_render_tab_elts
;
586 tnl
->Driver
.Render
.ClippedLine
= s3vRenderClippedLine
;
587 tnl
->Driver
.Render
.ClippedPolygon
= s3vRenderClippedPoly
;
592 /**********************************************************************/
593 /* High level hooks for t_vb_render.c */
594 /**********************************************************************/
598 /* Determine the rasterized primitive when not drawing unfilled
601 * Used only for the default render stage which always decomposes
602 * primitives to trianges/lines/points. For the accelerated stage,
603 * which renders strips as strips, the equivalent calculations are
604 * performed in s3v_render.c.
607 static void s3vRasterPrimitive( GLcontext
*ctx
, GLuint hwprim
)
609 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
610 /* __DRIdrawablePrivate *dPriv = vmesa->driDrawable; */
611 GLuint cmd
= vmesa
->CMD
;
613 unsigned int _hw_prim
= hwprim
;
615 DEBUG(("s3vRasterPrimitive: hwprim = 0x%x ", _hw_prim
));
617 /* printf("* vmesa->CMD = 0x%x\n", vmesa->CMD); */
619 if (vmesa
->hw_primitive
!= _hw_prim
)
621 DEBUG(("(new one) ***\n"));
623 cmd
&= ~ALPHA_BLEND_MASK
;
624 vmesa
->hw_primitive
= _hw_prim
;
626 if (_hw_prim
== PrimType_Triangles
) {
628 DEBUG(("->switching to tri\n"));
629 cmd
|= (vmesa
->_tri
[vmesa
->_3d_mode
] | vmesa
->_alpha
[vmesa
->_3d_mode
]);
630 } else if (_hw_prim
== PrimType_Lines
631 || _hw_prim
== PrimType_Points
) {
633 DEBUG(("->switching to line\n"));
634 cmd
|= (DO_3D_LINE
| vmesa
->_alpha
[0]);
637 DEBUG(("->switching to your sis'ass\n"));
642 vmesa
->restore_primitive
= _hw_prim
;
643 /* 0xacc16827: good value -> lightened newave!!! */
649 static void s3vRenderPrimitive( GLcontext
*ctx
, GLenum prim
)
651 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
652 __DRIdrawablePrivate
*dPriv
= vmesa
->driDrawable
;
653 GLuint cmd
= vmesa
->CMD
;
655 unsigned int _hw_prim
= hw_prim
[prim
];
657 vmesa
->render_primitive
= prim
;
658 vmesa
->hw_primitive
= _hw_prim
;
660 DEBUG(("s3vRenderPrimitive #%i ", prim
));
661 DEBUG(("_hw_prim = 0x%x\n", _hw_prim
));
663 /* printf(" vmesa->CMD = 0x%x\n", vmesa->CMD); */
665 if (_hw_prim
!= vmesa
->restore_primitive
) {
666 DEBUG(("_hw_prim != vmesa->restore_primitive (was 0x%x)\n",
667 vmesa
->restore_primitive
));
670 cmd
&= ~ALPHA_BLEND_MASK
;
672 printf(" cmd = 0x%x\n", cmd);
673 printf(" vmesa->_3d_mode=%i; vmesa->_tri[vmesa->_3d_mode]=0x%x\n",
674 vmesa->_3d_mode, vmesa->_tri[vmesa->_3d_mode]);
675 printf("vmesa->alpha[0] = 0x%x; vmesa->alpha[1] = 0x%x\n",
676 vmesa->_alpha[0], vmesa->_alpha[1]);
678 if (_hw_prim
== PrimType_Triangles
) { /* TRI */
679 DEBUG(("->switching to tri\n"));
680 cmd
|= (vmesa
->_tri
[vmesa
->_3d_mode
] | vmesa
->_alpha
[vmesa
->_3d_mode
]);
681 DEBUG(("vmesa->TexStride = %i\n", vmesa
->TexStride
));
682 DEBUG(("vmesa->TexOffset = %i\n", vmesa
->TexOffset
));
683 DMAOUT_CHECK(3DTRI_Z_BASE
, 12);
685 DEBUG(("->switching to line\n"));
686 cmd
|= (DO_3D_LINE
| vmesa
->_alpha
[0]);
687 DMAOUT_CHECK(3DLINE_Z_BASE
, 12);
690 DMAOUT(vmesa
->s3vScreen
->depthOffset
& 0x003FFFF8);
691 DMAOUT(vmesa
->DestBase
);
692 /* DMAOUT(vmesa->ScissorLR); */
693 /* DMAOUT(vmesa->ScissorTB); */
695 /* NOTE: we need to restore all these values since we
696 * are coming back from a vmesa->restore_primitive */
697 DMAOUT( (0 << 16) | (dPriv
->w
-1) );
698 DMAOUT( (0 << 16) | (dPriv
->h
-1) );
699 DMAOUT( (vmesa
->SrcStride
<< 16) | vmesa
->TexStride
);
700 DMAOUT(vmesa
->SrcStride
);
701 DMAOUT(vmesa
->TexOffset
);
702 DMAOUT(vmesa
->TextureBorderColor
);
707 /* 0xacc16827: good value -> lightened newave!!! */
716 vmesa
->restore_primitive
= _hw_prim
;
719 static void s3vRunPipeline( GLcontext
*ctx
)
721 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
723 DEBUG(("*** s3vRunPipeline ***\n"));
725 if ( vmesa
->new_state
)
726 s3vDDUpdateHWState( ctx
);
728 if (vmesa
->new_gl_state
) {
730 if (vmesa
->new_gl_state
& _NEW_TEXTURE
) {
731 s3vUpdateTextureState( ctx
);
734 if (!vmesa
->Fallback
) {
735 if (vmesa
->new_gl_state
& _S3V_NEW_VERTEX
)
736 s3vChooseVertexState( ctx
);
738 if (vmesa
->new_gl_state
& _S3V_NEW_RASTER_STATE
)
739 s3vChooseRasterState( ctx
);
741 if (vmesa
->new_gl_state
& _S3V_NEW_RENDERSTATE
)
742 s3vChooseRenderState( ctx
);
745 vmesa
->new_gl_state
= 0;
749 _tnl_run_pipeline( ctx
);
752 static void s3vRenderStart( GLcontext
*ctx
)
754 /* Check for projective texturing. Make sure all texcoord
755 * pointers point to something. (fix in mesa?)
758 DEBUG(("s3vRenderStart\n"));
759 /* s3vCheckTexSizes( ctx ); */
762 static void s3vRenderFinish( GLcontext
*ctx
)
765 _swrast_flush( ctx
); /* never needed */
768 static void s3vResetLineStipple( GLcontext
*ctx
)
770 /* s3vContextPtr vmesa = S3V_CONTEXT(ctx); */
772 /* Reset the hardware stipple counter.
775 CHECK_DMA_BUFFER(vmesa, 1);
776 WRITE(vmesa->buf, UpdateLineStippleCounters, 0);
781 /**********************************************************************/
782 /* Transition to/from hardware rasterization. */
783 /**********************************************************************/
786 void s3vFallback( s3vContextPtr vmesa
, GLuint bit
, GLboolean mode
)
788 GLcontext
*ctx
= vmesa
->glCtx
;
789 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
790 GLuint oldfallback
= vmesa
->Fallback
;
792 DEBUG(("*** s3vFallback: "));
795 vmesa
->Fallback
|= bit
;
796 if (oldfallback
== 0) {
797 DEBUG(("oldfallback == 0 ***\n"));
798 _swsetup_Wakeup( ctx
);
799 _tnl_need_projected_coords( ctx
, GL_TRUE
);
800 vmesa
->RenderIndex
= ~0;
805 vmesa
->Fallback
&= ~bit
;
806 if (oldfallback
== bit
) {
807 _swrast_flush( ctx
);
808 tnl
->Driver
.Render
.Start
= s3vRenderStart
;
809 tnl
->Driver
.Render
.PrimitiveNotify
= s3vRenderPrimitive
;
810 tnl
->Driver
.Render
.Finish
= s3vRenderFinish
;
811 tnl
->Driver
.Render
.BuildVertices
= s3vBuildVertices
;
812 tnl
->Driver
.Render
.ResetLineStipple
= s3vResetLineStipple
;
813 vmesa
->new_gl_state
|= (_S3V_NEW_RENDERSTATE
|
814 _S3V_NEW_RASTER_STATE
|
821 /**********************************************************************/
822 /* Initialization. */
823 /**********************************************************************/
826 void s3vInitTriFuncs( GLcontext
*ctx
)
828 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
829 TNLcontext
*tnl
= TNL_CONTEXT(ctx
);
830 static int firsttime
= 1;
838 vmesa
->RenderIndex
= ~0;
840 tnl
->Driver
.RunPipeline
= s3vRunPipeline
;
841 tnl
->Driver
.Render
.Start
= s3vRenderStart
;
842 tnl
->Driver
.Render
.Finish
= s3vRenderFinish
;
843 tnl
->Driver
.Render
.PrimitiveNotify
= s3vRenderPrimitive
;
844 tnl
->Driver
.Render
.ResetLineStipple
= s3vResetLineStipple
;
846 tnl->Driver.RenderInterp = _swsetup_RenderInterp;
847 tnl->Driver.RenderCopyPV = _swsetup_RenderCopyPV;
849 tnl
->Driver
.Render
.BuildVertices
= s3vBuildVertices
;