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_stencil.c,v 1.3 2000/09/26 15:56:49 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"
37 #include "sis_stencil.h"
40 sisDDStencilFuncSeparate( GLcontext
* ctx
, GLenum face
,
41 GLenum func
, GLint ref
, GLuint mask
)
43 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
44 __GLSiSHardware
*prev
= &smesa
->prev
;
45 __GLSiSHardware
*current
= &smesa
->current
;
48 current
->hwStSetting
= (STENCIL_FORMAT_8
|
49 ((ctx
->Stencil
.Ref
[0] & 0xff) << 8) |
50 (ctx
->Stencil
.ValueMask
[0] & 0xff));
55 current
->hwStSetting
|= SiS_STENCIL_NEVER
;
58 current
->hwStSetting
|= SiS_STENCIL_LESS
;
61 current
->hwStSetting
|= SiS_STENCIL_EQUAL
;
64 current
->hwStSetting
|= SiS_STENCIL_LEQUAL
;
67 current
->hwStSetting
|= SiS_STENCIL_GREATER
;
70 current
->hwStSetting
|= SiS_STENCIL_NOTEQUAL
;
73 current
->hwStSetting
|= SiS_STENCIL_GEQUAL
;
76 current
->hwStSetting
|= SiS_STENCIL_ALWAYS
;
80 if (current
->hwStSetting
!= prev
->hwStSetting
)
82 prev
->hwStSetting
= current
->hwStSetting
;
84 smesa
->GlobalFlag
|= GFLAG_STENCILSETTING
;
89 sisDDStencilMaskSeparate( GLcontext
* ctx
, GLenum face
, GLuint mask
)
91 if (!ctx
->Visual
.stencilBits
)
94 /* set Z buffer Write Enable */
95 sisDDDepthMask (ctx
, ctx
->Depth
.Mask
);
99 sisDDStencilOpSeparate( GLcontext
* ctx
, GLenum face
, GLenum fail
,
100 GLenum zfail
, GLenum zpass
)
102 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
103 __GLSiSHardware
*prev
= &smesa
->prev
;
104 __GLSiSHardware
*current
= &smesa
->current
;
106 current
->hwStSetting2
&= ~(MASK_StencilZPassOp
| MASK_StencilZFailOp
|
112 current
->hwStSetting2
|= SiS_SFAIL_KEEP
;
115 current
->hwStSetting2
|= SiS_SFAIL_ZERO
;
118 current
->hwStSetting2
|= SiS_SFAIL_REPLACE
;
121 current
->hwStSetting2
|= SiS_SFAIL_INVERT
;
124 current
->hwStSetting2
|= SiS_SFAIL_INCR
;
127 current
->hwStSetting2
|= SiS_SFAIL_DECR
;
130 current
->hwStSetting2
|= SiS_SFAIL_INCR_WRAP
;
133 current
->hwStSetting2
|= SiS_SFAIL_DECR_WRAP
;
140 current
->hwStSetting2
|= SiS_SPASS_ZFAIL_KEEP
;
143 current
->hwStSetting2
|= SiS_SPASS_ZFAIL_ZERO
;
146 current
->hwStSetting2
|= SiS_SPASS_ZFAIL_REPLACE
;
149 current
->hwStSetting2
|= SiS_SPASS_ZFAIL_INVERT
;
152 current
->hwStSetting2
|= SiS_SPASS_ZFAIL_INCR
;
155 current
->hwStSetting2
|= SiS_SPASS_ZFAIL_DECR
;
158 current
->hwStSetting2
|= SiS_SPASS_ZFAIL_INCR_WRAP
;
161 current
->hwStSetting2
|= SiS_SPASS_ZFAIL_DECR_WRAP
;
168 current
->hwStSetting2
|= SiS_SPASS_ZPASS_KEEP
;
171 current
->hwStSetting2
|= SiS_SPASS_ZPASS_ZERO
;
174 current
->hwStSetting2
|= SiS_SPASS_ZPASS_REPLACE
;
177 current
->hwStSetting2
|= SiS_SPASS_ZPASS_INVERT
;
180 current
->hwStSetting2
|= SiS_SPASS_ZPASS_INCR
;
183 current
->hwStSetting2
|= SiS_SPASS_ZPASS_DECR
;
186 current
->hwStSetting2
|= SiS_SPASS_ZPASS_INCR_WRAP
;
189 current
->hwStSetting2
|= SiS_SPASS_ZPASS_DECR_WRAP
;
193 if (current
->hwStSetting2
!= prev
->hwStSetting2
)
195 prev
->hwStSetting2
= current
->hwStSetting2
;
196 smesa
->GlobalFlag
|= GFLAG_STENCILSETTING
;
201 sisDDInitStencilFuncs( GLcontext
*ctx
)
203 ctx
->Driver
.StencilFuncSeparate
= sisDDStencilFuncSeparate
;
204 ctx
->Driver
.StencilMaskSeparate
= sisDDStencilMaskSeparate
;
205 ctx
->Driver
.StencilOpSeparate
= sisDDStencilOpSeparate
;