1 /**************************************************************************
3 Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
4 Copyright 2003 Eric Anholt
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 on the rights to use, copy, modify, merge, publish, distribute, sub
11 license, and/or sell copies of the Software, and to permit persons to whom
12 the 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 NON-INFRINGEMENT. IN NO EVENT SHALL
21 ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP BE LIABLE FOR ANY CLAIM,
22 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24 USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
30 * Sung-Ching Lin <sclin@sis.com.tw>
31 * Eric Anholt <anholt@FreeBSD.org>
34 #include "sis_context.h"
35 #include "sis_state.h"
43 #include "swrast/swrast.h"
46 #include "swrast_setup/swrast_setup.h"
48 #include "tnl/t_pipeline.h"
50 /* =============================================================
55 sisDDAlphaFunc( GLcontext
* ctx
, GLenum func
, GLfloat ref
)
57 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
60 __GLSiSHardware
*prev
= &smesa
->prev
;
61 __GLSiSHardware
*current
= &smesa
->current
;
63 CLAMPED_FLOAT_TO_UBYTE(refbyte
, ref
);
64 current
->hwAlpha
= refbyte
<< 16;
66 /* Alpha Test function */
70 current
->hwAlpha
|= SiS_ALPHA_NEVER
;
73 current
->hwAlpha
|= SiS_ALPHA_LESS
;
76 current
->hwAlpha
|= SiS_ALPHA_EQUAL
;
79 current
->hwAlpha
|= SiS_ALPHA_LEQUAL
;
82 current
->hwAlpha
|= SiS_ALPHA_GREATER
;
85 current
->hwAlpha
|= SiS_ALPHA_NOTEQUAL
;
88 current
->hwAlpha
|= SiS_ALPHA_GEQUAL
;
91 current
->hwAlpha
|= SiS_ALPHA_ALWAYS
;
95 prev
->hwAlpha
= current
->hwAlpha
;
96 smesa
->GlobalFlag
|= GFLAG_ALPHASETTING
;
100 sisDDBlendFuncSeparate( GLcontext
*ctx
,
101 GLenum sfactorRGB
, GLenum dfactorRGB
,
102 GLenum sfactorA
, GLenum dfactorA
)
104 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
106 __GLSiSHardware
*prev
= &smesa
->prev
;
107 __GLSiSHardware
*current
= &smesa
->current
;
109 current
->hwDstSrcBlend
= 0;
114 current
->hwDstSrcBlend
|= SiS_D_ZERO
;
117 current
->hwDstSrcBlend
|= SiS_D_ONE
;
120 current
->hwDstSrcBlend
|= SiS_D_SRC_COLOR
;
122 case GL_ONE_MINUS_SRC_COLOR
:
123 current
->hwDstSrcBlend
|= SiS_D_ONE_MINUS_SRC_COLOR
;
126 current
->hwDstSrcBlend
|= SiS_D_SRC_ALPHA
;
128 case GL_ONE_MINUS_SRC_ALPHA
:
129 current
->hwDstSrcBlend
|= SiS_D_ONE_MINUS_SRC_ALPHA
;
132 current
->hwDstSrcBlend
|= SiS_D_DST_COLOR
;
134 case GL_ONE_MINUS_DST_COLOR
:
135 current
->hwDstSrcBlend
|= SiS_D_ONE_MINUS_DST_COLOR
;
138 current
->hwDstSrcBlend
|= SiS_D_DST_ALPHA
;
140 case GL_ONE_MINUS_DST_ALPHA
:
141 current
->hwDstSrcBlend
|= SiS_D_ONE_MINUS_DST_ALPHA
;
144 fprintf(stderr
, "Unknown dst blend function 0x%x\n", dfactorRGB
);
151 current
->hwDstSrcBlend
|= SiS_S_ZERO
;
154 current
->hwDstSrcBlend
|= SiS_S_ONE
;
157 current
->hwDstSrcBlend
|= SiS_S_SRC_COLOR
;
159 case GL_ONE_MINUS_SRC_COLOR
:
160 current
->hwDstSrcBlend
|= SiS_S_ONE_MINUS_SRC_COLOR
;
163 current
->hwDstSrcBlend
|= SiS_S_SRC_ALPHA
;
165 case GL_ONE_MINUS_SRC_ALPHA
:
166 current
->hwDstSrcBlend
|= SiS_S_ONE_MINUS_SRC_ALPHA
;
169 current
->hwDstSrcBlend
|= SiS_S_DST_COLOR
;
171 case GL_ONE_MINUS_DST_COLOR
:
172 current
->hwDstSrcBlend
|= SiS_S_ONE_MINUS_DST_COLOR
;
175 current
->hwDstSrcBlend
|= SiS_S_DST_ALPHA
;
177 case GL_ONE_MINUS_DST_ALPHA
:
178 current
->hwDstSrcBlend
|= SiS_S_ONE_MINUS_DST_ALPHA
;
180 case GL_SRC_ALPHA_SATURATE
:
181 current
->hwDstSrcBlend
|= SiS_S_SRC_ALPHA_SATURATE
;
184 fprintf(stderr
, "Unknown src blend function 0x%x\n", sfactorRGB
);
188 if (current
->hwDstSrcBlend
!= prev
->hwDstSrcBlend
) {
189 prev
->hwDstSrcBlend
= current
->hwDstSrcBlend
;
190 smesa
->GlobalFlag
|= GFLAG_DSTBLEND
;
194 /* =============================================================
199 sisDDDepthFunc( GLcontext
* ctx
, GLenum func
)
201 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
202 __GLSiSHardware
*prev
= &smesa
->prev
;
203 __GLSiSHardware
*current
= &smesa
->current
;
205 current
->hwZ
&= ~MASK_ZTestMode
;
209 current
->hwZ
|= SiS_Z_COMP_S_LT_B
;
212 current
->hwZ
|= SiS_Z_COMP_S_GE_B
;
215 current
->hwZ
|= SiS_Z_COMP_S_LE_B
;
218 current
->hwZ
|= SiS_Z_COMP_S_GT_B
;
221 current
->hwZ
|= SiS_Z_COMP_S_NE_B
;
224 current
->hwZ
|= SiS_Z_COMP_S_EQ_B
;
227 current
->hwZ
|= SiS_Z_COMP_ALWAYS
;
230 current
->hwZ
|= SiS_Z_COMP_NEVER
;
234 if (current
->hwZ
!= prev
->hwZ
) {
235 prev
->hwZ
= current
->hwZ
;
236 smesa
->GlobalFlag
|= GFLAG_ZSETTING
;
241 sisDDDepthMask( GLcontext
* ctx
, GLboolean flag
)
243 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
244 __GLSiSHardware
*prev
= &smesa
->prev
;
245 __GLSiSHardware
*current
= &smesa
->current
;
247 if (!ctx
->Depth
.Test
)
250 if (ctx
->Visual
.stencilBits
) {
251 if (flag
|| (ctx
->Stencil
.WriteMask
[0] != 0)) {
252 current
->hwCapEnable
|= MASK_ZWriteEnable
;
253 if (flag
&& ((ctx
->Stencil
.WriteMask
[0] & 0xff) == 0xff)) {
254 current
->hwCapEnable2
&= ~MASK_ZMaskWriteEnable
;
256 current
->hwCapEnable2
|= MASK_ZMaskWriteEnable
;
257 current
->hwZMask
= (ctx
->Stencil
.WriteMask
[0] << 24) |
258 ((flag
) ? 0x00ffffff : 0);
260 if (current
->hwZMask
^ prev
->hwZMask
) {
261 prev
->hwZMask
= current
->hwZMask
;
262 smesa
->GlobalFlag
|= GFLAG_ZSETTING
;
266 current
->hwCapEnable
&= ~MASK_ZWriteEnable
;
270 current
->hwCapEnable
|= MASK_ZWriteEnable
;
271 current
->hwCapEnable2
&= ~MASK_ZMaskWriteEnable
;
273 current
->hwCapEnable
&= ~MASK_ZWriteEnable
;
278 /* =============================================================
283 sisUpdateClipping( GLcontext
*ctx
)
285 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
287 __GLSiSHardware
*prev
= &smesa
->prev
;
288 __GLSiSHardware
*current
= &smesa
->current
;
290 GLint x1
, y1
, x2
, y2
;
293 /* XXX: 6326 has its own clipping for now. Should be fixed */
294 sis6326UpdateClipping(ctx
);
300 x2
= smesa
->width
- 1;
301 y2
= smesa
->height
- 1;
303 if (ctx
->Scissor
.Enabled
) {
304 if (ctx
->Scissor
.X
> x1
)
306 if (ctx
->Scissor
.Y
> y1
)
308 if (ctx
->Scissor
.X
+ ctx
->Scissor
.Width
- 1 < x2
)
309 x2
= ctx
->Scissor
.X
+ ctx
->Scissor
.Width
- 1;
310 if (ctx
->Scissor
.Y
+ ctx
->Scissor
.Height
- 1 < y2
)
311 y2
= ctx
->Scissor
.Y
+ ctx
->Scissor
.Height
- 1;
317 current
->clipTopBottom
= (y2
<< 13) | y1
;
318 current
->clipLeftRight
= (x1
<< 13) | x2
;
320 if ((current
->clipTopBottom
^ prev
->clipTopBottom
) ||
321 (current
->clipLeftRight
^ prev
->clipLeftRight
))
323 prev
->clipTopBottom
= current
->clipTopBottom
;
324 prev
->clipLeftRight
= current
->clipLeftRight
;
325 smesa
->GlobalFlag
|= GFLAG_CLIPPING
;
330 sisDDScissor( GLcontext
*ctx
, GLint x
, GLint y
, GLsizei w
, GLsizei h
)
332 if (ctx
->Scissor
.Enabled
)
333 sisUpdateClipping( ctx
);
336 /* =============================================================
341 sisUpdateCull( GLcontext
*ctx
)
343 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
344 GLint cullflag
, frontface
;
346 cullflag
= ctx
->Polygon
.CullFaceMode
;
347 frontface
= ctx
->Polygon
.FrontFace
;
349 smesa
->AGPParseSet
&= ~(MASK_PsCullDirection_CCW
);
350 smesa
->dwPrimitiveSet
&= ~(MASK_CullDirection
);
352 if((cullflag
== GL_FRONT
&& frontface
== GL_CCW
) ||
353 (cullflag
== GL_BACK
&& frontface
== GL_CW
))
355 smesa
->AGPParseSet
|= MASK_PsCullDirection_CCW
;
356 smesa
->dwPrimitiveSet
|= OP_3D_CullDirection_CCW
;
362 sisDDCullFace( GLcontext
*ctx
, GLenum mode
)
364 sisUpdateCull( ctx
);
368 sisDDFrontFace( GLcontext
*ctx
, GLenum mode
)
370 sisUpdateCull( ctx
);
373 /* =============================================================
377 static void sisDDColorMask( GLcontext
*ctx
,
378 GLboolean r
, GLboolean g
,
379 GLboolean b
, GLboolean a
)
381 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
382 __GLSiSHardware
*prev
= &smesa
->prev
;
383 __GLSiSHardware
*current
= &smesa
->current
;
385 if (r
&& g
&& b
&& ((ctx
->Visual
.alphaBits
== 0) || a
)) {
386 current
->hwCapEnable2
&= ~(MASK_AlphaMaskWriteEnable
|
387 MASK_ColorMaskWriteEnable
);
389 current
->hwCapEnable2
|= (MASK_AlphaMaskWriteEnable
|
390 MASK_ColorMaskWriteEnable
);
392 current
->hwDstMask
= (r
) ? smesa
->redMask
: 0 |
393 (g
) ? smesa
->greenMask
: 0 |
394 (b
) ? smesa
->blueMask
: 0 |
395 (a
) ? smesa
->alphaMask
: 0;
398 if (current
->hwDstMask
!= prev
->hwDstMask
) {
399 prev
->hwDstMask
= current
->hwDstMask
;
400 smesa
->GlobalFlag
|= GFLAG_DESTSETTING
;
404 /* =============================================================
405 * Rendering attributes
408 static void sisUpdateSpecular(GLcontext
*ctx
)
410 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
411 __GLSiSHardware
*current
= &smesa
->current
;
413 if (NEED_SECONDARY_COLOR(ctx
))
414 current
->hwCapEnable
|= MASK_SpecularEnable
;
416 current
->hwCapEnable
&= ~MASK_SpecularEnable
;
419 static void sisDDLightModelfv(GLcontext
*ctx
, GLenum pname
,
420 const GLfloat
*param
)
422 if (pname
== GL_LIGHT_MODEL_COLOR_CONTROL
) {
423 sisUpdateSpecular(ctx
);
427 static void sisDDShadeModel( GLcontext
*ctx
, GLenum mode
)
429 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
431 /* Signal to sisRasterPrimitive to recalculate dwPrimitiveSet */
432 smesa
->hw_primitive
= -1;
435 /* =============================================================
439 /* =============================================================
443 static void sisCalcViewport( GLcontext
*ctx
)
445 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
446 const GLfloat
*v
= ctx
->Viewport
._WindowMap
.m
;
447 GLfloat
*m
= smesa
->hw_viewport
;
449 /* See also sis_translate_vertex.
451 m
[MAT_SX
] = v
[MAT_SX
];
452 m
[MAT_TX
] = v
[MAT_TX
] + SUBPIXEL_X
;
453 m
[MAT_SY
] = - v
[MAT_SY
];
454 m
[MAT_TY
] = - v
[MAT_TY
] + smesa
->driDrawable
->h
+ SUBPIXEL_Y
;
455 m
[MAT_SZ
] = v
[MAT_SZ
] * smesa
->depth_scale
;
456 m
[MAT_TZ
] = v
[MAT_TZ
] * smesa
->depth_scale
;
459 static void sisDDViewport( GLcontext
*ctx
,
461 GLsizei width
, GLsizei height
)
463 sisCalcViewport( ctx
);
466 static void sisDDDepthRange( GLcontext
*ctx
,
467 GLclampd nearval
, GLclampd farval
)
469 sisCalcViewport( ctx
);
472 /* =============================================================
477 sisDDLogicOpCode( GLcontext
*ctx
, GLenum opcode
)
479 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
481 __GLSiSHardware
*prev
= &smesa
->prev
;
482 __GLSiSHardware
*current
= &smesa
->current
;
484 current
->hwDstSet
&= ~MASK_ROP2
;
488 current
->hwDstSet
|= LOP_CLEAR
;
491 current
->hwDstSet
|= LOP_SET
;
494 current
->hwDstSet
|= LOP_COPY
;
496 case GL_COPY_INVERTED
:
497 current
->hwDstSet
|= LOP_COPY_INVERTED
;
500 current
->hwDstSet
|= LOP_NOOP
;
503 current
->hwDstSet
|= LOP_INVERT
;
506 current
->hwDstSet
|= LOP_AND
;
509 current
->hwDstSet
|= LOP_NAND
;
512 current
->hwDstSet
|= LOP_OR
;
515 current
->hwDstSet
|= LOP_NOR
;
518 current
->hwDstSet
|= LOP_XOR
;
521 current
->hwDstSet
|= LOP_EQUIV
;
524 current
->hwDstSet
|= LOP_AND_REVERSE
;
526 case GL_AND_INVERTED
:
527 current
->hwDstSet
|= LOP_AND_INVERTED
;
530 current
->hwDstSet
|= LOP_OR_REVERSE
;
533 current
->hwDstSet
|= LOP_OR_INVERTED
;
537 if (current
->hwDstSet
^ prev
->hwDstSet
) {
538 prev
->hwDstSet
= current
->hwDstSet
;
539 smesa
->GlobalFlag
|= GFLAG_DESTSETTING
;
543 void sisDDDrawBuffer( GLcontext
*ctx
, GLenum mode
)
545 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
546 __GLSiSHardware
*prev
= &smesa
->prev
;
547 __GLSiSHardware
*current
= &smesa
->current
;
550 * _DrawDestMask is easier to cope with than <mode>.
552 current
->hwDstSet
&= ~MASK_DstBufferPitch
;
553 switch ( ctx
->DrawBuffer
->_ColorDrawBufferMask
[0] ) {
554 case BUFFER_BIT_FRONT_LEFT
:
555 FALLBACK( smesa
, SIS_FALLBACK_DRAW_BUFFER
, GL_FALSE
);
556 current
->hwOffsetDest
= smesa
->front
.offset
>> 1;
557 current
->hwDstSet
|= smesa
->front
.pitch
>> 2;
559 case BUFFER_BIT_BACK_LEFT
:
560 FALLBACK( smesa
, SIS_FALLBACK_DRAW_BUFFER
, GL_FALSE
);
561 current
->hwOffsetDest
= smesa
->back
.offset
>> 1;
562 current
->hwDstSet
|= smesa
->back
.pitch
>> 2;
565 /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
566 FALLBACK( smesa
, SIS_FALLBACK_DRAW_BUFFER
, GL_TRUE
);
570 if (current
->hwDstSet
!= prev
->hwDstSet
) {
571 prev
->hwDstSet
= current
->hwDstSet
;
572 smesa
->GlobalFlag
|= GFLAG_DESTSETTING
;
575 if (current
->hwOffsetDest
!= prev
->hwOffsetDest
) {
576 prev
->hwOffsetDest
= current
->hwOffsetDest
;
577 smesa
->GlobalFlag
|= GFLAG_DESTSETTING
;
581 /* =============================================================
585 /* =============================================================
589 /* =============================================================
590 * State enable/disable
594 sisDDEnable( GLcontext
* ctx
, GLenum cap
, GLboolean state
)
596 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
598 __GLSiSHardware
*current
= &smesa
->current
;
604 current
->hwCapEnable
|= MASK_AlphaTestEnable
;
606 current
->hwCapEnable
&= ~MASK_AlphaTestEnable
;
611 /* if (state & !ctx->Color.ColorLogicOpEnabled) */
612 current
->hwCapEnable
|= MASK_BlendEnable
;
614 current
->hwCapEnable
&= ~MASK_BlendEnable
;
618 current
->hwCapEnable
|= MASK_CullEnable
;
620 current
->hwCapEnable
&= ~MASK_CullEnable
;
623 if (state
&& smesa
->depth
.offset
!= 0)
624 current
->hwCapEnable
|= MASK_ZTestEnable
;
626 current
->hwCapEnable
&= ~MASK_ZTestEnable
;
627 sisDDDepthMask( ctx
, ctx
->Depth
.Mask
);
631 current
->hwCapEnable
|= MASK_DitherEnable
;
633 current
->hwCapEnable
&= ~MASK_DitherEnable
;
637 current
->hwCapEnable
|= MASK_FogEnable
;
639 current
->hwCapEnable
&= ~MASK_FogEnable
;
641 case GL_COLOR_LOGIC_OP
:
643 sisDDLogicOpCode( ctx
, ctx
->Color
.LogicOp
);
645 sisDDLogicOpCode( ctx
, GL_COPY
);
647 case GL_SCISSOR_TEST
:
648 sisUpdateClipping( ctx
);
650 case GL_STENCIL_TEST
:
652 if (smesa
->zFormat
!= SiS_ZFORMAT_S8Z24
)
653 FALLBACK(smesa
, SIS_FALLBACK_STENCIL
, 1);
655 current
->hwCapEnable
|= (MASK_StencilTestEnable
|
656 MASK_StencilWriteEnable
);
658 FALLBACK(smesa
, SIS_FALLBACK_STENCIL
, 0);
659 current
->hwCapEnable
&= ~(MASK_StencilTestEnable
|
660 MASK_StencilWriteEnable
);
664 case GL_COLOR_SUM_EXT
:
665 sisUpdateSpecular(ctx
);
671 /* =============================================================
672 * State initialization, management
675 /* Called before beginning of rendering. */
677 sisUpdateHWState( GLcontext
*ctx
)
679 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
680 __GLSiSHardware
*prev
= &smesa
->prev
;
681 __GLSiSHardware
*current
= &smesa
->current
;
683 /* enable setting 1 */
684 if (current
->hwCapEnable
^ prev
->hwCapEnable
) {
685 prev
->hwCapEnable
= current
->hwCapEnable
;
686 smesa
->GlobalFlag
|= GFLAG_ENABLESETTING
;
689 /* enable setting 2 */
690 if (current
->hwCapEnable2
^ prev
->hwCapEnable2
) {
691 prev
->hwCapEnable2
= current
->hwCapEnable2
;
692 smesa
->GlobalFlag
|= GFLAG_ENABLESETTING2
;
695 if (smesa
->GlobalFlag
& GFLAG_RENDER_STATES
)
696 sis_update_render_state( smesa
);
698 if (smesa
->GlobalFlag
& GFLAG_TEXTURE_STATES
)
699 sis_update_texture_state( smesa
);
703 sisDDInvalidateState( GLcontext
*ctx
, GLuint new_state
)
705 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
707 _swrast_InvalidateState( ctx
, new_state
);
708 _swsetup_InvalidateState( ctx
, new_state
);
709 _vbo_InvalidateState( ctx
, new_state
);
710 _tnl_InvalidateState( ctx
, new_state
);
711 smesa
->NewGLState
|= new_state
;
714 /* Initialize the context's hardware state.
716 void sisDDInitState( sisContextPtr smesa
)
718 __GLSiSHardware
*current
= &smesa
->current
;
719 __GLSiSHardware
*prev
= &(smesa
->prev
);
720 GLcontext
*ctx
= smesa
->glCtx
;
722 /* add Texture Perspective Enable */
723 prev
->hwCapEnable
= MASK_FogPerspectiveEnable
| MASK_TextureCacheEnable
|
724 MASK_TexturePerspectiveEnable
| MASK_DitherEnable
;
727 prev->hwCapEnable2 = 0x00aa0080;
729 /* if multi-texture enabled, disable Z pre-test */
730 prev
->hwCapEnable2
= MASK_TextureMipmapBiasEnable
;
732 /* Z test mode is LESS */
733 prev
->hwZ
= SiS_Z_COMP_S_LT_B
;
736 prev
->hwZMask
= 0xffffffff;
738 /* Alpha test mode is ALWAYS, alpha ref value is 0 */
739 prev
->hwAlpha
= SiS_ALPHA_ALWAYS
;
741 /* ROP2 is COPYPEN */
742 prev
->hwDstSet
= LOP_COPY
;
745 prev
->hwDstMask
= 0xffffffff;
747 /* LinePattern is 0, Repeat Factor is 0 */
748 prev
->hwLinePattern
= 0x00008000;
750 /* Src blend is BLEND_ONE, Dst blend is D3DBLEND_ZERO */
751 prev
->hwDstSrcBlend
= SiS_S_ONE
| SiS_D_ZERO
;
753 /* Stenciling disabled, function ALWAYS, ref value zero, mask all ones */
754 prev
->hwStSetting
= STENCIL_FORMAT_8
| SiS_STENCIL_ALWAYS
| 0xff;
755 /* Op is KEEP for all three operations */
756 prev
->hwStSetting2
= SiS_SFAIL_KEEP
| SiS_SPASS_ZFAIL_KEEP
|
757 SiS_SPASS_ZPASS_KEEP
;
759 /* Texture mapping mode is Tile */
761 prev
->texture
[0].hwTextureSet
= 0x00030000;
763 /* Magnified & minified texture filter is NEAREST */
765 prev
->texture
[0].hwTextureMip
= 0;
768 /* Texture Blending setting -- use fragment color/alpha*/
769 prev
->hwTexBlendColor0
= STAGE0_C_CF
;
770 prev
->hwTexBlendColor1
= STAGE1_C_CF
;
771 prev
->hwTexBlendAlpha0
= STAGE0_A_AF
;
772 prev
->hwTexBlendAlpha1
= STAGE1_A_AF
;
774 switch (smesa
->bytesPerPixel
)
777 prev
->hwDstSet
|= DST_FORMAT_RGB_565
;
780 prev
->hwDstSet
|= DST_FORMAT_ARGB_8888
;
784 switch (ctx
->Visual
.depthBits
)
787 prev
->hwCapEnable
&= ~MASK_ZWriteEnable
;
789 smesa
->zFormat
= SiS_ZFORMAT_Z16
;
790 prev
->hwCapEnable
|= MASK_ZWriteEnable
;
791 smesa
->depth_scale
= 1.0 / (GLfloat
)0xffff;
794 smesa
->zFormat
= SiS_ZFORMAT_Z32
;
795 prev
->hwCapEnable
|= MASK_ZWriteEnable
;
796 smesa
->depth_scale
= 1.0 / (GLfloat
)0xffffffff;
799 assert (ctx
->Visual
.stencilBits
);
800 smesa
->zFormat
= SiS_ZFORMAT_S8Z24
;
801 prev
->hwCapEnable
|= MASK_StencilBufferEnable
;
802 prev
->hwCapEnable
|= MASK_ZWriteEnable
;
803 smesa
->depth_scale
= 1.0 / (GLfloat
)0xffffff;
807 prev
->hwZ
|= smesa
->zFormat
;
809 /* TODO: need to clear cache? */
810 smesa
->clearTexCache
= GL_TRUE
;
812 smesa
->clearColorPattern
= 0;
814 smesa
->AGPParseSet
= MASK_PsTexture1FromB
| MASK_PsBumpTextureFromC
;
815 smesa
->dwPrimitiveSet
= OP_3D_Texture1FromB
| OP_3D_TextureBumpFromC
;
817 sisUpdateZStencilPattern( smesa
, 1.0, 0 );
818 sisUpdateCull( ctx
);
820 memcpy( current
, prev
, sizeof (__GLSiSHardware
) );
822 /* Set initial fog settings. Start and end are the same case. */
823 sisDDFogfv( ctx
, GL_FOG_DENSITY
, &ctx
->Fog
.Density
);
824 sisDDFogfv( ctx
, GL_FOG_END
, &ctx
->Fog
.End
);
825 sisDDFogfv( ctx
, GL_FOG_COORDINATE_SOURCE_EXT
, NULL
);
826 sisDDFogfv( ctx
, GL_FOG_MODE
, NULL
);
829 /* Initialize the driver's state functions.
831 void sisDDInitStateFuncs( GLcontext
*ctx
)
833 ctx
->Driver
.UpdateState
= sisDDInvalidateState
;
835 ctx
->Driver
.Clear
= sisDDClear
;
836 ctx
->Driver
.ClearColor
= sisDDClearColor
;
837 ctx
->Driver
.ClearDepth
= sisDDClearDepth
;
838 ctx
->Driver
.ClearStencil
= sisDDClearStencil
;
840 ctx
->Driver
.AlphaFunc
= sisDDAlphaFunc
;
841 ctx
->Driver
.BlendFuncSeparate
= sisDDBlendFuncSeparate
;
842 ctx
->Driver
.ColorMask
= sisDDColorMask
;
843 ctx
->Driver
.CullFace
= sisDDCullFace
;
844 ctx
->Driver
.DepthMask
= sisDDDepthMask
;
845 ctx
->Driver
.DepthFunc
= sisDDDepthFunc
;
846 ctx
->Driver
.DepthRange
= sisDDDepthRange
;
847 ctx
->Driver
.DrawBuffer
= sisDDDrawBuffer
;
848 ctx
->Driver
.Enable
= sisDDEnable
;
849 ctx
->Driver
.FrontFace
= sisDDFrontFace
;
850 ctx
->Driver
.Fogfv
= sisDDFogfv
;
851 ctx
->Driver
.Hint
= NULL
;
852 ctx
->Driver
.Lightfv
= NULL
;
853 ctx
->Driver
.LogicOpcode
= sisDDLogicOpCode
;
854 ctx
->Driver
.PolygonMode
= NULL
;
855 ctx
->Driver
.PolygonStipple
= NULL
;
856 ctx
->Driver
.ReadBuffer
= NULL
;
857 ctx
->Driver
.RenderMode
= NULL
;
858 ctx
->Driver
.Scissor
= sisDDScissor
;
859 ctx
->Driver
.ShadeModel
= sisDDShadeModel
;
860 ctx
->Driver
.LightModelfv
= sisDDLightModelfv
;
861 ctx
->Driver
.Viewport
= sisDDViewport
;
863 /* XXX this should go away */
864 ctx
->Driver
.ResizeBuffers
= sisReAllocateBuffers
;