mesa: add KHR_no_error support for glStencilFuncSeparate()
[mesa.git] / src / mesa / main / stencil.c
1 /*
2 * Mesa 3-D graphics library
3 *
4 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25
26 /**
27 * \file stencil.c
28 * Stencil operations.
29 *
30 * Note: There's some conflict between GL_EXT_stencil_two_side and
31 * OpenGL 2.0's two-sided stencil feature.
32 *
33 * With GL_EXT_stencil_two_side, calling glStencilOp/Func/Mask() only the
34 * front OR back face state (as set by glActiveStencilFaceEXT) is set.
35 *
36 * But with OpenGL 2.0, calling glStencilOp/Func/Mask() sets BOTH the
37 * front AND back state.
38 *
39 * Also, note that GL_ATI_separate_stencil is different as well:
40 * glStencilFuncSeparateATI(GLenum frontfunc, GLenum backfunc, ...) vs.
41 * glStencilFuncSeparate(GLenum face, GLenum func, ...).
42 *
43 * This problem is solved by keeping three sets of stencil state:
44 * state[0] = GL_FRONT state.
45 * state[1] = OpenGL 2.0 / GL_ATI_separate_stencil GL_BACK state.
46 * state[2] = GL_EXT_stencil_two_side GL_BACK state.
47 */
48
49
50 #include "glheader.h"
51 #include "imports.h"
52 #include "context.h"
53 #include "macros.h"
54 #include "stencil.h"
55 #include "mtypes.h"
56
57
58 static GLboolean
59 validate_stencil_op(struct gl_context *ctx, GLenum op)
60 {
61 switch (op) {
62 case GL_KEEP:
63 case GL_ZERO:
64 case GL_REPLACE:
65 case GL_INCR:
66 case GL_DECR:
67 case GL_INVERT:
68 case GL_INCR_WRAP:
69 case GL_DECR_WRAP:
70 return GL_TRUE;
71 default:
72 return GL_FALSE;
73 }
74 }
75
76
77 static GLboolean
78 validate_stencil_func(struct gl_context *ctx, GLenum func)
79 {
80 switch (func) {
81 case GL_NEVER:
82 case GL_LESS:
83 case GL_LEQUAL:
84 case GL_GREATER:
85 case GL_GEQUAL:
86 case GL_EQUAL:
87 case GL_NOTEQUAL:
88 case GL_ALWAYS:
89 return GL_TRUE;
90 default:
91 return GL_FALSE;
92 }
93 }
94
95
96 /**
97 * Set the clear value for the stencil buffer.
98 *
99 * \param s clear value.
100 *
101 * \sa glClearStencil().
102 *
103 * Updates gl_stencil_attrib::Clear. On change
104 * flushes the vertices and notifies the driver via
105 * the dd_function_table::ClearStencil callback.
106 */
107 void GLAPIENTRY
108 _mesa_ClearStencil( GLint s )
109 {
110 GET_CURRENT_CONTEXT(ctx);
111
112 if (MESA_VERBOSE & VERBOSE_API)
113 _mesa_debug(ctx, "glClearStencil(%d)\n", s);
114
115 ctx->Stencil.Clear = (GLuint) s;
116 }
117
118
119 /**
120 * Set the function and reference value for stencil testing.
121 *
122 * \param frontfunc front test function.
123 * \param backfunc back test function.
124 * \param ref front and back reference value.
125 * \param mask front and back bitmask.
126 *
127 * \sa glStencilFunc().
128 *
129 * Verifies the parameters and updates the respective values in
130 * __struct gl_contextRec::Stencil. On change flushes the vertices and notifies
131 * the driver via the dd_function_table::StencilFunc callback.
132 */
133 void GLAPIENTRY
134 _mesa_StencilFuncSeparateATI( GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask )
135 {
136 GET_CURRENT_CONTEXT(ctx);
137
138 if (MESA_VERBOSE & VERBOSE_API)
139 _mesa_debug(ctx, "glStencilFuncSeparateATI()\n");
140
141 if (!validate_stencil_func(ctx, frontfunc)) {
142 _mesa_error(ctx, GL_INVALID_ENUM,
143 "glStencilFuncSeparateATI(frontfunc)");
144 return;
145 }
146 if (!validate_stencil_func(ctx, backfunc)) {
147 _mesa_error(ctx, GL_INVALID_ENUM,
148 "glStencilFuncSeparateATI(backfunc)");
149 return;
150 }
151
152 /* set both front and back state */
153 if (ctx->Stencil.Function[0] == frontfunc &&
154 ctx->Stencil.Function[1] == backfunc &&
155 ctx->Stencil.ValueMask[0] == mask &&
156 ctx->Stencil.ValueMask[1] == mask &&
157 ctx->Stencil.Ref[0] == ref &&
158 ctx->Stencil.Ref[1] == ref)
159 return;
160 FLUSH_VERTICES(ctx, _NEW_STENCIL);
161 ctx->Stencil.Function[0] = frontfunc;
162 ctx->Stencil.Function[1] = backfunc;
163 ctx->Stencil.Ref[0] = ctx->Stencil.Ref[1] = ref;
164 ctx->Stencil.ValueMask[0] = ctx->Stencil.ValueMask[1] = mask;
165 if (ctx->Driver.StencilFuncSeparate) {
166 ctx->Driver.StencilFuncSeparate(ctx, GL_FRONT,
167 frontfunc, ref, mask);
168 ctx->Driver.StencilFuncSeparate(ctx, GL_BACK,
169 backfunc, ref, mask);
170 }
171 }
172
173
174 /**
175 * Set the function and reference value for stencil testing.
176 *
177 * \param func test function.
178 * \param ref reference value.
179 * \param mask bitmask.
180 *
181 * \sa glStencilFunc().
182 *
183 * Verifies the parameters and updates the respective values in
184 * __struct gl_contextRec::Stencil. On change flushes the vertices and notifies
185 * the driver via the dd_function_table::StencilFunc callback.
186 */
187 void GLAPIENTRY
188 _mesa_StencilFunc( GLenum func, GLint ref, GLuint mask )
189 {
190 GET_CURRENT_CONTEXT(ctx);
191 const GLint face = ctx->Stencil.ActiveFace;
192
193 if (MESA_VERBOSE & VERBOSE_API)
194 _mesa_debug(ctx, "glStencilFunc()\n");
195
196 if (!validate_stencil_func(ctx, func)) {
197 _mesa_error(ctx, GL_INVALID_ENUM, "glStencilFunc(func)");
198 return;
199 }
200
201 if (face != 0) {
202 if (ctx->Stencil.Function[face] == func &&
203 ctx->Stencil.ValueMask[face] == mask &&
204 ctx->Stencil.Ref[face] == ref)
205 return;
206 FLUSH_VERTICES(ctx, _NEW_STENCIL);
207 ctx->Stencil.Function[face] = func;
208 ctx->Stencil.Ref[face] = ref;
209 ctx->Stencil.ValueMask[face] = mask;
210
211 /* Only propagate the change to the driver if EXT_stencil_two_side
212 * is enabled.
213 */
214 if (ctx->Driver.StencilFuncSeparate && ctx->Stencil.TestTwoSide) {
215 ctx->Driver.StencilFuncSeparate(ctx, GL_BACK, func, ref, mask);
216 }
217 }
218 else {
219 /* set both front and back state */
220 if (ctx->Stencil.Function[0] == func &&
221 ctx->Stencil.Function[1] == func &&
222 ctx->Stencil.ValueMask[0] == mask &&
223 ctx->Stencil.ValueMask[1] == mask &&
224 ctx->Stencil.Ref[0] == ref &&
225 ctx->Stencil.Ref[1] == ref)
226 return;
227 FLUSH_VERTICES(ctx, _NEW_STENCIL);
228 ctx->Stencil.Function[0] = ctx->Stencil.Function[1] = func;
229 ctx->Stencil.Ref[0] = ctx->Stencil.Ref[1] = ref;
230 ctx->Stencil.ValueMask[0] = ctx->Stencil.ValueMask[1] = mask;
231 if (ctx->Driver.StencilFuncSeparate) {
232 ctx->Driver.StencilFuncSeparate(ctx,
233 ((ctx->Stencil.TestTwoSide)
234 ? GL_FRONT : GL_FRONT_AND_BACK),
235 func, ref, mask);
236 }
237 }
238 }
239
240
241 /**
242 * Set the stencil writing mask.
243 *
244 * \param mask bit-mask to enable/disable writing of individual bits in the
245 * stencil planes.
246 *
247 * \sa glStencilMask().
248 *
249 * Updates gl_stencil_attrib::WriteMask. On change flushes the vertices and
250 * notifies the driver via the dd_function_table::StencilMask callback.
251 */
252 void GLAPIENTRY
253 _mesa_StencilMask( GLuint mask )
254 {
255 GET_CURRENT_CONTEXT(ctx);
256 const GLint face = ctx->Stencil.ActiveFace;
257
258 if (MESA_VERBOSE & VERBOSE_API)
259 _mesa_debug(ctx, "glStencilMask()\n");
260
261 if (face != 0) {
262 /* Only modify the EXT_stencil_two_side back-face state.
263 */
264 if (ctx->Stencil.WriteMask[face] == mask)
265 return;
266 FLUSH_VERTICES(ctx, _NEW_STENCIL);
267 ctx->Stencil.WriteMask[face] = mask;
268
269 /* Only propagate the change to the driver if EXT_stencil_two_side
270 * is enabled.
271 */
272 if (ctx->Driver.StencilMaskSeparate && ctx->Stencil.TestTwoSide) {
273 ctx->Driver.StencilMaskSeparate(ctx, GL_BACK, mask);
274 }
275 }
276 else {
277 /* set both front and back state */
278 if (ctx->Stencil.WriteMask[0] == mask &&
279 ctx->Stencil.WriteMask[1] == mask)
280 return;
281 FLUSH_VERTICES(ctx, _NEW_STENCIL);
282 ctx->Stencil.WriteMask[0] = ctx->Stencil.WriteMask[1] = mask;
283 if (ctx->Driver.StencilMaskSeparate) {
284 ctx->Driver.StencilMaskSeparate(ctx,
285 ((ctx->Stencil.TestTwoSide)
286 ? GL_FRONT : GL_FRONT_AND_BACK),
287 mask);
288 }
289 }
290 }
291
292
293 /**
294 * Set the stencil test actions.
295 *
296 * \param fail action to take when stencil test fails.
297 * \param zfail action to take when stencil test passes, but depth test fails.
298 * \param zpass action to take when stencil test passes and the depth test
299 * passes (or depth testing is not enabled).
300 *
301 * \sa glStencilOp().
302 *
303 * Verifies the parameters and updates the respective fields in
304 * __struct gl_contextRec::Stencil. On change flushes the vertices and notifies
305 * the driver via the dd_function_table::StencilOp callback.
306 */
307 void GLAPIENTRY
308 _mesa_StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
309 {
310 GET_CURRENT_CONTEXT(ctx);
311 const GLint face = ctx->Stencil.ActiveFace;
312
313 if (MESA_VERBOSE & VERBOSE_API)
314 _mesa_debug(ctx, "glStencilOp()\n");
315
316 if (!validate_stencil_op(ctx, fail)) {
317 _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOp(sfail)");
318 return;
319 }
320 if (!validate_stencil_op(ctx, zfail)) {
321 _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOp(zfail)");
322 return;
323 }
324 if (!validate_stencil_op(ctx, zpass)) {
325 _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOp(zpass)");
326 return;
327 }
328
329 if (face != 0) {
330 /* only set active face state */
331 if (ctx->Stencil.ZFailFunc[face] == zfail &&
332 ctx->Stencil.ZPassFunc[face] == zpass &&
333 ctx->Stencil.FailFunc[face] == fail)
334 return;
335 FLUSH_VERTICES(ctx, _NEW_STENCIL);
336 ctx->Stencil.ZFailFunc[face] = zfail;
337 ctx->Stencil.ZPassFunc[face] = zpass;
338 ctx->Stencil.FailFunc[face] = fail;
339
340 /* Only propagate the change to the driver if EXT_stencil_two_side
341 * is enabled.
342 */
343 if (ctx->Driver.StencilOpSeparate && ctx->Stencil.TestTwoSide) {
344 ctx->Driver.StencilOpSeparate(ctx, GL_BACK, fail, zfail, zpass);
345 }
346 }
347 else {
348 /* set both front and back state */
349 if (ctx->Stencil.ZFailFunc[0] == zfail &&
350 ctx->Stencil.ZFailFunc[1] == zfail &&
351 ctx->Stencil.ZPassFunc[0] == zpass &&
352 ctx->Stencil.ZPassFunc[1] == zpass &&
353 ctx->Stencil.FailFunc[0] == fail &&
354 ctx->Stencil.FailFunc[1] == fail)
355 return;
356 FLUSH_VERTICES(ctx, _NEW_STENCIL);
357 ctx->Stencil.ZFailFunc[0] = ctx->Stencil.ZFailFunc[1] = zfail;
358 ctx->Stencil.ZPassFunc[0] = ctx->Stencil.ZPassFunc[1] = zpass;
359 ctx->Stencil.FailFunc[0] = ctx->Stencil.FailFunc[1] = fail;
360 if (ctx->Driver.StencilOpSeparate) {
361 ctx->Driver.StencilOpSeparate(ctx,
362 ((ctx->Stencil.TestTwoSide)
363 ? GL_FRONT : GL_FRONT_AND_BACK),
364 fail, zfail, zpass);
365 }
366 }
367 }
368
369
370
371 /* GL_EXT_stencil_two_side */
372 void GLAPIENTRY
373 _mesa_ActiveStencilFaceEXT(GLenum face)
374 {
375 GET_CURRENT_CONTEXT(ctx);
376
377 if (MESA_VERBOSE & VERBOSE_API)
378 _mesa_debug(ctx, "glActiveStencilFaceEXT()\n");
379
380 if (!ctx->Extensions.EXT_stencil_two_side) {
381 _mesa_error(ctx, GL_INVALID_OPERATION, "glActiveStencilFaceEXT");
382 return;
383 }
384
385 if (face == GL_FRONT || face == GL_BACK) {
386 ctx->Stencil.ActiveFace = (face == GL_FRONT) ? 0 : 2;
387 }
388 else {
389 _mesa_error(ctx, GL_INVALID_ENUM, "glActiveStencilFaceEXT(face)");
390 }
391 }
392
393
394
395 void GLAPIENTRY
396 _mesa_StencilOpSeparate(GLenum face, GLenum sfail, GLenum zfail, GLenum zpass)
397 {
398 GLboolean set = GL_FALSE;
399 GET_CURRENT_CONTEXT(ctx);
400
401 if (MESA_VERBOSE & VERBOSE_API)
402 _mesa_debug(ctx, "glStencilOpSeparate()\n");
403
404 if (!validate_stencil_op(ctx, sfail)) {
405 _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(sfail)");
406 return;
407 }
408 if (!validate_stencil_op(ctx, zfail)) {
409 _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(zfail)");
410 return;
411 }
412 if (!validate_stencil_op(ctx, zpass)) {
413 _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(zpass)");
414 return;
415 }
416 if (face != GL_FRONT && face != GL_BACK && face != GL_FRONT_AND_BACK) {
417 _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(face)");
418 return;
419 }
420
421 if (face != GL_BACK) {
422 /* set front */
423 if (ctx->Stencil.ZFailFunc[0] != zfail ||
424 ctx->Stencil.ZPassFunc[0] != zpass ||
425 ctx->Stencil.FailFunc[0] != sfail){
426 FLUSH_VERTICES(ctx, _NEW_STENCIL);
427 ctx->Stencil.ZFailFunc[0] = zfail;
428 ctx->Stencil.ZPassFunc[0] = zpass;
429 ctx->Stencil.FailFunc[0] = sfail;
430 set = GL_TRUE;
431 }
432 }
433 if (face != GL_FRONT) {
434 /* set back */
435 if (ctx->Stencil.ZFailFunc[1] != zfail ||
436 ctx->Stencil.ZPassFunc[1] != zpass ||
437 ctx->Stencil.FailFunc[1] != sfail) {
438 FLUSH_VERTICES(ctx, _NEW_STENCIL);
439 ctx->Stencil.ZFailFunc[1] = zfail;
440 ctx->Stencil.ZPassFunc[1] = zpass;
441 ctx->Stencil.FailFunc[1] = sfail;
442 set = GL_TRUE;
443 }
444 }
445 if (set && ctx->Driver.StencilOpSeparate) {
446 ctx->Driver.StencilOpSeparate(ctx, face, sfail, zfail, zpass);
447 }
448 }
449
450
451 static void
452 stencil_func_separate(struct gl_context *ctx, GLenum face, GLenum func,
453 GLint ref, GLuint mask)
454 {
455 FLUSH_VERTICES(ctx, _NEW_STENCIL);
456
457 if (face != GL_BACK) {
458 /* set front */
459 ctx->Stencil.Function[0] = func;
460 ctx->Stencil.Ref[0] = ref;
461 ctx->Stencil.ValueMask[0] = mask;
462 }
463
464 if (face != GL_FRONT) {
465 /* set back */
466 ctx->Stencil.Function[1] = func;
467 ctx->Stencil.Ref[1] = ref;
468 ctx->Stencil.ValueMask[1] = mask;
469 }
470
471 if (ctx->Driver.StencilFuncSeparate) {
472 ctx->Driver.StencilFuncSeparate(ctx, face, func, ref, mask);
473 }
474 }
475
476
477 /* OpenGL 2.0 */
478 void GLAPIENTRY
479 _mesa_StencilFuncSeparate_no_error(GLenum face, GLenum func, GLint ref,
480 GLuint mask)
481 {
482 GET_CURRENT_CONTEXT(ctx);
483 stencil_func_separate(ctx, face, func, ref, mask);
484 }
485
486
487 void GLAPIENTRY
488 _mesa_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
489 {
490 GET_CURRENT_CONTEXT(ctx);
491
492 if (MESA_VERBOSE & VERBOSE_API)
493 _mesa_debug(ctx, "glStencilFuncSeparate()\n");
494
495 if (face != GL_FRONT && face != GL_BACK && face != GL_FRONT_AND_BACK) {
496 _mesa_error(ctx, GL_INVALID_ENUM, "glStencilFuncSeparate(face)");
497 return;
498 }
499
500 if (!validate_stencil_func(ctx, func)) {
501 _mesa_error(ctx, GL_INVALID_ENUM, "glStencilFuncSeparate(func)");
502 return;
503 }
504
505 stencil_func_separate(ctx, face, func, ref, mask);
506 }
507
508
509 /* OpenGL 2.0 */
510 void GLAPIENTRY
511 _mesa_StencilMaskSeparate(GLenum face, GLuint mask)
512 {
513 GET_CURRENT_CONTEXT(ctx);
514
515 if (MESA_VERBOSE & VERBOSE_API)
516 _mesa_debug(ctx, "glStencilMaskSeparate()\n");
517
518 if (face != GL_FRONT && face != GL_BACK && face != GL_FRONT_AND_BACK) {
519 _mesa_error(ctx, GL_INVALID_ENUM, "glStencilaMaskSeparate(face)");
520 return;
521 }
522
523 FLUSH_VERTICES(ctx, _NEW_STENCIL);
524
525 if (face != GL_BACK) {
526 ctx->Stencil.WriteMask[0] = mask;
527 }
528 if (face != GL_FRONT) {
529 ctx->Stencil.WriteMask[1] = mask;
530 }
531 if (ctx->Driver.StencilMaskSeparate) {
532 ctx->Driver.StencilMaskSeparate(ctx, face, mask);
533 }
534 }
535
536
537 /**
538 * Update derived stencil state.
539 */
540 void
541 _mesa_update_stencil(struct gl_context *ctx)
542 {
543 const GLint face = ctx->Stencil._BackFace;
544
545 ctx->Stencil._Enabled = (ctx->Stencil.Enabled &&
546 ctx->DrawBuffer->Visual.stencilBits > 0);
547
548 ctx->Stencil._TestTwoSide =
549 ctx->Stencil._Enabled &&
550 (ctx->Stencil.Function[0] != ctx->Stencil.Function[face] ||
551 ctx->Stencil.FailFunc[0] != ctx->Stencil.FailFunc[face] ||
552 ctx->Stencil.ZPassFunc[0] != ctx->Stencil.ZPassFunc[face] ||
553 ctx->Stencil.ZFailFunc[0] != ctx->Stencil.ZFailFunc[face] ||
554 ctx->Stencil.Ref[0] != ctx->Stencil.Ref[face] ||
555 ctx->Stencil.ValueMask[0] != ctx->Stencil.ValueMask[face] ||
556 ctx->Stencil.WriteMask[0] != ctx->Stencil.WriteMask[face]);
557
558 ctx->Stencil._WriteEnabled =
559 ctx->Stencil._Enabled &&
560 (ctx->Stencil.WriteMask[0] != 0 ||
561 (ctx->Stencil._TestTwoSide && ctx->Stencil.WriteMask[face] != 0));
562 }
563
564
565 /**
566 * Initialize the context stipple state.
567 *
568 * \param ctx GL context.
569 *
570 * Initializes __struct gl_contextRec::Stencil attribute group.
571 */
572 void
573 _mesa_init_stencil(struct gl_context *ctx)
574 {
575 ctx->Stencil.Enabled = GL_FALSE;
576 ctx->Stencil.TestTwoSide = GL_FALSE;
577 ctx->Stencil.ActiveFace = 0; /* 0 = GL_FRONT, 2 = GL_BACK */
578 ctx->Stencil.Function[0] = GL_ALWAYS;
579 ctx->Stencil.Function[1] = GL_ALWAYS;
580 ctx->Stencil.Function[2] = GL_ALWAYS;
581 ctx->Stencil.FailFunc[0] = GL_KEEP;
582 ctx->Stencil.FailFunc[1] = GL_KEEP;
583 ctx->Stencil.FailFunc[2] = GL_KEEP;
584 ctx->Stencil.ZPassFunc[0] = GL_KEEP;
585 ctx->Stencil.ZPassFunc[1] = GL_KEEP;
586 ctx->Stencil.ZPassFunc[2] = GL_KEEP;
587 ctx->Stencil.ZFailFunc[0] = GL_KEEP;
588 ctx->Stencil.ZFailFunc[1] = GL_KEEP;
589 ctx->Stencil.ZFailFunc[2] = GL_KEEP;
590 ctx->Stencil.Ref[0] = 0;
591 ctx->Stencil.Ref[1] = 0;
592 ctx->Stencil.Ref[2] = 0;
593
594 /* 4.1.4 Stencil Test section of the GL-ES 3.0 specification says:
595 *
596 * "In the initial state, [...] the front and back stencil mask are both
597 * set to the value 2^s − 1, where s is greater than or equal to the
598 * number of bits in the deepest stencil buffer* supported by the GL
599 * implementation."
600 *
601 * Since the maximum supported precision for stencil buffers is 8 bits,
602 * mask values should be initialized to 2^8 - 1 = 0xFF.
603 */
604 ctx->Stencil.ValueMask[0] = 0xFF;
605 ctx->Stencil.ValueMask[1] = 0xFF;
606 ctx->Stencil.ValueMask[2] = 0xFF;
607 ctx->Stencil.WriteMask[0] = 0xFF;
608 ctx->Stencil.WriteMask[1] = 0xFF;
609 ctx->Stencil.WriteMask[2] = 0xFF;
610
611 ctx->Stencil.Clear = 0;
612 ctx->Stencil._BackFace = 1;
613 }