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"
13 #include "array_cache/acache.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
, GLboolean all
,
77 GLint cx
, GLint cy
, GLint cw
, GLint ch
)
79 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
82 vmesa
->restore_primitive
= -1;
84 /* Update and emit any new state. We need to do this here to catch
85 * changes to the masks.
86 * FIXME: Just update the masks?
89 if ( vmesa
->new_state
)
90 s3vDDUpdateHWState( ctx
);
92 /* s3vUpdateMasks( ctx ); */
93 /* s3vUpdateClipping( ctx ); */
94 /* s3vEmitHwState( vmesa ); */
97 #if 1 /* soft (0)/hw (1)*/
99 DEBUG(("*** s3vDDClear ***\n"));
101 DMAOUT_CHECK(BITBLT_SRC_BASE
, 15);
102 DMAOUT(vmesa
->SrcBase
);
103 DMAOUT(vmesa
->DestBlit
);
104 DMAOUT( vmesa
->ScissorLR
);
105 DMAOUT( vmesa
->ScissorTB
);
106 DMAOUT( (vmesa
->SrcStride
<< 16) | vmesa
->SrcStride
); /* FIXME: unify */
107 DMAOUT( (~(0)) ); /* masks */
110 DMAOUT(vmesa
->ClearColor
);
114 DMAOUT(0x16000122 | 0x5 | (0xF0 << 17)); /* black magic to me */
115 DMAOUT(vmesa
->ScissorWH
);
116 DMAOUT(vmesa
->SrcXY
);
117 DMAOUT(vmesa
->DestXY
);
120 if (mask
& BUFFER_BIT_DEPTH
) { /* depth */
121 DEBUG(("BUFFER_BIT_DEPTH\n"));
123 _stride
= ((cw
+31)&~31) * 2;
125 DMAOUT_CHECK(BITBLT_SRC_BASE
, 15);
127 DMAOUT(vmesa
->s3vScreen
->depthOffset
);
128 DMAOUT( (0 << 16) | cw
);
129 DMAOUT( (0 << 16) | ch
);
130 DMAOUT( (vmesa
->SrcStride
<< 16) | vmesa
->DestStride
);
131 DMAOUT( (~(0)) ); /* masks */
134 DMAOUT(vmesa
->ClearDepth
); /* 0x7FFF */
138 DMAOUT(0x16000122 | 0x5 | (0xF0 << 17));
139 DMAOUT( ((cw
-1) << 16) | (ch
-1) );
141 DMAOUT( (0 << 16) | 0 );
144 DEBUG(("vmesa->ClearDepth = 0x%x\n", vmesa
->ClearDepth
));
145 mask
&= ~BUFFER_BIT_DEPTH
;
148 if (!vmesa
->NotClipped
) {
149 DEBUG(("vmesa->NotClipped\n")); /* yes */
152 if (!(vmesa
->EnabledFlags
& S3V_BACK_BUFFER
)) {
153 DEBUG(("!S3V_BACK_BUFFER -> flush\n"));
158 DEBUG(("still masked ;3(\n")); */ /* yes */
160 _swrast_Clear( ctx
, mask
, all
, cx
, cy
, cw
, ch
);
164 /* =============================================================
168 static void s3vUpdateZMode( GLcontext
*ctx
)
170 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
171 CARD32 cmd
= vmesa
->CMD
;
173 DEBUG(("Depth.Test = %i\n", ctx
->Depth
.Test
));
174 DEBUG(("CMD was = 0x%x ", cmd
));
176 /* printf("depth --- CMD was = 0x%x \n", cmd); */
178 cmd
&= ~Z_MASK
; /* 0xfc0fffff; */
179 /* Z_BUFFER */ /* 000 mode */ /* Z_UPDATE_OFF */
181 if (!ctx
->Depth
.Test
)
184 if ( ctx
->Depth
.Mask
)
187 switch ( ctx
->Depth
.Func
) {
214 DEBUG(("CMD is 0x%x\n", cmd
));
216 vmesa
->dirty
|= S3V_UPLOAD_DEPTH
;
220 static void s3vDDDepthFunc( GLcontext
*ctx
, GLenum func
)
222 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
224 /* FLUSH_BATCH( vmesa ); */
225 DEBUG(("s3vDDDepthFunc\n"));
226 vmesa
->new_state
|= S3V_NEW_DEPTH
;
229 static void s3vDDDepthMask( GLcontext
*ctx
, GLboolean flag
)
231 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
233 /* FLUSH_BATCH( vmesa ); */
234 DEBUG(("s3vDDDepthMask\n"));
235 vmesa
->new_state
|= S3V_NEW_DEPTH
;
238 static void s3vDDClearDepth( GLcontext
*ctx
, GLclampd d
)
240 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
242 switch ( vmesa
->DepthSize
) {
245 vmesa
->ClearDepth
= d
* 0x0000ffff; /* 65536 */
246 DEBUG(("GLclampd d = %f\n", d
));
247 DEBUG(("ctx->Depth.Clear = %f\n", ctx
->Depth
.Clear
));
248 DEBUG(("(They should be the same)\n"));
251 vmesa
->ClearDepth
= d
* 0x00ffffff;
254 vmesa
->ClearDepth
= d
* 0xffffffff;
259 static void s3vDDFinish( GLcontext
*ctx
)
261 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
265 static void s3vDDFlush( GLcontext
*ctx
)
267 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
271 /* =============================================================
275 static void s3vUpdateFogAttrib( GLcontext
*ctx
)
277 /* s3vContextPtr vmesa = S3V_CONTEXT(ctx); */
279 if (ctx
->Fog
.Enabled
) {
283 switch (ctx
->Fog
.Mode
) {
293 static void s3vDDFogfv( GLcontext
*ctx
, GLenum pname
, const GLfloat
*param
)
295 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
296 vmesa
->new_state
|= S3V_NEW_FOG
;
299 /* =============================================================
302 static void s3vDDLineWidth( GLcontext
*ctx
, GLfloat width
)
304 /* FIXME: on virge you only have one size of 3d lines *
305 * if we wanted more, we should start using tris instead *
306 * but virge has problem with some tris when all of the *
307 * vertices stay on a line */
310 /* =============================================================
313 static void s3vDDPointSize( GLcontext
*ctx
, GLfloat size
)
315 /* FIXME: we use 3d line to fake points. So same limitations
319 /* =============================================================
323 static void s3vUpdatePolygon( GLcontext
*ctx
)
325 /* FIXME: I don't think we could do much here */
327 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
328 vmesa
->dirty
|= S3V_UPLOAD_POLYGON
;
331 /* =============================================================
335 static void s3vUpdateClipping( GLcontext
*ctx
)
337 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
338 __DRIdrawablePrivate
*dPriv
= vmesa
->driDrawable
;
342 DEBUG((">>> s3vUpdateClipping <<<\n"));
344 if ( vmesa->driDrawable ) {
345 DEBUG(("s3vUpdateClipping\n"));
347 if (vmesa
->EnabledFlags
& S3V_BACK_BUFFER
) {
348 DEBUG(("S3V_BACK_BUFFER\n"));
356 vmesa
->DestBase
= vmesa
->s3vScreen
->backOffset
;
357 vmesa
->DestBlit
= vmesa
->DestBase
;
358 vmesa
->ScissorLR
= ( (0 << 16) | (dPriv
->w
-1) );
359 vmesa
->ScissorTB
= ( (0 << 16) | (dPriv
->h
-1) );
361 vmesa->ScissorLR = ( (x0 << 16) | x1 );
362 vmesa->ScissorTB = ( (y0 << 16) | y1 );
364 vmesa
->SrcStride
= ( ((dPriv
->w
+31)&~31) * vmesa
->s3vScreen
->cpp
);
365 vmesa
->DestStride
= vmesa
->driScreen
->fbWidth
*vmesa
->s3vScreen
->cpp
;
366 vmesa
->ScissorWH
= ( (dPriv
->w
<< 16) | dPriv
->h
);
368 /* vmesa->DestXY = ( (dPriv->x << 16) | dPriv->y ); */
369 vmesa
->DestXY
= ( (0 << 16) | 0 );
371 DEBUG(("S3V_FRONT_BUFFER\n"));
375 x1
= x0
+ dPriv
->w
- 1;
376 y1
= y0
+ dPriv
->h
- 1;
380 vmesa
->ScissorLR
= ( (x0
<< 16) | x1
);
381 vmesa
->ScissorTB
= ( (y0
<< 16) | y1
);
382 vmesa
->DestStride
= vmesa
->driScreen
->fbWidth
*vmesa
->s3vScreen
->cpp
;
383 vmesa
->SrcStride
= vmesa
->DestStride
;
384 vmesa
->DestBase
= (y0
* vmesa
->DestStride
)
385 + x0
*vmesa
->s3vScreen
->cpp
;
387 vmesa
->ScissorWH
= ( (x1
<< 16) | y1
);
389 vmesa
->DestXY
= ( (0 << 16) | 0 );
390 /* vmesa->DestXY = ( (dPriv->x << 16) | dPriv->y ); */
393 DEBUG(("x0=%i y0=%i x1=%i y1=%i\n", x0
, y0
, x1
, y1
));
394 DEBUG(("stride=%i rectWH=0x%x\n\n", vmesa
->DestStride
, vmesa
->ScissorWH
));
396 /* FIXME: how could we use the following info? */
397 /* if (ctx->Scissor.Enabled) {} */
399 vmesa
->dirty
|= S3V_UPLOAD_CLIP
;
403 static void s3vDDScissor( GLcontext
*ctx
,
404 GLint x
, GLint y
, GLsizei w
, GLsizei h
)
406 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
408 DEBUG((">>> s3vDDScissor <<<"));
409 /* FLUSH_BATCH( vmesa ); */
410 vmesa
->new_state
|= S3V_NEW_CLIP
;
413 /* =============================================================
417 static void s3vUpdateCull( GLcontext
*ctx
)
419 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
420 GLfloat backface_sign
= 1;
422 DEBUG(("s3vUpdateCull\n"));
423 /* FIXME: GL_FRONT_AND_BACK */
425 switch ( ctx
->Polygon
.CullFaceMode
) {
427 if (ctx
->Polygon
.FrontFace
== GL_CCW
)
432 if (ctx
->Polygon
.FrontFace
!= GL_CCW
)
440 vmesa
->backface_sign
= backface_sign
;
441 vmesa
->dirty
|= S3V_UPLOAD_GEOMETRY
;
445 static void s3vDDCullFace( GLcontext
*ctx
, GLenum mode
)
447 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
448 /* FLUSH_BATCH( vmesa ); */
449 vmesa
->new_state
|= S3V_NEW_CULL
;
452 static void s3vDDFrontFace( GLcontext
*ctx
, GLenum mode
)
454 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
455 /* FLUSH_BATCH( vmesa ); */
456 vmesa
->new_state
|= S3V_NEW_CULL
;
459 /* =============================================================
463 static void s3vUpdateMasks( GLcontext
*ctx
)
465 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
467 GLuint mask
= s3vPackColor( vmesa
->s3vScreen
->cpp
,
468 ctx
->Color
.ColorMask
[RCOMP
],
469 ctx
->Color
.ColorMask
[GCOMP
],
470 ctx
->Color
.ColorMask
[BCOMP
],
471 ctx
->Color
.ColorMask
[ACOMP
] );
473 if (vmesa
->s3vScreen
->cpp
== 2) mask
|= mask
<< 16;
475 /* FIXME: can we do something in virge? */
478 static void s3vDDColorMask( GLcontext *ctx, GLboolean r, GLboolean g,
479 GLboolean b, GLboolean a)
481 s3vContextPtr vmesa = S3V_CONTEXT(ctx);
483 FLUSH_BATCH( vmesa );
484 vmesa->new_state |= S3V_NEW_MASKS;
487 /* =============================================================
488 * Rendering attributes
491 /* =============================================================
495 static void s3vDDClearColor( GLcontext
*ctx
, const GLfloat color
[4])
497 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
499 DEBUG(("*** s3vDDClearColor\n"));
501 vmesa
->ClearColor
= s3vPackColor( 2, /* vmesa->s3vScreen->cpp, */
502 color
[0], color
[1], color
[2], color
[3] );
505 if (vmesa
->s3vScreen
->cpp
== 2) vmesa
->ClearColor
|= vmesa
->ClearColor
<<16;
509 static void s3vDDSetDrawBuffer( GLcontext
*ctx
, GLenum mode
)
511 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
514 DEBUG(("*** s3vDDSetDrawBuffer ***\n"));
516 /* FLUSH_BATCH( vmesa ); */
520 vmesa
->drawOffset
= vmesa
->s3vScreen
->frontOffset
;
523 vmesa
->drawOffset
= vmesa
->s3vScreen
->backOffset
;
524 /* vmesa->driScreen->fbHeight *
525 * vmesa->driScreen->fbWidth *
526 * vmesa->s3vScreen->cpp; */
533 DEBUG(("vmesa->drawOffset = 0x%x\n", vmesa
->drawOffset
));
534 /* return GL_TRUE; */
537 /* =============================================================
538 * Window position and viewport transformation
541 void s3vUpdateWindow( GLcontext
*ctx
)
543 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
544 __DRIdrawablePrivate
*dPriv
= vmesa
->driDrawable
;
545 GLfloat xoffset
= (GLfloat
)dPriv
->x
;
547 vmesa
->driScreen
->fbHeight
- (GLfloat
)dPriv
->y
- dPriv
->h
;
548 const GLfloat
*v
= ctx
->Viewport
._WindowMap
.m
;
550 GLfloat sx
= v
[MAT_SX
];
551 GLfloat tx
= v
[MAT_TX
] + xoffset
;
552 GLfloat sy
= v
[MAT_SY
];
553 GLfloat ty
= v
[MAT_TY
] + yoffset
;
554 GLfloat sz
= v
[MAT_SZ
] * vmesa
->depth_scale
;
555 GLfloat tz
= v
[MAT_TZ
] * vmesa
->depth_scale
;
557 vmesa
->dirty
|= S3V_UPLOAD_VIEWPORT
;
559 vmesa
->ViewportScaleX
= sx
;
560 vmesa
->ViewportScaleY
= sy
;
561 vmesa
->ViewportScaleZ
= sz
;
562 vmesa
->ViewportOffsetX
= tx
;
563 vmesa
->ViewportOffsetY
= ty
;
564 vmesa
->ViewportOffsetZ
= tz
;
569 static void s3vDDViewport( GLcontext *ctx, GLint x, GLint y,
570 GLsizei width, GLsizei height )
572 s3vUpdateWindow( ctx );
575 static void s3vDDDepthRange( GLcontext *ctx, GLclampd nearval,
578 s3vUpdateWindow( ctx );
581 void s3vUpdateViewportOffset( GLcontext
*ctx
)
583 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
584 __DRIdrawablePrivate
*dPriv
= vmesa
->driDrawable
;
585 GLfloat xoffset
= (GLfloat
)dPriv
->x
;
587 vmesa
->driScreen
->fbHeight
- (GLfloat
)dPriv
->y
- dPriv
->h
;
588 const GLfloat
*v
= ctx
->Viewport
._WindowMap
.m
;
590 GLfloat tx
= v
[MAT_TX
] + xoffset
;
591 GLfloat ty
= v
[MAT_TY
] + yoffset
;
593 DEBUG(("*** s3vUpdateViewportOffset ***\n"));
595 if ( vmesa
->ViewportOffsetX
!= tx
||
596 vmesa
->ViewportOffsetY
!= ty
)
598 vmesa
->ViewportOffsetX
= tx
;
599 vmesa
->ViewportOffsetY
= ty
;
601 vmesa
->new_state
|= S3V_NEW_WINDOW
;
604 /* vmesa->new_state |= S3V_NEW_CLIP; */
607 /* =============================================================
608 * State enable/disable
611 static void s3vDDEnable( GLcontext
*ctx
, GLenum cap
, GLboolean state
)
613 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
618 vmesa
->new_state
|= S3V_NEW_ALPHA
;
619 DEBUG(("s3vDDEnable: GL_BLEND\n"));
623 vmesa
->new_state
|= S3V_NEW_CULL
;
624 DEBUG(("s3vDDEnable: GL_CULL_FACE\n"));
628 vmesa
->new_state
|= S3V_NEW_DEPTH
;
629 DEBUG(("s3vDDEnable: GL_DEPTH\n"));
633 vmesa
->new_state
|= S3V_NEW_FOG
;
637 case GL_SCISSOR_TEST
:
638 vmesa
->new_state
|= S3V_NEW_CLIP
;
642 DEBUG(("*** GL_TEXTURE_2D: %i\n", state
));
643 vmesa
->_3d_mode
= state
;
644 vmesa
->restore_primitive
= -1;
652 /* =============================================================
653 * State initialization, management
658 * Load the current context's state into the hardware.
660 * NOTE: Be VERY careful about ensuring the context state is marked for
661 * upload, the only place it shouldn't be uploaded is when the setup
662 * state has changed in ReducedPrimitiveChange as this comes right after
665 * Blits of any type should always upload the context and masks after
668 void s3vEmitHwState( s3vContextPtr vmesa
)
670 if (!vmesa
->driDrawable
) return;
671 if (!vmesa
->dirty
) return;
673 DEBUG(("**********************\n"));
674 DEBUG(("*** s3vEmitHwState ***\n"));
675 DEBUG(("**********************\n"));
677 if (vmesa
->dirty
& S3V_UPLOAD_VIEWPORT
) {
678 vmesa
->dirty
&= ~S3V_UPLOAD_VIEWPORT
;
679 DEBUG(("S3V_UPLOAD_VIEWPORT\n"));
682 if ( (vmesa
->dirty
& S3V_UPLOAD_POINTMODE
) ||
683 (vmesa
->dirty
& S3V_UPLOAD_LINEMODE
) ||
684 (vmesa
->dirty
& S3V_UPLOAD_TRIMODE
) ) {
688 if (vmesa
->dirty
& S3V_UPLOAD_POINTMODE
) {
689 vmesa
->dirty
&= ~S3V_UPLOAD_POINTMODE
;
692 if (vmesa
->dirty
& S3V_UPLOAD_LINEMODE
) {
693 vmesa
->dirty
&= ~S3V_UPLOAD_LINEMODE
;
696 if (vmesa
->dirty
& S3V_UPLOAD_TRIMODE
) {
697 vmesa
->dirty
&= ~S3V_UPLOAD_TRIMODE
;
700 if (vmesa
->dirty
& S3V_UPLOAD_FOG
) {
702 UNCLAMPED_FLOAT_TO_RGB_CHAN( c
, vmesa
->glCtx
->Fog
.Color
);
703 DEBUG(("uploading ** FOG **\n"));
704 col
= s3vPackColor(2, c
[0], c
[1], c
[2], 0);
705 vmesa
->dirty
&= ~S3V_UPLOAD_FOG
;
708 if (vmesa
->dirty
& S3V_UPLOAD_DITHER
) {
709 vmesa
->dirty
&= ~S3V_UPLOAD_DITHER
;
712 if (vmesa
->dirty
& S3V_UPLOAD_LOGICOP
) {
713 vmesa
->dirty
&= ~S3V_UPLOAD_LOGICOP
;
716 if (vmesa
->dirty
& S3V_UPLOAD_CLIP
) {
717 vmesa
->dirty
&= ~S3V_UPLOAD_CLIP
;
718 DEBUG(("S3V_UPLOAD_CLIP\n"));
719 DEBUG(("vmesa->ScissorLR: %i\n", vmesa
->ScissorLR
));
720 DEBUG(("vmesa->ScissorTB: %i\n", vmesa
->ScissorTB
));
723 if (vmesa
->dirty
& S3V_UPLOAD_MASKS
) {
724 vmesa
->dirty
&= ~S3V_UPLOAD_MASKS
;
725 DEBUG(("S3V_UPLOAD_BLEND\n"));
728 if (vmesa
->dirty
& S3V_UPLOAD_ALPHA
) {
729 vmesa
->dirty
&= ~S3V_UPLOAD_ALPHA
;
730 DEBUG(("S3V_UPLOAD_ALPHA\n"));
733 if (vmesa
->dirty
& S3V_UPLOAD_SHADE
) {
734 vmesa
->dirty
&= ~S3V_UPLOAD_SHADE
;
737 if (vmesa
->dirty
& S3V_UPLOAD_POLYGON
) {
738 vmesa
->dirty
&= ~S3V_UPLOAD_POLYGON
;
741 if (vmesa
->dirty
& S3V_UPLOAD_DEPTH
) {
742 vmesa
->dirty
&= ~S3V_UPLOAD_DEPTH
;
743 DEBUG(("S3V_UPLOAD_DEPTH: DepthMode = 0x%x08\n", vmesa
->DepthMode
));
746 if (vmesa
->dirty
& S3V_UPLOAD_GEOMETRY
) {
747 vmesa
->dirty
&= ~S3V_UPLOAD_GEOMETRY
;
750 if (vmesa
->dirty
& S3V_UPLOAD_TRANSFORM
) {
751 vmesa
->dirty
&= ~S3V_UPLOAD_TRANSFORM
;
754 if (vmesa
->dirty
& S3V_UPLOAD_TEX0
) {
755 s3vTextureObjectPtr curTex
= vmesa
->CurrentTexObj
[0];
756 vmesa
->dirty
&= ~S3V_UPLOAD_TEX0
;
757 DEBUG(("S3V_UPLOAD_TEX0\n"));
759 DEBUG(("S3V_UPLOAD_TEX0: curTex\n"));
761 DEBUG(("S3V_UPLOAD_TEX0: !curTex\n"));
766 void s3vDDUpdateHWState( GLcontext
*ctx
)
768 s3vContextPtr vmesa
= S3V_CONTEXT(ctx
);
770 int new_state
= vmesa
->new_state
;
772 /* s3vUpdateClipping( ctx ); */
777 vmesa
->new_state
= 0;
779 /* Update the various parts of the context's state.
781 if ( new_state
& S3V_NEW_ALPHA
)
782 s3vUpdateAlphaMode( ctx
);
784 if ( new_state
& S3V_NEW_DEPTH
)
785 s3vUpdateZMode( ctx
);
787 if ( new_state
& S3V_NEW_FOG
)
788 s3vUpdateFogAttrib( ctx
);
790 if ( new_state
& S3V_NEW_CLIP
)
792 DEBUG(("---> going to s3vUpdateClipping\n"));
793 s3vUpdateClipping( ctx
);
796 if ( new_state
& S3V_NEW_POLYGON
)
797 s3vUpdatePolygon( ctx
);
799 if ( new_state
& S3V_NEW_CULL
)
800 s3vUpdateCull( ctx
);
802 if ( new_state
& S3V_NEW_MASKS
)
803 s3vUpdateMasks( ctx
);
805 if ( new_state
& S3V_NEW_WINDOW
)
806 s3vUpdateWindow( ctx
);
808 if ( new_state & S3_NEW_TEXTURE )
809 s3vUpdateTextureState( ctx );
815 s3vEmitHwState( vmesa
);
819 static void s3vDDUpdateState( GLcontext
*ctx
, GLuint new_state
)
821 _swrast_InvalidateState( ctx
, new_state
);
822 _swsetup_InvalidateState( ctx
, new_state
);
823 _ac_InvalidateState( ctx
, new_state
);
824 _tnl_InvalidateState( ctx
, new_state
);
825 S3V_CONTEXT(ctx
)->new_gl_state
|= new_state
;
829 /* Initialize the context's hardware state.
831 void s3vInitState( s3vContextPtr vmesa
)
833 vmesa
->new_state
= 0;
836 /* Initialize the driver's state functions.
838 void s3vInitStateFuncs( GLcontext
*ctx
)
840 ctx
->Driver
.UpdateState
= s3vDDUpdateState
;
842 ctx
->Driver
.Clear
= s3vDDClear
;
843 ctx
->Driver
.ClearIndex
= NULL
;
844 ctx
->Driver
.ClearColor
= s3vDDClearColor
;
845 ctx
->Driver
.DrawBuffer
= s3vDDSetDrawBuffer
;
846 ctx
->Driver
.ReadBuffer
= NULL
; /* XXX */
848 ctx
->Driver
.IndexMask
= NULL
;
849 ctx
->Driver
.ColorMask
= NULL
; /* s3vDDColorMask; */ /* FIXME */
851 ctx
->Driver
.AlphaFunc
= s3vDDAlphaFunc
; /* FIXME */
853 ctx
->Driver
.BlendEquation
= NULL
; /* s3vDDBlendEquation; */
854 ctx
->Driver
.BlendFunc
= s3vDDBlendFunc
; /* FIXME */
856 ctx
->Driver
.BlendFuncSeparate
= NULL
; /* s3vDDBlendFuncSeparate; */
857 ctx
->Driver
.ClearDepth
= s3vDDClearDepth
;
858 ctx
->Driver
.CullFace
= s3vDDCullFace
;
859 ctx
->Driver
.FrontFace
= s3vDDFrontFace
;
860 ctx
->Driver
.DepthFunc
= s3vDDDepthFunc
; /* FIXME */
861 ctx
->Driver
.DepthMask
= s3vDDDepthMask
; /* FIXME */
862 ctx
->Driver
.DepthRange
= NULL
; /* s3vDDDepthRange; */
863 ctx
->Driver
.Enable
= s3vDDEnable
; /* FIXME */
864 ctx
->Driver
.Finish
= s3vDDFinish
;
865 ctx
->Driver
.Flush
= s3vDDFlush
;
867 ctx
->Driver
.Fogfv
= NULL
; /* s3vDDFogfv; */
869 ctx
->Driver
.Hint
= NULL
;
870 ctx
->Driver
.LineWidth
= NULL
; /* s3vDDLineWidth; */
871 ctx
->Driver
.LineStipple
= NULL
; /* s3vDDLineStipple; */
873 ctx
->Driver
.Lightfv
= NULL
; /* s3vDDLightfv; */
875 ctx
->Driver
.LightModelfv
= NULL
; /* s3vDDLightModelfv; */
877 ctx
->Driver
.LogicOpcode
= NULL
; /* s3vDDLogicalOpcode; */
878 ctx
->Driver
.PointSize
= NULL
; /* s3vDDPointSize; */
879 ctx
->Driver
.PolygonMode
= NULL
; /* s3vDDPolygonMode; */
880 ctx
->Driver
.PolygonStipple
= NULL
; /* s3vDDPolygonStipple; */
881 ctx
->Driver
.Scissor
= s3vDDScissor
; /* ScissorLR / ScissorTB */
882 ctx
->Driver
.ShadeModel
= NULL
; /* s3vDDShadeModel; */
883 ctx
->Driver
.Viewport
= NULL
; /* s3vDDViewport; */