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