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"
39 #include "main/context.h"
40 #include "swrast/swrast.h"
43 #include "swrast_setup/swrast_setup.h"
46 /* =============================================================
51 sisDDAlphaFunc( GLcontext
* ctx
, GLenum func
, GLfloat ref
)
53 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
56 __GLSiSHardware
*prev
= &smesa
->prev
;
57 __GLSiSHardware
*current
= &smesa
->current
;
59 CLAMPED_FLOAT_TO_UBYTE(refbyte
, ref
);
60 current
->hwAlpha
= refbyte
<< 16;
62 /* Alpha Test function */
66 current
->hwAlpha
|= SiS_ALPHA_NEVER
;
69 current
->hwAlpha
|= SiS_ALPHA_LESS
;
72 current
->hwAlpha
|= SiS_ALPHA_EQUAL
;
75 current
->hwAlpha
|= SiS_ALPHA_LEQUAL
;
78 current
->hwAlpha
|= SiS_ALPHA_GREATER
;
81 current
->hwAlpha
|= SiS_ALPHA_NOTEQUAL
;
84 current
->hwAlpha
|= SiS_ALPHA_GEQUAL
;
87 current
->hwAlpha
|= SiS_ALPHA_ALWAYS
;
91 prev
->hwAlpha
= current
->hwAlpha
;
92 smesa
->GlobalFlag
|= GFLAG_ALPHASETTING
;
96 sisDDBlendFuncSeparate( GLcontext
*ctx
,
97 GLenum sfactorRGB
, GLenum dfactorRGB
,
98 GLenum sfactorA
, GLenum dfactorA
)
100 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
102 __GLSiSHardware
*prev
= &smesa
->prev
;
103 __GLSiSHardware
*current
= &smesa
->current
;
105 current
->hwDstSrcBlend
= 0;
110 current
->hwDstSrcBlend
|= SiS_D_ZERO
;
113 current
->hwDstSrcBlend
|= SiS_D_ONE
;
116 current
->hwDstSrcBlend
|= SiS_D_SRC_COLOR
;
118 case GL_ONE_MINUS_SRC_COLOR
:
119 current
->hwDstSrcBlend
|= SiS_D_ONE_MINUS_SRC_COLOR
;
122 current
->hwDstSrcBlend
|= SiS_D_SRC_ALPHA
;
124 case GL_ONE_MINUS_SRC_ALPHA
:
125 current
->hwDstSrcBlend
|= SiS_D_ONE_MINUS_SRC_ALPHA
;
128 current
->hwDstSrcBlend
|= SiS_D_DST_COLOR
;
130 case GL_ONE_MINUS_DST_COLOR
:
131 current
->hwDstSrcBlend
|= SiS_D_ONE_MINUS_DST_COLOR
;
134 current
->hwDstSrcBlend
|= SiS_D_DST_ALPHA
;
136 case GL_ONE_MINUS_DST_ALPHA
:
137 current
->hwDstSrcBlend
|= SiS_D_ONE_MINUS_DST_ALPHA
;
140 fprintf(stderr
, "Unknown dst blend function 0x%x\n", dfactorRGB
);
147 current
->hwDstSrcBlend
|= SiS_S_ZERO
;
150 current
->hwDstSrcBlend
|= SiS_S_ONE
;
153 current
->hwDstSrcBlend
|= SiS_S_SRC_COLOR
;
155 case GL_ONE_MINUS_SRC_COLOR
:
156 current
->hwDstSrcBlend
|= SiS_S_ONE_MINUS_SRC_COLOR
;
159 current
->hwDstSrcBlend
|= SiS_S_SRC_ALPHA
;
161 case GL_ONE_MINUS_SRC_ALPHA
:
162 current
->hwDstSrcBlend
|= SiS_S_ONE_MINUS_SRC_ALPHA
;
165 current
->hwDstSrcBlend
|= SiS_S_DST_COLOR
;
167 case GL_ONE_MINUS_DST_COLOR
:
168 current
->hwDstSrcBlend
|= SiS_S_ONE_MINUS_DST_COLOR
;
171 current
->hwDstSrcBlend
|= SiS_S_DST_ALPHA
;
173 case GL_ONE_MINUS_DST_ALPHA
:
174 current
->hwDstSrcBlend
|= SiS_S_ONE_MINUS_DST_ALPHA
;
176 case GL_SRC_ALPHA_SATURATE
:
177 current
->hwDstSrcBlend
|= SiS_S_SRC_ALPHA_SATURATE
;
180 fprintf(stderr
, "Unknown src blend function 0x%x\n", sfactorRGB
);
184 if (current
->hwDstSrcBlend
!= prev
->hwDstSrcBlend
) {
185 prev
->hwDstSrcBlend
= current
->hwDstSrcBlend
;
186 smesa
->GlobalFlag
|= GFLAG_DSTBLEND
;
190 /* =============================================================
195 sisDDDepthFunc( GLcontext
* ctx
, GLenum func
)
197 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
198 __GLSiSHardware
*prev
= &smesa
->prev
;
199 __GLSiSHardware
*current
= &smesa
->current
;
201 current
->hwZ
&= ~MASK_ZTestMode
;
205 current
->hwZ
|= SiS_Z_COMP_S_LT_B
;
208 current
->hwZ
|= SiS_Z_COMP_S_GE_B
;
211 current
->hwZ
|= SiS_Z_COMP_S_LE_B
;
214 current
->hwZ
|= SiS_Z_COMP_S_GT_B
;
217 current
->hwZ
|= SiS_Z_COMP_S_NE_B
;
220 current
->hwZ
|= SiS_Z_COMP_S_EQ_B
;
223 current
->hwZ
|= SiS_Z_COMP_ALWAYS
;
226 current
->hwZ
|= SiS_Z_COMP_NEVER
;
230 if (current
->hwZ
!= prev
->hwZ
) {
231 prev
->hwZ
= current
->hwZ
;
232 smesa
->GlobalFlag
|= GFLAG_ZSETTING
;
237 sisDDDepthMask( GLcontext
* ctx
, GLboolean flag
)
239 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
240 __GLSiSHardware
*prev
= &smesa
->prev
;
241 __GLSiSHardware
*current
= &smesa
->current
;
243 if (!ctx
->Depth
.Test
)
246 if (ctx
->Visual
.stencilBits
) {
247 if (flag
|| (ctx
->Stencil
.WriteMask
[0] != 0)) {
248 current
->hwCapEnable
|= MASK_ZWriteEnable
;
249 if (flag
&& ((ctx
->Stencil
.WriteMask
[0] & 0xff) == 0xff)) {
250 current
->hwCapEnable2
&= ~MASK_ZMaskWriteEnable
;
252 current
->hwCapEnable2
|= MASK_ZMaskWriteEnable
;
253 current
->hwZMask
= (ctx
->Stencil
.WriteMask
[0] << 24) |
254 ((flag
) ? 0x00ffffff : 0);
256 if (current
->hwZMask
^ prev
->hwZMask
) {
257 prev
->hwZMask
= current
->hwZMask
;
258 smesa
->GlobalFlag
|= GFLAG_ZSETTING
;
262 current
->hwCapEnable
&= ~MASK_ZWriteEnable
;
266 current
->hwCapEnable
|= MASK_ZWriteEnable
;
267 current
->hwCapEnable2
&= ~MASK_ZMaskWriteEnable
;
269 current
->hwCapEnable
&= ~MASK_ZWriteEnable
;
274 /* =============================================================
279 sisUpdateClipping( GLcontext
*ctx
)
281 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
283 __GLSiSHardware
*prev
= &smesa
->prev
;
284 __GLSiSHardware
*current
= &smesa
->current
;
286 GLint x1
, y1
, x2
, y2
;
289 /* XXX: 6326 has its own clipping for now. Should be fixed */
290 sis6326UpdateClipping(ctx
);
296 x2
= smesa
->width
- 1;
297 y2
= smesa
->height
- 1;
299 if (ctx
->Scissor
.Enabled
) {
300 if (ctx
->Scissor
.X
> x1
)
302 if (ctx
->Scissor
.Y
> y1
)
304 if (ctx
->Scissor
.X
+ ctx
->Scissor
.Width
- 1 < x2
)
305 x2
= ctx
->Scissor
.X
+ ctx
->Scissor
.Width
- 1;
306 if (ctx
->Scissor
.Y
+ ctx
->Scissor
.Height
- 1 < y2
)
307 y2
= ctx
->Scissor
.Y
+ ctx
->Scissor
.Height
- 1;
313 current
->clipTopBottom
= (y2
<< 13) | y1
;
314 current
->clipLeftRight
= (x1
<< 13) | x2
;
316 if ((current
->clipTopBottom
^ prev
->clipTopBottom
) ||
317 (current
->clipLeftRight
^ prev
->clipLeftRight
))
319 prev
->clipTopBottom
= current
->clipTopBottom
;
320 prev
->clipLeftRight
= current
->clipLeftRight
;
321 smesa
->GlobalFlag
|= GFLAG_CLIPPING
;
326 sisDDScissor( GLcontext
*ctx
, GLint x
, GLint y
, GLsizei w
, GLsizei h
)
328 if (ctx
->Scissor
.Enabled
)
329 sisUpdateClipping( ctx
);
332 /* =============================================================
337 sisUpdateCull( GLcontext
*ctx
)
339 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
340 GLint cullflag
, frontface
;
342 cullflag
= ctx
->Polygon
.CullFaceMode
;
343 frontface
= ctx
->Polygon
.FrontFace
;
345 smesa
->AGPParseSet
&= ~(MASK_PsCullDirection_CCW
);
346 smesa
->dwPrimitiveSet
&= ~(MASK_CullDirection
);
348 if((cullflag
== GL_FRONT
&& frontface
== GL_CCW
) ||
349 (cullflag
== GL_BACK
&& frontface
== GL_CW
))
351 smesa
->AGPParseSet
|= MASK_PsCullDirection_CCW
;
352 smesa
->dwPrimitiveSet
|= OP_3D_CullDirection_CCW
;
358 sisDDCullFace( GLcontext
*ctx
, GLenum mode
)
360 sisUpdateCull( ctx
);
364 sisDDFrontFace( GLcontext
*ctx
, GLenum mode
)
366 sisUpdateCull( ctx
);
369 /* =============================================================
373 static void sisDDColorMask( GLcontext
*ctx
,
374 GLboolean r
, GLboolean g
,
375 GLboolean b
, GLboolean a
)
377 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
378 __GLSiSHardware
*prev
= &smesa
->prev
;
379 __GLSiSHardware
*current
= &smesa
->current
;
381 if (r
&& g
&& b
&& ((ctx
->Visual
.alphaBits
== 0) || a
)) {
382 current
->hwCapEnable2
&= ~(MASK_AlphaMaskWriteEnable
|
383 MASK_ColorMaskWriteEnable
);
385 current
->hwCapEnable2
|= (MASK_AlphaMaskWriteEnable
|
386 MASK_ColorMaskWriteEnable
);
388 current
->hwDstMask
= (r
) ? smesa
->redMask
: 0 |
389 (g
) ? smesa
->greenMask
: 0 |
390 (b
) ? smesa
->blueMask
: 0 |
391 (a
) ? smesa
->alphaMask
: 0;
394 if (current
->hwDstMask
!= prev
->hwDstMask
) {
395 prev
->hwDstMask
= current
->hwDstMask
;
396 smesa
->GlobalFlag
|= GFLAG_DESTSETTING
;
400 /* =============================================================
401 * Rendering attributes
404 static void sisUpdateSpecular(GLcontext
*ctx
)
406 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
407 __GLSiSHardware
*current
= &smesa
->current
;
409 if (NEED_SECONDARY_COLOR(ctx
))
410 current
->hwCapEnable
|= MASK_SpecularEnable
;
412 current
->hwCapEnable
&= ~MASK_SpecularEnable
;
415 static void sisDDLightModelfv(GLcontext
*ctx
, GLenum pname
,
416 const GLfloat
*param
)
418 if (pname
== GL_LIGHT_MODEL_COLOR_CONTROL
) {
419 sisUpdateSpecular(ctx
);
423 static void sisDDShadeModel( GLcontext
*ctx
, GLenum mode
)
425 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
427 /* Signal to sisRasterPrimitive to recalculate dwPrimitiveSet */
428 smesa
->hw_primitive
= -1;
431 /* =============================================================
435 /* =============================================================
439 static void sisCalcViewport( GLcontext
*ctx
)
441 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
442 const GLfloat
*v
= ctx
->Viewport
._WindowMap
.m
;
443 GLfloat
*m
= smesa
->hw_viewport
;
445 /* See also sis_translate_vertex.
447 m
[MAT_SX
] = v
[MAT_SX
];
448 m
[MAT_TX
] = v
[MAT_TX
] + SUBPIXEL_X
;
449 m
[MAT_SY
] = - v
[MAT_SY
];
450 m
[MAT_TY
] = - v
[MAT_TY
] + smesa
->driDrawable
->h
+ SUBPIXEL_Y
;
451 m
[MAT_SZ
] = v
[MAT_SZ
] * smesa
->depth_scale
;
452 m
[MAT_TZ
] = v
[MAT_TZ
] * smesa
->depth_scale
;
455 static void sisDDViewport( GLcontext
*ctx
,
457 GLsizei width
, GLsizei height
)
459 sisCalcViewport( ctx
);
462 static void sisDDDepthRange( GLcontext
*ctx
,
463 GLclampd nearval
, GLclampd farval
)
465 sisCalcViewport( ctx
);
468 /* =============================================================
473 sisDDLogicOpCode( GLcontext
*ctx
, GLenum opcode
)
475 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
477 __GLSiSHardware
*prev
= &smesa
->prev
;
478 __GLSiSHardware
*current
= &smesa
->current
;
480 current
->hwDstSet
&= ~MASK_ROP2
;
484 current
->hwDstSet
|= LOP_CLEAR
;
487 current
->hwDstSet
|= LOP_SET
;
490 current
->hwDstSet
|= LOP_COPY
;
492 case GL_COPY_INVERTED
:
493 current
->hwDstSet
|= LOP_COPY_INVERTED
;
496 current
->hwDstSet
|= LOP_NOOP
;
499 current
->hwDstSet
|= LOP_INVERT
;
502 current
->hwDstSet
|= LOP_AND
;
505 current
->hwDstSet
|= LOP_NAND
;
508 current
->hwDstSet
|= LOP_OR
;
511 current
->hwDstSet
|= LOP_NOR
;
514 current
->hwDstSet
|= LOP_XOR
;
517 current
->hwDstSet
|= LOP_EQUIV
;
520 current
->hwDstSet
|= LOP_AND_REVERSE
;
522 case GL_AND_INVERTED
:
523 current
->hwDstSet
|= LOP_AND_INVERTED
;
526 current
->hwDstSet
|= LOP_OR_REVERSE
;
529 current
->hwDstSet
|= LOP_OR_INVERTED
;
533 if (current
->hwDstSet
^ prev
->hwDstSet
) {
534 prev
->hwDstSet
= current
->hwDstSet
;
535 smesa
->GlobalFlag
|= GFLAG_DESTSETTING
;
539 void sisDDDrawBuffer( GLcontext
*ctx
, GLenum mode
)
541 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
542 __GLSiSHardware
*prev
= &smesa
->prev
;
543 __GLSiSHardware
*current
= &smesa
->current
;
545 if (ctx
->DrawBuffer
->_NumColorDrawBuffers
!= 1) {
546 FALLBACK( smesa
, SIS_FALLBACK_DRAW_BUFFER
, GL_TRUE
);
550 current
->hwDstSet
&= ~MASK_DstBufferPitch
;
551 switch ( ctx
->DrawBuffer
->_ColorDrawBufferIndexes
[0] ) {
552 case BUFFER_FRONT_LEFT
:
553 FALLBACK( smesa
, SIS_FALLBACK_DRAW_BUFFER
, GL_FALSE
);
554 current
->hwOffsetDest
= smesa
->front
.offset
>> 1;
555 current
->hwDstSet
|= smesa
->front
.pitch
>> 2;
557 case BUFFER_BACK_LEFT
:
558 FALLBACK( smesa
, SIS_FALLBACK_DRAW_BUFFER
, GL_FALSE
);
559 current
->hwOffsetDest
= smesa
->back
.offset
>> 1;
560 current
->hwDstSet
|= smesa
->back
.pitch
>> 2;
563 FALLBACK( smesa
, SIS_FALLBACK_DRAW_BUFFER
, GL_TRUE
);
567 if (current
->hwDstSet
!= prev
->hwDstSet
) {
568 prev
->hwDstSet
= current
->hwDstSet
;
569 smesa
->GlobalFlag
|= GFLAG_DESTSETTING
;
572 if (current
->hwOffsetDest
!= prev
->hwOffsetDest
) {
573 prev
->hwOffsetDest
= current
->hwOffsetDest
;
574 smesa
->GlobalFlag
|= GFLAG_DESTSETTING
;
578 /* =============================================================
582 /* =============================================================
586 /* =============================================================
587 * State enable/disable
591 sisDDEnable( GLcontext
* ctx
, GLenum cap
, GLboolean state
)
593 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
595 __GLSiSHardware
*current
= &smesa
->current
;
601 current
->hwCapEnable
|= MASK_AlphaTestEnable
;
603 current
->hwCapEnable
&= ~MASK_AlphaTestEnable
;
608 /* if (state & !ctx->Color.ColorLogicOpEnabled) */
609 current
->hwCapEnable
|= MASK_BlendEnable
;
611 current
->hwCapEnable
&= ~MASK_BlendEnable
;
615 current
->hwCapEnable
|= MASK_CullEnable
;
617 current
->hwCapEnable
&= ~MASK_CullEnable
;
620 if (state
&& smesa
->depth
.offset
!= 0)
621 current
->hwCapEnable
|= MASK_ZTestEnable
;
623 current
->hwCapEnable
&= ~MASK_ZTestEnable
;
624 sisDDDepthMask( ctx
, ctx
->Depth
.Mask
);
628 current
->hwCapEnable
|= MASK_DitherEnable
;
630 current
->hwCapEnable
&= ~MASK_DitherEnable
;
634 current
->hwCapEnable
|= MASK_FogEnable
;
636 current
->hwCapEnable
&= ~MASK_FogEnable
;
638 case GL_COLOR_LOGIC_OP
:
640 sisDDLogicOpCode( ctx
, ctx
->Color
.LogicOp
);
642 sisDDLogicOpCode( ctx
, GL_COPY
);
644 case GL_SCISSOR_TEST
:
645 sisUpdateClipping( ctx
);
647 case GL_STENCIL_TEST
:
649 if (smesa
->zFormat
!= SiS_ZFORMAT_S8Z24
)
650 FALLBACK(smesa
, SIS_FALLBACK_STENCIL
, 1);
652 current
->hwCapEnable
|= (MASK_StencilTestEnable
|
653 MASK_StencilWriteEnable
);
655 FALLBACK(smesa
, SIS_FALLBACK_STENCIL
, 0);
656 current
->hwCapEnable
&= ~(MASK_StencilTestEnable
|
657 MASK_StencilWriteEnable
);
661 case GL_COLOR_SUM_EXT
:
662 sisUpdateSpecular(ctx
);
668 /* =============================================================
669 * State initialization, management
672 /* Called before beginning of rendering. */
674 sisUpdateHWState( GLcontext
*ctx
)
676 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
677 __GLSiSHardware
*prev
= &smesa
->prev
;
678 __GLSiSHardware
*current
= &smesa
->current
;
680 /* enable setting 1 */
681 if (current
->hwCapEnable
^ prev
->hwCapEnable
) {
682 prev
->hwCapEnable
= current
->hwCapEnable
;
683 smesa
->GlobalFlag
|= GFLAG_ENABLESETTING
;
686 /* enable setting 2 */
687 if (current
->hwCapEnable2
^ prev
->hwCapEnable2
) {
688 prev
->hwCapEnable2
= current
->hwCapEnable2
;
689 smesa
->GlobalFlag
|= GFLAG_ENABLESETTING2
;
692 if (smesa
->GlobalFlag
& GFLAG_RENDER_STATES
)
693 sis_update_render_state( smesa
);
695 if (smesa
->GlobalFlag
& GFLAG_TEXTURE_STATES
)
696 sis_update_texture_state( smesa
);
700 sisDDInvalidateState( GLcontext
*ctx
, GLuint new_state
)
702 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
704 _swrast_InvalidateState( ctx
, new_state
);
705 _swsetup_InvalidateState( ctx
, new_state
);
706 _vbo_InvalidateState( ctx
, new_state
);
707 _tnl_InvalidateState( ctx
, new_state
);
708 smesa
->NewGLState
|= new_state
;
711 /* Initialize the context's hardware state.
713 void sisDDInitState( sisContextPtr smesa
)
715 __GLSiSHardware
*current
= &smesa
->current
;
716 __GLSiSHardware
*prev
= &(smesa
->prev
);
717 GLcontext
*ctx
= smesa
->glCtx
;
719 /* add Texture Perspective Enable */
720 prev
->hwCapEnable
= MASK_FogPerspectiveEnable
| MASK_TextureCacheEnable
|
721 MASK_TexturePerspectiveEnable
| MASK_DitherEnable
;
724 prev->hwCapEnable2 = 0x00aa0080;
726 /* if multi-texture enabled, disable Z pre-test */
727 prev
->hwCapEnable2
= MASK_TextureMipmapBiasEnable
;
729 /* Z test mode is LESS */
730 prev
->hwZ
= SiS_Z_COMP_S_LT_B
;
733 prev
->hwZMask
= 0xffffffff;
735 /* Alpha test mode is ALWAYS, alpha ref value is 0 */
736 prev
->hwAlpha
= SiS_ALPHA_ALWAYS
;
738 /* ROP2 is COPYPEN */
739 prev
->hwDstSet
= LOP_COPY
;
742 prev
->hwDstMask
= 0xffffffff;
744 /* LinePattern is 0, Repeat Factor is 0 */
745 prev
->hwLinePattern
= 0x00008000;
747 /* Src blend is BLEND_ONE, Dst blend is D3DBLEND_ZERO */
748 prev
->hwDstSrcBlend
= SiS_S_ONE
| SiS_D_ZERO
;
750 /* Stenciling disabled, function ALWAYS, ref value zero, mask all ones */
751 prev
->hwStSetting
= STENCIL_FORMAT_8
| SiS_STENCIL_ALWAYS
| 0xff;
752 /* Op is KEEP for all three operations */
753 prev
->hwStSetting2
= SiS_SFAIL_KEEP
| SiS_SPASS_ZFAIL_KEEP
|
754 SiS_SPASS_ZPASS_KEEP
;
756 /* Texture mapping mode is Tile */
758 prev
->texture
[0].hwTextureSet
= 0x00030000;
760 /* Magnified & minified texture filter is NEAREST */
762 prev
->texture
[0].hwTextureMip
= 0;
765 /* Texture Blending setting -- use fragment color/alpha*/
766 prev
->hwTexBlendColor0
= STAGE0_C_CF
;
767 prev
->hwTexBlendColor1
= STAGE1_C_CF
;
768 prev
->hwTexBlendAlpha0
= STAGE0_A_AF
;
769 prev
->hwTexBlendAlpha1
= STAGE1_A_AF
;
771 switch (smesa
->bytesPerPixel
)
774 prev
->hwDstSet
|= DST_FORMAT_RGB_565
;
777 prev
->hwDstSet
|= DST_FORMAT_ARGB_8888
;
781 switch (ctx
->Visual
.depthBits
)
784 prev
->hwCapEnable
&= ~MASK_ZWriteEnable
;
786 smesa
->zFormat
= SiS_ZFORMAT_Z16
;
787 prev
->hwCapEnable
|= MASK_ZWriteEnable
;
788 smesa
->depth_scale
= 1.0 / (GLfloat
)0xffff;
791 smesa
->zFormat
= SiS_ZFORMAT_Z32
;
792 prev
->hwCapEnable
|= MASK_ZWriteEnable
;
793 smesa
->depth_scale
= 1.0 / (GLfloat
)0xffffffff;
796 assert (ctx
->Visual
.stencilBits
);
797 smesa
->zFormat
= SiS_ZFORMAT_S8Z24
;
798 prev
->hwCapEnable
|= MASK_StencilBufferEnable
;
799 prev
->hwCapEnable
|= MASK_ZWriteEnable
;
800 smesa
->depth_scale
= 1.0 / (GLfloat
)0xffffff;
804 prev
->hwZ
|= smesa
->zFormat
;
806 /* TODO: need to clear cache? */
807 smesa
->clearTexCache
= GL_TRUE
;
809 smesa
->clearColorPattern
= 0;
811 smesa
->AGPParseSet
= MASK_PsTexture1FromB
| MASK_PsBumpTextureFromC
;
812 smesa
->dwPrimitiveSet
= OP_3D_Texture1FromB
| OP_3D_TextureBumpFromC
;
814 sisUpdateZStencilPattern( smesa
, 1.0, 0 );
815 sisUpdateCull( ctx
);
817 memcpy( current
, prev
, sizeof (__GLSiSHardware
) );
819 /* Set initial fog settings. Start and end are the same case. */
820 sisDDFogfv( ctx
, GL_FOG_DENSITY
, &ctx
->Fog
.Density
);
821 sisDDFogfv( ctx
, GL_FOG_END
, &ctx
->Fog
.End
);
822 sisDDFogfv( ctx
, GL_FOG_COORDINATE_SOURCE_EXT
, NULL
);
823 sisDDFogfv( ctx
, GL_FOG_MODE
, NULL
);
826 /* Initialize the driver's state functions.
828 void sisDDInitStateFuncs( GLcontext
*ctx
)
830 ctx
->Driver
.UpdateState
= sisDDInvalidateState
;
832 ctx
->Driver
.Clear
= sisDDClear
;
833 ctx
->Driver
.ClearColor
= sisDDClearColor
;
834 ctx
->Driver
.ClearDepth
= sisDDClearDepth
;
835 ctx
->Driver
.ClearStencil
= sisDDClearStencil
;
837 ctx
->Driver
.AlphaFunc
= sisDDAlphaFunc
;
838 ctx
->Driver
.BlendFuncSeparate
= sisDDBlendFuncSeparate
;
839 ctx
->Driver
.ColorMask
= sisDDColorMask
;
840 ctx
->Driver
.CullFace
= sisDDCullFace
;
841 ctx
->Driver
.DepthMask
= sisDDDepthMask
;
842 ctx
->Driver
.DepthFunc
= sisDDDepthFunc
;
843 ctx
->Driver
.DepthRange
= sisDDDepthRange
;
844 ctx
->Driver
.DrawBuffer
= sisDDDrawBuffer
;
845 ctx
->Driver
.Enable
= sisDDEnable
;
846 ctx
->Driver
.FrontFace
= sisDDFrontFace
;
847 ctx
->Driver
.Fogfv
= sisDDFogfv
;
848 ctx
->Driver
.Hint
= NULL
;
849 ctx
->Driver
.Lightfv
= NULL
;
850 ctx
->Driver
.LogicOpcode
= sisDDLogicOpCode
;
851 ctx
->Driver
.PolygonMode
= NULL
;
852 ctx
->Driver
.PolygonStipple
= NULL
;
853 ctx
->Driver
.ReadBuffer
= NULL
;
854 ctx
->Driver
.RenderMode
= NULL
;
855 ctx
->Driver
.Scissor
= sisDDScissor
;
856 ctx
->Driver
.ShadeModel
= sisDDShadeModel
;
857 ctx
->Driver
.LightModelfv
= sisDDLightModelfv
;
858 ctx
->Driver
.Viewport
= sisDDViewport
;
860 /* XXX this should go away */
861 ctx
->Driver
.ResizeBuffers
= sisReAllocateBuffers
;