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 current
->hwDstSet
&= ~MASK_ROP2
;
448 current
->hwDstSet
|= LOP_CLEAR
;
451 current
->hwDstSet
|= LOP_SET
;
454 current
->hwDstSet
|= LOP_COPY
;
456 case GL_COPY_INVERTED
:
457 current
->hwDstSet
|= LOP_COPY_INVERTED
;
460 current
->hwDstSet
|= LOP_NOOP
;
463 current
->hwDstSet
|= LOP_INVERT
;
466 current
->hwDstSet
|= LOP_AND
;
469 current
->hwDstSet
|= LOP_NAND
;
472 current
->hwDstSet
|= LOP_OR
;
475 current
->hwDstSet
|= LOP_NOR
;
478 current
->hwDstSet
|= LOP_XOR
;
481 current
->hwDstSet
|= LOP_EQUIV
;
484 current
->hwDstSet
|= LOP_AND_REVERSE
;
486 case GL_AND_INVERTED
:
487 current
->hwDstSet
|= LOP_AND_INVERTED
;
490 current
->hwDstSet
|= LOP_OR_REVERSE
;
493 current
->hwDstSet
|= LOP_OR_INVERTED
;
497 if (current
->hwDstSet
^ prev
->hwDstSet
) {
498 prev
->hwDstSet
= current
->hwDstSet
;
499 smesa
->GlobalFlag
|= GFLAG_DESTSETTING
;
503 void sisDDDrawBuffer( GLcontext
*ctx
, GLenum mode
)
505 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
507 __GLSiSHardware
*prev
= &smesa
->prev
;
508 __GLSiSHardware
*current
= &smesa
->current
;
511 * _DrawDestMask is easier to cope with than <mode>.
513 switch ( ctx
->Color
._DrawDestMask
[0] ) {
514 case DD_FRONT_LEFT_BIT
:
515 case DD_BACK_LEFT_BIT
:
516 FALLBACK( smesa
, SIS_FALLBACK_DRAW_BUFFER
, GL_FALSE
);
519 /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
520 FALLBACK( smesa
, SIS_FALLBACK_DRAW_BUFFER
, GL_TRUE
);
524 /* We want to update the s/w rast state too so that sisDDSetBuffer()
527 _swrast_DrawBuffer(ctx
, mode
);
529 current
->hwOffsetDest
= (smesa
->drawOffset
) >> 1;
530 current
->hwDstSet
&= ~MASK_DstBufferPitch
;
531 current
->hwDstSet
|= smesa
->drawPitch
>> 2;
533 if (current
->hwDstSet
!= prev
->hwDstSet
) {
534 prev
->hwDstSet
= current
->hwDstSet
;
535 smesa
->GlobalFlag
|= GFLAG_DESTSETTING
;
538 if (current
->hwOffsetDest
!= prev
->hwOffsetDest
) {
539 prev
->hwOffsetDest
= current
->hwOffsetDest
;
540 smesa
->GlobalFlag
|= GFLAG_DESTSETTING
;
544 /* =============================================================
548 /* =============================================================
552 /* =============================================================
553 * State enable/disable
557 sisDDEnable( GLcontext
* ctx
, GLenum cap
, GLboolean state
)
559 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
561 __GLSiSHardware
*current
= &smesa
->current
;
567 current
->hwCapEnable
|= MASK_AlphaTestEnable
;
569 current
->hwCapEnable
&= ~MASK_AlphaTestEnable
;
574 /* if (state & !ctx->Color.ColorLogicOpEnabled) */
575 current
->hwCapEnable
|= MASK_BlendEnable
;
577 current
->hwCapEnable
&= ~MASK_BlendEnable
;
581 current
->hwCapEnable
|= MASK_CullEnable
;
583 current
->hwCapEnable
&= ~MASK_CullEnable
;
586 if (state
&& smesa
->depthbuffer
)
587 current
->hwCapEnable
|= MASK_ZTestEnable
;
589 current
->hwCapEnable
&= ~MASK_ZTestEnable
;
590 sisDDDepthMask( ctx
, ctx
->Depth
.Mask
);
594 current
->hwCapEnable
|= MASK_DitherEnable
;
596 current
->hwCapEnable
&= ~MASK_DitherEnable
;
600 current
->hwCapEnable
|= MASK_FogEnable
;
602 current
->hwCapEnable
&= ~MASK_FogEnable
;
604 case GL_COLOR_LOGIC_OP
:
606 sisDDLogicOpCode( ctx
, ctx
->Color
.LogicOp
);
608 sisDDLogicOpCode( ctx
, GL_COPY
);
610 case GL_SCISSOR_TEST
:
611 sisUpdateClipping( ctx
);
613 case GL_STENCIL_TEST
:
615 if (smesa
->zFormat
!= SiS_ZFORMAT_S8Z24
)
616 FALLBACK(smesa
, SIS_FALLBACK_STENCIL
, 1);
618 current
->hwCapEnable
|= (MASK_StencilTestEnable
|
619 MASK_StencilWriteEnable
);
621 FALLBACK(smesa
, SIS_FALLBACK_STENCIL
, 0);
622 current
->hwCapEnable
&= ~(MASK_StencilTestEnable
|
623 MASK_StencilWriteEnable
);
630 /* =============================================================
631 * State initialization, management
634 /* Called before beginning of rendering. */
636 sisUpdateHWState( GLcontext
*ctx
)
638 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
639 __GLSiSHardware
*prev
= &smesa
->prev
;
640 __GLSiSHardware
*current
= &smesa
->current
;
642 /* enable setting 1 */
643 if (current
->hwCapEnable
^ prev
->hwCapEnable
) {
644 prev
->hwCapEnable
= current
->hwCapEnable
;
645 smesa
->GlobalFlag
|= GFLAG_ENABLESETTING
;
648 /* enable setting 2 */
649 if (current
->hwCapEnable2
^ prev
->hwCapEnable2
) {
650 prev
->hwCapEnable2
= current
->hwCapEnable2
;
651 smesa
->GlobalFlag
|= GFLAG_ENABLESETTING2
;
654 if (smesa
->GlobalFlag
& GFLAG_RENDER_STATES
)
655 sis_update_render_state( smesa
);
657 if (smesa
->GlobalFlag
& GFLAG_TEXTURE_STATES
)
658 sis_update_texture_state( smesa
);
662 sisDDInvalidateState( GLcontext
*ctx
, GLuint new_state
)
664 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
666 _swrast_InvalidateState( ctx
, new_state
);
667 _swsetup_InvalidateState( ctx
, new_state
);
668 _ac_InvalidateState( ctx
, new_state
);
669 _tnl_InvalidateState( ctx
, new_state
);
670 smesa
->NewGLState
|= new_state
;
673 /* Initialize the context's hardware state.
675 void sisDDInitState( sisContextPtr smesa
)
677 __GLSiSHardware
*current
= &smesa
->current
;
678 __GLSiSHardware
*prev
= &(smesa
->prev
);
679 GLcontext
*ctx
= smesa
->glCtx
;
681 /* add Texture Perspective Enable */
682 prev
->hwCapEnable
= MASK_FogPerspectiveEnable
| MASK_TextureCacheEnable
|
683 MASK_TexturePerspectiveEnable
| MASK_DitherEnable
;
684 /*| MASK_SpecularEnable*/
687 prev->hwCapEnable2 = 0x00aa0080;
689 /* if multi-texture enabled, disable Z pre-test */
690 prev
->hwCapEnable2
= MASK_TextureMipmapBiasEnable
;
692 /* Z test mode is LESS */
693 prev
->hwZ
= SiS_Z_COMP_S_LT_B
;
696 prev
->hwZMask
= 0xffffffff;
698 /* Alpha test mode is ALWAYS, alpha ref value is 0 */
699 prev
->hwAlpha
= SiS_ALPHA_ALWAYS
;
701 /* ROP2 is COPYPEN */
702 prev
->hwDstSet
= LOP_COPY
;
705 prev
->hwDstMask
= 0xffffffff;
707 /* LinePattern is 0, Repeat Factor is 0 */
708 prev
->hwLinePattern
= 0x00008000;
710 /* Src blend is BLEND_ONE, Dst blend is D3DBLEND_ZERO */
711 prev
->hwDstSrcBlend
= SiS_S_ONE
| SiS_D_ZERO
;
713 /* Stenciling disabled, function ALWAYS, ref value zero, mask all ones */
714 prev
->hwStSetting
= STENCIL_FORMAT_8
| SiS_STENCIL_ALWAYS
| 0xff;
715 /* Op is KEEP for all three operations */
716 prev
->hwStSetting2
= SiS_SFAIL_KEEP
| SiS_SPASS_ZFAIL_KEEP
|
717 SiS_SPASS_ZPASS_KEEP
;
719 /* Texture mapping mode is Tile */
721 prev
->texture
[0].hwTextureSet
= 0x00030000;
723 /* Magnified & minified texture filter is NEAREST */
725 prev
->texture
[0].hwTextureMip
= 0;
728 /* Texture Blending setting -- use fragment color/alpha*/
729 prev
->hwTexBlendColor0
= STAGE0_C_CF
;
730 prev
->hwTexBlendColor1
= STAGE1_C_CF
;
731 prev
->hwTexBlendAlpha0
= STAGE0_A_AF
;
732 prev
->hwTexBlendAlpha1
= STAGE1_A_AF
;
734 switch (smesa
->bytesPerPixel
)
737 prev
->hwDstSet
|= DST_FORMAT_RGB_565
;
740 prev
->hwDstSet
|= DST_FORMAT_ARGB_8888
;
744 switch (ctx
->Visual
.depthBits
)
747 prev
->hwCapEnable
&= ~MASK_ZWriteEnable
;
749 smesa
->zFormat
= SiS_ZFORMAT_Z16
;
750 prev
->hwCapEnable
|= MASK_ZWriteEnable
;
751 smesa
->depth_scale
= 1.0 / (GLfloat
)0xffff;
754 smesa
->zFormat
= SiS_ZFORMAT_Z32
;
755 prev
->hwCapEnable
|= MASK_ZWriteEnable
;
756 smesa
->depth_scale
= 1.0 / (GLfloat
)0xffffffff;
759 assert (ctx
->Visual
.stencilBits
);
760 smesa
->zFormat
= SiS_ZFORMAT_S8Z24
;
761 prev
->hwCapEnable
|= MASK_StencilBufferEnable
;
762 prev
->hwCapEnable
|= MASK_ZWriteEnable
;
763 smesa
->depth_scale
= 1.0 / (GLfloat
)0xffffff;
767 prev
->hwZ
|= smesa
->zFormat
;
769 /* TODO: need to clear cache? */
770 smesa
->clearTexCache
= GL_TRUE
;
772 smesa
->clearColorPattern
= 0;
774 smesa
->AGPParseSet
= MASK_PsTexture1FromB
| MASK_PsBumpTextureFromC
;
775 smesa
->dwPrimitiveSet
= OP_3D_Texture1FromB
| OP_3D_TextureBumpFromC
;
777 sisUpdateZStencilPattern( smesa
, 1.0, 0 );
778 sisUpdateCull( ctx
);
780 memcpy( current
, prev
, sizeof (__GLSiSHardware
) );
782 /* Set initial fog settings. Start and end are the same case. */
783 sisDDFogfv( ctx
, GL_FOG_DENSITY
, &ctx
->Fog
.Density
);
784 sisDDFogfv( ctx
, GL_FOG_END
, &ctx
->Fog
.End
);
785 sisDDFogfv( ctx
, GL_FOG_MODE
, NULL
);
788 /* Initialize the driver's state functions.
790 void sisDDInitStateFuncs( GLcontext
*ctx
)
792 ctx
->Driver
.UpdateState
= sisDDInvalidateState
;
794 ctx
->Driver
.Clear
= sisDDClear
;
795 ctx
->Driver
.ClearColor
= sisDDClearColor
;
796 ctx
->Driver
.ClearDepth
= sisDDClearDepth
;
797 ctx
->Driver
.ClearStencil
= sisDDClearStencil
;
799 ctx
->Driver
.AlphaFunc
= sisDDAlphaFunc
;
800 ctx
->Driver
.BlendFuncSeparate
= sisDDBlendFuncSeparate
;
801 ctx
->Driver
.ColorMask
= sisDDColorMask
;
802 ctx
->Driver
.CullFace
= sisDDCullFace
;
803 ctx
->Driver
.DepthMask
= sisDDDepthMask
;
804 ctx
->Driver
.DepthFunc
= sisDDDepthFunc
;
805 ctx
->Driver
.DepthRange
= sisDDDepthRange
;
806 ctx
->Driver
.DrawBuffer
= sisDDDrawBuffer
;
807 ctx
->Driver
.Enable
= sisDDEnable
;
808 ctx
->Driver
.FrontFace
= sisDDFrontFace
;
809 ctx
->Driver
.Fogfv
= sisDDFogfv
;
810 ctx
->Driver
.Hint
= NULL
;
811 ctx
->Driver
.Lightfv
= NULL
;
812 ctx
->Driver
.LogicOpcode
= sisDDLogicOpCode
;
813 ctx
->Driver
.PolygonMode
= NULL
;
814 ctx
->Driver
.PolygonStipple
= NULL
;
815 ctx
->Driver
.ReadBuffer
= NULL
;
816 ctx
->Driver
.RenderMode
= NULL
;
817 ctx
->Driver
.Scissor
= sisDDScissor
;
818 ctx
->Driver
.ShadeModel
= sisDDShadeModel
;
819 ctx
->Driver
.Viewport
= sisDDViewport
;
821 /* Pixel path fallbacks. */
822 ctx
->Driver
.Accum
= _swrast_Accum
;
823 ctx
->Driver
.Bitmap
= _swrast_Bitmap
;
824 ctx
->Driver
.CopyPixels
= _swrast_CopyPixels
;
825 ctx
->Driver
.DrawPixels
= _swrast_DrawPixels
;
826 ctx
->Driver
.ReadPixels
= _swrast_ReadPixels
;
828 /* Swrast hooks for imaging extensions:
830 ctx
->Driver
.CopyColorTable
= _swrast_CopyColorTable
;
831 ctx
->Driver
.CopyColorSubTable
= _swrast_CopyColorSubTable
;
832 ctx
->Driver
.CopyConvolutionFilter1D
= _swrast_CopyConvolutionFilter1D
;
833 ctx
->Driver
.CopyConvolutionFilter2D
= _swrast_CopyConvolutionFilter2D
;