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 ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS 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 sisDDStencilFunc( GLcontext
* ctx
, 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
| (ctx
->Stencil
.Ref
[0] << 8) |
48 ctx
->Stencil
.ValueMask
[0];
53 current
->hwStSetting
|= SiS_STENCIL_NEVER
;
56 current
->hwStSetting
|= SiS_STENCIL_LESS
;
59 current
->hwStSetting
|= SiS_STENCIL_EQUAL
;
62 current
->hwStSetting
|= SiS_STENCIL_LEQUAL
;
65 current
->hwStSetting
|= SiS_STENCIL_GREATER
;
68 current
->hwStSetting
|= SiS_STENCIL_NOTEQUAL
;
71 current
->hwStSetting
|= SiS_STENCIL_GEQUAL
;
74 current
->hwStSetting
|= SiS_STENCIL_ALWAYS
;
78 if (current
->hwStSetting
!= prev
->hwStSetting
)
80 prev
->hwStSetting
= current
->hwStSetting
;
82 smesa
->GlobalFlag
|= GFLAG_STENCILSETTING
;
87 sisDDStencilMask( GLcontext
* ctx
, GLuint mask
)
89 if (!ctx
->Visual
.stencilBits
)
92 /* set Z buffer Write Enable */
93 sisDDDepthMask (ctx
, ctx
->Depth
.Mask
);
97 sisDDStencilOp( GLcontext
* ctx
, GLenum fail
, GLenum zfail
, GLenum zpass
)
99 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
100 __GLSiSHardware
*prev
= &smesa
->prev
;
101 __GLSiSHardware
*current
= &smesa
->current
;
103 current
->hwStSetting2
&= ~(MASK_StencilZPassOp
| MASK_StencilZFailOp
|
109 current
->hwStSetting2
|= SiS_SFAIL_KEEP
;
112 current
->hwStSetting2
|= SiS_SFAIL_ZERO
;
115 current
->hwStSetting2
|= SiS_SFAIL_REPLACE
;
118 current
->hwStSetting2
|= SiS_SFAIL_INVERT
;
121 current
->hwStSetting2
|= SiS_SFAIL_INCR
;
124 current
->hwStSetting2
|= SiS_SFAIL_DECR
;
131 current
->hwStSetting2
|= SiS_SPASS_ZFAIL_KEEP
;
134 current
->hwStSetting2
|= SiS_SPASS_ZFAIL_ZERO
;
137 current
->hwStSetting2
|= SiS_SPASS_ZFAIL_REPLACE
;
140 current
->hwStSetting2
|= SiS_SPASS_ZFAIL_INVERT
;
143 current
->hwStSetting2
|= SiS_SPASS_ZFAIL_INCR
;
146 current
->hwStSetting2
|= SiS_SPASS_ZFAIL_DECR
;
153 current
->hwStSetting2
|= SiS_SPASS_ZPASS_KEEP
;
156 current
->hwStSetting2
|= SiS_SPASS_ZPASS_ZERO
;
159 current
->hwStSetting2
|= SiS_SPASS_ZPASS_REPLACE
;
162 current
->hwStSetting2
|= SiS_SPASS_ZPASS_INVERT
;
165 current
->hwStSetting2
|= SiS_SPASS_ZPASS_INCR
;
168 current
->hwStSetting2
|= SiS_SPASS_ZPASS_DECR
;
172 if (current
->hwStSetting2
!= prev
->hwStSetting2
)
174 prev
->hwStSetting2
= current
->hwStSetting2
;
175 smesa
->GlobalFlag
|= GFLAG_STENCILSETTING
;
180 sisDDInitStencilFuncs( GLcontext
*ctx
)
182 ctx
->Driver
.StencilFunc
= sisDDStencilFunc
;
183 ctx
->Driver
.StencilMask
= sisDDStencilMask
;
184 ctx
->Driver
.StencilOp
= sisDDStencilOp
;