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 **************************************************************************/
27 /* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_ctx.c,v 1.3 2000/09/26 15:56:48 tsi Exp $ */
31 * Sung-Ching Lin <sclin@sis.com.tw>
32 * Eric Anholt <anholt@FreeBSD.org>
35 #include "sis_context.h"
36 #include "sis_state.h"
41 #include "main/context.h"
42 #include "main/enums.h"
43 #include "main/colormac.h"
44 #include "swrast/swrast.h"
47 #include "swrast_setup/swrast_setup.h"
49 #include "tnl/t_pipeline.h"
51 /* =============================================================
56 sisDDAlphaFunc( GLcontext
* ctx
, GLenum func
, GLfloat ref
)
58 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
61 __GLSiSHardware
*prev
= &smesa
->prev
;
62 __GLSiSHardware
*current
= &smesa
->current
;
64 CLAMPED_FLOAT_TO_UBYTE(refbyte
, ref
);
65 current
->hwAlpha
= refbyte
<< 16;
67 /* Alpha Test function */
71 current
->hwAlpha
|= SiS_ALPHA_NEVER
;
74 current
->hwAlpha
|= SiS_ALPHA_LESS
;
77 current
->hwAlpha
|= SiS_ALPHA_EQUAL
;
80 current
->hwAlpha
|= SiS_ALPHA_LEQUAL
;
83 current
->hwAlpha
|= SiS_ALPHA_GREATER
;
86 current
->hwAlpha
|= SiS_ALPHA_NOTEQUAL
;
89 current
->hwAlpha
|= SiS_ALPHA_GEQUAL
;
92 current
->hwAlpha
|= SiS_ALPHA_ALWAYS
;
96 prev
->hwAlpha
= current
->hwAlpha
;
97 smesa
->GlobalFlag
|= GFLAG_ALPHASETTING
;
101 sisDDBlendFuncSeparate( GLcontext
*ctx
,
102 GLenum sfactorRGB
, GLenum dfactorRGB
,
103 GLenum sfactorA
, GLenum dfactorA
)
105 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
107 __GLSiSHardware
*prev
= &smesa
->prev
;
108 __GLSiSHardware
*current
= &smesa
->current
;
110 current
->hwDstSrcBlend
= 0;
115 current
->hwDstSrcBlend
|= SiS_D_ZERO
;
118 current
->hwDstSrcBlend
|= SiS_D_ONE
;
121 current
->hwDstSrcBlend
|= SiS_D_SRC_COLOR
;
123 case GL_ONE_MINUS_SRC_COLOR
:
124 current
->hwDstSrcBlend
|= SiS_D_ONE_MINUS_SRC_COLOR
;
127 current
->hwDstSrcBlend
|= SiS_D_SRC_ALPHA
;
129 case GL_ONE_MINUS_SRC_ALPHA
:
130 current
->hwDstSrcBlend
|= SiS_D_ONE_MINUS_SRC_ALPHA
;
133 current
->hwDstSrcBlend
|= SiS_D_DST_COLOR
;
135 case GL_ONE_MINUS_DST_COLOR
:
136 current
->hwDstSrcBlend
|= SiS_D_ONE_MINUS_DST_COLOR
;
139 current
->hwDstSrcBlend
|= SiS_D_DST_ALPHA
;
141 case GL_ONE_MINUS_DST_ALPHA
:
142 current
->hwDstSrcBlend
|= SiS_D_ONE_MINUS_DST_ALPHA
;
145 fprintf(stderr
, "Unknown dst blend function 0x%x\n", dfactorRGB
);
152 current
->hwDstSrcBlend
|= SiS_S_ZERO
;
155 current
->hwDstSrcBlend
|= SiS_S_ONE
;
158 current
->hwDstSrcBlend
|= SiS_S_SRC_COLOR
;
160 case GL_ONE_MINUS_SRC_COLOR
:
161 current
->hwDstSrcBlend
|= SiS_S_ONE_MINUS_SRC_COLOR
;
164 current
->hwDstSrcBlend
|= SiS_S_SRC_ALPHA
;
166 case GL_ONE_MINUS_SRC_ALPHA
:
167 current
->hwDstSrcBlend
|= SiS_S_ONE_MINUS_SRC_ALPHA
;
170 current
->hwDstSrcBlend
|= SiS_S_DST_COLOR
;
172 case GL_ONE_MINUS_DST_COLOR
:
173 current
->hwDstSrcBlend
|= SiS_S_ONE_MINUS_DST_COLOR
;
176 current
->hwDstSrcBlend
|= SiS_S_DST_ALPHA
;
178 case GL_ONE_MINUS_DST_ALPHA
:
179 current
->hwDstSrcBlend
|= SiS_S_ONE_MINUS_DST_ALPHA
;
181 case GL_SRC_ALPHA_SATURATE
:
182 current
->hwDstSrcBlend
|= SiS_S_SRC_ALPHA_SATURATE
;
185 fprintf(stderr
, "Unknown src blend function 0x%x\n", sfactorRGB
);
189 if (current
->hwDstSrcBlend
!= prev
->hwDstSrcBlend
) {
190 prev
->hwDstSrcBlend
= current
->hwDstSrcBlend
;
191 smesa
->GlobalFlag
|= GFLAG_DSTBLEND
;
195 /* =============================================================
200 sisDDDepthFunc( GLcontext
* ctx
, GLenum func
)
202 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
203 __GLSiSHardware
*prev
= &smesa
->prev
;
204 __GLSiSHardware
*current
= &smesa
->current
;
206 current
->hwZ
&= ~MASK_ZTestMode
;
210 current
->hwZ
|= SiS_Z_COMP_S_LT_B
;
213 current
->hwZ
|= SiS_Z_COMP_S_GE_B
;
216 current
->hwZ
|= SiS_Z_COMP_S_LE_B
;
219 current
->hwZ
|= SiS_Z_COMP_S_GT_B
;
222 current
->hwZ
|= SiS_Z_COMP_S_NE_B
;
225 current
->hwZ
|= SiS_Z_COMP_S_EQ_B
;
228 current
->hwZ
|= SiS_Z_COMP_ALWAYS
;
231 current
->hwZ
|= SiS_Z_COMP_NEVER
;
235 if (current
->hwZ
!= prev
->hwZ
) {
236 prev
->hwZ
= current
->hwZ
;
237 smesa
->GlobalFlag
|= GFLAG_ZSETTING
;
242 sisDDDepthMask( GLcontext
* ctx
, GLboolean flag
)
244 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
245 __GLSiSHardware
*prev
= &smesa
->prev
;
246 __GLSiSHardware
*current
= &smesa
->current
;
248 if (!ctx
->Depth
.Test
)
251 if (ctx
->Visual
.stencilBits
) {
252 if (flag
|| (ctx
->Stencil
.WriteMask
[0] != 0)) {
253 current
->hwCapEnable
|= MASK_ZWriteEnable
;
254 if (flag
&& ((ctx
->Stencil
.WriteMask
[0] & 0xff) == 0xff)) {
255 current
->hwCapEnable2
&= ~MASK_ZMaskWriteEnable
;
257 current
->hwCapEnable2
|= MASK_ZMaskWriteEnable
;
258 current
->hwZMask
= (ctx
->Stencil
.WriteMask
[0] << 24) |
259 ((flag
) ? 0x00ffffff : 0);
261 if (current
->hwZMask
^ prev
->hwZMask
) {
262 prev
->hwZMask
= current
->hwZMask
;
263 smesa
->GlobalFlag
|= GFLAG_ZSETTING
;
267 current
->hwCapEnable
&= ~MASK_ZWriteEnable
;
271 current
->hwCapEnable
|= MASK_ZWriteEnable
;
272 current
->hwCapEnable2
&= ~MASK_ZMaskWriteEnable
;
274 current
->hwCapEnable
&= ~MASK_ZWriteEnable
;
279 /* =============================================================
284 sisUpdateClipping( GLcontext
*ctx
)
286 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
288 __GLSiSHardware
*prev
= &smesa
->prev
;
289 __GLSiSHardware
*current
= &smesa
->current
;
291 GLint x1
, y1
, x2
, y2
;
294 /* XXX: 6326 has its own clipping for now. Should be fixed */
295 sis6326UpdateClipping(ctx
);
301 x2
= smesa
->width
- 1;
302 y2
= smesa
->height
- 1;
304 if (ctx
->Scissor
.Enabled
) {
305 if (ctx
->Scissor
.X
> x1
)
307 if (ctx
->Scissor
.Y
> y1
)
309 if (ctx
->Scissor
.X
+ ctx
->Scissor
.Width
- 1 < x2
)
310 x2
= ctx
->Scissor
.X
+ ctx
->Scissor
.Width
- 1;
311 if (ctx
->Scissor
.Y
+ ctx
->Scissor
.Height
- 1 < y2
)
312 y2
= ctx
->Scissor
.Y
+ ctx
->Scissor
.Height
- 1;
318 current
->clipTopBottom
= (y2
<< 13) | y1
;
319 current
->clipLeftRight
= (x1
<< 13) | x2
;
321 if ((current
->clipTopBottom
^ prev
->clipTopBottom
) ||
322 (current
->clipLeftRight
^ prev
->clipLeftRight
))
324 prev
->clipTopBottom
= current
->clipTopBottom
;
325 prev
->clipLeftRight
= current
->clipLeftRight
;
326 smesa
->GlobalFlag
|= GFLAG_CLIPPING
;
331 sisDDScissor( GLcontext
*ctx
, GLint x
, GLint y
, GLsizei w
, GLsizei h
)
333 if (ctx
->Scissor
.Enabled
)
334 sisUpdateClipping( ctx
);
337 /* =============================================================
342 sisUpdateCull( GLcontext
*ctx
)
344 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
345 GLint cullflag
, frontface
;
347 cullflag
= ctx
->Polygon
.CullFaceMode
;
348 frontface
= ctx
->Polygon
.FrontFace
;
350 smesa
->AGPParseSet
&= ~(MASK_PsCullDirection_CCW
);
351 smesa
->dwPrimitiveSet
&= ~(MASK_CullDirection
);
353 if((cullflag
== GL_FRONT
&& frontface
== GL_CCW
) ||
354 (cullflag
== GL_BACK
&& frontface
== GL_CW
))
356 smesa
->AGPParseSet
|= MASK_PsCullDirection_CCW
;
357 smesa
->dwPrimitiveSet
|= OP_3D_CullDirection_CCW
;
363 sisDDCullFace( GLcontext
*ctx
, GLenum mode
)
365 sisUpdateCull( ctx
);
369 sisDDFrontFace( GLcontext
*ctx
, GLenum mode
)
371 sisUpdateCull( ctx
);
374 /* =============================================================
378 static void sisDDColorMask( GLcontext
*ctx
,
379 GLboolean r
, GLboolean g
,
380 GLboolean b
, GLboolean a
)
382 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
383 __GLSiSHardware
*prev
= &smesa
->prev
;
384 __GLSiSHardware
*current
= &smesa
->current
;
386 if (r
&& g
&& b
&& ((ctx
->Visual
.alphaBits
== 0) || a
)) {
387 current
->hwCapEnable2
&= ~(MASK_AlphaMaskWriteEnable
|
388 MASK_ColorMaskWriteEnable
);
390 current
->hwCapEnable2
|= (MASK_AlphaMaskWriteEnable
|
391 MASK_ColorMaskWriteEnable
);
393 current
->hwDstMask
= (r
) ? smesa
->redMask
: 0 |
394 (g
) ? smesa
->greenMask
: 0 |
395 (b
) ? smesa
->blueMask
: 0 |
396 (a
) ? smesa
->alphaMask
: 0;
399 if (current
->hwDstMask
!= prev
->hwDstMask
) {
400 prev
->hwDstMask
= current
->hwDstMask
;
401 smesa
->GlobalFlag
|= GFLAG_DESTSETTING
;
405 /* =============================================================
406 * Rendering attributes
409 static void sisUpdateSpecular(GLcontext
*ctx
)
411 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
412 __GLSiSHardware
*current
= &smesa
->current
;
414 if (NEED_SECONDARY_COLOR(ctx
))
415 current
->hwCapEnable
|= MASK_SpecularEnable
;
417 current
->hwCapEnable
&= ~MASK_SpecularEnable
;
420 static void sisDDLightModelfv(GLcontext
*ctx
, GLenum pname
,
421 const GLfloat
*param
)
423 if (pname
== GL_LIGHT_MODEL_COLOR_CONTROL
) {
424 sisUpdateSpecular(ctx
);
428 static void sisDDShadeModel( GLcontext
*ctx
, GLenum mode
)
430 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
432 /* Signal to sisRasterPrimitive to recalculate dwPrimitiveSet */
433 smesa
->hw_primitive
= -1;
436 /* =============================================================
440 /* =============================================================
444 static void sisCalcViewport( GLcontext
*ctx
)
446 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
447 const GLfloat
*v
= ctx
->Viewport
._WindowMap
.m
;
448 GLfloat
*m
= smesa
->hw_viewport
;
450 /* See also sis_translate_vertex.
452 m
[MAT_SX
] = v
[MAT_SX
];
453 m
[MAT_TX
] = v
[MAT_TX
] + SUBPIXEL_X
;
454 m
[MAT_SY
] = - v
[MAT_SY
];
455 m
[MAT_TY
] = - v
[MAT_TY
] + smesa
->driDrawable
->h
+ SUBPIXEL_Y
;
456 m
[MAT_SZ
] = v
[MAT_SZ
] * smesa
->depth_scale
;
457 m
[MAT_TZ
] = v
[MAT_TZ
] * smesa
->depth_scale
;
460 static void sisDDViewport( GLcontext
*ctx
,
462 GLsizei width
, GLsizei height
)
464 sisCalcViewport( ctx
);
467 static void sisDDDepthRange( GLcontext
*ctx
,
468 GLclampd nearval
, GLclampd farval
)
470 sisCalcViewport( ctx
);
473 /* =============================================================
478 sisDDLogicOpCode( GLcontext
*ctx
, GLenum opcode
)
480 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
482 __GLSiSHardware
*prev
= &smesa
->prev
;
483 __GLSiSHardware
*current
= &smesa
->current
;
485 current
->hwDstSet
&= ~MASK_ROP2
;
489 current
->hwDstSet
|= LOP_CLEAR
;
492 current
->hwDstSet
|= LOP_SET
;
495 current
->hwDstSet
|= LOP_COPY
;
497 case GL_COPY_INVERTED
:
498 current
->hwDstSet
|= LOP_COPY_INVERTED
;
501 current
->hwDstSet
|= LOP_NOOP
;
504 current
->hwDstSet
|= LOP_INVERT
;
507 current
->hwDstSet
|= LOP_AND
;
510 current
->hwDstSet
|= LOP_NAND
;
513 current
->hwDstSet
|= LOP_OR
;
516 current
->hwDstSet
|= LOP_NOR
;
519 current
->hwDstSet
|= LOP_XOR
;
522 current
->hwDstSet
|= LOP_EQUIV
;
525 current
->hwDstSet
|= LOP_AND_REVERSE
;
527 case GL_AND_INVERTED
:
528 current
->hwDstSet
|= LOP_AND_INVERTED
;
531 current
->hwDstSet
|= LOP_OR_REVERSE
;
534 current
->hwDstSet
|= LOP_OR_INVERTED
;
538 if (current
->hwDstSet
^ prev
->hwDstSet
) {
539 prev
->hwDstSet
= current
->hwDstSet
;
540 smesa
->GlobalFlag
|= GFLAG_DESTSETTING
;
544 void sisDDDrawBuffer( GLcontext
*ctx
, GLenum mode
)
546 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
547 __GLSiSHardware
*prev
= &smesa
->prev
;
548 __GLSiSHardware
*current
= &smesa
->current
;
550 if (ctx
->DrawBuffer
->_NumColorDrawBuffers
!= 1) {
551 FALLBACK( smesa
, SIS_FALLBACK_DRAW_BUFFER
, GL_TRUE
);
555 current
->hwDstSet
&= ~MASK_DstBufferPitch
;
556 switch ( ctx
->DrawBuffer
->_ColorDrawBufferIndexes
[0] ) {
557 case BUFFER_FRONT_LEFT
:
558 FALLBACK( smesa
, SIS_FALLBACK_DRAW_BUFFER
, GL_FALSE
);
559 current
->hwOffsetDest
= smesa
->front
.offset
>> 1;
560 current
->hwDstSet
|= smesa
->front
.pitch
>> 2;
562 case BUFFER_BACK_LEFT
:
563 FALLBACK( smesa
, SIS_FALLBACK_DRAW_BUFFER
, GL_FALSE
);
564 current
->hwOffsetDest
= smesa
->back
.offset
>> 1;
565 current
->hwDstSet
|= smesa
->back
.pitch
>> 2;
568 FALLBACK( smesa
, SIS_FALLBACK_DRAW_BUFFER
, GL_TRUE
);
572 if (current
->hwDstSet
!= prev
->hwDstSet
) {
573 prev
->hwDstSet
= current
->hwDstSet
;
574 smesa
->GlobalFlag
|= GFLAG_DESTSETTING
;
577 if (current
->hwOffsetDest
!= prev
->hwOffsetDest
) {
578 prev
->hwOffsetDest
= current
->hwOffsetDest
;
579 smesa
->GlobalFlag
|= GFLAG_DESTSETTING
;
583 /* =============================================================
587 /* =============================================================
591 /* =============================================================
592 * State enable/disable
596 sisDDEnable( GLcontext
* ctx
, GLenum cap
, GLboolean state
)
598 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
600 __GLSiSHardware
*current
= &smesa
->current
;
606 current
->hwCapEnable
|= MASK_AlphaTestEnable
;
608 current
->hwCapEnable
&= ~MASK_AlphaTestEnable
;
613 /* if (state & !ctx->Color.ColorLogicOpEnabled) */
614 current
->hwCapEnable
|= MASK_BlendEnable
;
616 current
->hwCapEnable
&= ~MASK_BlendEnable
;
620 current
->hwCapEnable
|= MASK_CullEnable
;
622 current
->hwCapEnable
&= ~MASK_CullEnable
;
625 if (state
&& smesa
->depth
.offset
!= 0)
626 current
->hwCapEnable
|= MASK_ZTestEnable
;
628 current
->hwCapEnable
&= ~MASK_ZTestEnable
;
629 sisDDDepthMask( ctx
, ctx
->Depth
.Mask
);
633 current
->hwCapEnable
|= MASK_DitherEnable
;
635 current
->hwCapEnable
&= ~MASK_DitherEnable
;
639 current
->hwCapEnable
|= MASK_FogEnable
;
641 current
->hwCapEnable
&= ~MASK_FogEnable
;
643 case GL_COLOR_LOGIC_OP
:
645 sisDDLogicOpCode( ctx
, ctx
->Color
.LogicOp
);
647 sisDDLogicOpCode( ctx
, GL_COPY
);
649 case GL_SCISSOR_TEST
:
650 sisUpdateClipping( ctx
);
652 case GL_STENCIL_TEST
:
654 if (smesa
->zFormat
!= SiS_ZFORMAT_S8Z24
)
655 FALLBACK(smesa
, SIS_FALLBACK_STENCIL
, 1);
657 current
->hwCapEnable
|= (MASK_StencilTestEnable
|
658 MASK_StencilWriteEnable
);
660 FALLBACK(smesa
, SIS_FALLBACK_STENCIL
, 0);
661 current
->hwCapEnable
&= ~(MASK_StencilTestEnable
|
662 MASK_StencilWriteEnable
);
666 case GL_COLOR_SUM_EXT
:
667 sisUpdateSpecular(ctx
);
673 /* =============================================================
674 * State initialization, management
677 /* Called before beginning of rendering. */
679 sisUpdateHWState( GLcontext
*ctx
)
681 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
682 __GLSiSHardware
*prev
= &smesa
->prev
;
683 __GLSiSHardware
*current
= &smesa
->current
;
685 /* enable setting 1 */
686 if (current
->hwCapEnable
^ prev
->hwCapEnable
) {
687 prev
->hwCapEnable
= current
->hwCapEnable
;
688 smesa
->GlobalFlag
|= GFLAG_ENABLESETTING
;
691 /* enable setting 2 */
692 if (current
->hwCapEnable2
^ prev
->hwCapEnable2
) {
693 prev
->hwCapEnable2
= current
->hwCapEnable2
;
694 smesa
->GlobalFlag
|= GFLAG_ENABLESETTING2
;
697 if (smesa
->GlobalFlag
& GFLAG_RENDER_STATES
)
698 sis_update_render_state( smesa
);
700 if (smesa
->GlobalFlag
& GFLAG_TEXTURE_STATES
)
701 sis_update_texture_state( smesa
);
705 sisDDInvalidateState( GLcontext
*ctx
, GLuint new_state
)
707 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
709 _swrast_InvalidateState( ctx
, new_state
);
710 _swsetup_InvalidateState( ctx
, new_state
);
711 _vbo_InvalidateState( ctx
, new_state
);
712 _tnl_InvalidateState( ctx
, new_state
);
713 smesa
->NewGLState
|= new_state
;
716 /* Initialize the context's hardware state.
718 void sisDDInitState( sisContextPtr smesa
)
720 __GLSiSHardware
*current
= &smesa
->current
;
721 __GLSiSHardware
*prev
= &(smesa
->prev
);
722 GLcontext
*ctx
= smesa
->glCtx
;
724 /* add Texture Perspective Enable */
725 prev
->hwCapEnable
= MASK_FogPerspectiveEnable
| MASK_TextureCacheEnable
|
726 MASK_TexturePerspectiveEnable
| MASK_DitherEnable
;
729 prev->hwCapEnable2 = 0x00aa0080;
731 /* if multi-texture enabled, disable Z pre-test */
732 prev
->hwCapEnable2
= MASK_TextureMipmapBiasEnable
;
734 /* Z test mode is LESS */
735 prev
->hwZ
= SiS_Z_COMP_S_LT_B
;
738 prev
->hwZMask
= 0xffffffff;
740 /* Alpha test mode is ALWAYS, alpha ref value is 0 */
741 prev
->hwAlpha
= SiS_ALPHA_ALWAYS
;
743 /* ROP2 is COPYPEN */
744 prev
->hwDstSet
= LOP_COPY
;
747 prev
->hwDstMask
= 0xffffffff;
749 /* LinePattern is 0, Repeat Factor is 0 */
750 prev
->hwLinePattern
= 0x00008000;
752 /* Src blend is BLEND_ONE, Dst blend is D3DBLEND_ZERO */
753 prev
->hwDstSrcBlend
= SiS_S_ONE
| SiS_D_ZERO
;
755 /* Stenciling disabled, function ALWAYS, ref value zero, mask all ones */
756 prev
->hwStSetting
= STENCIL_FORMAT_8
| SiS_STENCIL_ALWAYS
| 0xff;
757 /* Op is KEEP for all three operations */
758 prev
->hwStSetting2
= SiS_SFAIL_KEEP
| SiS_SPASS_ZFAIL_KEEP
|
759 SiS_SPASS_ZPASS_KEEP
;
761 /* Texture mapping mode is Tile */
763 prev
->texture
[0].hwTextureSet
= 0x00030000;
765 /* Magnified & minified texture filter is NEAREST */
767 prev
->texture
[0].hwTextureMip
= 0;
770 /* Texture Blending setting -- use fragment color/alpha*/
771 prev
->hwTexBlendColor0
= STAGE0_C_CF
;
772 prev
->hwTexBlendColor1
= STAGE1_C_CF
;
773 prev
->hwTexBlendAlpha0
= STAGE0_A_AF
;
774 prev
->hwTexBlendAlpha1
= STAGE1_A_AF
;
776 switch (smesa
->bytesPerPixel
)
779 prev
->hwDstSet
|= DST_FORMAT_RGB_565
;
782 prev
->hwDstSet
|= DST_FORMAT_ARGB_8888
;
786 switch (ctx
->Visual
.depthBits
)
789 prev
->hwCapEnable
&= ~MASK_ZWriteEnable
;
791 smesa
->zFormat
= SiS_ZFORMAT_Z16
;
792 prev
->hwCapEnable
|= MASK_ZWriteEnable
;
793 smesa
->depth_scale
= 1.0 / (GLfloat
)0xffff;
796 smesa
->zFormat
= SiS_ZFORMAT_Z32
;
797 prev
->hwCapEnable
|= MASK_ZWriteEnable
;
798 smesa
->depth_scale
= 1.0 / (GLfloat
)0xffffffff;
801 assert (ctx
->Visual
.stencilBits
);
802 smesa
->zFormat
= SiS_ZFORMAT_S8Z24
;
803 prev
->hwCapEnable
|= MASK_StencilBufferEnable
;
804 prev
->hwCapEnable
|= MASK_ZWriteEnable
;
805 smesa
->depth_scale
= 1.0 / (GLfloat
)0xffffff;
809 prev
->hwZ
|= smesa
->zFormat
;
811 /* TODO: need to clear cache? */
812 smesa
->clearTexCache
= GL_TRUE
;
814 smesa
->clearColorPattern
= 0;
816 smesa
->AGPParseSet
= MASK_PsTexture1FromB
| MASK_PsBumpTextureFromC
;
817 smesa
->dwPrimitiveSet
= OP_3D_Texture1FromB
| OP_3D_TextureBumpFromC
;
819 sisUpdateZStencilPattern( smesa
, 1.0, 0 );
820 sisUpdateCull( ctx
);
822 memcpy( current
, prev
, sizeof (__GLSiSHardware
) );
824 /* Set initial fog settings. Start and end are the same case. */
825 sisDDFogfv( ctx
, GL_FOG_DENSITY
, &ctx
->Fog
.Density
);
826 sisDDFogfv( ctx
, GL_FOG_END
, &ctx
->Fog
.End
);
827 sisDDFogfv( ctx
, GL_FOG_COORDINATE_SOURCE_EXT
, NULL
);
828 sisDDFogfv( ctx
, GL_FOG_MODE
, NULL
);
831 /* Initialize the driver's state functions.
833 void sisDDInitStateFuncs( GLcontext
*ctx
)
835 ctx
->Driver
.UpdateState
= sisDDInvalidateState
;
837 ctx
->Driver
.Clear
= sisDDClear
;
838 ctx
->Driver
.ClearColor
= sisDDClearColor
;
839 ctx
->Driver
.ClearDepth
= sisDDClearDepth
;
840 ctx
->Driver
.ClearStencil
= sisDDClearStencil
;
842 ctx
->Driver
.AlphaFunc
= sisDDAlphaFunc
;
843 ctx
->Driver
.BlendFuncSeparate
= sisDDBlendFuncSeparate
;
844 ctx
->Driver
.ColorMask
= sisDDColorMask
;
845 ctx
->Driver
.CullFace
= sisDDCullFace
;
846 ctx
->Driver
.DepthMask
= sisDDDepthMask
;
847 ctx
->Driver
.DepthFunc
= sisDDDepthFunc
;
848 ctx
->Driver
.DepthRange
= sisDDDepthRange
;
849 ctx
->Driver
.DrawBuffer
= sisDDDrawBuffer
;
850 ctx
->Driver
.Enable
= sisDDEnable
;
851 ctx
->Driver
.FrontFace
= sisDDFrontFace
;
852 ctx
->Driver
.Fogfv
= sisDDFogfv
;
853 ctx
->Driver
.Hint
= NULL
;
854 ctx
->Driver
.Lightfv
= NULL
;
855 ctx
->Driver
.LogicOpcode
= sisDDLogicOpCode
;
856 ctx
->Driver
.PolygonMode
= NULL
;
857 ctx
->Driver
.PolygonStipple
= NULL
;
858 ctx
->Driver
.ReadBuffer
= NULL
;
859 ctx
->Driver
.RenderMode
= NULL
;
860 ctx
->Driver
.Scissor
= sisDDScissor
;
861 ctx
->Driver
.ShadeModel
= sisDDShadeModel
;
862 ctx
->Driver
.LightModelfv
= sisDDLightModelfv
;
863 ctx
->Driver
.Viewport
= sisDDViewport
;
865 /* XXX this should go away */
866 ctx
->Driver
.ResizeBuffers
= sisReAllocateBuffers
;