2 * Author: Max Lingua <sunmax@libero.it>
5 #include <X11/Xlibint.h>
6 #include "s3v_context.h"
7 #include "s3v_macros.h"
11 #include "swrast/swrast.h"
12 #include "swrast_setup/swrast_setup.h"
16 /* #define DEBUG(str) printf str */
17 #define ENABLELIGHTING 0
20 /* =============================================================
24 static void s3vUpdateAlphaMode( GLcontext
*ctx
)
26 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
27 CARD32 cmd
= vmesa
->CMD
;
28 cmd
&= ~ALPHA_BLEND_MASK
;
30 if ( ctx
->Color
.BlendEnabled
) {
31 DEBUG(("ctx->Color.AlphaEnabled = 1"));
32 vmesa
->_alpha
[0] = ALPHA_SRC
;
33 vmesa
->_alpha
[1] = vmesa
->_alpha_tex
; /* FIXME: not all tex modes
36 DEBUG(("ctx->Color.AlphaEnabled = 0"));
37 vmesa
->_alpha
[0] = vmesa
->_alpha
[1] = ALPHA_OFF
;
40 if ((cmd
& DO_MASK
) & DO_3D_LINE
) { /* we are drawing 3d lines */
41 /* which don't support tex */
42 cmd
|= vmesa
->_alpha
[0];
44 cmd
|= vmesa
->_alpha
[vmesa
->_3d_mode
];
47 vmesa
->CMD
= cmd
; /* FIXME: enough? */
49 vmesa
->restore_primitive
= -1;
54 static void s3vDDAlphaFunc( GLcontext
*ctx
, GLenum func
, GLfloat ref
)
56 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
58 DEBUG(("s3vDDAlphaFunc\n"));
60 vmesa
->new_state
|= S3V_NEW_ALPHA
;
63 static void s3vDDBlendFunc( GLcontext
*ctx
, GLenum sfactor
, GLenum dfactor
)
65 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
67 DEBUG(("s3vDDBlendFunc\n"));
69 vmesa
->new_state
|= S3V_NEW_ALPHA
;
72 /* ================================================================
76 static void s3vDDClear( GLcontext
*ctx
, GLbitfield mask
)
78 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
80 GLint cx
= ctx
->DrawBuffer
->_Xmin
;
81 GLint cy
= ctx
->DrawBuffer
->_Ymin
;
82 GLint cw
= ctx
->DrawBuffer
->_Xmax
- cx
;
83 GLint ch
= ctx
->DrawBuffer
->_Ymax
- cy
;
85 /* XXX FIX ME: the cx,cy,cw,ch vars are currently ignored! */
87 vmesa
->restore_primitive
= -1;
89 /* Update and emit any new state. We need to do this here to catch
90 * changes to the masks.
91 * FIXME: Just update the masks?
94 if ( vmesa
->new_state
)
95 s3vDDUpdateHWState( ctx
);
97 /* s3vUpdateMasks( ctx ); */
98 /* s3vUpdateClipping( ctx ); */
99 /* s3vEmitHwState( vmesa ); */
102 #if 1 /* soft (0)/hw (1)*/
104 DEBUG(("*** s3vDDClear ***\n"));
106 DMAOUT_CHECK(BITBLT_SRC_BASE
, 15);
107 DMAOUT(vmesa
->SrcBase
);
108 DMAOUT(vmesa
->DestBlit
);
109 DMAOUT( vmesa
->ScissorLR
);
110 DMAOUT( vmesa
->ScissorTB
);
111 DMAOUT( (vmesa
->SrcStride
<< 16) | vmesa
->SrcStride
); /* FIXME: unify */
112 DMAOUT( (~(0)) ); /* masks */
115 DMAOUT(vmesa
->ClearColor
);
119 DMAOUT(0x16000122 | 0x5 | (0xF0 << 17)); /* black magic to me */
120 DMAOUT(vmesa
->ScissorWH
);
121 DMAOUT(vmesa
->SrcXY
);
122 DMAOUT(vmesa
->DestXY
);
125 if (mask
& BUFFER_BIT_DEPTH
) { /* depth */
126 DEBUG(("BUFFER_BIT_DEPTH\n"));
128 _stride
= ((cw
+31)&~31) * 2; /* XXX cw or Buffer->Width??? */
130 DMAOUT_CHECK(BITBLT_SRC_BASE
, 15);
132 DMAOUT(vmesa
->s3vScreen
->depthOffset
);
133 DMAOUT( (0 << 16) | cw
);
134 DMAOUT( (0 << 16) | ch
);
135 DMAOUT( (vmesa
->SrcStride
<< 16) | vmesa
->DestStride
);
136 DMAOUT( (~(0)) ); /* masks */
139 DMAOUT(vmesa
->ClearDepth
); /* 0x7FFF */
143 DMAOUT(0x16000122 | 0x5 | (0xF0 << 17));
144 DMAOUT( ((cw
-1) << 16) | (ch
-1) );
146 DMAOUT( (0 << 16) | 0 );
149 DEBUG(("vmesa->ClearDepth = 0x%x\n", vmesa
->ClearDepth
));
150 mask
&= ~BUFFER_BIT_DEPTH
;
153 if (!vmesa
->NotClipped
) {
154 DEBUG(("vmesa->NotClipped\n")); /* yes */
157 if (!(vmesa
->EnabledFlags
& S3V_BACK_BUFFER
)) {
158 DEBUG(("!S3V_BACK_BUFFER -> flush\n"));
163 DEBUG(("still masked ;3(\n")); */ /* yes */
165 _swrast_Clear( ctx
, mask
);
169 /* =============================================================
173 static void s3vUpdateZMode( GLcontext
*ctx
)
175 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
176 CARD32 cmd
= vmesa
->CMD
;
178 DEBUG(("Depth.Test = %i\n", ctx
->Depth
.Test
));
179 DEBUG(("CMD was = 0x%x ", cmd
));
181 /* printf("depth --- CMD was = 0x%x \n", cmd); */
183 cmd
&= ~Z_MASK
; /* 0xfc0fffff; */
184 /* Z_BUFFER */ /* 000 mode */ /* Z_UPDATE_OFF */
186 if (!ctx
->Depth
.Test
)
189 if ( ctx
->Depth
.Mask
)
192 switch ( ctx
->Depth
.Func
) {
219 DEBUG(("CMD is 0x%x\n", cmd
));
221 vmesa
->dirty
|= S3V_UPLOAD_DEPTH
;
225 static void s3vDDDepthFunc( GLcontext
*ctx
, GLenum func
)
227 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
229 /* FLUSH_BATCH( vmesa ); */
230 DEBUG(("s3vDDDepthFunc\n"));
231 vmesa
->new_state
|= S3V_NEW_DEPTH
;
234 static void s3vDDDepthMask( GLcontext
*ctx
, GLboolean flag
)
236 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
238 /* FLUSH_BATCH( vmesa ); */
239 DEBUG(("s3vDDDepthMask\n"));
240 vmesa
->new_state
|= S3V_NEW_DEPTH
;
243 static void s3vDDClearDepth( GLcontext
*ctx
, GLclampd d
)
245 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
247 switch ( vmesa
->DepthSize
) {
250 vmesa
->ClearDepth
= d
* 0x0000ffff; /* 65536 */
251 DEBUG(("GLclampd d = %f\n", d
));
252 DEBUG(("ctx->Depth.Clear = %f\n", ctx
->Depth
.Clear
));
253 DEBUG(("(They should be the same)\n"));
256 vmesa
->ClearDepth
= d
* 0x00ffffff;
259 vmesa
->ClearDepth
= d
* 0xffffffff;
264 static void s3vDDFinish( GLcontext
*ctx
)
266 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
270 static void s3vDDFlush( GLcontext
*ctx
)
272 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
276 /* =============================================================
280 static void s3vUpdateFogAttrib( GLcontext
*ctx
)
282 /* s3vContextPtr vmesa = S3V_CONTEXT(ctx); */
284 if (ctx
->Fog
.Enabled
) {
288 switch (ctx
->Fog
.Mode
) {
298 static void s3vDDFogfv( GLcontext
*ctx
, GLenum pname
, const GLfloat
*param
)
300 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
301 vmesa
->new_state
|= S3V_NEW_FOG
;
304 /* =============================================================
307 static void s3vDDLineWidth( GLcontext
*ctx
, GLfloat width
)
309 /* FIXME: on virge you only have one size of 3d lines *
310 * if we wanted more, we should start using tris instead *
311 * but virge has problem with some tris when all of the *
312 * vertices stay on a line */
315 /* =============================================================
318 static void s3vDDPointSize( GLcontext
*ctx
, GLfloat size
)
320 /* FIXME: we use 3d line to fake points. So same limitations
324 /* =============================================================
328 static void s3vUpdatePolygon( GLcontext
*ctx
)
330 /* FIXME: I don't think we could do much here */
332 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
333 vmesa
->dirty
|= S3V_UPLOAD_POLYGON
;
336 /* =============================================================
340 static void s3vUpdateClipping( GLcontext
*ctx
)
342 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
343 __DRIdrawablePrivate
*dPriv
= vmesa
->driDrawable
;
347 DEBUG((">>> s3vUpdateClipping <<<\n"));
349 if ( vmesa->driDrawable ) {
350 DEBUG(("s3vUpdateClipping\n"));
352 if (vmesa
->EnabledFlags
& S3V_BACK_BUFFER
) {
353 DEBUG(("S3V_BACK_BUFFER\n"));
361 vmesa
->DestBase
= vmesa
->s3vScreen
->backOffset
;
362 vmesa
->DestBlit
= vmesa
->DestBase
;
363 vmesa
->ScissorLR
= ( (0 << 16) | (dPriv
->w
-1) );
364 vmesa
->ScissorTB
= ( (0 << 16) | (dPriv
->h
-1) );
366 vmesa->ScissorLR = ( (x0 << 16) | x1 );
367 vmesa->ScissorTB = ( (y0 << 16) | y1 );
369 vmesa
->SrcStride
= ( ((dPriv
->w
+31)&~31) * vmesa
->s3vScreen
->cpp
);
370 vmesa
->DestStride
= vmesa
->driScreen
->fbWidth
*vmesa
->s3vScreen
->cpp
;
371 vmesa
->ScissorWH
= ( (dPriv
->w
<< 16) | dPriv
->h
);
373 /* vmesa->DestXY = ( (dPriv->x << 16) | dPriv->y ); */
374 vmesa
->DestXY
= ( (0 << 16) | 0 );
376 DEBUG(("S3V_FRONT_BUFFER\n"));
380 x1
= x0
+ dPriv
->w
- 1;
381 y1
= y0
+ dPriv
->h
- 1;
385 vmesa
->ScissorLR
= ( (x0
<< 16) | x1
);
386 vmesa
->ScissorTB
= ( (y0
<< 16) | y1
);
387 vmesa
->DestStride
= vmesa
->driScreen
->fbWidth
*vmesa
->s3vScreen
->cpp
;
388 vmesa
->SrcStride
= vmesa
->DestStride
;
389 vmesa
->DestBase
= (y0
* vmesa
->DestStride
)
390 + x0
*vmesa
->s3vScreen
->cpp
;
392 vmesa
->ScissorWH
= ( (x1
<< 16) | y1
);
394 vmesa
->DestXY
= ( (0 << 16) | 0 );
395 /* vmesa->DestXY = ( (dPriv->x << 16) | dPriv->y ); */
398 DEBUG(("x0=%i y0=%i x1=%i y1=%i\n", x0
, y0
, x1
, y1
));
399 DEBUG(("stride=%i rectWH=0x%x\n\n", vmesa
->DestStride
, vmesa
->ScissorWH
));
401 /* FIXME: how could we use the following info? */
402 /* if (ctx->Scissor.Enabled) {} */
404 vmesa
->dirty
|= S3V_UPLOAD_CLIP
;
408 static void s3vDDScissor( GLcontext
*ctx
,
409 GLint x
, GLint y
, GLsizei w
, GLsizei h
)
411 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
413 DEBUG((">>> s3vDDScissor <<<"));
414 /* FLUSH_BATCH( vmesa ); */
415 vmesa
->new_state
|= S3V_NEW_CLIP
;
418 /* =============================================================
422 static void s3vUpdateCull( GLcontext
*ctx
)
424 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
425 GLfloat backface_sign
= 1;
427 DEBUG(("s3vUpdateCull\n"));
428 /* FIXME: GL_FRONT_AND_BACK */
430 switch ( ctx
->Polygon
.CullFaceMode
) {
432 if (ctx
->Polygon
.FrontFace
== GL_CCW
)
437 if (ctx
->Polygon
.FrontFace
!= GL_CCW
)
445 vmesa
->backface_sign
= backface_sign
;
446 vmesa
->dirty
|= S3V_UPLOAD_GEOMETRY
;
450 static void s3vDDCullFace( GLcontext
*ctx
, GLenum mode
)
452 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
453 /* FLUSH_BATCH( vmesa ); */
454 vmesa
->new_state
|= S3V_NEW_CULL
;
457 static void s3vDDFrontFace( GLcontext
*ctx
, GLenum mode
)
459 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
460 /* FLUSH_BATCH( vmesa ); */
461 vmesa
->new_state
|= S3V_NEW_CULL
;
464 /* =============================================================
468 static void s3vUpdateMasks( GLcontext
*ctx
)
470 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
472 GLuint mask
= s3vPackColor( vmesa
->s3vScreen
->cpp
,
473 ctx
->Color
.ColorMask
[RCOMP
],
474 ctx
->Color
.ColorMask
[GCOMP
],
475 ctx
->Color
.ColorMask
[BCOMP
],
476 ctx
->Color
.ColorMask
[ACOMP
] );
478 if (vmesa
->s3vScreen
->cpp
== 2) mask
|= mask
<< 16;
480 /* FIXME: can we do something in virge? */
483 static void s3vDDColorMask( GLcontext *ctx, GLboolean r, GLboolean g,
484 GLboolean b, GLboolean a)
486 s3vContextPtr vmesa = S3V_CONTEXT(ctx);
488 FLUSH_BATCH( vmesa );
489 vmesa->new_state |= S3V_NEW_MASKS;
492 /* =============================================================
493 * Rendering attributes
496 /* =============================================================
500 static void s3vDDClearColor( GLcontext
*ctx
, const GLfloat color
[4])
502 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
504 DEBUG(("*** s3vDDClearColor\n"));
506 vmesa
->ClearColor
= s3vPackColor( 2, /* vmesa->s3vScreen->cpp, */
507 color
[0], color
[1], color
[2], color
[3] );
510 if (vmesa
->s3vScreen
->cpp
== 2) vmesa
->ClearColor
|= vmesa
->ClearColor
<<16;
514 static void s3vDDSetDrawBuffer( GLcontext
*ctx
, GLenum mode
)
516 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
519 DEBUG(("*** s3vDDSetDrawBuffer ***\n"));
521 /* FLUSH_BATCH( vmesa ); */
525 vmesa
->drawOffset
= vmesa
->s3vScreen
->frontOffset
;
528 vmesa
->drawOffset
= vmesa
->s3vScreen
->backOffset
;
529 /* vmesa->driScreen->fbHeight *
530 * vmesa->driScreen->fbWidth *
531 * vmesa->s3vScreen->cpp; */
538 DEBUG(("vmesa->drawOffset = 0x%x\n", vmesa
->drawOffset
));
539 /* return GL_TRUE; */
542 /* =============================================================
543 * Window position and viewport transformation
546 void s3vUpdateWindow( GLcontext
*ctx
)
548 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
549 __DRIdrawablePrivate
*dPriv
= vmesa
->driDrawable
;
550 GLfloat xoffset
= (GLfloat
)dPriv
->x
;
552 vmesa
->driScreen
->fbHeight
- (GLfloat
)dPriv
->y
- dPriv
->h
;
553 const GLfloat
*v
= ctx
->Viewport
._WindowMap
.m
;
555 GLfloat sx
= v
[MAT_SX
];
556 GLfloat tx
= v
[MAT_TX
] + xoffset
;
557 GLfloat sy
= v
[MAT_SY
];
558 GLfloat ty
= v
[MAT_TY
] + yoffset
;
559 GLfloat sz
= v
[MAT_SZ
] * vmesa
->depth_scale
;
560 GLfloat tz
= v
[MAT_TZ
] * vmesa
->depth_scale
;
562 vmesa
->dirty
|= S3V_UPLOAD_VIEWPORT
;
564 vmesa
->ViewportScaleX
= sx
;
565 vmesa
->ViewportScaleY
= sy
;
566 vmesa
->ViewportScaleZ
= sz
;
567 vmesa
->ViewportOffsetX
= tx
;
568 vmesa
->ViewportOffsetY
= ty
;
569 vmesa
->ViewportOffsetZ
= tz
;
574 static void s3vDDViewport( GLcontext *ctx, GLint x, GLint y,
575 GLsizei width, GLsizei height )
577 s3vUpdateWindow( ctx );
580 static void s3vDDDepthRange( GLcontext *ctx, GLclampd nearval,
583 s3vUpdateWindow( ctx );
586 void s3vUpdateViewportOffset( GLcontext
*ctx
)
588 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
589 __DRIdrawablePrivate
*dPriv
= vmesa
->driDrawable
;
590 GLfloat xoffset
= (GLfloat
)dPriv
->x
;
592 vmesa
->driScreen
->fbHeight
- (GLfloat
)dPriv
->y
- dPriv
->h
;
593 const GLfloat
*v
= ctx
->Viewport
._WindowMap
.m
;
595 GLfloat tx
= v
[MAT_TX
] + xoffset
;
596 GLfloat ty
= v
[MAT_TY
] + yoffset
;
598 DEBUG(("*** s3vUpdateViewportOffset ***\n"));
600 if ( vmesa
->ViewportOffsetX
!= tx
||
601 vmesa
->ViewportOffsetY
!= ty
)
603 vmesa
->ViewportOffsetX
= tx
;
604 vmesa
->ViewportOffsetY
= ty
;
606 vmesa
->new_state
|= S3V_NEW_WINDOW
;
609 /* vmesa->new_state |= S3V_NEW_CLIP; */
612 /* =============================================================
613 * State enable/disable
616 static void s3vDDEnable( GLcontext
*ctx
, GLenum cap
, GLboolean state
)
618 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
623 vmesa
->new_state
|= S3V_NEW_ALPHA
;
624 DEBUG(("s3vDDEnable: GL_BLEND\n"));
628 vmesa
->new_state
|= S3V_NEW_CULL
;
629 DEBUG(("s3vDDEnable: GL_CULL_FACE\n"));
633 vmesa
->new_state
|= S3V_NEW_DEPTH
;
634 DEBUG(("s3vDDEnable: GL_DEPTH\n"));
638 vmesa
->new_state
|= S3V_NEW_FOG
;
642 case GL_SCISSOR_TEST
:
643 vmesa
->new_state
|= S3V_NEW_CLIP
;
647 DEBUG(("*** GL_TEXTURE_2D: %i\n", state
));
648 vmesa
->_3d_mode
= state
;
649 vmesa
->restore_primitive
= -1;
657 /* =============================================================
658 * State initialization, management
663 * Load the current context's state into the hardware.
665 * NOTE: Be VERY careful about ensuring the context state is marked for
666 * upload, the only place it shouldn't be uploaded is when the setup
667 * state has changed in ReducedPrimitiveChange as this comes right after
670 * Blits of any type should always upload the context and masks after
673 void s3vEmitHwState( s3vContextPtr vmesa
)
675 if (!vmesa
->driDrawable
) return;
676 if (!vmesa
->dirty
) return;
678 DEBUG(("**********************\n"));
679 DEBUG(("*** s3vEmitHwState ***\n"));
680 DEBUG(("**********************\n"));
682 if (vmesa
->dirty
& S3V_UPLOAD_VIEWPORT
) {
683 vmesa
->dirty
&= ~S3V_UPLOAD_VIEWPORT
;
684 DEBUG(("S3V_UPLOAD_VIEWPORT\n"));
687 if ( (vmesa
->dirty
& S3V_UPLOAD_POINTMODE
) ||
688 (vmesa
->dirty
& S3V_UPLOAD_LINEMODE
) ||
689 (vmesa
->dirty
& S3V_UPLOAD_TRIMODE
) ) {
693 if (vmesa
->dirty
& S3V_UPLOAD_POINTMODE
) {
694 vmesa
->dirty
&= ~S3V_UPLOAD_POINTMODE
;
697 if (vmesa
->dirty
& S3V_UPLOAD_LINEMODE
) {
698 vmesa
->dirty
&= ~S3V_UPLOAD_LINEMODE
;
701 if (vmesa
->dirty
& S3V_UPLOAD_TRIMODE
) {
702 vmesa
->dirty
&= ~S3V_UPLOAD_TRIMODE
;
705 if (vmesa
->dirty
& S3V_UPLOAD_FOG
) {
707 UNCLAMPED_FLOAT_TO_RGB_CHAN( c
, vmesa
->glCtx
->Fog
.Color
);
708 DEBUG(("uploading ** FOG **\n"));
709 col
= s3vPackColor(2, c
[0], c
[1], c
[2], 0);
710 vmesa
->dirty
&= ~S3V_UPLOAD_FOG
;
713 if (vmesa
->dirty
& S3V_UPLOAD_DITHER
) {
714 vmesa
->dirty
&= ~S3V_UPLOAD_DITHER
;
717 if (vmesa
->dirty
& S3V_UPLOAD_LOGICOP
) {
718 vmesa
->dirty
&= ~S3V_UPLOAD_LOGICOP
;
721 if (vmesa
->dirty
& S3V_UPLOAD_CLIP
) {
722 vmesa
->dirty
&= ~S3V_UPLOAD_CLIP
;
723 DEBUG(("S3V_UPLOAD_CLIP\n"));
724 DEBUG(("vmesa->ScissorLR: %i\n", vmesa
->ScissorLR
));
725 DEBUG(("vmesa->ScissorTB: %i\n", vmesa
->ScissorTB
));
728 if (vmesa
->dirty
& S3V_UPLOAD_MASKS
) {
729 vmesa
->dirty
&= ~S3V_UPLOAD_MASKS
;
730 DEBUG(("S3V_UPLOAD_BLEND\n"));
733 if (vmesa
->dirty
& S3V_UPLOAD_ALPHA
) {
734 vmesa
->dirty
&= ~S3V_UPLOAD_ALPHA
;
735 DEBUG(("S3V_UPLOAD_ALPHA\n"));
738 if (vmesa
->dirty
& S3V_UPLOAD_SHADE
) {
739 vmesa
->dirty
&= ~S3V_UPLOAD_SHADE
;
742 if (vmesa
->dirty
& S3V_UPLOAD_POLYGON
) {
743 vmesa
->dirty
&= ~S3V_UPLOAD_POLYGON
;
746 if (vmesa
->dirty
& S3V_UPLOAD_DEPTH
) {
747 vmesa
->dirty
&= ~S3V_UPLOAD_DEPTH
;
748 DEBUG(("S3V_UPLOAD_DEPTH: DepthMode = 0x%x08\n", vmesa
->DepthMode
));
751 if (vmesa
->dirty
& S3V_UPLOAD_GEOMETRY
) {
752 vmesa
->dirty
&= ~S3V_UPLOAD_GEOMETRY
;
755 if (vmesa
->dirty
& S3V_UPLOAD_TRANSFORM
) {
756 vmesa
->dirty
&= ~S3V_UPLOAD_TRANSFORM
;
759 if (vmesa
->dirty
& S3V_UPLOAD_TEX0
) {
760 s3vTextureObjectPtr curTex
= vmesa
->CurrentTexObj
[0];
761 vmesa
->dirty
&= ~S3V_UPLOAD_TEX0
;
762 DEBUG(("S3V_UPLOAD_TEX0\n"));
764 DEBUG(("S3V_UPLOAD_TEX0: curTex\n"));
766 DEBUG(("S3V_UPLOAD_TEX0: !curTex\n"));
771 void s3vDDUpdateHWState( GLcontext
*ctx
)
773 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
775 int new_state
= vmesa
->new_state
;
777 /* s3vUpdateClipping( ctx ); */
782 vmesa
->new_state
= 0;
784 /* Update the various parts of the context's state.
786 if ( new_state
& S3V_NEW_ALPHA
)
787 s3vUpdateAlphaMode( ctx
);
789 if ( new_state
& S3V_NEW_DEPTH
)
790 s3vUpdateZMode( ctx
);
792 if ( new_state
& S3V_NEW_FOG
)
793 s3vUpdateFogAttrib( ctx
);
795 if ( new_state
& S3V_NEW_CLIP
)
797 DEBUG(("---> going to s3vUpdateClipping\n"));
798 s3vUpdateClipping( ctx
);
801 if ( new_state
& S3V_NEW_POLYGON
)
802 s3vUpdatePolygon( ctx
);
804 if ( new_state
& S3V_NEW_CULL
)
805 s3vUpdateCull( ctx
);
807 if ( new_state
& S3V_NEW_MASKS
)
808 s3vUpdateMasks( ctx
);
810 if ( new_state
& S3V_NEW_WINDOW
)
811 s3vUpdateWindow( ctx
);
813 if ( new_state & S3_NEW_TEXTURE )
814 s3vUpdateTextureState( ctx );
820 s3vEmitHwState( vmesa
);
824 static void s3vDDUpdateState( GLcontext
*ctx
, GLuint new_state
)
826 _swrast_InvalidateState( ctx
, new_state
);
827 _swsetup_InvalidateState( ctx
, new_state
);
828 _vbo_InvalidateState( ctx
, new_state
);
829 _tnl_InvalidateState( ctx
, new_state
);
830 S3V_CONTEXT(ctx
)->new_gl_state
|= new_state
;
834 /* Initialize the context's hardware state.
836 void s3vInitState( s3vContextPtr vmesa
)
838 vmesa
->new_state
= 0;
841 /* Initialize the driver's state functions.
843 void s3vInitStateFuncs( GLcontext
*ctx
)
845 ctx
->Driver
.UpdateState
= s3vDDUpdateState
;
847 ctx
->Driver
.Clear
= s3vDDClear
;
848 ctx
->Driver
.ClearIndex
= NULL
;
849 ctx
->Driver
.ClearColor
= s3vDDClearColor
;
850 ctx
->Driver
.DrawBuffer
= s3vDDSetDrawBuffer
;
851 ctx
->Driver
.ReadBuffer
= NULL
; /* XXX */
853 ctx
->Driver
.IndexMask
= NULL
;
854 ctx
->Driver
.ColorMask
= NULL
; /* s3vDDColorMask; */ /* FIXME */
856 ctx
->Driver
.AlphaFunc
= s3vDDAlphaFunc
; /* FIXME */
858 ctx
->Driver
.BlendEquation
= NULL
; /* s3vDDBlendEquation; */
859 ctx
->Driver
.BlendFunc
= s3vDDBlendFunc
; /* FIXME */
861 ctx
->Driver
.BlendFuncSeparate
= NULL
; /* s3vDDBlendFuncSeparate; */
862 ctx
->Driver
.ClearDepth
= s3vDDClearDepth
;
863 ctx
->Driver
.CullFace
= s3vDDCullFace
;
864 ctx
->Driver
.FrontFace
= s3vDDFrontFace
;
865 ctx
->Driver
.DepthFunc
= s3vDDDepthFunc
; /* FIXME */
866 ctx
->Driver
.DepthMask
= s3vDDDepthMask
; /* FIXME */
867 ctx
->Driver
.DepthRange
= NULL
; /* s3vDDDepthRange; */
868 ctx
->Driver
.Enable
= s3vDDEnable
; /* FIXME */
869 ctx
->Driver
.Finish
= s3vDDFinish
;
870 ctx
->Driver
.Flush
= s3vDDFlush
;
872 ctx
->Driver
.Fogfv
= NULL
; /* s3vDDFogfv; */
874 ctx
->Driver
.Hint
= NULL
;
875 ctx
->Driver
.LineWidth
= NULL
; /* s3vDDLineWidth; */
876 ctx
->Driver
.LineStipple
= NULL
; /* s3vDDLineStipple; */
878 ctx
->Driver
.Lightfv
= NULL
; /* s3vDDLightfv; */
880 ctx
->Driver
.LightModelfv
= NULL
; /* s3vDDLightModelfv; */
882 ctx
->Driver
.LogicOpcode
= NULL
; /* s3vDDLogicalOpcode; */
883 ctx
->Driver
.PointSize
= NULL
; /* s3vDDPointSize; */
884 ctx
->Driver
.PolygonMode
= NULL
; /* s3vDDPolygonMode; */
885 ctx
->Driver
.PolygonStipple
= NULL
; /* s3vDDPolygonStipple; */
886 ctx
->Driver
.Scissor
= s3vDDScissor
; /* ScissorLR / ScissorTB */
887 ctx
->Driver
.ShadeModel
= NULL
; /* s3vDDShadeModel; */
888 ctx
->Driver
.Viewport
= NULL
; /* s3vDDViewport; */