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"
45 #include "swrast/swrast.h"
46 #include "array_cache/acache.h"
48 #include "swrast_setup/swrast_setup.h"
50 #include "tnl/t_pipeline.h"
52 /* =============================================================
57 sisDDAlphaFunc( GLcontext
* ctx
, GLenum func
, GLfloat ref
)
59 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
62 __GLSiSHardware
*prev
= &smesa
->prev
;
63 __GLSiSHardware
*current
= &smesa
->current
;
65 CLAMPED_FLOAT_TO_UBYTE(refbyte
, ref
);
66 current
->hwAlpha
= refbyte
<< 16;
68 /* Alpha Test function */
72 current
->hwAlpha
|= SiS_ALPHA_NEVER
;
75 current
->hwAlpha
|= SiS_ALPHA_LESS
;
78 current
->hwAlpha
|= SiS_ALPHA_EQUAL
;
81 current
->hwAlpha
|= SiS_ALPHA_LEQUAL
;
84 current
->hwAlpha
|= SiS_ALPHA_GREATER
;
87 current
->hwAlpha
|= SiS_ALPHA_NOTEQUAL
;
90 current
->hwAlpha
|= SiS_ALPHA_GEQUAL
;
93 current
->hwAlpha
|= SiS_ALPHA_ALWAYS
;
97 prev
->hwAlpha
= current
->hwAlpha
;
98 smesa
->GlobalFlag
|= GFLAG_ALPHASETTING
;
102 sisDDBlendFuncSeparate( GLcontext
*ctx
,
103 GLenum sfactorRGB
, GLenum dfactorRGB
,
104 GLenum sfactorA
, GLenum dfactorA
)
106 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
108 __GLSiSHardware
*prev
= &smesa
->prev
;
109 __GLSiSHardware
*current
= &smesa
->current
;
111 current
->hwDstSrcBlend
= 0;
116 current
->hwDstSrcBlend
|= SiS_D_ZERO
;
119 current
->hwDstSrcBlend
|= SiS_D_ONE
;
122 current
->hwDstSrcBlend
|= SiS_D_SRC_COLOR
;
124 case GL_ONE_MINUS_SRC_COLOR
:
125 current
->hwDstSrcBlend
|= SiS_D_ONE_MINUS_SRC_COLOR
;
128 current
->hwDstSrcBlend
|= SiS_D_SRC_ALPHA
;
130 case GL_ONE_MINUS_SRC_ALPHA
:
131 current
->hwDstSrcBlend
|= SiS_D_ONE_MINUS_SRC_ALPHA
;
134 current
->hwDstSrcBlend
|= SiS_D_DST_COLOR
;
136 case GL_ONE_MINUS_DST_COLOR
:
137 current
->hwDstSrcBlend
|= SiS_D_ONE_MINUS_DST_COLOR
;
140 current
->hwDstSrcBlend
|= SiS_D_DST_ALPHA
;
142 case GL_ONE_MINUS_DST_ALPHA
:
143 current
->hwDstSrcBlend
|= SiS_D_ONE_MINUS_DST_ALPHA
;
146 fprintf(stderr
, "Unknown dst blend function 0x%x\n", dfactorRGB
);
153 current
->hwDstSrcBlend
|= SiS_S_ZERO
;
156 current
->hwDstSrcBlend
|= SiS_S_ONE
;
159 current
->hwDstSrcBlend
|= SiS_S_SRC_COLOR
;
161 case GL_ONE_MINUS_SRC_COLOR
:
162 current
->hwDstSrcBlend
|= SiS_S_ONE_MINUS_SRC_COLOR
;
165 current
->hwDstSrcBlend
|= SiS_S_SRC_ALPHA
;
167 case GL_ONE_MINUS_SRC_ALPHA
:
168 current
->hwDstSrcBlend
|= SiS_S_ONE_MINUS_SRC_ALPHA
;
171 current
->hwDstSrcBlend
|= SiS_S_DST_COLOR
;
173 case GL_ONE_MINUS_DST_COLOR
:
174 current
->hwDstSrcBlend
|= SiS_S_ONE_MINUS_DST_COLOR
;
177 current
->hwDstSrcBlend
|= SiS_S_DST_ALPHA
;
179 case GL_ONE_MINUS_DST_ALPHA
:
180 current
->hwDstSrcBlend
|= SiS_S_ONE_MINUS_DST_ALPHA
;
182 case GL_SRC_ALPHA_SATURATE
:
183 current
->hwDstSrcBlend
|= SiS_S_SRC_ALPHA_SATURATE
;
186 fprintf(stderr
, "Unknown src blend function 0x%x\n", sfactorRGB
);
190 if (current
->hwDstSrcBlend
!= prev
->hwDstSrcBlend
) {
191 prev
->hwDstSrcBlend
= current
->hwDstSrcBlend
;
192 smesa
->GlobalFlag
|= GFLAG_DSTBLEND
;
196 /* =============================================================
201 sisDDDepthFunc( GLcontext
* ctx
, GLenum func
)
203 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
204 __GLSiSHardware
*prev
= &smesa
->prev
;
205 __GLSiSHardware
*current
= &smesa
->current
;
207 current
->hwZ
&= ~MASK_ZTestMode
;
211 current
->hwZ
|= SiS_Z_COMP_S_LT_B
;
214 current
->hwZ
|= SiS_Z_COMP_S_GE_B
;
217 current
->hwZ
|= SiS_Z_COMP_S_LE_B
;
220 current
->hwZ
|= SiS_Z_COMP_S_GT_B
;
223 current
->hwZ
|= SiS_Z_COMP_S_NE_B
;
226 current
->hwZ
|= SiS_Z_COMP_S_EQ_B
;
229 current
->hwZ
|= SiS_Z_COMP_ALWAYS
;
232 current
->hwZ
|= SiS_Z_COMP_NEVER
;
236 if (current
->hwZ
!= prev
->hwZ
) {
237 prev
->hwZ
= current
->hwZ
;
238 smesa
->GlobalFlag
|= GFLAG_ZSETTING
;
243 sisDDDepthMask( GLcontext
* ctx
, GLboolean flag
)
245 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
246 __GLSiSHardware
*prev
= &smesa
->prev
;
247 __GLSiSHardware
*current
= &smesa
->current
;
249 if (!ctx
->Depth
.Test
)
252 if (ctx
->Visual
.stencilBits
) {
253 if (flag
|| (ctx
->Stencil
.WriteMask
[0] != 0)) {
254 current
->hwCapEnable
|= MASK_ZWriteEnable
;
255 if (flag
&& (ctx
->Stencil
.WriteMask
[0] == 0xff)) {
256 current
->hwCapEnable2
&= ~MASK_ZMaskWriteEnable
;
258 current
->hwCapEnable2
|= MASK_ZMaskWriteEnable
;
259 current
->hwZMask
= (ctx
->Stencil
.WriteMask
[0] << 24) |
260 ((flag
) ? 0x00ffffff : 0);
262 if (current
->hwZMask
^ prev
->hwZMask
) {
263 prev
->hwZMask
= current
->hwZMask
;
264 smesa
->GlobalFlag
|= GFLAG_ZSETTING
;
268 current
->hwCapEnable
&= ~MASK_ZWriteEnable
;
272 current
->hwCapEnable
|= MASK_ZWriteEnable
;
273 current
->hwCapEnable2
&= ~MASK_ZMaskWriteEnable
;
275 current
->hwCapEnable
&= ~MASK_ZWriteEnable
;
280 /* =============================================================
285 sisUpdateClipping( GLcontext
*ctx
)
287 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
289 __GLSiSHardware
*prev
= &smesa
->prev
;
290 __GLSiSHardware
*current
= &smesa
->current
;
292 GLint x1
, y1
, x2
, y2
;
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 sisDDShadeModel( GLcontext
*ctx
, GLenum mode
)
406 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
408 /* Signal to sisRasterPrimitive to recalculate dwPrimitiveSet */
409 smesa
->hw_primitive
= -1;
412 /* =============================================================
416 /* =============================================================
420 static void sisCalcViewport( GLcontext
*ctx
)
422 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
423 const GLfloat
*v
= ctx
->Viewport
._WindowMap
.m
;
424 GLfloat
*m
= smesa
->hw_viewport
;
426 /* See also sis_translate_vertex.
428 m
[MAT_SX
] = v
[MAT_SX
];
429 m
[MAT_TX
] = v
[MAT_TX
] + SUBPIXEL_X
;
430 m
[MAT_SY
] = - v
[MAT_SY
];
431 m
[MAT_TY
] = - v
[MAT_TY
] + smesa
->driDrawable
->h
+ SUBPIXEL_Y
;
432 m
[MAT_SZ
] = v
[MAT_SZ
] * smesa
->depth_scale
;
433 m
[MAT_TZ
] = v
[MAT_TZ
] * smesa
->depth_scale
;
436 static void sisDDViewport( GLcontext
*ctx
,
438 GLsizei width
, GLsizei height
)
440 /* update size of Mesa/software ancillary buffers */
441 _mesa_ResizeBuffersMESA();
442 sisCalcViewport( ctx
);
445 static void sisDDDepthRange( GLcontext
*ctx
,
446 GLclampd nearval
, GLclampd farval
)
448 sisCalcViewport( ctx
);
451 /* =============================================================
456 sisDDLogicOpCode( GLcontext
*ctx
, GLenum opcode
)
458 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
460 __GLSiSHardware
*prev
= &smesa
->prev
;
461 __GLSiSHardware
*current
= &smesa
->current
;
463 current
->hwDstSet
&= ~MASK_ROP2
;
467 current
->hwDstSet
|= LOP_CLEAR
;
470 current
->hwDstSet
|= LOP_SET
;
473 current
->hwDstSet
|= LOP_COPY
;
475 case GL_COPY_INVERTED
:
476 current
->hwDstSet
|= LOP_COPY_INVERTED
;
479 current
->hwDstSet
|= LOP_NOOP
;
482 current
->hwDstSet
|= LOP_INVERT
;
485 current
->hwDstSet
|= LOP_AND
;
488 current
->hwDstSet
|= LOP_NAND
;
491 current
->hwDstSet
|= LOP_OR
;
494 current
->hwDstSet
|= LOP_NOR
;
497 current
->hwDstSet
|= LOP_XOR
;
500 current
->hwDstSet
|= LOP_EQUIV
;
503 current
->hwDstSet
|= LOP_AND_REVERSE
;
505 case GL_AND_INVERTED
:
506 current
->hwDstSet
|= LOP_AND_INVERTED
;
509 current
->hwDstSet
|= LOP_OR_REVERSE
;
512 current
->hwDstSet
|= LOP_OR_INVERTED
;
516 if (current
->hwDstSet
^ prev
->hwDstSet
) {
517 prev
->hwDstSet
= current
->hwDstSet
;
518 smesa
->GlobalFlag
|= GFLAG_DESTSETTING
;
522 void sisDDDrawBuffer( GLcontext
*ctx
, GLenum mode
)
524 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
526 __GLSiSHardware
*prev
= &smesa
->prev
;
527 __GLSiSHardware
*current
= &smesa
->current
;
530 * _DrawDestMask is easier to cope with than <mode>.
532 switch ( ctx
->DrawBuffer
->_ColorDrawBufferMask
[0] ) {
533 case BUFFER_BIT_FRONT_LEFT
:
534 case BUFFER_BIT_BACK_LEFT
:
535 FALLBACK( smesa
, SIS_FALLBACK_DRAW_BUFFER
, GL_FALSE
);
538 /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
539 FALLBACK( smesa
, SIS_FALLBACK_DRAW_BUFFER
, GL_TRUE
);
543 /* We want to update the s/w rast state too so that sisDDSetBuffer()
546 _swrast_DrawBuffer(ctx
, mode
);
548 current
->hwOffsetDest
= (smesa
->drawOffset
) >> 1;
549 current
->hwDstSet
&= ~MASK_DstBufferPitch
;
550 current
->hwDstSet
|= smesa
->drawPitch
>> 2;
552 if (current
->hwDstSet
!= prev
->hwDstSet
) {
553 prev
->hwDstSet
= current
->hwDstSet
;
554 smesa
->GlobalFlag
|= GFLAG_DESTSETTING
;
557 if (current
->hwOffsetDest
!= prev
->hwOffsetDest
) {
558 prev
->hwOffsetDest
= current
->hwOffsetDest
;
559 smesa
->GlobalFlag
|= GFLAG_DESTSETTING
;
563 /* =============================================================
567 /* =============================================================
571 /* =============================================================
572 * State enable/disable
576 sisDDEnable( GLcontext
* ctx
, GLenum cap
, GLboolean state
)
578 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
580 __GLSiSHardware
*current
= &smesa
->current
;
586 current
->hwCapEnable
|= MASK_AlphaTestEnable
;
588 current
->hwCapEnable
&= ~MASK_AlphaTestEnable
;
593 /* if (state & !ctx->Color.ColorLogicOpEnabled) */
594 current
->hwCapEnable
|= MASK_BlendEnable
;
596 current
->hwCapEnable
&= ~MASK_BlendEnable
;
600 current
->hwCapEnable
|= MASK_CullEnable
;
602 current
->hwCapEnable
&= ~MASK_CullEnable
;
605 if (state
&& smesa
->depthbuffer
)
606 current
->hwCapEnable
|= MASK_ZTestEnable
;
608 current
->hwCapEnable
&= ~MASK_ZTestEnable
;
609 sisDDDepthMask( ctx
, ctx
->Depth
.Mask
);
613 current
->hwCapEnable
|= MASK_DitherEnable
;
615 current
->hwCapEnable
&= ~MASK_DitherEnable
;
619 current
->hwCapEnable
|= MASK_FogEnable
;
621 current
->hwCapEnable
&= ~MASK_FogEnable
;
623 case GL_COLOR_LOGIC_OP
:
625 sisDDLogicOpCode( ctx
, ctx
->Color
.LogicOp
);
627 sisDDLogicOpCode( ctx
, GL_COPY
);
629 case GL_SCISSOR_TEST
:
630 sisUpdateClipping( ctx
);
632 case GL_STENCIL_TEST
:
634 if (smesa
->zFormat
!= SiS_ZFORMAT_S8Z24
)
635 FALLBACK(smesa
, SIS_FALLBACK_STENCIL
, 1);
637 current
->hwCapEnable
|= (MASK_StencilTestEnable
|
638 MASK_StencilWriteEnable
);
640 FALLBACK(smesa
, SIS_FALLBACK_STENCIL
, 0);
641 current
->hwCapEnable
&= ~(MASK_StencilTestEnable
|
642 MASK_StencilWriteEnable
);
649 /* =============================================================
650 * State initialization, management
653 /* Called before beginning of rendering. */
655 sisUpdateHWState( GLcontext
*ctx
)
657 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
658 __GLSiSHardware
*prev
= &smesa
->prev
;
659 __GLSiSHardware
*current
= &smesa
->current
;
661 /* enable setting 1 */
662 if (current
->hwCapEnable
^ prev
->hwCapEnable
) {
663 prev
->hwCapEnable
= current
->hwCapEnable
;
664 smesa
->GlobalFlag
|= GFLAG_ENABLESETTING
;
667 /* enable setting 2 */
668 if (current
->hwCapEnable2
^ prev
->hwCapEnable2
) {
669 prev
->hwCapEnable2
= current
->hwCapEnable2
;
670 smesa
->GlobalFlag
|= GFLAG_ENABLESETTING2
;
673 if (smesa
->GlobalFlag
& GFLAG_RENDER_STATES
)
674 sis_update_render_state( smesa
);
676 if (smesa
->GlobalFlag
& GFLAG_TEXTURE_STATES
)
677 sis_update_texture_state( smesa
);
681 sisDDInvalidateState( GLcontext
*ctx
, GLuint new_state
)
683 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
685 _swrast_InvalidateState( ctx
, new_state
);
686 _swsetup_InvalidateState( ctx
, new_state
);
687 _ac_InvalidateState( ctx
, new_state
);
688 _tnl_InvalidateState( ctx
, new_state
);
689 smesa
->NewGLState
|= new_state
;
692 /* Initialize the context's hardware state.
694 void sisDDInitState( sisContextPtr smesa
)
696 __GLSiSHardware
*current
= &smesa
->current
;
697 __GLSiSHardware
*prev
= &(smesa
->prev
);
698 GLcontext
*ctx
= smesa
->glCtx
;
700 /* add Texture Perspective Enable */
701 prev
->hwCapEnable
= MASK_FogPerspectiveEnable
| MASK_TextureCacheEnable
|
702 MASK_TexturePerspectiveEnable
| MASK_DitherEnable
;
703 /*| MASK_SpecularEnable*/
706 prev->hwCapEnable2 = 0x00aa0080;
708 /* if multi-texture enabled, disable Z pre-test */
709 prev
->hwCapEnable2
= MASK_TextureMipmapBiasEnable
;
711 /* Z test mode is LESS */
712 prev
->hwZ
= SiS_Z_COMP_S_LT_B
;
715 prev
->hwZMask
= 0xffffffff;
717 /* Alpha test mode is ALWAYS, alpha ref value is 0 */
718 prev
->hwAlpha
= SiS_ALPHA_ALWAYS
;
720 /* ROP2 is COPYPEN */
721 prev
->hwDstSet
= LOP_COPY
;
724 prev
->hwDstMask
= 0xffffffff;
726 /* LinePattern is 0, Repeat Factor is 0 */
727 prev
->hwLinePattern
= 0x00008000;
729 /* Src blend is BLEND_ONE, Dst blend is D3DBLEND_ZERO */
730 prev
->hwDstSrcBlend
= SiS_S_ONE
| SiS_D_ZERO
;
732 /* Stenciling disabled, function ALWAYS, ref value zero, mask all ones */
733 prev
->hwStSetting
= STENCIL_FORMAT_8
| SiS_STENCIL_ALWAYS
| 0xff;
734 /* Op is KEEP for all three operations */
735 prev
->hwStSetting2
= SiS_SFAIL_KEEP
| SiS_SPASS_ZFAIL_KEEP
|
736 SiS_SPASS_ZPASS_KEEP
;
738 /* Texture mapping mode is Tile */
740 prev
->texture
[0].hwTextureSet
= 0x00030000;
742 /* Magnified & minified texture filter is NEAREST */
744 prev
->texture
[0].hwTextureMip
= 0;
747 /* Texture Blending setting -- use fragment color/alpha*/
748 prev
->hwTexBlendColor0
= STAGE0_C_CF
;
749 prev
->hwTexBlendColor1
= STAGE1_C_CF
;
750 prev
->hwTexBlendAlpha0
= STAGE0_A_AF
;
751 prev
->hwTexBlendAlpha1
= STAGE1_A_AF
;
753 switch (smesa
->bytesPerPixel
)
756 prev
->hwDstSet
|= DST_FORMAT_RGB_565
;
759 prev
->hwDstSet
|= DST_FORMAT_ARGB_8888
;
763 switch (ctx
->Visual
.depthBits
)
766 prev
->hwCapEnable
&= ~MASK_ZWriteEnable
;
768 smesa
->zFormat
= SiS_ZFORMAT_Z16
;
769 prev
->hwCapEnable
|= MASK_ZWriteEnable
;
770 smesa
->depth_scale
= 1.0 / (GLfloat
)0xffff;
773 smesa
->zFormat
= SiS_ZFORMAT_Z32
;
774 prev
->hwCapEnable
|= MASK_ZWriteEnable
;
775 smesa
->depth_scale
= 1.0 / (GLfloat
)0xffffffff;
778 assert (ctx
->Visual
.stencilBits
);
779 smesa
->zFormat
= SiS_ZFORMAT_S8Z24
;
780 prev
->hwCapEnable
|= MASK_StencilBufferEnable
;
781 prev
->hwCapEnable
|= MASK_ZWriteEnable
;
782 smesa
->depth_scale
= 1.0 / (GLfloat
)0xffffff;
786 prev
->hwZ
|= smesa
->zFormat
;
788 /* TODO: need to clear cache? */
789 smesa
->clearTexCache
= GL_TRUE
;
791 smesa
->clearColorPattern
= 0;
793 smesa
->AGPParseSet
= MASK_PsTexture1FromB
| MASK_PsBumpTextureFromC
;
794 smesa
->dwPrimitiveSet
= OP_3D_Texture1FromB
| OP_3D_TextureBumpFromC
;
796 sisUpdateZStencilPattern( smesa
, 1.0, 0 );
797 sisUpdateCull( ctx
);
799 memcpy( current
, prev
, sizeof (__GLSiSHardware
) );
801 /* Set initial fog settings. Start and end are the same case. */
802 sisDDFogfv( ctx
, GL_FOG_DENSITY
, &ctx
->Fog
.Density
);
803 sisDDFogfv( ctx
, GL_FOG_END
, &ctx
->Fog
.End
);
804 sisDDFogfv( ctx
, GL_FOG_MODE
, NULL
);
807 /* Initialize the driver's state functions.
809 void sisDDInitStateFuncs( GLcontext
*ctx
)
811 ctx
->Driver
.UpdateState
= sisDDInvalidateState
;
813 ctx
->Driver
.Clear
= sisDDClear
;
814 ctx
->Driver
.ClearColor
= sisDDClearColor
;
815 ctx
->Driver
.ClearDepth
= sisDDClearDepth
;
816 ctx
->Driver
.ClearStencil
= sisDDClearStencil
;
818 ctx
->Driver
.AlphaFunc
= sisDDAlphaFunc
;
819 ctx
->Driver
.BlendFuncSeparate
= sisDDBlendFuncSeparate
;
820 ctx
->Driver
.ColorMask
= sisDDColorMask
;
821 ctx
->Driver
.CullFace
= sisDDCullFace
;
822 ctx
->Driver
.DepthMask
= sisDDDepthMask
;
823 ctx
->Driver
.DepthFunc
= sisDDDepthFunc
;
824 ctx
->Driver
.DepthRange
= sisDDDepthRange
;
825 ctx
->Driver
.DrawBuffer
= sisDDDrawBuffer
;
826 ctx
->Driver
.Enable
= sisDDEnable
;
827 ctx
->Driver
.FrontFace
= sisDDFrontFace
;
828 ctx
->Driver
.Fogfv
= sisDDFogfv
;
829 ctx
->Driver
.Hint
= NULL
;
830 ctx
->Driver
.Lightfv
= NULL
;
831 ctx
->Driver
.LogicOpcode
= sisDDLogicOpCode
;
832 ctx
->Driver
.PolygonMode
= NULL
;
833 ctx
->Driver
.PolygonStipple
= NULL
;
834 ctx
->Driver
.ReadBuffer
= NULL
;
835 ctx
->Driver
.RenderMode
= NULL
;
836 ctx
->Driver
.Scissor
= sisDDScissor
;
837 ctx
->Driver
.ShadeModel
= sisDDShadeModel
;
838 ctx
->Driver
.Viewport
= sisDDViewport
;
840 /* Pixel path fallbacks. */
841 ctx
->Driver
.Accum
= _swrast_Accum
;
842 ctx
->Driver
.Bitmap
= _swrast_Bitmap
;
843 ctx
->Driver
.CopyPixels
= _swrast_CopyPixels
;
844 ctx
->Driver
.DrawPixels
= _swrast_DrawPixels
;
845 ctx
->Driver
.ReadPixels
= _swrast_ReadPixels
;
847 /* Swrast hooks for imaging extensions:
849 ctx
->Driver
.CopyColorTable
= _swrast_CopyColorTable
;
850 ctx
->Driver
.CopyColorSubTable
= _swrast_CopyColorSubTable
;
851 ctx
->Driver
.CopyConvolutionFilter1D
= _swrast_CopyConvolutionFilter1D
;
852 ctx
->Driver
.CopyConvolutionFilter2D
= _swrast_CopyConvolutionFilter2D
;