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 **************************************************************************/
30 * Sung-Ching Lin <sclin@sis.com.tw>
31 * Eric Anholt <anholt@FreeBSD.org>
34 #include "sis_context.h"
35 #include "sis_state.h"
36 #include "sis_stencil.h"
39 sisDDStencilFuncSeparate( GLcontext
* ctx
, GLenum face
,
40 GLenum func
, GLint ref
, GLuint mask
)
42 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
43 __GLSiSHardware
*prev
= &smesa
->prev
;
44 __GLSiSHardware
*current
= &smesa
->current
;
47 current
->hwStSetting
= (STENCIL_FORMAT_8
|
48 ((ctx
->Stencil
.Ref
[0] & 0xff) << 8) |
49 (ctx
->Stencil
.ValueMask
[0] & 0xff));
54 current
->hwStSetting
|= SiS_STENCIL_NEVER
;
57 current
->hwStSetting
|= SiS_STENCIL_LESS
;
60 current
->hwStSetting
|= SiS_STENCIL_EQUAL
;
63 current
->hwStSetting
|= SiS_STENCIL_LEQUAL
;
66 current
->hwStSetting
|= SiS_STENCIL_GREATER
;
69 current
->hwStSetting
|= SiS_STENCIL_NOTEQUAL
;
72 current
->hwStSetting
|= SiS_STENCIL_GEQUAL
;
75 current
->hwStSetting
|= SiS_STENCIL_ALWAYS
;
79 if (current
->hwStSetting
!= prev
->hwStSetting
)
81 prev
->hwStSetting
= current
->hwStSetting
;
83 smesa
->GlobalFlag
|= GFLAG_STENCILSETTING
;
88 sisDDStencilMaskSeparate( GLcontext
* ctx
, GLenum face
, GLuint mask
)
90 if (!ctx
->Visual
.stencilBits
)
93 /* set Z buffer Write Enable */
94 sisDDDepthMask (ctx
, ctx
->Depth
.Mask
);
98 sisDDStencilOpSeparate( GLcontext
* ctx
, GLenum face
, GLenum fail
,
99 GLenum zfail
, GLenum zpass
)
101 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
102 __GLSiSHardware
*prev
= &smesa
->prev
;
103 __GLSiSHardware
*current
= &smesa
->current
;
105 current
->hwStSetting2
&= ~(MASK_StencilZPassOp
| MASK_StencilZFailOp
|
111 current
->hwStSetting2
|= SiS_SFAIL_KEEP
;
114 current
->hwStSetting2
|= SiS_SFAIL_ZERO
;
117 current
->hwStSetting2
|= SiS_SFAIL_REPLACE
;
120 current
->hwStSetting2
|= SiS_SFAIL_INVERT
;
123 current
->hwStSetting2
|= SiS_SFAIL_INCR
;
126 current
->hwStSetting2
|= SiS_SFAIL_DECR
;
129 current
->hwStSetting2
|= SiS_SFAIL_INCR_WRAP
;
132 current
->hwStSetting2
|= SiS_SFAIL_DECR_WRAP
;
139 current
->hwStSetting2
|= SiS_SPASS_ZFAIL_KEEP
;
142 current
->hwStSetting2
|= SiS_SPASS_ZFAIL_ZERO
;
145 current
->hwStSetting2
|= SiS_SPASS_ZFAIL_REPLACE
;
148 current
->hwStSetting2
|= SiS_SPASS_ZFAIL_INVERT
;
151 current
->hwStSetting2
|= SiS_SPASS_ZFAIL_INCR
;
154 current
->hwStSetting2
|= SiS_SPASS_ZFAIL_DECR
;
157 current
->hwStSetting2
|= SiS_SPASS_ZFAIL_INCR_WRAP
;
160 current
->hwStSetting2
|= SiS_SPASS_ZFAIL_DECR_WRAP
;
167 current
->hwStSetting2
|= SiS_SPASS_ZPASS_KEEP
;
170 current
->hwStSetting2
|= SiS_SPASS_ZPASS_ZERO
;
173 current
->hwStSetting2
|= SiS_SPASS_ZPASS_REPLACE
;
176 current
->hwStSetting2
|= SiS_SPASS_ZPASS_INVERT
;
179 current
->hwStSetting2
|= SiS_SPASS_ZPASS_INCR
;
182 current
->hwStSetting2
|= SiS_SPASS_ZPASS_DECR
;
185 current
->hwStSetting2
|= SiS_SPASS_ZPASS_INCR_WRAP
;
188 current
->hwStSetting2
|= SiS_SPASS_ZPASS_DECR_WRAP
;
192 if (current
->hwStSetting2
!= prev
->hwStSetting2
)
194 prev
->hwStSetting2
= current
->hwStSetting2
;
195 smesa
->GlobalFlag
|= GFLAG_STENCILSETTING
;
200 sisDDInitStencilFuncs( GLcontext
*ctx
)
202 ctx
->Driver
.StencilFuncSeparate
= sisDDStencilFuncSeparate
;
203 ctx
->Driver
.StencilMaskSeparate
= sisDDStencilMaskSeparate
;
204 ctx
->Driver
.StencilOpSeparate
= sisDDStencilOpSeparate
;