1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
/**************************************************************************
Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
Copyright 2003 Eric Anholt
All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
on the rights to use, copy, modify, merge, publish, distribute, sub
license, and/or sell copies of the Software, and to permit persons to whom
the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************/
/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_stencil.c,v 1.3 2000/09/26 15:56:49 tsi Exp $ */
/*
* Authors:
* Sung-Ching Lin <sclin@sis.com.tw>
* Eric Anholt <anholt@FreeBSD.org>
*/
#include "sis_context.h"
#include "sis_state.h"
#include "sis_stencil.h"
static void
sisDDStencilFuncSeparate( GLcontext * ctx, GLenum face,
GLenum func, GLint ref, GLuint mask )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
__GLSiSHardware *prev = &smesa->prev;
__GLSiSHardware *current = &smesa->current;
/* set reference */
current->hwStSetting = STENCIL_FORMAT_8 | (ctx->Stencil.Ref[0] << 8) |
ctx->Stencil.ValueMask[0];
switch (func)
{
case GL_NEVER:
current->hwStSetting |= SiS_STENCIL_NEVER;
break;
case GL_LESS:
current->hwStSetting |= SiS_STENCIL_LESS;
break;
case GL_EQUAL:
current->hwStSetting |= SiS_STENCIL_EQUAL;
break;
case GL_LEQUAL:
current->hwStSetting |= SiS_STENCIL_LEQUAL;
break;
case GL_GREATER:
current->hwStSetting |= SiS_STENCIL_GREATER;
break;
case GL_NOTEQUAL:
current->hwStSetting |= SiS_STENCIL_NOTEQUAL;
break;
case GL_GEQUAL:
current->hwStSetting |= SiS_STENCIL_GEQUAL;
break;
case GL_ALWAYS:
current->hwStSetting |= SiS_STENCIL_ALWAYS;
break;
}
if (current->hwStSetting != prev->hwStSetting)
{
prev->hwStSetting = current->hwStSetting;
smesa->GlobalFlag |= GFLAG_STENCILSETTING;
}
}
static void
sisDDStencilMaskSeparate( GLcontext * ctx, GLenum face, GLuint mask )
{
if (!ctx->Visual.stencilBits)
return;
/* set Z buffer Write Enable */
sisDDDepthMask (ctx, ctx->Depth.Mask);
}
static void
sisDDStencilOpSeparate( GLcontext * ctx, GLenum face, GLenum fail,
GLenum zfail, GLenum zpass )
{
sisContextPtr smesa = SIS_CONTEXT(ctx);
__GLSiSHardware *prev = &smesa->prev;
__GLSiSHardware *current = &smesa->current;
current->hwStSetting2 &= ~(MASK_StencilZPassOp | MASK_StencilZFailOp |
MASK_StencilFailOp);
switch (fail)
{
case GL_KEEP:
current->hwStSetting2 |= SiS_SFAIL_KEEP;
break;
case GL_ZERO:
current->hwStSetting2 |= SiS_SFAIL_ZERO;
break;
case GL_REPLACE:
current->hwStSetting2 |= SiS_SFAIL_REPLACE;
break;
case GL_INVERT:
current->hwStSetting2 |= SiS_SFAIL_INVERT;
break;
case GL_INCR:
current->hwStSetting2 |= SiS_SFAIL_INCR;
break;
case GL_DECR:
current->hwStSetting2 |= SiS_SFAIL_DECR;
break;
}
switch (zfail)
{
case GL_KEEP:
current->hwStSetting2 |= SiS_SPASS_ZFAIL_KEEP;
break;
case GL_ZERO:
current->hwStSetting2 |= SiS_SPASS_ZFAIL_ZERO;
break;
case GL_REPLACE:
current->hwStSetting2 |= SiS_SPASS_ZFAIL_REPLACE;
break;
case GL_INVERT:
current->hwStSetting2 |= SiS_SPASS_ZFAIL_INVERT;
break;
case GL_INCR:
current->hwStSetting2 |= SiS_SPASS_ZFAIL_INCR;
break;
case GL_DECR:
current->hwStSetting2 |= SiS_SPASS_ZFAIL_DECR;
break;
}
switch (zpass)
{
case GL_KEEP:
current->hwStSetting2 |= SiS_SPASS_ZPASS_KEEP;
break;
case GL_ZERO:
current->hwStSetting2 |= SiS_SPASS_ZPASS_ZERO;
break;
case GL_REPLACE:
current->hwStSetting2 |= SiS_SPASS_ZPASS_REPLACE;
break;
case GL_INVERT:
current->hwStSetting2 |= SiS_SPASS_ZPASS_INVERT;
break;
case GL_INCR:
current->hwStSetting2 |= SiS_SPASS_ZPASS_INCR;
break;
case GL_DECR:
current->hwStSetting2 |= SiS_SPASS_ZPASS_DECR;
break;
}
if (current->hwStSetting2 != prev->hwStSetting2)
{
prev->hwStSetting2 = current->hwStSetting2;
smesa->GlobalFlag |= GFLAG_STENCILSETTING;
}
}
void
sisDDInitStencilFuncs( GLcontext *ctx )
{
ctx->Driver.StencilFuncSeparate = sisDDStencilFuncSeparate;
ctx->Driver.StencilMaskSeparate = sisDDStencilMaskSeparate;
ctx->Driver.StencilOpSeparate = sisDDStencilOpSeparate;
}
|