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"
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 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 /* TODO: in ICD, if no blend, it will reset these value */
111 /* blending enable */
112 current
->hwDstSrcBlend
= 0x10000; /* Default destination alpha */
117 current
->hwDstSrcBlend
|= SiS_D_ZERO
;
120 current
->hwDstSrcBlend
|= SiS_D_ONE
;
123 current
->hwDstSrcBlend
|= SiS_D_SRC_COLOR
;
125 case GL_ONE_MINUS_SRC_COLOR
:
126 current
->hwDstSrcBlend
|= SiS_D_ONE_MINUS_SRC_COLOR
;
129 current
->hwDstSrcBlend
|= SiS_D_SRC_ALPHA
;
131 case GL_ONE_MINUS_SRC_ALPHA
:
132 current
->hwDstSrcBlend
|= SiS_D_ONE_MINUS_SRC_ALPHA
;
135 current
->hwDstSrcBlend
|= SiS_D_DST_ALPHA
;
137 case GL_ONE_MINUS_DST_ALPHA
:
138 current
->hwDstSrcBlend
|= SiS_D_ONE_MINUS_DST_ALPHA
;
145 current
->hwDstSrcBlend
|= SiS_S_ZERO
;
148 current
->hwDstSrcBlend
|= SiS_S_ONE
;
151 current
->hwDstSrcBlend
|= SiS_S_SRC_ALPHA
;
153 case GL_ONE_MINUS_SRC_ALPHA
:
154 current
->hwDstSrcBlend
|= SiS_S_ONE_MINUS_SRC_ALPHA
;
157 current
->hwDstSrcBlend
|= SiS_S_DST_ALPHA
;
159 case GL_ONE_MINUS_DST_ALPHA
:
160 current
->hwDstSrcBlend
|= SiS_S_ONE_MINUS_DST_ALPHA
;
163 current
->hwDstSrcBlend
|= SiS_S_DST_COLOR
;
165 case GL_ONE_MINUS_DST_COLOR
:
166 current
->hwDstSrcBlend
|= SiS_S_ONE_MINUS_DST_COLOR
;
168 case GL_SRC_ALPHA_SATURATE
:
169 current
->hwDstSrcBlend
|= SiS_S_SRC_ALPHA_SATURATE
;
173 if (current
->hwDstSrcBlend
!= prev
->hwDstSrcBlend
) {
174 prev
->hwDstSrcBlend
= current
->hwDstSrcBlend
;
175 smesa
->GlobalFlag
|= GFLAG_DSTBLEND
;
179 /* =============================================================
184 sisDDDepthFunc( GLcontext
* ctx
, GLenum func
)
186 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
187 __GLSiSHardware
*prev
= &smesa
->prev
;
188 __GLSiSHardware
*current
= &smesa
->current
;
190 current
->hwZ
&= ~MASK_ZTestMode
;
194 current
->hwZ
|= SiS_Z_COMP_S_LT_B
;
197 current
->hwZ
|= SiS_Z_COMP_S_GE_B
;
200 current
->hwZ
|= SiS_Z_COMP_S_LE_B
;
203 current
->hwZ
|= SiS_Z_COMP_S_GT_B
;
206 current
->hwZ
|= SiS_Z_COMP_S_NE_B
;
209 current
->hwZ
|= SiS_Z_COMP_S_EQ_B
;
212 current
->hwZ
|= SiS_Z_COMP_ALWAYS
;
215 current
->hwZ
|= SiS_Z_COMP_NEVER
;
219 if (current
->hwZ
!= prev
->hwZ
) {
220 prev
->hwZ
= current
->hwZ
;
221 smesa
->GlobalFlag
|= GFLAG_ZSETTING
;
226 sisDDDepthMask( GLcontext
* ctx
, GLboolean flag
)
228 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
229 __GLSiSHardware
*prev
= &smesa
->prev
;
230 __GLSiSHardware
*current
= &smesa
->current
;
232 if (!ctx
->Depth
.Test
)
235 if (ctx
->Visual
.stencilBits
) {
236 if (flag
|| (ctx
->Stencil
.WriteMask
[0] != 0)) {
237 current
->hwCapEnable
|= MASK_ZWriteEnable
;
238 if (flag
&& (ctx
->Stencil
.WriteMask
[0] == 0xff)) {
239 current
->hwCapEnable2
&= ~MASK_ZMaskWriteEnable
;
241 current
->hwCapEnable2
|= MASK_ZMaskWriteEnable
;
242 current
->hwZMask
= (ctx
->Stencil
.WriteMask
[0] << 24) |
243 ((flag
) ? 0x00ffffff : 0);
245 if (current
->hwZMask
^ prev
->hwZMask
) {
246 prev
->hwZMask
= current
->hwZMask
;
247 smesa
->GlobalFlag
|= GFLAG_ZSETTING
;
251 current
->hwCapEnable
&= ~MASK_ZWriteEnable
;
255 current
->hwCapEnable
|= MASK_ZWriteEnable
;
256 current
->hwCapEnable2
&= ~MASK_ZMaskWriteEnable
;
258 current
->hwCapEnable
&= ~MASK_ZWriteEnable
;
263 /* =============================================================
268 sisUpdateClipping( GLcontext
*ctx
)
270 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
272 __GLSiSHardware
*prev
= &smesa
->prev
;
273 __GLSiSHardware
*current
= &smesa
->current
;
275 GLint x1
, y1
, x2
, y2
;
279 x2
= smesa
->width
- 1;
280 y2
= smesa
->height
- 1;
282 if (ctx
->Scissor
.Enabled
) {
283 if (ctx
->Scissor
.X
> x1
)
285 if (ctx
->Scissor
.Y
> y1
)
287 if (ctx
->Scissor
.X
+ ctx
->Scissor
.Width
- 1 < x2
)
288 x2
= ctx
->Scissor
.X
+ ctx
->Scissor
.Width
- 1;
289 if (ctx
->Scissor
.Y
+ ctx
->Scissor
.Height
- 1 < y2
)
290 y2
= ctx
->Scissor
.Y
+ ctx
->Scissor
.Height
- 1;
296 current
->clipTopBottom
= (y2
<< 13) | y1
;
297 current
->clipLeftRight
= (x1
<< 13) | x2
;
299 if ((current
->clipTopBottom
^ prev
->clipTopBottom
) ||
300 (current
->clipLeftRight
^ prev
->clipLeftRight
))
302 prev
->clipTopBottom
= current
->clipTopBottom
;
303 prev
->clipLeftRight
= current
->clipLeftRight
;
304 smesa
->GlobalFlag
|= GFLAG_CLIPPING
;
309 sisDDScissor( GLcontext
*ctx
, GLint x
, GLint y
, GLsizei w
, GLsizei h
)
311 if (ctx
->Scissor
.Enabled
)
312 sisUpdateClipping( ctx
);
315 /* =============================================================
320 sisUpdateCull( GLcontext
*ctx
)
322 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
323 GLint cullflag
, frontface
;
325 cullflag
= ctx
->Polygon
.CullFaceMode
;
326 frontface
= ctx
->Polygon
.FrontFace
;
328 smesa
->AGPParseSet
&= ~(MASK_PsCullDirection_CCW
);
329 smesa
->dwPrimitiveSet
&= ~(MASK_CullDirection
);
331 if((cullflag
== GL_FRONT
&& frontface
== GL_CCW
) ||
332 (cullflag
== GL_BACK
&& frontface
== GL_CW
))
334 smesa
->AGPParseSet
|= MASK_PsCullDirection_CCW
;
335 smesa
->dwPrimitiveSet
|= OP_3D_CullDirection_CCW
;
341 sisDDCullFace( GLcontext
*ctx
, GLenum mode
)
343 sisUpdateCull( ctx
);
347 sisDDFrontFace( GLcontext
*ctx
, GLenum mode
)
349 sisUpdateCull( ctx
);
352 /* =============================================================
356 static void sisDDColorMask( GLcontext
*ctx
,
357 GLboolean r
, GLboolean g
,
358 GLboolean b
, GLboolean a
)
360 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
361 __GLSiSHardware
*prev
= &smesa
->prev
;
362 __GLSiSHardware
*current
= &smesa
->current
;
364 if (r
&& g
&& b
&& ((ctx
->Visual
.alphaBits
== 0) || a
)) {
365 current
->hwCapEnable2
&= ~(MASK_AlphaMaskWriteEnable
|
366 MASK_ColorMaskWriteEnable
);
368 current
->hwCapEnable2
|= (MASK_AlphaMaskWriteEnable
|
369 MASK_ColorMaskWriteEnable
);
371 current
->hwDstMask
= (r
) ? smesa
->redMask
: 0 |
372 (g
) ? smesa
->greenMask
: 0 |
373 (b
) ? smesa
->blueMask
: 0 |
374 (a
) ? smesa
->alphaMask
: 0;
377 if (current
->hwDstMask
!= prev
->hwDstMask
) {
378 prev
->hwDstMask
= current
->hwDstMask
;
379 smesa
->GlobalFlag
|= GFLAG_DESTSETTING
;
383 /* =============================================================
384 * Rendering attributes
387 static void sisDDShadeModel( GLcontext
*ctx
, GLenum mode
)
389 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
391 /* Signal to sisRasterPrimitive to recalculate dwPrimitiveSet */
392 smesa
->hw_primitive
= -1;
395 /* =============================================================
399 /* =============================================================
403 static void sisCalcViewport( GLcontext
*ctx
)
405 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
406 const GLfloat
*v
= ctx
->Viewport
._WindowMap
.m
;
407 GLfloat
*m
= smesa
->hw_viewport
;
409 /* See also sis_translate_vertex.
411 m
[MAT_SX
] = v
[MAT_SX
];
412 m
[MAT_TX
] = v
[MAT_TX
] + SUBPIXEL_X
;
413 m
[MAT_SY
] = - v
[MAT_SY
];
414 m
[MAT_TY
] = - v
[MAT_TY
] + smesa
->driDrawable
->h
+ SUBPIXEL_Y
;
415 m
[MAT_SZ
] = v
[MAT_SZ
] * smesa
->depth_scale
;
416 m
[MAT_TZ
] = v
[MAT_TZ
] * smesa
->depth_scale
;
419 static void sisDDViewport( GLcontext
*ctx
,
421 GLsizei width
, GLsizei height
)
423 sisCalcViewport( ctx
);
426 static void sisDDDepthRange( GLcontext
*ctx
,
427 GLclampd nearval
, GLclampd farval
)
429 sisCalcViewport( ctx
);
432 /* =============================================================
437 sisDDLogicOpCode( GLcontext
*ctx
, GLenum opcode
)
439 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
441 __GLSiSHardware
*prev
= &smesa
->prev
;
442 __GLSiSHardware
*current
= &smesa
->current
;
444 if (!ctx
->Color
.ColorLogicOpEnabled
)
447 current
->hwDstSet
&= ~MASK_ROP2
;
451 current
->hwDstSet
|= LOP_CLEAR
;
454 current
->hwDstSet
|= LOP_SET
;
457 current
->hwDstSet
|= LOP_COPY
;
459 case GL_COPY_INVERTED
:
460 current
->hwDstSet
|= LOP_COPY_INVERTED
;
463 current
->hwDstSet
|= LOP_NOOP
;
466 current
->hwDstSet
|= LOP_INVERT
;
469 current
->hwDstSet
|= LOP_AND
;
472 current
->hwDstSet
|= LOP_NAND
;
475 current
->hwDstSet
|= LOP_OR
;
478 current
->hwDstSet
|= LOP_NOR
;
481 current
->hwDstSet
|= LOP_XOR
;
484 current
->hwDstSet
|= LOP_EQUIV
;
487 current
->hwDstSet
|= LOP_AND_REVERSE
;
489 case GL_AND_INVERTED
:
490 current
->hwDstSet
|= LOP_AND_INVERTED
;
493 current
->hwDstSet
|= LOP_OR_REVERSE
;
496 current
->hwDstSet
|= LOP_OR_INVERTED
;
500 if (current
->hwDstSet
^ prev
->hwDstSet
) {
501 prev
->hwDstSet
= current
->hwDstSet
;
502 smesa
->GlobalFlag
|= GFLAG_DESTSETTING
;
506 void sisDDDrawBuffer( GLcontext
*ctx
, GLenum mode
)
508 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
510 __GLSiSHardware
*prev
= &smesa
->prev
;
511 __GLSiSHardware
*current
= &smesa
->current
;
514 * _DrawDestMask is easier to cope with than <mode>.
516 switch ( ctx
->Color
._DrawDestMask
) {
519 FALLBACK( smesa
, SIS_FALLBACK_DRAW_BUFFER
, GL_FALSE
);
522 /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
523 FALLBACK( smesa
, SIS_FALLBACK_DRAW_BUFFER
, GL_TRUE
);
527 /* We want to update the s/w rast state too so that sisDDSetBuffer()
530 _swrast_DrawBuffer(ctx
, mode
);
532 current
->hwOffsetDest
= (smesa
->drawOffset
) >> 1;
533 current
->hwDstSet
&= ~MASK_DstBufferPitch
;
534 current
->hwDstSet
|= smesa
->drawPitch
>> 2;
536 if (current
->hwDstSet
!= prev
->hwDstSet
) {
537 prev
->hwDstSet
= current
->hwDstSet
;
538 smesa
->GlobalFlag
|= GFLAG_DESTSETTING
;
541 if (current
->hwOffsetDest
!= prev
->hwOffsetDest
) {
542 prev
->hwOffsetDest
= current
->hwOffsetDest
;
543 smesa
->GlobalFlag
|= GFLAG_DESTSETTING
;
547 /* =============================================================
551 /* =============================================================
555 /* =============================================================
556 * State enable/disable
560 sisDDEnable( GLcontext
* ctx
, GLenum cap
, GLboolean state
)
562 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
564 __GLSiSHardware
*current
= &smesa
->current
;
570 current
->hwCapEnable
|= MASK_AlphaTestEnable
;
572 current
->hwCapEnable
&= ~MASK_AlphaTestEnable
;
577 /* if (state & !ctx->Color.ColorLogicOpEnabled) */
578 current
->hwCapEnable
|= MASK_BlendEnable
;
580 current
->hwCapEnable
&= ~MASK_BlendEnable
;
584 current
->hwCapEnable
|= MASK_CullEnable
;
586 current
->hwCapEnable
&= ~MASK_CullEnable
;
589 if (state
&& smesa
->depthbuffer
)
590 current
->hwCapEnable
|= MASK_ZTestEnable
;
592 current
->hwCapEnable
&= ~MASK_ZTestEnable
;
593 sisDDDepthMask( ctx
, ctx
->Depth
.Mask
);
597 current
->hwCapEnable
|= MASK_DitherEnable
;
599 current
->hwCapEnable
&= ~MASK_DitherEnable
;
603 current
->hwCapEnable
|= MASK_FogEnable
;
605 current
->hwCapEnable
&= ~MASK_FogEnable
;
607 case GL_COLOR_LOGIC_OP
:
609 sisDDLogicOpCode( ctx
, ctx
->Color
.LogicOp
);
611 sisDDLogicOpCode( ctx
, GL_COPY
);
613 case GL_SCISSOR_TEST
:
614 sisUpdateClipping( ctx
);
616 case GL_STENCIL_TEST
:
618 if (smesa
->zFormat
!= SiS_ZFORMAT_S8Z24
)
619 FALLBACK(smesa
, SIS_FALLBACK_STENCIL
, 1);
621 current
->hwCapEnable
|= (MASK_StencilTestEnable
|
622 MASK_StencilWriteEnable
);
624 FALLBACK(smesa
, SIS_FALLBACK_STENCIL
, 0);
625 current
->hwCapEnable
&= ~(MASK_StencilTestEnable
|
626 MASK_StencilWriteEnable
);
632 /* =============================================================
637 sisDDDrawPixels( GLcontext
*ctx
,
638 GLint x
, GLint y
, GLsizei width
, GLsizei height
,
639 GLenum format
, GLenum type
,
640 const struct gl_pixelstore_attrib
*unpack
,
641 const GLvoid
*pixels
)
643 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
646 _swrast_DrawPixels( ctx
, x
, y
, width
, height
, format
, type
, unpack
, pixels
);
651 sisDDReadPixels( GLcontext
*ctx
,
652 GLint x
, GLint y
, GLsizei width
, GLsizei height
,
653 GLenum format
, GLenum type
,
654 const struct gl_pixelstore_attrib
*pack
,
657 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
660 _swrast_ReadPixels( ctx
, x
, y
, width
, height
, format
, type
, pack
,
666 sisDDBitmap( GLcontext
*ctx
, GLint px
, GLint py
,
667 GLsizei width
, GLsizei height
,
668 const struct gl_pixelstore_attrib
*unpack
,
669 const GLubyte
*bitmap
)
671 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
674 _swrast_Bitmap( ctx
, px
, py
, width
, height
, unpack
, bitmap
);
678 /* =============================================================
679 * State initialization, management
682 /* Called before beginning of rendering. */
684 sisUpdateHWState( GLcontext
*ctx
)
686 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
687 __GLSiSHardware
*prev
= &smesa
->prev
;
688 __GLSiSHardware
*current
= &smesa
->current
;
690 if (smesa
->NewGLState
& _NEW_TEXTURE
)
691 sisUpdateTextureState( ctx
);
693 /* enable setting 1 */
694 if (current
->hwCapEnable
^ prev
->hwCapEnable
) {
695 prev
->hwCapEnable
= current
->hwCapEnable
;
696 smesa
->GlobalFlag
|= GFLAG_ENABLESETTING
;
699 /* enable setting 2 */
700 if (current
->hwCapEnable2
^ prev
->hwCapEnable2
) {
701 prev
->hwCapEnable2
= current
->hwCapEnable2
;
702 smesa
->GlobalFlag
|= GFLAG_ENABLESETTING2
;
705 if (smesa
->GlobalFlag
& GFLAG_RENDER_STATES
)
706 sis_update_render_state( smesa
);
708 if (smesa
->GlobalFlag
& GFLAG_TEXTURE_STATES
)
709 sis_update_texture_state( smesa
);
713 sisDDInvalidateState( GLcontext
*ctx
, GLuint new_state
)
715 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
717 _swrast_InvalidateState( ctx
, new_state
);
718 _swsetup_InvalidateState( ctx
, new_state
);
719 _ac_InvalidateState( ctx
, new_state
);
720 _tnl_InvalidateState( ctx
, new_state
);
721 smesa
->NewGLState
|= new_state
;
724 /* Initialize the context's hardware state.
726 void sisDDInitState( sisContextPtr smesa
)
728 __GLSiSHardware
*current
= &smesa
->current
;
729 __GLSiSHardware
*prev
= &(smesa
->prev
);
730 GLcontext
*ctx
= smesa
->glCtx
;
732 /* add Texture Perspective Enable */
733 prev
->hwCapEnable
= MASK_FogPerspectiveEnable
| MASK_TextureCacheEnable
|
734 MASK_TexturePerspectiveEnable
| MASK_DitherEnable
;
735 /*| MASK_SpecularEnable*/
738 prev->hwCapEnable2 = 0x00aa0080;
740 /* if multi-texture enabled, disable Z pre-test */
741 prev
->hwCapEnable2
= MASK_TextureMipmapBiasEnable
;
743 /* Z test mode is LESS */
744 prev
->hwZ
= SiS_Z_COMP_S_LT_B
;
747 prev
->hwZMask
= 0xffffffff;
749 /* Alpha test mode is ALWAYS, alpha ref value is 0 */
750 prev
->hwAlpha
= SiS_ALPHA_ALWAYS
;
752 /* ROP2 is COPYPEN */
753 prev
->hwDstSet
= LOP_COPY
;
756 prev
->hwDstMask
= 0xffffffff;
758 /* LinePattern is 0, Repeat Factor is 0 */
759 prev
->hwLinePattern
= 0x00008000;
761 /* Src blend is BLEND_ONE, Dst blend is D3DBLEND_ZERO */
762 prev
->hwDstSrcBlend
= SiS_S_ONE
| SiS_D_ZERO
;
764 /* Stenciling disabled, function ALWAYS, ref value zero, mask all ones */
765 prev
->hwStSetting
= STENCIL_FORMAT_8
| SiS_STENCIL_ALWAYS
| 0xff;
766 /* Op is KEEP for all three operations */
767 prev
->hwStSetting2
= SiS_SFAIL_KEEP
| SiS_SPASS_ZFAIL_KEEP
|
768 SiS_SPASS_ZPASS_KEEP
;
770 /* Texture mapping mode is Tile */
772 prev
->texture
[0].hwTextureSet
= 0x00030000;
774 /* Magnified & minified texture filter is NEAREST */
776 prev
->texture
[0].hwTextureMip
= 0;
779 /* Texture Blending setting -- use fragment color/alpha*/
780 prev
->hwTexBlendColor0
= STAGE0_C_CF
;
781 prev
->hwTexBlendColor1
= STAGE1_C_CF
;
782 prev
->hwTexBlendAlpha0
= STAGE0_A_AF
;
783 prev
->hwTexBlendAlpha1
= STAGE1_A_AF
;
785 switch (smesa
->bytesPerPixel
)
788 prev
->hwDstSet
|= DST_FORMAT_RGB_565
;
791 prev
->hwDstSet
|= DST_FORMAT_ARGB_8888
;
795 switch (ctx
->Visual
.depthBits
)
798 prev
->hwCapEnable
&= ~MASK_ZWriteEnable
;
800 smesa
->zFormat
= SiS_ZFORMAT_Z16
;
801 prev
->hwCapEnable
|= MASK_ZWriteEnable
;
802 smesa
->depth_scale
= 1.0 / (GLfloat
)0xffff;
805 smesa
->zFormat
= SiS_ZFORMAT_Z32
;
806 prev
->hwCapEnable
|= MASK_ZWriteEnable
;
807 smesa
->depth_scale
= 1.0 / (GLfloat
)0xffffffff;
810 assert (ctx
->Visual
.stencilBits
);
811 smesa
->zFormat
= SiS_ZFORMAT_S8Z24
;
812 prev
->hwCapEnable
|= MASK_StencilBufferEnable
;
813 prev
->hwCapEnable
|= MASK_ZWriteEnable
;
814 smesa
->depth_scale
= 1.0 / (GLfloat
)0xffffff;
818 prev
->hwZ
|= smesa
->zFormat
;
820 /* TODO: need to clear cache? */
821 smesa
->clearTexCache
= GL_TRUE
;
823 smesa
->clearColorPattern
= 0;
825 smesa
->AGPParseSet
= MASK_PsTexture1FromB
;
826 smesa
->dwPrimitiveSet
= OP_3D_Texture1FromB
| OP_3D_TextureBumpFromC
;
828 sisUpdateZStencilPattern( smesa
, 1.0, 0 );
829 sisUpdateCull( ctx
);
831 memcpy( current
, prev
, sizeof (__GLSiSHardware
) );
833 /* Set initial fog settings. Start and end are the same case. */
834 sisDDFogfv( ctx
, GL_FOG_DENSITY
, &ctx
->Fog
.Density
);
835 sisDDFogfv( ctx
, GL_FOG_END
, &ctx
->Fog
.End
);
836 sisDDFogfv( ctx
, GL_FOG_MODE
, NULL
);
839 /* Initialize the driver's state functions.
841 void sisDDInitStateFuncs( GLcontext
*ctx
)
843 ctx
->Driver
.UpdateState
= sisDDInvalidateState
;
845 ctx
->Driver
.Clear
= sisDDClear
;
846 ctx
->Driver
.ClearColor
= sisDDClearColor
;
847 ctx
->Driver
.ClearDepth
= sisDDClearDepth
;
848 ctx
->Driver
.ClearStencil
= sisDDClearStencil
;
850 ctx
->Driver
.AlphaFunc
= sisDDAlphaFunc
;
851 ctx
->Driver
.Bitmap
= sisDDBitmap
;
852 ctx
->Driver
.BlendFuncSeparate
= sisDDBlendFuncSeparate
;
853 ctx
->Driver
.ColorMask
= sisDDColorMask
;
854 ctx
->Driver
.CullFace
= sisDDCullFace
;
855 ctx
->Driver
.DepthMask
= sisDDDepthMask
;
856 ctx
->Driver
.DepthFunc
= sisDDDepthFunc
;
857 ctx
->Driver
.DepthRange
= sisDDDepthRange
;
858 ctx
->Driver
.DrawBuffer
= sisDDDrawBuffer
;
859 ctx
->Driver
.DrawPixels
= sisDDDrawPixels
;
860 ctx
->Driver
.Enable
= sisDDEnable
;
861 ctx
->Driver
.FrontFace
= sisDDFrontFace
;
862 ctx
->Driver
.Fogfv
= sisDDFogfv
;
863 ctx
->Driver
.Hint
= NULL
;
864 ctx
->Driver
.Lightfv
= NULL
;
865 ctx
->Driver
.LogicOpcode
= sisDDLogicOpCode
;
866 ctx
->Driver
.PolygonMode
= NULL
;
867 ctx
->Driver
.PolygonStipple
= NULL
;
868 ctx
->Driver
.ReadBuffer
= NULL
;
869 ctx
->Driver
.ReadPixels
= sisDDReadPixels
;
870 ctx
->Driver
.RenderMode
= NULL
;
871 ctx
->Driver
.Scissor
= sisDDScissor
;
872 ctx
->Driver
.ShadeModel
= sisDDShadeModel
;
873 ctx
->Driver
.Viewport
= sisDDViewport
;
875 /* Pixel path fallbacks.
877 ctx
->Driver
.Accum
= _swrast_Accum
;
878 ctx
->Driver
.CopyPixels
= _swrast_CopyPixels
;
880 /* Swrast hooks for imaging extensions:
882 ctx
->Driver
.CopyColorTable
= _swrast_CopyColorTable
;
883 ctx
->Driver
.CopyColorSubTable
= _swrast_CopyColorSubTable
;
884 ctx
->Driver
.CopyConvolutionFilter1D
= _swrast_CopyConvolutionFilter1D
;
885 ctx
->Driver
.CopyConvolutionFilter2D
= _swrast_CopyConvolutionFilter2D
;