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/tdfx/tdfx_state.c,v 1.7 2002/10/30 12:52:00 alanh Exp $ */
30 * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
33 * Gareth Hughes <gareth@valinux.com>
34 * Brian Paul <brianp@valinux.com>
35 * Keith Whitwell <keith@tungstengraphics.com> (port to 3.5)
41 #include "texformat.h"
45 #include "swrast/swrast.h"
46 #include "array_cache/acache.h"
48 #include "tnl/t_pipeline.h"
49 #include "swrast_setup/swrast_setup.h"
51 #include "tdfx_context.h"
52 #include "tdfx_state.h"
55 #include "tdfx_texman.h"
56 #include "tdfx_texstate.h"
57 #include "tdfx_tris.h"
58 #include "tdfx_render.h"
62 /* =============================================================
66 static void tdfxUpdateAlphaMode( GLcontext
*ctx
)
68 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
70 GrAlphaBlendFnc_t srcRGB
, dstRGB
, srcA
, dstA
;
71 GrAlpha_t ref
= (GLint
) (ctx
->Color
.AlphaRef
* 255.0);
73 if ( TDFX_DEBUG
& DEBUG_VERBOSE_API
) {
74 fprintf( stderr
, "%s()\n", __FUNCTION__
);
77 if ( ctx
->Color
.AlphaEnabled
) {
78 switch ( ctx
->Color
.AlphaFunc
) {
95 func
= GR_CMP_GREATER
;
98 func
= GR_CMP_NOTEQUAL
;
102 func
= GR_CMP_ALWAYS
;
106 func
= GR_CMP_ALWAYS
;
109 if ( ctx
->Color
.BlendEnabled
110 && (fxMesa
->Fallback
& TDFX_FALLBACK_BLEND
) == 0 ) {
111 switch ( ctx
->Color
.BlendSrcRGB
) {
113 srcRGB
= GR_BLEND_ZERO
;
116 srcRGB
= GR_BLEND_ONE
;
119 srcRGB
= GR_BLEND_DST_COLOR
;
121 case GL_ONE_MINUS_DST_COLOR
:
122 srcRGB
= GR_BLEND_ONE_MINUS_DST_COLOR
;
125 srcRGB
= GR_BLEND_SRC_ALPHA
;
127 case GL_ONE_MINUS_SRC_ALPHA
:
128 srcRGB
= GR_BLEND_ONE_MINUS_SRC_ALPHA
;
131 srcRGB
= GR_BLEND_DST_ALPHA
;
133 case GL_ONE_MINUS_DST_ALPHA
:
134 srcRGB
= GR_BLEND_ONE_MINUS_DST_ALPHA
;
136 case GL_SRC_ALPHA_SATURATE
:
137 srcRGB
= GR_BLEND_ALPHA_SATURATE
;
140 srcRGB
= GR_BLEND_ONE
;
143 switch ( ctx
->Color
.BlendSrcA
) {
145 srcA
= GR_BLEND_ZERO
;
151 srcA
= GR_BLEND_DST_ALPHA
; /* Napalm only */
153 case GL_ONE_MINUS_DST_COLOR
:
154 srcA
= GR_BLEND_ONE_MINUS_DST_ALPHA
; /* Napalm only */
157 srcA
= GR_BLEND_SRC_ALPHA
; /* Napalm only */
159 case GL_ONE_MINUS_SRC_ALPHA
:
160 srcA
= GR_BLEND_ONE_MINUS_SRC_ALPHA
; /* Napalm only */
163 srcA
= GR_BLEND_DST_ALPHA
; /* Napalm only */
165 case GL_ONE_MINUS_DST_ALPHA
:
166 srcA
= GR_BLEND_ONE_MINUS_DST_ALPHA
; /* Napalm only */
168 case GL_SRC_ALPHA_SATURATE
:
175 switch ( ctx
->Color
.BlendDstRGB
) {
177 dstRGB
= GR_BLEND_ZERO
;
180 dstRGB
= GR_BLEND_ONE
;
183 dstRGB
= GR_BLEND_SRC_COLOR
;
185 case GL_ONE_MINUS_SRC_COLOR
:
186 dstRGB
= GR_BLEND_ONE_MINUS_SRC_COLOR
;
189 dstRGB
= GR_BLEND_SRC_ALPHA
;
191 case GL_ONE_MINUS_SRC_ALPHA
:
192 dstRGB
= GR_BLEND_ONE_MINUS_SRC_ALPHA
;
195 dstRGB
= GR_BLEND_DST_ALPHA
;
197 case GL_ONE_MINUS_DST_ALPHA
:
198 dstRGB
= GR_BLEND_ONE_MINUS_DST_ALPHA
;
201 dstRGB
= GR_BLEND_ZERO
;
204 switch ( ctx
->Color
.BlendDstA
) {
206 dstA
= GR_BLEND_ZERO
;
212 dstA
= GR_BLEND_SRC_ALPHA
; /* Napalm only */
214 case GL_ONE_MINUS_SRC_COLOR
:
215 dstA
= GR_BLEND_ONE_MINUS_SRC_ALPHA
; /* Napalm only */
218 dstA
= GR_BLEND_SRC_ALPHA
; /* Napalm only */
220 case GL_ONE_MINUS_SRC_ALPHA
:
221 dstA
= GR_BLEND_ONE_MINUS_SRC_ALPHA
; /* Napalm only */
224 dstA
= GR_BLEND_DST_ALPHA
; /* Napalm only */
226 case GL_ONE_MINUS_DST_ALPHA
:
227 dstA
= GR_BLEND_ONE_MINUS_DST_ALPHA
; /* Napalm only */
230 dstA
= GR_BLEND_ZERO
;
234 srcRGB
= GR_BLEND_ONE
;
235 dstRGB
= GR_BLEND_ZERO
;
237 dstA
= GR_BLEND_ZERO
;
240 if ( fxMesa
->Color
.AlphaFunc
!= func
) {
241 fxMesa
->Color
.AlphaFunc
= func
;
242 fxMesa
->dirty
|= TDFX_UPLOAD_ALPHA_TEST
;
244 if ( fxMesa
->Color
.AlphaRef
!= ref
) {
245 fxMesa
->Color
.AlphaRef
= ref
;
246 fxMesa
->dirty
|= TDFX_UPLOAD_ALPHA_REF
;
249 if ( fxMesa
->Color
.BlendSrcRGB
!= srcRGB
||
250 fxMesa
->Color
.BlendDstRGB
!= dstRGB
||
251 fxMesa
->Color
.BlendSrcA
!= srcA
||
252 fxMesa
->Color
.BlendDstA
!= dstA
)
254 fxMesa
->Color
.BlendSrcRGB
= srcRGB
;
255 fxMesa
->Color
.BlendDstRGB
= dstRGB
;
256 fxMesa
->Color
.BlendSrcA
= srcA
;
257 fxMesa
->Color
.BlendDstA
= dstA
;
258 fxMesa
->dirty
|= TDFX_UPLOAD_BLEND_FUNC
;
262 static void tdfxDDAlphaFunc( GLcontext
*ctx
, GLenum func
, GLfloat ref
)
264 tdfxContextPtr fxMesa
= TDFX_CONTEXT( ctx
);
266 FLUSH_BATCH( fxMesa
);
267 fxMesa
->new_state
|= TDFX_NEW_ALPHA
;
270 static void tdfxDDBlendEquation( GLcontext
*ctx
, GLenum mode
)
272 tdfxContextPtr fxMesa
= TDFX_CONTEXT( ctx
);
274 FLUSH_BATCH( fxMesa
);
275 fxMesa
->new_state
|= TDFX_NEW_ALPHA
;
278 static void tdfxDDBlendFunc( GLcontext
*ctx
, GLenum sfactor
, GLenum dfactor
)
280 tdfxContextPtr fxMesa
= TDFX_CONTEXT( ctx
);
282 FLUSH_BATCH( fxMesa
);
283 fxMesa
->new_state
|= TDFX_NEW_ALPHA
;
286 * XXX - Voodoo5 seems to suffer from precision problems in some
287 * blend modes. To pass all the conformance tests we'd have to
288 * fall back to software for many modes. Revisit someday.
292 static void tdfxDDBlendFuncSeparate( GLcontext
*ctx
,
293 GLenum sfactorRGB
, GLenum dfactorRGB
,
294 GLenum sfactorA
, GLenum dfactorA
)
296 tdfxContextPtr fxMesa
= TDFX_CONTEXT( ctx
);
298 FLUSH_BATCH( fxMesa
);
299 fxMesa
->new_state
|= TDFX_NEW_ALPHA
;
302 /* =============================================================
306 void tdfxUpdateStipple( GLcontext
*ctx
)
308 tdfxContextPtr fxMesa
= TDFX_CONTEXT( ctx
);
309 GrStippleMode_t mode
= GR_STIPPLE_DISABLE
;
311 if ( TDFX_DEBUG
& DEBUG_VERBOSE_API
) {
312 fprintf( stderr
, "%s()\n", __FUNCTION__
);
315 FLUSH_BATCH( fxMesa
);
317 if (ctx
->Polygon
.StippleFlag
) {
318 mode
= GR_STIPPLE_PATTERN
;
321 if ( fxMesa
->Stipple
.Mode
!= mode
) {
322 fxMesa
->Stipple
.Mode
= mode
;
323 fxMesa
->dirty
|= TDFX_UPLOAD_STIPPLE
;
328 /* =============================================================
332 static void tdfxUpdateZMode( GLcontext
*ctx
)
334 tdfxContextPtr fxMesa
= TDFX_CONTEXT( ctx
);
339 if ( TDFX_DEBUG
& DEBUG_VERBOSE_API
)
340 fprintf( stderr
, "%s()\n", __FUNCTION__
);
343 bias
= (FxI32
) (ctx
->Polygon
.OffsetUnits
* TDFX_DEPTH_BIAS_SCALE
);
345 if ( ctx
->Depth
.Test
) {
346 switch ( ctx
->Depth
.Func
) {
354 func
= GR_CMP_LEQUAL
;
360 func
= GR_CMP_GEQUAL
;
363 func
= GR_CMP_GREATER
;
366 func
= GR_CMP_NOTEQUAL
;
370 func
= GR_CMP_ALWAYS
;
374 if ( ctx
->Depth
.Mask
) {
382 /* depth testing disabled */
383 func
= GR_CMP_ALWAYS
; /* fragments always pass */
384 mask
= FXFALSE
; /* zbuffer is not touched */
387 fxMesa
->Depth
.Clear
= (FxU32
) (((1 << fxMesa
->glCtx
->Visual
.depthBits
) - 1)
390 if ( fxMesa
->Depth
.Bias
!= bias
) {
391 fxMesa
->Depth
.Bias
= bias
;
392 fxMesa
->dirty
|= TDFX_UPLOAD_DEPTH_BIAS
;
394 if ( fxMesa
->Depth
.Func
!= func
) {
395 fxMesa
->Depth
.Func
= func
;
396 fxMesa
->dirty
|= TDFX_UPLOAD_DEPTH_FUNC
| TDFX_UPLOAD_DEPTH_MASK
;
398 if ( fxMesa
->Depth
.Mask
!= mask
) {
399 fxMesa
->Depth
.Mask
= mask
;
400 fxMesa
->dirty
|= TDFX_UPLOAD_DEPTH_MASK
;
404 static void tdfxDDDepthFunc( GLcontext
*ctx
, GLenum func
)
406 tdfxContextPtr fxMesa
= TDFX_CONTEXT( ctx
);
408 FLUSH_BATCH( fxMesa
);
409 fxMesa
->new_state
|= TDFX_NEW_DEPTH
;
412 static void tdfxDDDepthMask( GLcontext
*ctx
, GLboolean flag
)
414 tdfxContextPtr fxMesa
= TDFX_CONTEXT( ctx
);
416 FLUSH_BATCH( fxMesa
);
417 fxMesa
->new_state
|= TDFX_NEW_DEPTH
;
420 static void tdfxDDClearDepth( GLcontext
*ctx
, GLclampd d
)
422 tdfxContextPtr fxMesa
= TDFX_CONTEXT( ctx
);
424 FLUSH_BATCH( fxMesa
);
425 fxMesa
->new_state
|= TDFX_NEW_DEPTH
;
430 /* =============================================================
435 /* Evaluate all stencil state and make the Glide calls.
437 static GrStencil_t
convertGLStencilOp( GLenum op
)
441 return GR_STENCILOP_KEEP
;
443 return GR_STENCILOP_ZERO
;
445 return GR_STENCILOP_REPLACE
;
447 return GR_STENCILOP_INCR_CLAMP
;
449 return GR_STENCILOP_DECR_CLAMP
;
451 return GR_STENCILOP_INVERT
;
452 case GL_INCR_WRAP_EXT
:
453 return GR_STENCILOP_INCR_WRAP
;
454 case GL_DECR_WRAP_EXT
:
455 return GR_STENCILOP_DECR_WRAP
;
457 _mesa_problem( NULL
, "bad stencil op in convertGLStencilOp" );
459 return GR_STENCILOP_KEEP
; /* never get, silence compiler warning */
463 static void tdfxUpdateStencil( GLcontext
*ctx
)
465 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
467 if ( TDFX_DEBUG
& DEBUG_VERBOSE_API
) {
468 fprintf( stderr
, "%s()\n", __FUNCTION__
);
471 if (fxMesa
->haveHwStencil
) {
472 if (ctx
->Stencil
.Enabled
) {
473 fxMesa
->Stencil
.Function
= ctx
->Stencil
.Function
[0] - GL_NEVER
;
474 fxMesa
->Stencil
.RefValue
= ctx
->Stencil
.Ref
[0];
475 fxMesa
->Stencil
.ValueMask
= ctx
->Stencil
.ValueMask
[0];
476 fxMesa
->Stencil
.WriteMask
= ctx
->Stencil
.WriteMask
[0];
477 fxMesa
->Stencil
.FailFunc
= convertGLStencilOp(ctx
->Stencil
.FailFunc
[0]);
478 fxMesa
->Stencil
.ZFailFunc
= convertGLStencilOp(ctx
->Stencil
.ZFailFunc
[0]);
479 fxMesa
->Stencil
.ZPassFunc
= convertGLStencilOp(ctx
->Stencil
.ZPassFunc
[0]);
480 fxMesa
->Stencil
.Clear
= ctx
->Stencil
.Clear
& 0xff;
482 fxMesa
->dirty
|= TDFX_UPLOAD_STENCIL
;
487 static void tdfxDDStencilFunc( GLcontext
*ctx
, GLenum func
,
488 GLint ref
, GLuint mask
)
490 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
492 FLUSH_BATCH( fxMesa
);
493 fxMesa
->new_state
|= TDFX_NEW_STENCIL
;
496 static void tdfxDDStencilMask( GLcontext
*ctx
, GLuint mask
)
498 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
500 FLUSH_BATCH( fxMesa
);
501 fxMesa
->new_state
|= TDFX_NEW_STENCIL
;
504 static void tdfxDDStencilOp( GLcontext
*ctx
, GLenum sfail
,
505 GLenum zfail
, GLenum zpass
)
507 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
509 FLUSH_BATCH( fxMesa
);
510 fxMesa
->new_state
|= TDFX_NEW_STENCIL
;
514 /* =============================================================
515 * Fog - orthographic fog still not working
518 static void tdfxUpdateFogAttrib( GLcontext
*ctx
)
520 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
524 if ( TDFX_DEBUG
& DEBUG_VERBOSE_API
) {
525 fprintf( stderr
, "%s()\n", __FUNCTION__
);
528 if ( ctx
->Fog
.Enabled
) {
529 mode
= GR_FOG_WITH_TABLE_ON_Q
;
531 mode
= GR_FOG_DISABLE
;
534 color
= TDFXPACKCOLOR888((GLubyte
)(ctx
->Fog
.Color
[0]*255.0F
),
535 (GLubyte
)(ctx
->Fog
.Color
[1]*255.0F
),
536 (GLubyte
)(ctx
->Fog
.Color
[2]*255.0F
));
538 if ( fxMesa
->Fog
.Mode
!= mode
) {
539 fxMesa
->Fog
.Mode
= mode
;
540 fxMesa
->dirty
|= TDFX_UPLOAD_FOG_MODE
;
542 if ( fxMesa
->Fog
.Color
!= color
) {
543 fxMesa
->Fog
.Color
= color
;
544 fxMesa
->dirty
|= TDFX_UPLOAD_FOG_COLOR
;
546 if ( fxMesa
->Fog
.TableMode
!= ctx
->Fog
.Mode
||
547 fxMesa
->Fog
.Density
!= ctx
->Fog
.Density
||
548 fxMesa
->Fog
.Near
!= ctx
->Fog
.Start
||
549 fxMesa
->Fog
.Far
!= ctx
->Fog
.End
)
551 switch( ctx
->Fog
.Mode
) {
553 fxMesa
->Glide
.guFogGenerateExp( fxMesa
->Fog
.Table
, ctx
->Fog
.Density
);
556 fxMesa
->Glide
.guFogGenerateExp2( fxMesa
->Fog
.Table
, ctx
->Fog
.Density
);
559 fxMesa
->Glide
.guFogGenerateLinear( fxMesa
->Fog
.Table
,
560 ctx
->Fog
.Start
, ctx
->Fog
.End
);
564 fxMesa
->Fog
.TableMode
= ctx
->Fog
.Mode
;
565 fxMesa
->Fog
.Density
= ctx
->Fog
.Density
;
566 fxMesa
->Fog
.Near
= ctx
->Fog
.Start
;
567 fxMesa
->Fog
.Far
= ctx
->Fog
.End
;
568 fxMesa
->dirty
|= TDFX_UPLOAD_FOG_TABLE
;
572 static void tdfxDDFogfv( GLcontext
*ctx
, GLenum pname
, const GLfloat
*param
)
574 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
576 FLUSH_BATCH( fxMesa
);
577 fxMesa
->new_state
|= TDFX_NEW_FOG
;
581 /* =============================================================
585 static int intersect_rect( XF86DRIClipRectPtr out
,
586 const XF86DRIClipRectPtr a
,
587 const XF86DRIClipRectPtr b
)
590 if (b
->x1
> out
->x1
) out
->x1
= b
->x1
;
591 if (b
->y1
> out
->y1
) out
->y1
= b
->y1
;
592 if (b
->x2
< out
->x2
) out
->x2
= b
->x2
;
593 if (b
->y2
< out
->y2
) out
->y2
= b
->y2
;
594 if (out
->x1
>= out
->x2
) return 0;
595 if (out
->y1
>= out
->y2
) return 0;
601 * Examine XF86 cliprect list and scissor state to recompute our
604 void tdfxUpdateClipping( GLcontext
*ctx
)
606 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
607 __DRIdrawablePrivate
*dPriv
= fxMesa
->driDrawable
;
609 if ( TDFX_DEBUG
& DEBUG_VERBOSE_API
) {
610 fprintf( stderr
, "%s()\n", __FUNCTION__
);
617 if ( dPriv
->x
!= fxMesa
->x_offset
|| dPriv
->y
!= fxMesa
->y_offset
||
618 dPriv
->w
!= fxMesa
->width
|| dPriv
->h
!= fxMesa
->height
) {
619 fxMesa
->x_offset
= dPriv
->x
;
620 fxMesa
->y_offset
= dPriv
->y
;
621 fxMesa
->width
= dPriv
->w
;
622 fxMesa
->height
= dPriv
->h
;
624 fxMesa
->screen_height
- fxMesa
->y_offset
- fxMesa
->height
;
625 tdfxUpdateViewport( ctx
);
628 if (fxMesa
->scissoredClipRects
&& fxMesa
->pClipRects
) {
629 free(fxMesa
->pClipRects
);
632 if (ctx
->Scissor
.Enabled
) {
633 /* intersect OpenGL scissor box with all cliprects to make a new
636 XF86DRIClipRectRec scissor
;
637 int x1
= ctx
->Scissor
.X
+ fxMesa
->x_offset
;
638 int y1
= fxMesa
->screen_height
- fxMesa
->y_delta
639 - ctx
->Scissor
.Y
- ctx
->Scissor
.Height
;
640 int x2
= x1
+ ctx
->Scissor
.Width
;
641 int y2
= y1
+ ctx
->Scissor
.Height
;
642 scissor
.x1
= MAX2(x1
, 0);
643 scissor
.y1
= MAX2(y1
, 0);
644 scissor
.x2
= MAX2(x2
, 0);
645 scissor
.y2
= MAX2(y2
, 0);
647 assert(scissor
.x2
>= scissor
.x1
);
648 assert(scissor
.y2
>= scissor
.y1
);
650 fxMesa
->pClipRects
= malloc(dPriv
->numClipRects
651 * sizeof(XF86DRIClipRectRec
));
652 if (fxMesa
->pClipRects
) {
654 fxMesa
->numClipRects
= 0;
655 for (i
= 0; i
< dPriv
->numClipRects
; i
++) {
656 if (intersect_rect(&fxMesa
->pClipRects
[fxMesa
->numClipRects
],
657 &scissor
, &dPriv
->pClipRects
[i
])) {
658 fxMesa
->numClipRects
++;
661 fxMesa
->scissoredClipRects
= GL_TRUE
;
664 /* out of memory, forgo scissor */
665 fxMesa
->numClipRects
= dPriv
->numClipRects
;
666 fxMesa
->pClipRects
= dPriv
->pClipRects
;
667 fxMesa
->scissoredClipRects
= GL_FALSE
;
671 fxMesa
->numClipRects
= dPriv
->numClipRects
;
672 fxMesa
->pClipRects
= dPriv
->pClipRects
;
673 fxMesa
->scissoredClipRects
= GL_FALSE
;
676 fxMesa
->dirty
|= TDFX_UPLOAD_CLIP
;
681 /* =============================================================
685 void tdfxUpdateCull( GLcontext
*ctx
)
687 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
688 GrCullMode_t mode
= GR_CULL_DISABLE
;
690 /* KW: don't need to check raster_primitive here as we don't
691 * attempt to draw lines or points with triangles.
693 if ( ctx
->Polygon
.CullFlag
) {
694 switch ( ctx
->Polygon
.CullFaceMode
) {
696 if ( ctx
->Polygon
.FrontFace
== GL_CCW
) {
697 mode
= GR_CULL_POSITIVE
;
699 mode
= GR_CULL_NEGATIVE
;
704 if ( ctx
->Polygon
.FrontFace
== GL_CCW
) {
705 mode
= GR_CULL_NEGATIVE
;
707 mode
= GR_CULL_POSITIVE
;
711 case GL_FRONT_AND_BACK
:
712 /* Handled as a fallback on triangles in tdfx_tris.c */
721 if ( fxMesa
->CullMode
!= mode
) {
722 fxMesa
->CullMode
= mode
;
723 fxMesa
->dirty
|= TDFX_UPLOAD_CULL
;
727 static void tdfxDDCullFace( GLcontext
*ctx
, GLenum mode
)
729 tdfxContextPtr fxMesa
= TDFX_CONTEXT( ctx
);
731 FLUSH_BATCH( fxMesa
);
732 fxMesa
->new_state
|= TDFX_NEW_CULL
;
735 static void tdfxDDFrontFace( GLcontext
*ctx
, GLenum mode
)
737 tdfxContextPtr fxMesa
= TDFX_CONTEXT( ctx
);
739 FLUSH_BATCH( fxMesa
);
740 fxMesa
->new_state
|= TDFX_NEW_CULL
;
744 /* =============================================================
748 static void tdfxUpdateLine( GLcontext
*ctx
)
750 tdfxContextPtr fxMesa
= TDFX_CONTEXT( ctx
);
752 if ( TDFX_DEBUG
& DEBUG_VERBOSE_API
) {
753 fprintf( stderr
, "%s()\n", __FUNCTION__
);
756 FLUSH_BATCH( fxMesa
);
757 fxMesa
->dirty
|= TDFX_UPLOAD_LINE
;
761 static void tdfxDDLineWidth( GLcontext
*ctx
, GLfloat width
)
763 tdfxContextPtr fxMesa
= TDFX_CONTEXT( ctx
);
764 FLUSH_BATCH( fxMesa
);
765 fxMesa
->new_state
|= TDFX_NEW_LINE
;
769 /* =============================================================
773 static void tdfxDDColorMask( GLcontext
*ctx
,
774 GLboolean r
, GLboolean g
,
775 GLboolean b
, GLboolean a
)
777 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
779 FLUSH_BATCH( fxMesa
);
781 if ( fxMesa
->Color
.ColorMask
[RCOMP
] != r
||
782 fxMesa
->Color
.ColorMask
[GCOMP
] != g
||
783 fxMesa
->Color
.ColorMask
[BCOMP
] != b
||
784 fxMesa
->Color
.ColorMask
[ACOMP
] != a
) {
785 fxMesa
->Color
.ColorMask
[RCOMP
] = r
;
786 fxMesa
->Color
.ColorMask
[GCOMP
] = g
;
787 fxMesa
->Color
.ColorMask
[BCOMP
] = b
;
788 fxMesa
->Color
.ColorMask
[ACOMP
] = a
;
789 fxMesa
->dirty
|= TDFX_UPLOAD_COLOR_MASK
;
791 if (ctx
->Visual
.redBits
< 8) {
792 /* Can't do RGB colormasking in 16bpp mode. */
793 /* We can completely ignore the alpha mask. */
794 FALLBACK( fxMesa
, TDFX_FALLBACK_COLORMASK
, (r
!= g
|| g
!= b
) );
800 static void tdfxDDClearColor( GLcontext
*ctx
,
801 const GLfloat color
[4] )
803 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
805 FLUSH_BATCH( fxMesa
);
806 CLAMPED_FLOAT_TO_UBYTE(c
[0], color
[0]);
807 CLAMPED_FLOAT_TO_UBYTE(c
[1], color
[1]);
808 CLAMPED_FLOAT_TO_UBYTE(c
[2], color
[2]);
809 CLAMPED_FLOAT_TO_UBYTE(c
[3], color
[3]);
810 fxMesa
->Color
.ClearColor
= TDFXPACKCOLOR888( c
[0], c
[1], c
[2] );
811 fxMesa
->Color
.ClearAlpha
= c
[3];
815 /* =============================================================
819 static void tdfxDDLightModelfv( GLcontext
*ctx
, GLenum pname
,
820 const GLfloat
*param
)
822 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
824 if ( pname
== GL_LIGHT_MODEL_COLOR_CONTROL
) {
825 FALLBACK( fxMesa
, TDFX_FALLBACK_SPECULAR
,
826 (ctx
->Light
.Enabled
&&
827 ctx
->Light
.Model
.ColorControl
== GL_SEPARATE_SPECULAR_COLOR
));
831 static void tdfxDDShadeModel( GLcontext
*ctx
, GLenum mode
)
833 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
835 /* FIXME: Can we implement native flat shading? */
836 FLUSH_BATCH( fxMesa
);
837 fxMesa
->new_state
|= TDFX_NEW_TEXTURE
;
841 /* =============================================================
846 tdfxDDScissor(GLcontext
* ctx
, GLint x
, GLint y
, GLsizei w
, GLsizei h
)
848 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
849 FLUSH_BATCH( fxMesa
);
850 fxMesa
->new_state
|= TDFX_NEW_CLIP
;
853 /* =============================================================
857 static void tdfxUpdateRenderAttrib( GLcontext
*ctx
)
859 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
860 FLUSH_BATCH( fxMesa
);
861 fxMesa
->dirty
|= TDFX_UPLOAD_RENDER_BUFFER
;
864 /* =============================================================
868 void tdfxUpdateViewport( GLcontext
*ctx
)
870 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
871 const GLfloat
*v
= ctx
->Viewport
._WindowMap
.m
;
872 GLfloat
*m
= fxMesa
->hw_viewport
;
874 m
[MAT_SX
] = v
[MAT_SX
];
875 m
[MAT_TX
] = v
[MAT_TX
] + fxMesa
->x_offset
+ TRI_X_OFFSET
;
876 m
[MAT_SY
] = v
[MAT_SY
];
877 m
[MAT_TY
] = v
[MAT_TY
] + fxMesa
->y_delta
+ TRI_Y_OFFSET
;
878 m
[MAT_SZ
] = v
[MAT_SZ
];
879 m
[MAT_TZ
] = v
[MAT_TZ
];
881 fxMesa
->SetupNewInputs
|= VERT_BIT_POS
;
885 static void tdfxDDViewport( GLcontext
*ctx
, GLint x
, GLint y
,
886 GLsizei w
, GLsizei h
)
888 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
889 FLUSH_BATCH( fxMesa
);
890 fxMesa
->new_state
|= TDFX_NEW_VIEWPORT
;
894 static void tdfxDDDepthRange( GLcontext
*ctx
, GLclampd nearVal
, GLclampd farVal
)
896 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
897 FLUSH_BATCH( fxMesa
);
898 fxMesa
->new_state
|= TDFX_NEW_VIEWPORT
;
902 /* =============================================================
903 * State enable/disable
906 static void tdfxDDEnable( GLcontext
*ctx
, GLenum cap
, GLboolean state
)
908 tdfxContextPtr fxMesa
= TDFX_CONTEXT( ctx
);
912 FLUSH_BATCH( fxMesa
);
913 fxMesa
->new_state
|= TDFX_NEW_ALPHA
;
917 FLUSH_BATCH( fxMesa
);
918 fxMesa
->new_state
|= TDFX_NEW_ALPHA
;
919 FALLBACK( fxMesa
, TDFX_FALLBACK_LOGICOP
,
920 (ctx
->Color
.ColorLogicOpEnabled
&&
921 ctx
->Color
.LogicOp
!= GL_COPY
));
925 FLUSH_BATCH( fxMesa
);
926 fxMesa
->new_state
|= TDFX_NEW_CULL
;
930 FLUSH_BATCH( fxMesa
);
931 fxMesa
->new_state
|= TDFX_NEW_DEPTH
;
935 FLUSH_BATCH( fxMesa
);
937 fxMesa
->Color
.Dither
= GR_DITHER_2x2
;
939 fxMesa
->Color
.Dither
= GR_DITHER_DISABLE
;
941 fxMesa
->dirty
|= TDFX_UPLOAD_DITHER
;
945 FLUSH_BATCH( fxMesa
);
946 fxMesa
->new_state
|= TDFX_NEW_FOG
;
949 case GL_COLOR_LOGIC_OP
:
950 FALLBACK( fxMesa
, TDFX_FALLBACK_LOGICOP
,
951 (ctx
->Color
.ColorLogicOpEnabled
&&
952 ctx
->Color
.LogicOp
!= GL_COPY
));
956 FALLBACK( fxMesa
, TDFX_FALLBACK_SPECULAR
,
957 (ctx
->Light
.Enabled
&&
958 ctx
->Light
.Model
.ColorControl
== GL_SEPARATE_SPECULAR_COLOR
));
962 FLUSH_BATCH( fxMesa
);
963 fxMesa
->new_state
|= TDFX_NEW_LINE
;
966 case GL_LINE_STIPPLE
:
967 FALLBACK(fxMesa
, TDFX_FALLBACK_LINE_STIPPLE
, state
);
970 case GL_POLYGON_STIPPLE
:
972 fxMesa
->new_state
|= TDFX_NEW_STIPPLE
;
975 case GL_SCISSOR_TEST
:
976 FLUSH_BATCH( fxMesa
);
977 fxMesa
->new_state
|= TDFX_NEW_CLIP
;
980 case GL_STENCIL_TEST
:
981 FLUSH_BATCH( fxMesa
);
982 FALLBACK( fxMesa
, TDFX_FALLBACK_STENCIL
, state
&& !fxMesa
->haveHwStencil
);
987 FLUSH_BATCH( fxMesa
);
988 FALLBACK( fxMesa
, TDFX_FALLBACK_TEXTURE_1D_3D
, state
); /* wrong */
989 fxMesa
->new_state
|= TDFX_NEW_TEXTURE
;
993 FLUSH_BATCH( fxMesa
);
994 fxMesa
->new_state
|= TDFX_NEW_TEXTURE
;
1004 /* Set the buffer used for drawing */
1005 /* XXX support for separate read/draw buffers hasn't been tested */
1006 static void tdfxDDDrawBuffer( GLcontext
*ctx
, GLenum mode
)
1008 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
1010 if ( TDFX_DEBUG
& DEBUG_VERBOSE_API
) {
1011 fprintf( stderr
, "%s()\n", __FUNCTION__
);
1014 FLUSH_BATCH( fxMesa
);
1017 * _DrawDestMask is easier to cope with than <mode>.
1019 switch ( ctx
->Color
._DrawDestMask
) {
1020 case FRONT_LEFT_BIT
:
1021 fxMesa
->DrawBuffer
= fxMesa
->ReadBuffer
= GR_BUFFER_FRONTBUFFER
;
1022 fxMesa
->new_state
|= TDFX_NEW_RENDER
;
1023 FALLBACK( fxMesa
, TDFX_FALLBACK_DRAW_BUFFER
, GL_FALSE
);
1026 fxMesa
->DrawBuffer
= fxMesa
->ReadBuffer
= GR_BUFFER_BACKBUFFER
;
1027 fxMesa
->new_state
|= TDFX_NEW_RENDER
;
1028 FALLBACK( fxMesa
, TDFX_FALLBACK_DRAW_BUFFER
, GL_FALSE
);
1031 FX_grColorMaskv( ctx
, false4
);
1032 FALLBACK( fxMesa
, TDFX_FALLBACK_DRAW_BUFFER
, GL_FALSE
);
1035 FALLBACK( fxMesa
, TDFX_FALLBACK_DRAW_BUFFER
, GL_TRUE
);
1039 /* We want to update the s/w rast state too so that tdfxDDSetBuffer()
1042 _swrast_DrawBuffer(ctx
, mode
);
1046 static void tdfxDDReadBuffer( GLcontext
*ctx
, GLenum mode
)
1052 /* =============================================================
1056 static void tdfxDDPolygonStipple( GLcontext
*ctx
, const GLubyte
*mask
)
1058 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
1059 const GLubyte
*m
= mask
;
1062 GLboolean allBitsSet
;
1064 /* int active = (ctx->Polygon.StippleFlag && */
1065 /* fxMesa->reduced_prim == GL_TRIANGLES); */
1067 FLUSH_BATCH(fxMesa
);
1068 fxMesa
->Stipple
.Pattern
= 0xffffffff;
1069 fxMesa
->dirty
|= TDFX_UPLOAD_STIPPLE
;
1070 fxMesa
->new_state
|= TDFX_NEW_STIPPLE
;
1072 /* Check if the stipple pattern is fully opaque. If so, use software
1073 * rendering. This basically a trick to make sure the OpenGL conformance
1076 allBitsSet
= GL_TRUE
;
1077 for (i
= 0; i
< 32; i
++) {
1078 if (((GLuint
*) mask
)[i
] != 0xffffffff) {
1079 allBitsSet
= GL_FALSE
;
1084 fxMesa
->haveHwStipple
= GL_FALSE
;
1093 for (k
= 0 ; k
< 8 ; k
++)
1094 for (j
= 0 ; j
< 4; j
++)
1095 for (i
= 0 ; i
< 4 ; i
++,m
++) {
1097 fxMesa
->haveHwStipple
= GL_FALSE
;
1102 fxMesa
->haveHwStipple
= GL_TRUE
;
1103 fxMesa
->Stipple
.Pattern
= ( (q
[0] << 0) |
1111 static void tdfxDDRenderMode( GLcontext
*ctx
, GLenum mode
)
1113 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
1114 FALLBACK( fxMesa
, TDFX_FALLBACK_RENDER_MODE
, (mode
!= GL_RENDER
) );
1119 static void tdfxDDPrintState( const char *msg
, GLuint flags
)
1122 "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s\n",
1125 (flags
& TDFX_NEW_COLOR
) ? "color, " : "",
1126 (flags
& TDFX_NEW_ALPHA
) ? "alpha, " : "",
1127 (flags
& TDFX_NEW_DEPTH
) ? "depth, " : "",
1128 (flags
& TDFX_NEW_RENDER
) ? "render, " : "",
1129 (flags
& TDFX_NEW_FOG
) ? "fog, " : "",
1130 (flags
& TDFX_NEW_STENCIL
) ? "stencil, " : "",
1131 (flags
& TDFX_NEW_STIPPLE
) ? "stipple, " : "",
1132 (flags
& TDFX_NEW_CLIP
) ? "clip, " : "",
1133 (flags
& TDFX_NEW_VIEWPORT
) ? "viewport, " : "",
1134 (flags
& TDFX_NEW_CULL
) ? "cull, " : "",
1135 (flags
& TDFX_NEW_GLIDE
) ? "glide, " : "",
1136 (flags
& TDFX_NEW_TEXTURE
) ? "texture, " : "",
1137 (flags
& TDFX_NEW_CONTEXT
) ? "context, " : "");
1142 void tdfxDDUpdateHwState( GLcontext
*ctx
)
1144 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
1145 int new_state
= fxMesa
->new_state
;
1147 if ( TDFX_DEBUG
& DEBUG_VERBOSE_API
) {
1148 fprintf( stderr
, "%s()\n", __FUNCTION__
);
1153 FLUSH_BATCH( fxMesa
);
1155 fxMesa
->new_state
= 0;
1158 tdfxDDPrintState( "tdfxUpdateHwState", new_state
);
1160 /* Update the various parts of the context's state.
1162 if ( new_state
& TDFX_NEW_ALPHA
) {
1163 tdfxUpdateAlphaMode( ctx
);
1166 if ( new_state
& TDFX_NEW_DEPTH
)
1167 tdfxUpdateZMode( ctx
);
1169 if ( new_state
& TDFX_NEW_FOG
)
1170 tdfxUpdateFogAttrib( ctx
);
1172 if ( new_state
& TDFX_NEW_CLIP
)
1173 tdfxUpdateClipping( ctx
);
1175 if ( new_state
& TDFX_NEW_STIPPLE
)
1176 tdfxUpdateStipple( ctx
);
1178 if ( new_state
& TDFX_NEW_CULL
)
1179 tdfxUpdateCull( ctx
);
1181 if ( new_state
& TDFX_NEW_LINE
)
1182 tdfxUpdateLine( ctx
);
1184 if ( new_state
& TDFX_NEW_VIEWPORT
)
1185 tdfxUpdateViewport( ctx
);
1187 if ( new_state
& TDFX_NEW_RENDER
)
1188 tdfxUpdateRenderAttrib( ctx
);
1190 if ( new_state
& TDFX_NEW_STENCIL
)
1191 tdfxUpdateStencil( ctx
);
1193 if ( new_state
& TDFX_NEW_TEXTURE
) {
1194 tdfxUpdateTextureState( ctx
);
1196 else if ( new_state
& TDFX_NEW_TEXTURE_BIND
) {
1197 tdfxUpdateTextureBinding( ctx
);
1202 FxI32 bias
= (FxI32
) (ctx
->Polygon
.OffsetUnits
* TDFX_DEPTH_BIAS_SCALE
);
1204 if ( fxMesa
->Depth
.Bias
!= bias
) {
1205 fxMesa
->Depth
.Bias
= bias
;
1206 fxMesa
->dirty
|= TDFX_UPLOAD_DEPTH_BIAS
;
1210 if ( fxMesa
->dirty
) {
1211 LOCK_HARDWARE( fxMesa
);
1212 tdfxEmitHwStateLocked( fxMesa
);
1213 UNLOCK_HARDWARE( fxMesa
);
1218 static void tdfxDDInvalidateState( GLcontext
*ctx
, GLuint new_state
)
1220 _swrast_InvalidateState( ctx
, new_state
);
1221 _swsetup_InvalidateState( ctx
, new_state
);
1222 _ac_InvalidateState( ctx
, new_state
);
1223 _tnl_InvalidateState( ctx
, new_state
);
1224 TDFX_CONTEXT(ctx
)->new_gl_state
|= new_state
;
1229 /* Initialize the context's Glide state mirror. These values will be
1230 * used as Glide function call parameters when the time comes.
1232 void tdfxInitState( tdfxContextPtr fxMesa
)
1234 GLcontext
*ctx
= fxMesa
->glCtx
;
1237 fxMesa
->ColorCombine
.Function
= GR_COMBINE_FUNCTION_LOCAL
;
1238 fxMesa
->ColorCombine
.Factor
= GR_COMBINE_FACTOR_NONE
;
1239 fxMesa
->ColorCombine
.Local
= GR_COMBINE_LOCAL_ITERATED
;
1240 fxMesa
->ColorCombine
.Other
= GR_COMBINE_OTHER_NONE
;
1241 fxMesa
->ColorCombine
.Invert
= FXFALSE
;
1242 fxMesa
->AlphaCombine
.Function
= GR_COMBINE_FUNCTION_LOCAL
;
1243 fxMesa
->AlphaCombine
.Factor
= GR_COMBINE_FACTOR_NONE
;
1244 fxMesa
->AlphaCombine
.Local
= GR_COMBINE_LOCAL_ITERATED
;
1245 fxMesa
->AlphaCombine
.Other
= GR_COMBINE_OTHER_NONE
;
1246 fxMesa
->AlphaCombine
.Invert
= FXFALSE
;
1248 fxMesa
->ColorCombineExt
.SourceA
= GR_CMBX_ITRGB
;
1249 fxMesa
->ColorCombineExt
.ModeA
= GR_FUNC_MODE_X
;
1250 fxMesa
->ColorCombineExt
.SourceB
= GR_CMBX_ZERO
;
1251 fxMesa
->ColorCombineExt
.ModeB
= GR_FUNC_MODE_ZERO
;
1252 fxMesa
->ColorCombineExt
.SourceC
= GR_CMBX_ZERO
;
1253 fxMesa
->ColorCombineExt
.InvertC
= FXTRUE
;
1254 fxMesa
->ColorCombineExt
.SourceD
= GR_CMBX_ZERO
;
1255 fxMesa
->ColorCombineExt
.InvertD
= FXFALSE
;
1256 fxMesa
->ColorCombineExt
.Shift
= 0;
1257 fxMesa
->ColorCombineExt
.Invert
= FXFALSE
;
1258 fxMesa
->AlphaCombineExt
.SourceA
= GR_CMBX_ITALPHA
;
1259 fxMesa
->AlphaCombineExt
.ModeA
= GR_FUNC_MODE_X
;
1260 fxMesa
->AlphaCombineExt
.SourceB
= GR_CMBX_ZERO
;
1261 fxMesa
->AlphaCombineExt
.ModeB
= GR_FUNC_MODE_ZERO
;
1262 fxMesa
->AlphaCombineExt
.SourceC
= GR_CMBX_ZERO
;
1263 fxMesa
->AlphaCombineExt
.InvertC
= FXTRUE
;
1264 fxMesa
->AlphaCombineExt
.SourceD
= GR_CMBX_ZERO
;
1265 fxMesa
->AlphaCombineExt
.InvertD
= FXFALSE
;
1266 fxMesa
->AlphaCombineExt
.Shift
= 0;
1267 fxMesa
->AlphaCombineExt
.Invert
= FXFALSE
;
1269 fxMesa
->sScale0
= fxMesa
->tScale0
= 1.0;
1270 fxMesa
->sScale1
= fxMesa
->tScale1
= 1.0;
1272 fxMesa
->TexPalette
.Type
= 0;
1273 fxMesa
->TexPalette
.Data
= NULL
;
1275 for ( i
= 0 ; i
< TDFX_NUM_TMU
; i
++ ) {
1276 fxMesa
->TexSource
[i
].StartAddress
= 0;
1277 fxMesa
->TexSource
[i
].EvenOdd
= GR_MIPMAPLEVELMASK_EVEN
;
1278 fxMesa
->TexSource
[i
].Info
= NULL
;
1280 fxMesa
->TexCombine
[i
].FunctionRGB
= 0;
1281 fxMesa
->TexCombine
[i
].FactorRGB
= 0;
1282 fxMesa
->TexCombine
[i
].FunctionAlpha
= 0;
1283 fxMesa
->TexCombine
[i
].FactorAlpha
= 0;
1284 fxMesa
->TexCombine
[i
].InvertRGB
= FXFALSE
;
1285 fxMesa
->TexCombine
[i
].InvertAlpha
= FXFALSE
;
1287 fxMesa
->TexCombineExt
[i
].Alpha
.SourceA
= 0;
1288 /* XXX more state to init here */
1289 fxMesa
->TexCombineExt
[i
].Color
.SourceA
= 0;
1290 fxMesa
->TexCombineExt
[i
].EnvColor
= 0x0;
1292 fxMesa
->TexParams
[i
].sClamp
= GR_TEXTURECLAMP_WRAP
;
1293 fxMesa
->TexParams
[i
].tClamp
= GR_TEXTURECLAMP_WRAP
;
1294 fxMesa
->TexParams
[i
].minFilt
= GR_TEXTUREFILTER_POINT_SAMPLED
;
1295 fxMesa
->TexParams
[i
].magFilt
= GR_TEXTUREFILTER_BILINEAR
;
1296 fxMesa
->TexParams
[i
].mmMode
= GR_MIPMAP_DISABLE
;
1297 fxMesa
->TexParams
[i
].LODblend
= FXFALSE
;
1298 fxMesa
->TexParams
[i
].LodBias
= 0.0;
1300 fxMesa
->TexState
.EnvMode
[i
] = ~0;
1301 fxMesa
->TexState
.TexFormat
[i
] = ~0;
1302 fxMesa
->TexState
.Enabled
[i
] = 0;
1305 if ( ctx
->Visual
.doubleBufferMode
) {
1306 fxMesa
->DrawBuffer
= GR_BUFFER_BACKBUFFER
;
1307 fxMesa
->ReadBuffer
= GR_BUFFER_BACKBUFFER
;
1309 fxMesa
->DrawBuffer
= GR_BUFFER_FRONTBUFFER
;
1310 fxMesa
->ReadBuffer
= GR_BUFFER_FRONTBUFFER
;
1313 fxMesa
->Color
.ClearColor
= 0x00000000;
1314 fxMesa
->Color
.ClearAlpha
= 0x00;
1315 fxMesa
->Color
.ColorMask
[RCOMP
] = FXTRUE
;
1316 fxMesa
->Color
.ColorMask
[BCOMP
] = FXTRUE
;
1317 fxMesa
->Color
.ColorMask
[GCOMP
] = FXTRUE
;
1318 fxMesa
->Color
.ColorMask
[ACOMP
] = FXTRUE
;
1319 fxMesa
->Color
.MonoColor
= 0xffffffff;
1321 fxMesa
->Color
.AlphaFunc
= GR_CMP_ALWAYS
;
1322 fxMesa
->Color
.AlphaRef
= 0x00;
1323 fxMesa
->Color
.BlendSrcRGB
= GR_BLEND_ONE
;
1324 fxMesa
->Color
.BlendDstRGB
= GR_BLEND_ZERO
;
1325 fxMesa
->Color
.BlendSrcA
= GR_BLEND_ONE
;
1326 fxMesa
->Color
.BlendSrcA
= GR_BLEND_ZERO
;
1328 fxMesa
->Color
.Dither
= GR_DITHER_2x2
;
1330 if ( fxMesa
->glCtx
->Visual
.depthBits
> 0 ) {
1331 fxMesa
->Depth
.Mode
= GR_DEPTHBUFFER_ZBUFFER
;
1333 fxMesa
->Depth
.Mode
= GR_DEPTHBUFFER_DISABLE
;
1335 fxMesa
->Depth
.Bias
= 0;
1336 fxMesa
->Depth
.Func
= GR_CMP_LESS
;
1337 fxMesa
->Depth
.Clear
= 0; /* computed later */
1338 fxMesa
->Depth
.Mask
= FXTRUE
;
1341 fxMesa
->Fog
.Mode
= GR_FOG_DISABLE
;
1342 fxMesa
->Fog
.Color
= 0x00000000;
1343 fxMesa
->Fog
.Table
= NULL
;
1344 fxMesa
->Fog
.Density
= 1.0;
1345 fxMesa
->Fog
.Near
= 1.0;
1346 fxMesa
->Fog
.Far
= 1.0;
1348 fxMesa
->Stencil
.Function
= GR_CMP_ALWAYS
;
1349 fxMesa
->Stencil
.RefValue
= 0;
1350 fxMesa
->Stencil
.ValueMask
= 0xff;
1351 fxMesa
->Stencil
.WriteMask
= 0xff;
1352 fxMesa
->Stencil
.FailFunc
= 0;
1353 fxMesa
->Stencil
.ZFailFunc
= 0;
1354 fxMesa
->Stencil
.ZPassFunc
= 0;
1355 fxMesa
->Stencil
.Clear
= 0;
1357 fxMesa
->Stipple
.Mode
= GR_STIPPLE_DISABLE
;
1358 fxMesa
->Stipple
.Pattern
= 0xffffffff;
1360 fxMesa
->Scissor
.minX
= 0;
1361 fxMesa
->Scissor
.minY
= 0;
1362 fxMesa
->Scissor
.maxX
= 0;
1363 fxMesa
->Scissor
.maxY
= 0;
1365 fxMesa
->Viewport
.Mode
= GR_WINDOW_COORDS
;
1366 fxMesa
->Viewport
.X
= 0;
1367 fxMesa
->Viewport
.Y
= 0;
1368 fxMesa
->Viewport
.Width
= 0;
1369 fxMesa
->Viewport
.Height
= 0;
1370 fxMesa
->Viewport
.Near
= 0.0;
1371 fxMesa
->Viewport
.Far
= 0.0;
1373 fxMesa
->CullMode
= GR_CULL_DISABLE
;
1375 fxMesa
->Glide
.ColorFormat
= GR_COLORFORMAT_ABGR
;
1376 fxMesa
->Glide
.Origin
= GR_ORIGIN_LOWER_LEFT
;
1377 fxMesa
->Glide
.Initialized
= FXFALSE
;
1382 void tdfxDDInitStateFuncs( GLcontext
*ctx
)
1384 tdfxContextPtr fxMesa
= TDFX_CONTEXT(ctx
);
1386 ctx
->Driver
.UpdateState
= tdfxDDInvalidateState
;
1389 /* State notification callbacks:
1391 ctx
->Driver
.ClearColor
= tdfxDDClearColor
;
1392 ctx
->Driver
.DrawBuffer
= tdfxDDDrawBuffer
;
1393 ctx
->Driver
.ReadBuffer
= tdfxDDReadBuffer
;
1395 ctx
->Driver
.ColorMask
= tdfxDDColorMask
;
1397 ctx
->Driver
.AlphaFunc
= tdfxDDAlphaFunc
;
1398 ctx
->Driver
.BlendEquation
= tdfxDDBlendEquation
;
1399 ctx
->Driver
.BlendFunc
= tdfxDDBlendFunc
;
1400 ctx
->Driver
.BlendFuncSeparate
= tdfxDDBlendFuncSeparate
;
1401 ctx
->Driver
.ClearDepth
= tdfxDDClearDepth
;
1402 ctx
->Driver
.CullFace
= tdfxDDCullFace
;
1403 ctx
->Driver
.FrontFace
= tdfxDDFrontFace
;
1404 ctx
->Driver
.DepthFunc
= tdfxDDDepthFunc
;
1405 ctx
->Driver
.DepthMask
= tdfxDDDepthMask
;
1406 ctx
->Driver
.DepthRange
= tdfxDDDepthRange
;
1407 ctx
->Driver
.Enable
= tdfxDDEnable
;
1408 ctx
->Driver
.Fogfv
= tdfxDDFogfv
;
1409 ctx
->Driver
.LightModelfv
= tdfxDDLightModelfv
;
1410 ctx
->Driver
.LineWidth
= tdfxDDLineWidth
;
1411 ctx
->Driver
.PolygonStipple
= tdfxDDPolygonStipple
;
1412 ctx
->Driver
.RenderMode
= tdfxDDRenderMode
;
1413 ctx
->Driver
.Scissor
= tdfxDDScissor
;
1414 ctx
->Driver
.ShadeModel
= tdfxDDShadeModel
;
1416 /* ctx->Driver.GetTexImage = tdfxDDGetTexImage; */
1417 ctx
->Driver
.UpdateTexturePalette
= tdfxDDTexturePalette
;
1419 if ( fxMesa
->haveHwStencil
) {
1420 ctx
->Driver
.StencilFunc
= tdfxDDStencilFunc
;
1421 ctx
->Driver
.StencilMask
= tdfxDDStencilMask
;
1422 ctx
->Driver
.StencilOp
= tdfxDDStencilOp
;
1425 ctx
->Driver
.Viewport
= tdfxDDViewport
;
1427 /* Swrast hooks for imaging extensions:
1429 ctx
->Driver
.CopyColorTable
= _swrast_CopyColorTable
;
1430 ctx
->Driver
.CopyColorSubTable
= _swrast_CopyColorSubTable
;
1431 ctx
->Driver
.CopyConvolutionFilter1D
= _swrast_CopyConvolutionFilter1D
;
1432 ctx
->Driver
.CopyConvolutionFilter2D
= _swrast_CopyConvolutionFilter2D
;