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 ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS 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"
44 #include "swrast/swrast.h"
45 #include "array_cache/acache.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 sisDDBlendFunc( GLcontext
*ctx
, GLenum sfactor
, GLenum dfactor
)
103 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
105 __GLSiSHardware
*prev
= &smesa
->prev
;
106 __GLSiSHardware
*current
= &smesa
->current
;
108 /* TODO: in ICD, if no blend, it will reset these value */
109 /* blending enable */
110 current
->hwDstSrcBlend
= 0x10000; /* Default destination alpha */
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_ALPHA
;
135 case GL_ONE_MINUS_DST_ALPHA
:
136 current
->hwDstSrcBlend
|= SiS_D_ONE_MINUS_DST_ALPHA
;
143 current
->hwDstSrcBlend
|= SiS_S_ZERO
;
146 current
->hwDstSrcBlend
|= SiS_S_ONE
;
149 current
->hwDstSrcBlend
|= SiS_S_SRC_ALPHA
;
151 case GL_ONE_MINUS_SRC_ALPHA
:
152 current
->hwDstSrcBlend
|= SiS_S_ONE_MINUS_SRC_ALPHA
;
155 current
->hwDstSrcBlend
|= SiS_S_DST_ALPHA
;
157 case GL_ONE_MINUS_DST_ALPHA
:
158 current
->hwDstSrcBlend
|= SiS_S_ONE_MINUS_DST_ALPHA
;
161 current
->hwDstSrcBlend
|= SiS_S_DST_COLOR
;
163 case GL_ONE_MINUS_DST_COLOR
:
164 current
->hwDstSrcBlend
|= SiS_S_ONE_MINUS_DST_COLOR
;
166 case GL_SRC_ALPHA_SATURATE
:
167 current
->hwDstSrcBlend
|= SiS_S_SRC_ALPHA_SATURATE
;
171 if (current
->hwDstSrcBlend
!= prev
->hwDstSrcBlend
) {
172 prev
->hwDstSrcBlend
= current
->hwDstSrcBlend
;
173 smesa
->GlobalFlag
|= GFLAG_DSTBLEND
;
177 /* =============================================================
182 sisDDDepthFunc( GLcontext
* ctx
, GLenum func
)
184 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
185 __GLSiSHardware
*prev
= &smesa
->prev
;
186 __GLSiSHardware
*current
= &smesa
->current
;
188 current
->hwZ
&= ~MASK_ZTestMode
;
192 current
->hwZ
|= SiS_Z_COMP_S_LT_B
;
195 current
->hwZ
|= SiS_Z_COMP_S_GE_B
;
198 current
->hwZ
|= SiS_Z_COMP_S_LE_B
;
201 current
->hwZ
|= SiS_Z_COMP_S_GT_B
;
204 current
->hwZ
|= SiS_Z_COMP_S_NE_B
;
207 current
->hwZ
|= SiS_Z_COMP_S_EQ_B
;
210 current
->hwZ
|= SiS_Z_COMP_ALWAYS
;
213 current
->hwZ
|= SiS_Z_COMP_NEVER
;
217 if (current
->hwZ
!= prev
->hwZ
) {
218 prev
->hwZ
= current
->hwZ
;
219 smesa
->GlobalFlag
|= GFLAG_ZSETTING
;
224 sisDDDepthMask( GLcontext
* ctx
, GLboolean flag
)
226 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
227 __GLSiSHardware
*prev
= &smesa
->prev
;
228 __GLSiSHardware
*current
= &smesa
->current
;
230 if (!ctx
->Depth
.Test
)
233 if (ctx
->Visual
.stencilBits
) {
234 if (flag
|| (ctx
->Stencil
.WriteMask
[0] != 0)) {
235 current
->hwCapEnable
|= MASK_ZWriteEnable
;
236 if (flag
&& (ctx
->Stencil
.WriteMask
[0] == 0xff)) {
237 current
->hwCapEnable2
&= ~MASK_ZMaskWriteEnable
;
239 current
->hwCapEnable2
|= MASK_ZMaskWriteEnable
;
240 current
->hwZMask
= (ctx
->Stencil
.WriteMask
[0] << 24) |
241 ((flag
) ? 0x00ffffff : 0);
243 if (current
->hwZMask
^ prev
->hwZMask
) {
244 prev
->hwZMask
= current
->hwZMask
;
245 smesa
->GlobalFlag
|= GFLAG_ZSETTING
;
249 current
->hwCapEnable
&= ~MASK_ZWriteEnable
;
253 current
->hwCapEnable
|= MASK_ZWriteEnable
;
254 current
->hwCapEnable2
&= ~MASK_ZMaskWriteEnable
;
256 current
->hwCapEnable
&= ~MASK_ZWriteEnable
;
261 /* =============================================================
266 sisUpdateClipping( GLcontext
*ctx
)
268 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
270 __GLSiSHardware
*prev
= &smesa
->prev
;
271 __GLSiSHardware
*current
= &smesa
->current
;
273 GLint x1
, y1
, x2
, y2
;
277 x2
= smesa
->width
- 1;
278 y2
= smesa
->height
- 1;
280 if (ctx
->Scissor
.Enabled
) {
281 if (ctx
->Scissor
.X
> x1
)
283 if (ctx
->Scissor
.Y
> y1
)
285 if (ctx
->Scissor
.X
+ ctx
->Scissor
.Width
- 1 < x2
)
286 x2
= ctx
->Scissor
.X
+ ctx
->Scissor
.Width
- 1;
287 if (ctx
->Scissor
.Y
+ ctx
->Scissor
.Height
- 1 < y2
)
288 y2
= ctx
->Scissor
.Y
+ ctx
->Scissor
.Height
- 1;
294 current
->clipTopBottom
= (y2
<< 13) | y1
;
295 current
->clipLeftRight
= (x1
<< 13) | x2
;
297 if ((current
->clipTopBottom
^ prev
->clipTopBottom
) ||
298 (current
->clipLeftRight
^ prev
->clipLeftRight
))
300 prev
->clipTopBottom
= current
->clipTopBottom
;
301 prev
->clipLeftRight
= current
->clipLeftRight
;
302 smesa
->GlobalFlag
|= GFLAG_CLIPPING
;
307 sisDDScissor( GLcontext
*ctx
, GLint x
, GLint y
, GLsizei w
, GLsizei h
)
309 if (ctx
->Scissor
.Enabled
)
310 sisUpdateClipping( ctx
);
313 /* =============================================================
318 sisUpdateCull( GLcontext
*ctx
)
320 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
321 GLint cullflag
, frontface
;
323 cullflag
= ctx
->Polygon
.CullFaceMode
;
324 frontface
= ctx
->Polygon
.FrontFace
;
326 smesa
->AGPParseSet
&= ~(MASK_PsCullDirection_CCW
);
327 smesa
->dwPrimitiveSet
&= ~(MASK_CullDirection
);
329 if((cullflag
== GL_FRONT
&& frontface
== GL_CCW
) ||
330 (cullflag
== GL_BACK
&& frontface
== GL_CW
))
332 smesa
->AGPParseSet
|= MASK_PsCullDirection_CCW
;
333 smesa
->dwPrimitiveSet
|= OP_3D_CullDirection_CCW
;
339 sisDDCullFace( GLcontext
*ctx
, GLenum mode
)
341 sisUpdateCull( ctx
);
345 sisDDFrontFace( GLcontext
*ctx
, GLenum mode
)
347 sisUpdateCull( ctx
);
350 /* =============================================================
354 static void sisDDColorMask( GLcontext
*ctx
,
355 GLboolean r
, GLboolean g
,
356 GLboolean b
, GLboolean a
)
358 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
359 __GLSiSHardware
*prev
= &smesa
->prev
;
360 __GLSiSHardware
*current
= &smesa
->current
;
362 if (r
&& g
&& b
&& ((ctx
->Visual
.alphaBits
== 0) || a
)) {
363 current
->hwCapEnable2
&= ~(MASK_AlphaMaskWriteEnable
|
364 MASK_ColorMaskWriteEnable
);
366 current
->hwCapEnable2
|= (MASK_AlphaMaskWriteEnable
|
367 MASK_ColorMaskWriteEnable
);
369 current
->hwDstMask
= (r
) ? GET_RMASK(smesa
) : 0 |
370 (g
) ? GET_GMASK(smesa
) : 0 |
371 (b
) ? GET_BMASK(smesa
) : 0 |
372 (a
) ? GET_AMASK(smesa
) : 0;
375 if (current
->hwDstMask
!= prev
->hwDstMask
) {
376 prev
->hwDstMask
= current
->hwDstMask
;
377 smesa
->GlobalFlag
|= GFLAG_DESTSETTING
;
381 /* =============================================================
382 * Rendering attributes
385 static void sisDDShadeModel( GLcontext
*ctx
, GLenum mode
)
387 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
389 /* Signal to sisRasterPrimitive to recalculate dwPrimitiveSet */
390 smesa
->hw_primitive
= -1;
393 /* =============================================================
397 /* =============================================================
401 static void sisCalcViewport( GLcontext
*ctx
)
403 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
404 const GLfloat
*v
= ctx
->Viewport
._WindowMap
.m
;
405 GLfloat
*m
= smesa
->hw_viewport
;
407 /* See also sis_translate_vertex.
409 m
[MAT_SX
] = v
[MAT_SX
];
410 m
[MAT_TX
] = v
[MAT_TX
] + SUBPIXEL_X
;
411 m
[MAT_SY
] = - v
[MAT_SY
];
412 m
[MAT_TY
] = - v
[MAT_TY
] + smesa
->driDrawable
->h
+ SUBPIXEL_Y
;
413 m
[MAT_SZ
] = v
[MAT_SZ
] * smesa
->depth_scale
;
414 m
[MAT_TZ
] = v
[MAT_TZ
] * smesa
->depth_scale
;
417 static void sisDDViewport( GLcontext
*ctx
,
419 GLsizei width
, GLsizei height
)
421 sisCalcViewport( ctx
);
424 static void sisDDDepthRange( GLcontext
*ctx
,
425 GLclampd nearval
, GLclampd farval
)
427 sisCalcViewport( ctx
);
430 /* =============================================================
435 sisDDLogicOpCode( GLcontext
*ctx
, GLenum opcode
)
437 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
439 __GLSiSHardware
*prev
= &smesa
->prev
;
440 __GLSiSHardware
*current
= &smesa
->current
;
442 if (!ctx
->Color
.ColorLogicOpEnabled
)
445 current
->hwDstSet
&= ~MASK_ROP2
;
449 current
->hwDstSet
|= LOP_CLEAR
;
452 current
->hwDstSet
|= LOP_SET
;
455 current
->hwDstSet
|= LOP_COPY
;
457 case GL_COPY_INVERTED
:
458 current
->hwDstSet
|= LOP_COPY_INVERTED
;
461 current
->hwDstSet
|= LOP_NOOP
;
464 current
->hwDstSet
|= LOP_INVERT
;
467 current
->hwDstSet
|= LOP_AND
;
470 current
->hwDstSet
|= LOP_NAND
;
473 current
->hwDstSet
|= LOP_OR
;
476 current
->hwDstSet
|= LOP_NOR
;
479 current
->hwDstSet
|= LOP_XOR
;
482 current
->hwDstSet
|= LOP_EQUIV
;
485 current
->hwDstSet
|= LOP_AND_REVERSE
;
487 case GL_AND_INVERTED
:
488 current
->hwDstSet
|= LOP_AND_INVERTED
;
491 current
->hwDstSet
|= LOP_OR_REVERSE
;
494 current
->hwDstSet
|= LOP_OR_INVERTED
;
498 if (current
->hwDstSet
^ prev
->hwDstSet
) {
499 prev
->hwDstSet
= current
->hwDstSet
;
500 smesa
->GlobalFlag
|= GFLAG_DESTSETTING
;
504 void sisDDDrawBuffer( GLcontext
*ctx
, GLenum mode
)
506 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
508 __GLSiSHardware
*prev
= &smesa
->prev
;
509 __GLSiSHardware
*current
= &smesa
->current
;
512 * _DrawDestMask is easier to cope with than <mode>.
514 switch ( ctx
->Color
._DrawDestMask
) {
517 FALLBACK( smesa
, SIS_FALLBACK_DRAW_BUFFER
, GL_FALSE
);
520 /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
521 FALLBACK( smesa
, SIS_FALLBACK_DRAW_BUFFER
, GL_TRUE
);
525 /* We want to update the s/w rast state too so that sisDDSetBuffer()
528 _swrast_DrawBuffer(ctx
, mode
);
530 current
->hwOffsetDest
= (smesa
->drawOffset
) >> 1;
531 current
->hwDstSet
&= ~MASK_DstBufferPitch
;
532 current
->hwDstSet
|= smesa
->drawPitch
>> 2;
534 if (current
->hwDstSet
!= prev
->hwDstSet
) {
535 prev
->hwDstSet
= current
->hwDstSet
;
536 smesa
->GlobalFlag
|= GFLAG_DESTSETTING
;
539 if (current
->hwOffsetDest
!= prev
->hwOffsetDest
) {
540 prev
->hwOffsetDest
= current
->hwOffsetDest
;
541 smesa
->GlobalFlag
|= GFLAG_DESTSETTING
;
546 sisDDHint( GLcontext
*ctx
, GLenum target
, GLenum mode
)
551 /* Update fog mode setting */
552 sisDDFogfv(ctx
, GL_FOG_MODE
, NULL
);
558 /* =============================================================
562 /* =============================================================
566 /* =============================================================
567 * State enable/disable
571 sisDDEnable( GLcontext
* ctx
, GLenum cap
, GLboolean state
)
573 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
575 __GLSiSHardware
*current
= &smesa
->current
;
581 current
->hwCapEnable
|= MASK_AlphaTestEnable
;
583 current
->hwCapEnable
&= ~MASK_AlphaTestEnable
;
588 /* if (state & !ctx->Color.ColorLogicOpEnabled) */
589 current
->hwCapEnable
|= MASK_BlendEnable
;
591 current
->hwCapEnable
&= ~MASK_BlendEnable
;
595 current
->hwCapEnable
|= MASK_CullEnable
;
597 current
->hwCapEnable
&= ~MASK_CullEnable
;
600 if (state
&& smesa
->depthbuffer
)
601 current
->hwCapEnable
|= MASK_ZTestEnable
;
603 current
->hwCapEnable
&= ~MASK_ZTestEnable
;
604 sisDDDepthMask( ctx
, ctx
->Depth
.Mask
);
608 current
->hwCapEnable
|= MASK_DitherEnable
;
610 current
->hwCapEnable
&= ~MASK_DitherEnable
;
614 current
->hwCapEnable
|= MASK_FogEnable
;
616 current
->hwCapEnable
&= ~MASK_FogEnable
;
618 case GL_COLOR_LOGIC_OP
:
620 sisDDLogicOpCode( ctx
, ctx
->Color
.LogicOp
);
622 sisDDLogicOpCode( ctx
, GL_COPY
);
624 case GL_SCISSOR_TEST
:
625 sisUpdateClipping( ctx
);
627 case GL_STENCIL_TEST
:
629 if (smesa
->zFormat
!= SiS_ZFORMAT_S8Z24
)
630 FALLBACK(smesa
, SIS_FALLBACK_STENCIL
, 1);
632 current
->hwCapEnable
|= (MASK_StencilTestEnable
|
633 MASK_StencilWriteEnable
);
635 FALLBACK(smesa
, SIS_FALLBACK_STENCIL
, 0);
636 current
->hwCapEnable
&= ~(MASK_StencilTestEnable
|
637 MASK_StencilWriteEnable
);
643 /* =============================================================
648 sisDDDrawPixels( GLcontext
*ctx
,
649 GLint x
, GLint y
, GLsizei width
, GLsizei height
,
650 GLenum format
, GLenum type
,
651 const struct gl_pixelstore_attrib
*unpack
,
652 const GLvoid
*pixels
)
654 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
657 _swrast_DrawPixels( ctx
, x
, y
, width
, height
, format
, type
, unpack
, pixels
);
662 sisDDReadPixels( GLcontext
*ctx
,
663 GLint x
, GLint y
, GLsizei width
, GLsizei height
,
664 GLenum format
, GLenum type
,
665 const struct gl_pixelstore_attrib
*pack
,
668 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
671 _swrast_ReadPixels( ctx
, x
, y
, width
, height
, format
, type
, pack
,
677 sisDDBitmap( GLcontext
*ctx
, GLint px
, GLint py
,
678 GLsizei width
, GLsizei height
,
679 const struct gl_pixelstore_attrib
*unpack
,
680 const GLubyte
*bitmap
)
682 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
685 _swrast_Bitmap( ctx
, px
, py
, width
, height
, unpack
, bitmap
);
689 /* =============================================================
690 * State initialization, management
693 /* Called before beginning of rendering. */
695 sisUpdateHWState( GLcontext
*ctx
)
697 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
698 __GLSiSHardware
*prev
= &smesa
->prev
;
699 __GLSiSHardware
*current
= &smesa
->current
;
701 if (smesa
->NewGLState
& _NEW_TEXTURE
)
702 sisUpdateTextureState( ctx
);
704 /* enable setting 1 */
705 if (current
->hwCapEnable
^ prev
->hwCapEnable
) {
706 prev
->hwCapEnable
= current
->hwCapEnable
;
707 smesa
->GlobalFlag
|= GFLAG_ENABLESETTING
;
710 /* enable setting 2 */
711 if (current
->hwCapEnable2
^ prev
->hwCapEnable2
) {
712 prev
->hwCapEnable2
= current
->hwCapEnable2
;
713 smesa
->GlobalFlag
|= GFLAG_ENABLESETTING2
;
716 /* TODO: if fog disable, don't check */
717 if (current
->hwCapEnable
& MASK_FogEnable
) {
719 if (current
->hwFog
!= prev
->hwFog
) {
720 prev
->hwFog
= current
->hwFog
;
721 smesa
->GlobalFlag
|= GFLAG_FOGSETTING
;
723 if (current
->hwFogFar
!= prev
->hwFogFar
) {
724 prev
->hwFogFar
= current
->hwFogFar
;
725 smesa
->GlobalFlag
|= GFLAG_FOGSETTING
;
727 if (current
->hwFogInverse
!= prev
->hwFogInverse
) {
728 prev
->hwFogInverse
= current
->hwFogInverse
;
729 smesa
->GlobalFlag
|= GFLAG_FOGSETTING
;
731 if (current
->hwFogDensity
!= prev
->hwFogDensity
) {
732 prev
->hwFogDensity
= current
->hwFogDensity
;
733 smesa
->GlobalFlag
|= GFLAG_FOGSETTING
;
737 if (smesa
->GlobalFlag
& GFLAG_RENDER_STATES
)
738 sis_update_render_state( smesa
);
740 if (smesa
->GlobalFlag
& GFLAG_TEXTURE_STATES
)
741 sis_update_texture_state( smesa
);
745 sisDDInvalidateState( GLcontext
*ctx
, GLuint new_state
)
747 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
749 _swrast_InvalidateState( ctx
, new_state
);
750 _swsetup_InvalidateState( ctx
, new_state
);
751 _ac_InvalidateState( ctx
, new_state
);
752 _tnl_InvalidateState( ctx
, new_state
);
753 smesa
->NewGLState
|= new_state
;
756 /* Initialize the context's hardware state.
758 void sisDDInitState( sisContextPtr smesa
)
760 __GLSiSHardware
*current
= &smesa
->current
;
761 __GLSiSHardware
*prev
= &(smesa
->prev
);
762 GLcontext
*ctx
= smesa
->glCtx
;
764 /* add Texture Perspective Enable */
765 prev
->hwCapEnable
= MASK_FogPerspectiveEnable
| MASK_TextureCacheEnable
|
766 MASK_TexturePerspectiveEnable
| MASK_DitherEnable
;
767 /*| MASK_SpecularEnable*/
770 prev->hwCapEnable2 = 0x00aa0080;
772 /* if multi-texture enabled, disable Z pre-test */
773 prev
->hwCapEnable2
= MASK_TextureMipmapBiasEnable
;
775 /* Z test mode is LESS */
776 prev
->hwZ
= SiS_Z_COMP_S_LT_B
;
779 prev
->hwZMask
= 0xffffffff;
781 /* Alpha test mode is ALWAYS, alpha ref value is 0 */
782 prev
->hwAlpha
= SiS_ALPHA_ALWAYS
;
784 /* ROP2 is COPYPEN */
785 prev
->hwDstSet
= LOP_COPY
;
788 prev
->hwDstMask
= 0xffffffff;
790 /* LinePattern is 0, Repeat Factor is 0 */
791 prev
->hwLinePattern
= 0x00008000;
793 /* Src blend is BLEND_ONE, Dst blend is D3DBLEND_ZERO */
794 prev
->hwDstSrcBlend
= SiS_S_ONE
| SiS_D_ZERO
;
796 /* Stenciling disabled, function ALWAYS, ref value zero, mask all ones */
797 prev
->hwStSetting
= STENCIL_FORMAT_8
| SiS_STENCIL_ALWAYS
| 0xff;
798 /* Op is KEEP for all three operations */
799 prev
->hwStSetting2
= SiS_SFAIL_KEEP
| SiS_SPASS_ZFAIL_KEEP
|
800 SiS_SPASS_ZPASS_KEEP
;
802 /* Texture mapping mode is Tile */
804 prev
->texture
[0].hwTextureSet
= 0x00030000;
806 /* Magnified & minified texture filter is NEAREST */
808 prev
->texture
[0].hwTextureMip
= 0;
811 /* Texture Blending seeting */
812 prev
->hwTexBlendClr0
= L_REPLACE__RGB_STAGE0
;
813 prev
->hwTexBlendClr1
= 0x294B4000;
814 prev
->hwTexBlendAlpha0
= 0x333A0000;
815 prev
->hwTexBlendAlpha1
= 0x333A0000;
817 switch (smesa
->bytesPerPixel
)
820 prev
->hwDstSet
|= DST_FORMAT_RGB_565
;
823 prev
->hwDstSet
|= DST_FORMAT_ARGB_8888
;
827 switch (ctx
->Visual
.depthBits
)
830 prev
->hwCapEnable
&= ~MASK_ZWriteEnable
;
832 smesa
->zFormat
= SiS_ZFORMAT_Z16
;
833 prev
->hwCapEnable
|= MASK_ZWriteEnable
;
834 smesa
->depth_scale
= 1.0 / (GLfloat
)0xffff;
837 smesa
->zFormat
= SiS_ZFORMAT_Z32
;
838 prev
->hwCapEnable
|= MASK_ZWriteEnable
;
839 smesa
->depth_scale
= 1.0 / (GLfloat
)0xffffffff;
842 assert (ctx
->Visual
.stencilBits
);
843 smesa
->zFormat
= SiS_ZFORMAT_S8Z24
;
844 prev
->hwCapEnable
|= MASK_StencilBufferEnable
;
845 prev
->hwCapEnable
|= MASK_ZWriteEnable
;
846 smesa
->depth_scale
= 1.0 / (GLfloat
)0xffffff;
850 prev
->hwZ
|= smesa
->zFormat
;
852 /* TODO: need to clear cache? */
853 smesa
->clearTexCache
= GL_TRUE
;
855 smesa
->clearColorPattern
= 0;
857 smesa
->AGPParseSet
= MASK_PsTexture1FromB
;
858 smesa
->dwPrimitiveSet
= OP_3D_Texture1FromB
| OP_3D_TextureBumpFromC
;
860 sisUpdateZStencilPattern( smesa
, 1.0, 0 );
861 sisUpdateCull( ctx
);
863 memcpy( current
, prev
, sizeof (__GLSiSHardware
) );
865 /* Set initial fog settings. Start and end are the same case. */
866 sisDDFogfv( ctx
, GL_FOG_DENSITY
, &ctx
->Fog
.Density
);
867 sisDDFogfv( ctx
, GL_FOG_END
, &ctx
->Fog
.End
);
868 sisDDFogfv( ctx
, GL_FOG_MODE
, NULL
);
871 /* Initialize the driver's state functions.
873 void sisDDInitStateFuncs( GLcontext
*ctx
)
875 ctx
->Driver
.UpdateState
= sisDDInvalidateState
;
877 ctx
->Driver
.Clear
= sisDDClear
;
878 ctx
->Driver
.ClearColor
= sisDDClearColor
;
879 ctx
->Driver
.ClearDepth
= sisDDClearDepth
;
880 ctx
->Driver
.ClearStencil
= sisDDClearStencil
;
882 ctx
->Driver
.AlphaFunc
= sisDDAlphaFunc
;
883 ctx
->Driver
.Bitmap
= sisDDBitmap
;
884 ctx
->Driver
.BlendFunc
= sisDDBlendFunc
;
885 ctx
->Driver
.ColorMask
= sisDDColorMask
;
886 ctx
->Driver
.CullFace
= sisDDCullFace
;
887 ctx
->Driver
.DepthMask
= sisDDDepthMask
;
888 ctx
->Driver
.DepthFunc
= sisDDDepthFunc
;
889 ctx
->Driver
.DepthRange
= sisDDDepthRange
;
890 ctx
->Driver
.DrawBuffer
= sisDDDrawBuffer
;
891 ctx
->Driver
.DrawPixels
= sisDDDrawPixels
;
892 ctx
->Driver
.Enable
= sisDDEnable
;
893 ctx
->Driver
.FrontFace
= sisDDFrontFace
;
894 ctx
->Driver
.Fogfv
= sisDDFogfv
;
895 ctx
->Driver
.Hint
= sisDDHint
;
896 ctx
->Driver
.Lightfv
= NULL
;
897 ctx
->Driver
.LogicOpcode
= sisDDLogicOpCode
;
898 ctx
->Driver
.PolygonMode
= NULL
;
899 ctx
->Driver
.PolygonStipple
= NULL
;
900 ctx
->Driver
.ReadBuffer
= NULL
;
901 ctx
->Driver
.ReadPixels
= sisDDReadPixels
;
902 ctx
->Driver
.RenderMode
= NULL
;
903 ctx
->Driver
.Scissor
= sisDDScissor
;
904 ctx
->Driver
.ShadeModel
= sisDDShadeModel
;
905 ctx
->Driver
.Viewport
= sisDDViewport
;
907 /* Pixel path fallbacks.
909 ctx
->Driver
.Accum
= _swrast_Accum
;
910 ctx
->Driver
.CopyPixels
= _swrast_CopyPixels
;
912 /* Swrast hooks for imaging extensions:
914 ctx
->Driver
.CopyColorTable
= _swrast_CopyColorTable
;
915 ctx
->Driver
.CopyColorSubTable
= _swrast_CopyColorSubTable
;
916 ctx
->Driver
.CopyConvolutionFilter1D
= _swrast_CopyConvolutionFilter1D
;
917 ctx
->Driver
.CopyConvolutionFilter2D
= _swrast_CopyConvolutionFilter2D
;