VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_stencil.c@ 78375

最後變更 在這個檔案從78375是 78375,由 vboxsync 提交於 6 年 前

Additions/common/crOpengl,GuestHost/OpenGL,HostServices/SharedOpenGL: Eliminate all global variables from the state tracker library (state_tracker) in preparation of the SPU DLL merging, bugref:9435

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id Revision
檔案大小: 53.9 KB
 
1/* Copyright (c) 2001, Stanford University
2 * All rights reserved
3 *
4 * See the file LICENSE.txt for information on redistributing this software.
5 */
6
7#include <stdio.h>
8#include "state.h"
9#include "state/cr_statetypes.h"
10#include "state_internals.h"
11
12
13static GLint crStateStencilBufferGetIdxAndCount(PCRStateTracker pState, CRStencilState *s, GLenum face, GLint *pIdx, GLint *pBitsIdx)
14{
15 switch (face)
16 {
17 case GL_FRONT_AND_BACK:
18 *pIdx = 0;
19 *pBitsIdx = CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK;
20 return 2;
21 case GL_FRONT:
22 *pIdx = CRSTATE_STENCIL_BUFFER_ID_FRONT;
23 *pBitsIdx = CRSTATE_STENCIL_BUFFER_REF_ID_FRONT;
24 return 1;
25 case GL_BACK:
26 *pIdx = CRSTATE_STENCIL_BUFFER_ID_BACK;
27 *pBitsIdx = CRSTATE_STENCIL_BUFFER_REF_ID_BACK;
28 return 1;
29 case 0:
30 if (!s->stencilTwoSideEXT || s->activeStencilFace == GL_FRONT)
31 {
32 /* both front and back */
33 *pIdx = 0;
34 *pBitsIdx = CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK;
35 return 2;
36 }
37 *pIdx = CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK;
38 *pBitsIdx = CRSTATE_STENCIL_BUFFER_REF_ID_TWO_SIDE_BACK;
39 return 1;
40 default:
41 crStateError(pState, __LINE__,__FILE__,GL_INVALID_ENUM, "crStateStencilBufferGetIdxAndCount");
42 return 0;
43 }
44#ifndef VBOX /* unreachable */
45 crError("should never be here!");
46 return 0;
47#endif
48}
49
50void crStateStencilBufferInit(CRStencilBufferState *s)
51{
52 s->func = GL_ALWAYS;
53 s->mask = 0xFFFFFFFF;
54 s->ref = 0;
55
56 s->fail = GL_KEEP;
57 s->passDepthFail = GL_KEEP;
58 s->passDepthPass = GL_KEEP;
59}
60
61static void crStateStencilBufferRefBitsInit(CRContext *ctx, CRStencilBufferRefBits *sb)
62{
63 RESET(sb->func, ctx->bitid);
64 RESET(sb->op, ctx->bitid);
65}
66
67void crStateStencilInit(CRContext *ctx)
68{
69 CRStencilState *s = &ctx->stencil;
70 CRStateBits *stateb = GetCurrentBits(ctx->pStateTracker);
71 CRStencilBits *sb = &(stateb->stencil);
72 int i;
73
74 s->stencilTest = GL_FALSE;
75 RESET(sb->enable, ctx->bitid);
76
77 s->stencilTwoSideEXT = GL_FALSE;
78 RESET(sb->enableTwoSideEXT, ctx->bitid);
79
80 s->activeStencilFace = GL_FRONT;
81 RESET(sb->activeStencilFace, ctx->bitid);
82
83 s->clearValue = 0;
84 RESET(sb->clearValue, ctx->bitid);
85
86 s->writeMask = 0xFFFFFFFF;
87 RESET(sb->writeMask, ctx->bitid);
88
89 RESET(sb->dirty, ctx->bitid);
90
91 for (i = 0; i < CRSTATE_STENCIL_BUFFER_COUNT; ++i)
92 {
93 crStateStencilBufferInit(&s->buffers[i]);
94 }
95
96 for (i = 0; i < CRSTATE_STENCIL_BUFFER_REF_COUNT; ++i)
97 {
98 crStateStencilBufferRefBitsInit(ctx, &sb->bufferRefs[i]);
99 }
100}
101
102static void crStateStencilBufferFunc(CRContext *g, CRStencilBufferState *s, GLenum func, GLint ref, GLuint mask)
103{
104 (void)g;
105 s->func = func;
106 s->ref = ref;
107 s->mask = mask;
108}
109
110static void crStateStencilFuncPerform(PCRStateTracker pState, GLenum face, GLenum func, GLint ref, GLuint mask)
111{
112 CRContext *g = GetCurrentContext(pState);
113 CRStencilState *s = &(g->stencil);
114 CRStateBits *stateb = GetCurrentBits(pState);
115 CRStencilBits *sb = &(stateb->stencil);
116 GLint idx, bitsIdx, count, i;
117
118
119 if (g->current.inBeginEnd)
120 {
121 crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
122 "glStencilFunc called in begin/end");
123 return;
124 }
125
126 FLUSH();
127
128 if (func != GL_NEVER &&
129 func != GL_LESS &&
130 func != GL_LEQUAL &&
131 func != GL_GREATER &&
132 func != GL_GEQUAL &&
133 func != GL_EQUAL &&
134 func != GL_NOTEQUAL &&
135 func != GL_ALWAYS)
136 {
137 crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM,
138 "glStencilFunc called with bogu func: %d", func);
139 return;
140 }
141
142 count = crStateStencilBufferGetIdxAndCount(pState, s, face, &idx, &bitsIdx);
143 if (count)
144 {
145 for (i = idx; i < idx + count; ++i)
146 {
147 crStateStencilBufferFunc(g, &s->buffers[i], func, ref, mask);
148 }
149 DIRTY(sb->bufferRefs[bitsIdx].func, g->neg_bitid);
150
151 DIRTY(sb->dirty, g->neg_bitid);
152 }
153}
154
155void STATE_APIENTRY crStateStencilFuncSeparate(PCRStateTracker pState, GLenum face, GLenum func, GLint ref, GLuint mask)
156{
157 if (!face)
158 {
159 /* crStateStencilFuncPerform accepts 0 value, while glStencilFuncSeparate does not,
160 * filter it out here */
161 crStateError(pState, __LINE__,__FILE__,GL_INVALID_ENUM, "crStateStencilFuncSeparate");
162 return;
163 }
164 crStateStencilFuncPerform(pState, face, func, ref, mask);
165}
166
167void STATE_APIENTRY crStateStencilFunc(PCRStateTracker pState, GLenum func, GLint ref, GLuint mask)
168{
169 crStateStencilFuncPerform(pState, 0, func, ref, mask);
170}
171
172static void STATE_APIENTRY crStateStencilBufferOp (CRContext *g, CRStencilBufferState *s, GLenum fail, GLenum zfail, GLenum zpass)
173{
174 (void)g;
175 s->fail = fail;
176 s->passDepthFail = zfail;
177 s->passDepthPass = zpass;
178}
179
180static void crStateStencilOpPerform (PCRStateTracker pState, GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
181{
182 CRContext *g = GetCurrentContext(pState);
183 CRStencilState *s = &(g->stencil);
184 CRStateBits *stateb = GetCurrentBits(pState);
185 CRStencilBits *sb = &(stateb->stencil);
186 GLint idx, bitsIdx, count, i;
187
188 if (g->current.inBeginEnd)
189 {
190 crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
191 "glStencilOp called in begin/end");
192 return;
193 }
194
195 FLUSH();
196
197 switch (fail) {
198 case GL_KEEP:
199 case GL_ZERO:
200 case GL_REPLACE:
201 case GL_INCR:
202 case GL_DECR:
203 case GL_INVERT:
204#ifdef CR_EXT_stencil_wrap
205 case GL_INCR_WRAP_EXT:
206 case GL_DECR_WRAP_EXT:
207#endif
208 break;
209 default:
210 crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM,
211 "glStencilOp called with bogus fail: %d", fail);
212 return;
213 }
214
215 switch (zfail) {
216 case GL_KEEP:
217 case GL_ZERO:
218 case GL_REPLACE:
219 case GL_INCR:
220 case GL_DECR:
221 case GL_INVERT:
222#ifdef CR_EXT_stencil_wrap
223 case GL_INCR_WRAP_EXT:
224 case GL_DECR_WRAP_EXT:
225#endif
226 break;
227 default:
228 crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM,
229 "glStencilOp called with bogus zfail: %d", zfail);
230 return;
231 }
232
233 switch (zpass) {
234 case GL_KEEP:
235 case GL_ZERO:
236 case GL_REPLACE:
237 case GL_INCR:
238 case GL_DECR:
239 case GL_INVERT:
240#ifdef CR_EXT_stencil_wrap
241 case GL_INCR_WRAP_EXT:
242 case GL_DECR_WRAP_EXT:
243#endif
244 break;
245 default:
246 crStateError(pState, __LINE__, __FILE__, GL_INVALID_ENUM,
247 "glStencilOp called with bogus zpass: %d", zpass);
248 return;
249 }
250
251 count = crStateStencilBufferGetIdxAndCount(pState, s, face, &idx, &bitsIdx);
252 if (count)
253 {
254 for (i = idx; i < idx + count; ++i)
255 {
256 crStateStencilBufferOp(g, &s->buffers[i], fail, zfail, zpass);
257 }
258
259 DIRTY(sb->bufferRefs[bitsIdx].op, g->neg_bitid);
260
261 DIRTY(sb->dirty, g->neg_bitid);
262 }
263}
264
265void STATE_APIENTRY crStateStencilOpSeparate (PCRStateTracker pState, GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
266{
267 if (!face)
268 {
269 /* crStateStencilOpPerform accepts 0 value, while glStencilOpSeparate does not,
270 * filter it out here */
271 crStateError(pState, __LINE__,__FILE__,GL_INVALID_ENUM, "crStateStencilOpSeparate");
272 return;
273 }
274 crStateStencilOpPerform (pState, 0, fail, zfail, zpass);
275}
276
277void STATE_APIENTRY crStateStencilOp (PCRStateTracker pState, GLenum fail, GLenum zfail, GLenum zpass)
278{
279 crStateStencilOpPerform (pState, 0, fail, zfail, zpass);
280}
281
282void STATE_APIENTRY crStateClearStencil (PCRStateTracker pState, GLint c)
283{
284 CRContext *g = GetCurrentContext(pState);
285 CRStencilState *s = &(g->stencil);
286 CRStateBits *stateb = GetCurrentBits(pState);
287 CRStencilBits *sb = &(stateb->stencil);
288
289 if (g->current.inBeginEnd)
290 {
291 crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
292 "glClearStencil called in begin/end");
293 return;
294 }
295
296 FLUSH();
297
298 s->clearValue = c;
299
300 DIRTY(sb->clearValue, g->neg_bitid);
301 DIRTY(sb->dirty, g->neg_bitid);
302}
303
304void STATE_APIENTRY crStateStencilMask (PCRStateTracker pState, GLuint mask)
305{
306 CRContext *g = GetCurrentContext(pState);
307 CRStencilState *s = &(g->stencil);
308 CRStateBits *stateb = GetCurrentBits(pState);
309 CRStencilBits *sb = &(stateb->stencil);
310
311 if (g->current.inBeginEnd)
312 {
313 crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
314 "glStencilMask called in begin/end");
315 return;
316 }
317
318 FLUSH();
319
320 s->writeMask = mask;
321
322 DIRTY(sb->writeMask, g->neg_bitid);
323 DIRTY(sb->dirty, g->neg_bitid);
324}
325
326void STATE_APIENTRY crStateActiveStencilFaceEXT (PCRStateTracker pState, GLenum face)
327{
328 CRContext *g = GetCurrentContext(pState);
329 CRStencilState *s = &(g->stencil);
330 CRStateBits *stateb = GetCurrentBits(pState);
331 CRStencilBits *sb = &(stateb->stencil);
332
333 switch (face)
334 {
335 case GL_FRONT:
336 case GL_BACK:
337 s->activeStencilFace = face;
338 break;
339 default:
340 crStateError(pState, __LINE__,__FILE__,GL_INVALID_ENUM, "crStateActiveStencilFaceEXT");
341 return;
342 }
343
344 DIRTY(sb->activeStencilFace, g->neg_bitid);
345 DIRTY(sb->dirty, g->neg_bitid);
346}
347
348#ifdef CRSTATE_DEBUG_STENCIL_ERR
349#define CRSTATE_CLEARERR() do { \
350 while (pState->diff_api.GetError() != GL_NO_ERROR) {} \
351 } while (0)
352
353#define CRSTATE_CHECKGLERR(_op) do {\
354 GLenum _glErr; \
355 CRSTATE_CLEARERR(); \
356 _op; \
357 while ((_glErr = pState->diff_api.GetError()) != GL_NO_ERROR) { Assert(0);} \
358 }while (0)
359#else
360#define CRSTATE_CHECKGLERR(_op) do { _op; } while (0)
361#endif
362
363#define CR_STATE_STENCIL_FUNC_MATCH(_s1, _i1, _s2, _i2) (\
364 (_s1)->buffers[(_i1)].func == (_s2)->buffers[(_i2)].func && \
365 (_s1)->buffers[(_i1)].ref == (_s2)->buffers[(_i2)].ref && \
366 (_s1)->buffers[(_i1)].mask == (_s2)->buffers[(_i2)].mask)
367
368#define CR_STATE_STENCIL_FUNC_COPY(_s1, _i1, _s2, _i2) do { \
369 (_s1)->buffers[(_i1)].func = (_s2)->buffers[(_i2)].func; \
370 (_s1)->buffers[(_i1)].ref = (_s2)->buffers[(_i2)].ref; \
371 (_s1)->buffers[(_i1)].mask = (_s2)->buffers[(_i2)].mask; \
372 } while (0)
373
374
375#define CR_STATE_STENCIL_OP_MATCH(_s1, _i1, _s2, _i2) (\
376 (_s1)->buffers[(_i1)].fail == (_s2)->buffers[(_i2)].fail && \
377 (_s1)->buffers[(_i1)].passDepthFail == (_s2)->buffers[(_i2)].passDepthFail && \
378 (_s1)->buffers[(_i1)].passDepthPass == (_s2)->buffers[(_i2)].passDepthPass)
379
380#define CR_STATE_STENCIL_OP_COPY(_s1, _i1, _s2, _i2) do { \
381 (_s1)->buffers[(_i1)].fail = (_s2)->buffers[(_i2)].fail; \
382 (_s1)->buffers[(_i1)].passDepthFail = (_s2)->buffers[(_i2)].passDepthFail; \
383 (_s1)->buffers[(_i1)].passDepthPass = (_s2)->buffers[(_i2)].passDepthPass; \
384 } while (0)
385
386
387void crStateStencilDiff(CRStencilBits *b, CRbitvalue *bitID,
388 CRContext *fromCtx, CRContext *toCtx)
389{
390 PCRStateTracker pState = fromCtx->pStateTracker;
391 CRStencilState *from = &(fromCtx->stencil);
392 CRStencilState *to = &(toCtx->stencil);
393 unsigned int j, i;
394 GLenum activeFace;
395 GLboolean backIsSet = GL_FALSE, frontIsSet = GL_FALSE, frontBackDirty, frontDirty, backDirty;
396 GLchar frontMatch = -1, backMatch = -1, toFrontBackMatch = -1;
397 CRbitvalue nbitID[CR_MAX_BITARRAY];
398
399 CRASSERT(fromCtx->pStateTracker == toCtx->pStateTracker);
400
401 for (j=0;j<CR_MAX_BITARRAY;j++)
402 nbitID[j] = ~bitID[j];
403 i = 0; /* silence compiler */
404
405 if (CHECKDIRTY(b->enable, bitID))
406 {
407 glAble able[2];
408 able[0] = pState->diff_api.Disable;
409 able[1] = pState->diff_api.Enable;
410 if (from->stencilTest != to->stencilTest)
411 {
412 able[to->stencilTest](GL_STENCIL_TEST);
413 from->stencilTest = to->stencilTest;
414 }
415 CLEARDIRTY(b->enable, nbitID);
416 }
417
418 if (CHECKDIRTY(b->enableTwoSideEXT, bitID))
419 {
420 glAble able[2];
421 able[0] = pState->diff_api.Disable;
422 able[1] = pState->diff_api.Enable;
423 if (from->stencilTwoSideEXT != to->stencilTwoSideEXT)
424 {
425 able[to->stencilTwoSideEXT](GL_STENCIL_TEST_TWO_SIDE_EXT);
426 from->stencilTwoSideEXT = to->stencilTwoSideEXT;
427 }
428 CLEARDIRTY(b->enableTwoSideEXT, nbitID);
429 }
430
431 if (CHECKDIRTY(b->clearValue, bitID))
432 {
433 if (from->clearValue != to->clearValue)
434 {
435 pState->diff_api.ClearStencil (to->clearValue);
436 from->clearValue = to->clearValue;
437 }
438 CLEARDIRTY(b->clearValue, nbitID);
439 }
440
441 activeFace = to->activeStencilFace;
442
443
444 /* func */
445 frontBackDirty = CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK].func, bitID);
446 frontDirty = CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT].func, bitID);
447 backDirty = CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_BACK].func, bitID);
448#define CR_STATE_STENCIL_FUNC_FRONT_MATCH() ( \
449 frontMatch >= 0 ? \
450 frontMatch \
451 : (frontMatch = CR_STATE_STENCIL_FUNC_MATCH(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT)))
452
453#define CR_STATE_STENCIL_FUNC_BACK_MATCH() ( \
454 backMatch >= 0 ? \
455 backMatch \
456 : (backMatch = CR_STATE_STENCIL_FUNC_MATCH(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_BACK)))
457
458#define CR_STATE_STENCIL_FUNC_TO_FRONT_BACK_MATCH() ( \
459 toFrontBackMatch >= 0 ? \
460 toFrontBackMatch \
461 : (toFrontBackMatch = CR_STATE_STENCIL_FUNC_MATCH(to, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_BACK)))
462
463 if (frontBackDirty)
464 {
465 if (!CR_STATE_STENCIL_FUNC_FRONT_MATCH()
466 || !CR_STATE_STENCIL_FUNC_BACK_MATCH())
467 {
468 if (CR_STATE_STENCIL_FUNC_TO_FRONT_BACK_MATCH())
469 {
470 if (activeFace == GL_BACK)
471 {
472 pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
473 activeFace = GL_FRONT;
474 }
475
476 pState->diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
477 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref,
478 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask);
479
480 CR_STATE_STENCIL_FUNC_COPY(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT);
481 CR_STATE_STENCIL_FUNC_COPY(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_FRONT);
482 frontIsSet = GL_TRUE;
483 backIsSet = GL_TRUE;
484 }
485 else if (!CR_STATE_STENCIL_FUNC_FRONT_MATCH())
486 {
487 if (activeFace == GL_BACK)
488 {
489 pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
490 activeFace = GL_FRONT;
491 }
492
493 pState->diff_api.StencilFuncSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
494 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref,
495 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask);
496
497 CR_STATE_STENCIL_FUNC_COPY(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT);
498 frontIsSet = GL_TRUE;
499 }
500 else if (!CR_STATE_STENCIL_FUNC_BACK_MATCH())
501 {
502 if (activeFace == GL_BACK)
503 {
504 pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
505 activeFace = GL_FRONT;
506 }
507
508 pState->diff_api.StencilFuncSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].func,
509 to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].ref,
510 to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].mask);
511
512 CR_STATE_STENCIL_FUNC_COPY(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_BACK);
513
514 backIsSet = GL_TRUE;
515 }
516 }
517
518 CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK].func, nbitID);
519 }
520
521 if (frontDirty)
522 {
523 if (!CR_STATE_STENCIL_FUNC_FRONT_MATCH())
524 {
525 if (CR_STATE_STENCIL_FUNC_TO_FRONT_BACK_MATCH())
526 {
527 if (!frontIsSet || !backIsSet)
528 {
529 if (activeFace == GL_BACK)
530 {
531 pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
532 activeFace = GL_FRONT;
533 }
534
535 pState->diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
536 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref,
537 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask);
538
539 CR_STATE_STENCIL_FUNC_COPY(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT);
540 CR_STATE_STENCIL_FUNC_COPY(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_FRONT);
541
542 frontIsSet = GL_TRUE;
543 backIsSet = GL_TRUE;
544 }
545 }
546 else if (!CR_STATE_STENCIL_FUNC_FRONT_MATCH())
547 {
548 if (!frontIsSet)
549 {
550 if (activeFace == GL_BACK)
551 {
552 pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
553 activeFace = GL_FRONT;
554 }
555
556 pState->diff_api.StencilFuncSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
557 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref,
558 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask);
559
560 CR_STATE_STENCIL_FUNC_COPY(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT);
561 frontIsSet = GL_TRUE;
562 }
563 }
564 else if (!CR_STATE_STENCIL_FUNC_BACK_MATCH())
565 {
566 if (!backIsSet)
567 {
568 if (activeFace == GL_BACK)
569 {
570 pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
571 activeFace = GL_FRONT;
572 }
573
574 pState->diff_api.StencilFuncSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].func,
575 to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].ref,
576 to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].mask);
577 CR_STATE_STENCIL_FUNC_COPY(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_BACK);
578 backIsSet = GL_TRUE;
579 }
580 }
581 }
582 CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT].func, nbitID);
583 }
584
585
586 if (backDirty)
587 {
588 if (!CR_STATE_STENCIL_FUNC_FRONT_MATCH())
589 {
590 if (CR_STATE_STENCIL_FUNC_TO_FRONT_BACK_MATCH())
591 {
592 if (!frontIsSet || !backIsSet)
593 {
594 if (activeFace == GL_BACK)
595 {
596 pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
597 activeFace = GL_FRONT;
598 }
599
600 pState->diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
601 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref,
602 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask);
603
604 CR_STATE_STENCIL_FUNC_COPY(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT);
605 CR_STATE_STENCIL_FUNC_COPY(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_FRONT);
606
607 frontIsSet = GL_TRUE;
608 backIsSet = GL_TRUE;
609 }
610 }
611 else if (!CR_STATE_STENCIL_FUNC_FRONT_MATCH())
612 {
613 if (!frontIsSet)
614 {
615 if (activeFace == GL_BACK)
616 {
617 pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
618 activeFace = GL_FRONT;
619 }
620
621 pState->diff_api.StencilFuncSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
622 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref,
623 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask);
624
625 CR_STATE_STENCIL_FUNC_COPY(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT);
626 frontIsSet = GL_TRUE;
627 }
628 }
629 else if (!CR_STATE_STENCIL_FUNC_BACK_MATCH())
630 {
631 if (!backIsSet)
632 {
633 if (activeFace == GL_BACK)
634 {
635 pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
636 activeFace = GL_FRONT;
637 }
638
639 pState->diff_api.StencilFuncSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].func,
640 to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].ref,
641 to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].mask);
642 CR_STATE_STENCIL_FUNC_COPY(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_BACK);
643 backIsSet = GL_TRUE;
644 }
645 }
646 }
647 CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_BACK].func, nbitID);
648 }
649
650 if (CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_TWO_SIDE_BACK].func, bitID))
651 {
652 if (!CR_STATE_STENCIL_FUNC_MATCH(from, CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK, to, CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK))
653 {
654 if (activeFace == GL_FRONT)
655 {
656 pState->diff_api.ActiveStencilFaceEXT(GL_BACK);
657 activeFace = GL_BACK;
658 }
659
660 pState->diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].func,
661 to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].ref,
662 to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].mask);
663 CR_STATE_STENCIL_FUNC_COPY(from, CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK, to, CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK);
664 }
665 CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_TWO_SIDE_BACK].func, nbitID);
666 }
667
668#undef CR_STATE_STENCIL_FUNC_FRONT_MATCH
669#undef CR_STATE_STENCIL_FUNC_BACK_MATCH
670#undef CR_STATE_STENCIL_FUNC_TO_FRONT_BACK_MATCH
671
672 /* op */
673 backIsSet = GL_FALSE, frontIsSet = GL_FALSE;
674 frontMatch = -1, backMatch = -1, toFrontBackMatch = -1;
675 frontBackDirty = CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK].op, bitID);
676 frontDirty = CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT].op, bitID);
677 backDirty = CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_BACK].op, bitID);
678
679#define CR_STATE_STENCIL_OP_FRONT_MATCH() ( \
680 frontMatch >= 0 ? \
681 frontMatch \
682 : (frontMatch = CR_STATE_STENCIL_OP_MATCH(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT)))
683
684#define CR_STATE_STENCIL_OP_BACK_MATCH() ( \
685 backMatch >= 0 ? \
686 backMatch \
687 : (backMatch = CR_STATE_STENCIL_OP_MATCH(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_BACK)))
688
689#define CR_STATE_STENCIL_OP_TO_FRONT_BACK_MATCH() ( \
690 toFrontBackMatch >= 0 ? \
691 toFrontBackMatch \
692 : (toFrontBackMatch = CR_STATE_STENCIL_OP_MATCH(to, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_BACK)))
693
694 if (frontBackDirty)
695 {
696 if (!CR_STATE_STENCIL_OP_FRONT_MATCH()
697 || !CR_STATE_STENCIL_OP_BACK_MATCH())
698 {
699 if (CR_STATE_STENCIL_OP_TO_FRONT_BACK_MATCH())
700 {
701 if (activeFace == GL_BACK)
702 {
703 pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
704 activeFace = GL_FRONT;
705 }
706
707 pState->diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
708 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail,
709 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass);
710
711 CR_STATE_STENCIL_OP_COPY(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT);
712 CR_STATE_STENCIL_OP_COPY(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_FRONT);
713
714 frontIsSet = GL_TRUE;
715 backIsSet = GL_TRUE;
716 }
717 else if (!CR_STATE_STENCIL_OP_FRONT_MATCH())
718 {
719 if (activeFace == GL_BACK)
720 {
721 pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
722 activeFace = GL_FRONT;
723 }
724
725 pState->diff_api.StencilOpSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
726 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail,
727 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass);
728 CR_STATE_STENCIL_OP_COPY(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT);
729 frontIsSet = GL_TRUE;
730 }
731 else if (!CR_STATE_STENCIL_OP_BACK_MATCH())
732 {
733 if (activeFace == GL_BACK)
734 {
735 pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
736 activeFace = GL_FRONT;
737 }
738
739 pState->diff_api.StencilOpSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].fail,
740 to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthFail,
741 to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthPass);
742 CR_STATE_STENCIL_OP_COPY(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_BACK);
743 backIsSet = GL_TRUE;
744 }
745 }
746
747 CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK].op, nbitID);
748 }
749
750 if (frontDirty)
751 {
752 if (!CR_STATE_STENCIL_OP_FRONT_MATCH())
753 {
754 if (CR_STATE_STENCIL_OP_TO_FRONT_BACK_MATCH())
755 {
756 if (!frontIsSet || !backIsSet)
757 {
758 if (activeFace == GL_BACK)
759 {
760 pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
761 activeFace = GL_FRONT;
762 }
763
764 pState->diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
765 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail,
766 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass);
767
768 CR_STATE_STENCIL_OP_COPY(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT);
769 CR_STATE_STENCIL_OP_COPY(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_FRONT);
770
771 frontIsSet = GL_TRUE;
772 backIsSet = GL_TRUE;
773 }
774 }
775 else if (!CR_STATE_STENCIL_OP_FRONT_MATCH())
776 {
777 if (!frontIsSet)
778 {
779 if (activeFace == GL_BACK)
780 {
781 pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
782 activeFace = GL_FRONT;
783 }
784
785 pState->diff_api.StencilOpSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
786 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail,
787 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass);
788
789 CR_STATE_STENCIL_OP_COPY(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT);
790
791 frontIsSet = GL_TRUE;
792 }
793 }
794 else if (!CR_STATE_STENCIL_OP_BACK_MATCH())
795 {
796 if (!backIsSet)
797 {
798 if (activeFace == GL_BACK)
799 {
800 pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
801 activeFace = GL_FRONT;
802 }
803
804 pState->diff_api.StencilOpSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].fail,
805 to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthFail,
806 to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthPass);
807 CR_STATE_STENCIL_OP_COPY(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_BACK);
808 backIsSet = GL_TRUE;
809 }
810 }
811 }
812 CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT].op, nbitID);
813 }
814
815
816 if (backDirty)
817 {
818 if (!CR_STATE_STENCIL_OP_FRONT_MATCH())
819 {
820 if (CR_STATE_STENCIL_OP_TO_FRONT_BACK_MATCH())
821 {
822 if (!frontIsSet || !backIsSet)
823 {
824 if (activeFace == GL_BACK)
825 {
826 pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
827 activeFace = GL_FRONT;
828 }
829
830 pState->diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
831 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail,
832 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass);
833
834 CR_STATE_STENCIL_OP_COPY(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT);
835 CR_STATE_STENCIL_OP_COPY(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_FRONT);
836
837 frontIsSet = GL_TRUE;
838 backIsSet = GL_TRUE;
839 }
840 }
841 else if (!CR_STATE_STENCIL_OP_FRONT_MATCH())
842 {
843 if (!frontIsSet)
844 {
845 if (activeFace == GL_BACK)
846 {
847 pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
848 activeFace = GL_FRONT;
849 }
850
851 pState->diff_api.StencilOpSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
852 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail,
853 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass);
854
855 CR_STATE_STENCIL_OP_COPY(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT);
856
857 frontIsSet = GL_TRUE;
858 }
859 }
860 else if (!CR_STATE_STENCIL_OP_BACK_MATCH())
861 {
862 if (!backIsSet)
863 {
864 if (activeFace == GL_BACK)
865 {
866 pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
867 activeFace = GL_FRONT;
868 }
869
870 pState->diff_api.StencilOpSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].fail,
871 to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthFail,
872 to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthPass);
873 CR_STATE_STENCIL_OP_COPY(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_BACK);
874 backIsSet = GL_TRUE;
875 }
876 }
877 }
878 CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_BACK].op, nbitID);
879 }
880
881 if (CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_TWO_SIDE_BACK].op, bitID))
882 {
883 if (!CR_STATE_STENCIL_OP_MATCH(from, CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK, to, CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK))
884 {
885 if (activeFace == GL_FRONT)
886 {
887 pState->diff_api.ActiveStencilFaceEXT(GL_BACK);
888 activeFace = GL_BACK;
889 }
890
891 pState->diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].fail,
892 to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].passDepthFail,
893 to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].passDepthPass);
894 CR_STATE_STENCIL_OP_COPY(from, CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK, to, CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK);
895 }
896 CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_TWO_SIDE_BACK].op, nbitID);
897 }
898
899#undef CR_STATE_STENCIL_OP_FRONT_MATCH
900#undef CR_STATE_STENCIL_OP_BACK_MATCH
901#undef CR_STATE_STENCIL_OP_TO_FRONT_BACK_MATCH
902
903
904 if (activeFace != to->activeStencilFace)
905 {
906 pState->diff_api.ActiveStencilFaceEXT(activeFace);
907 }
908
909 if (CHECKDIRTY(b->activeStencilFace, bitID))
910 {
911 if (from->activeStencilFace != to->activeStencilFace)
912 {
913 /* we already did it ( see above )*/
914 /* diff_api.ActiveStencilFaceEXT(to->activeStencilFace); */
915 from->activeStencilFace = to->activeStencilFace;
916 }
917 CLEARDIRTY(b->activeStencilFace, nbitID);
918 }
919
920 if (CHECKDIRTY(b->writeMask, bitID))
921 {
922 if (from->writeMask != to->writeMask)
923 {
924 pState->diff_api.StencilMask (to->writeMask);
925 from->writeMask = to->writeMask;
926 }
927 CLEARDIRTY(b->writeMask, nbitID);
928 }
929 CLEARDIRTY(b->dirty, nbitID);
930}
931
932void crStateStencilSwitch(CRStencilBits *b, CRbitvalue *bitID,
933 CRContext *fromCtx, CRContext *toCtx)
934{
935 PCRStateTracker pState = fromCtx->pStateTracker;
936 CRStencilState *from = &(fromCtx->stencil);
937 CRStencilState *to = &(toCtx->stencil);
938 unsigned int j, i;
939 GLenum activeFace;
940 GLboolean backIsSet = GL_FALSE, frontIsSet = GL_FALSE, frontBackDirty, frontDirty, backDirty;
941 GLchar frontMatch = -1, backMatch = -1, toFrontBackMatch = -1;
942 CRbitvalue nbitID[CR_MAX_BITARRAY];
943
944 CRASSERT(fromCtx->pStateTracker == toCtx->pStateTracker);
945
946 for (j=0;j<CR_MAX_BITARRAY;j++)
947 nbitID[j] = ~bitID[j];
948 i = 0; /* silence compiler */
949
950 if (CHECKDIRTY(b->enable, bitID))
951 {
952 glAble able[2];
953 able[0] = pState->diff_api.Disable;
954 able[1] = pState->diff_api.Enable;
955 if (from->stencilTest != to->stencilTest)
956 {
957 CRSTATE_CHECKGLERR(able[to->stencilTest](GL_STENCIL_TEST));
958 FILLDIRTY(b->enable);
959 FILLDIRTY(b->dirty);
960 }
961 CLEARDIRTY(b->enable, nbitID);
962 }
963 if (CHECKDIRTY(b->enableTwoSideEXT, bitID))
964 {
965 glAble able[2];
966 able[0] = pState->diff_api.Disable;
967 able[1] = pState->diff_api.Enable;
968 if (from->stencilTwoSideEXT != to->stencilTwoSideEXT)
969 {
970 CRSTATE_CHECKGLERR(able[to->stencilTwoSideEXT](GL_STENCIL_TEST_TWO_SIDE_EXT));
971 FILLDIRTY(b->enableTwoSideEXT);
972 FILLDIRTY(b->dirty);
973 }
974 CLEARDIRTY(b->enableTwoSideEXT, nbitID);
975 }
976 if (CHECKDIRTY(b->clearValue, bitID))
977 {
978 if (from->clearValue != to->clearValue)
979 {
980 CRSTATE_CHECKGLERR(pState->diff_api.ClearStencil (to->clearValue));
981 FILLDIRTY(b->clearValue);
982 FILLDIRTY(b->dirty);
983 }
984 CLEARDIRTY(b->clearValue, nbitID);
985 }
986
987 activeFace = from->activeStencilFace;
988
989 /* func */
990 frontBackDirty = CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK].func, bitID);
991 frontDirty = CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT].func, bitID);
992 backDirty = CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_BACK].func, bitID);
993#define CR_STATE_STENCIL_FUNC_FRONT_MATCH() ( \
994 frontMatch >= 0 ? \
995 frontMatch \
996 : (frontMatch = CR_STATE_STENCIL_FUNC_MATCH(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT)))
997
998#define CR_STATE_STENCIL_FUNC_BACK_MATCH() ( \
999 backMatch >= 0 ? \
1000 backMatch \
1001 : (backMatch = CR_STATE_STENCIL_FUNC_MATCH(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_BACK)))
1002
1003#define CR_STATE_STENCIL_FUNC_TO_FRONT_BACK_MATCH() ( \
1004 toFrontBackMatch >= 0 ? \
1005 toFrontBackMatch \
1006 : (toFrontBackMatch = CR_STATE_STENCIL_FUNC_MATCH(to, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_BACK)))
1007
1008 if (frontBackDirty)
1009 {
1010 if (!CR_STATE_STENCIL_FUNC_FRONT_MATCH()
1011 || !CR_STATE_STENCIL_FUNC_BACK_MATCH())
1012 {
1013 if (CR_STATE_STENCIL_FUNC_TO_FRONT_BACK_MATCH())
1014 {
1015 if (activeFace == GL_BACK)
1016 {
1017 pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
1018 activeFace = GL_FRONT;
1019 }
1020
1021 CRSTATE_CHECKGLERR(pState->diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
1022 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref,
1023 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask));
1024
1025 frontIsSet = GL_TRUE;
1026 backIsSet = GL_TRUE;
1027 }
1028 else if (!CR_STATE_STENCIL_FUNC_FRONT_MATCH())
1029 {
1030 if (activeFace == GL_BACK)
1031 {
1032 pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
1033 activeFace = GL_FRONT;
1034 }
1035
1036 CRSTATE_CHECKGLERR(pState->diff_api.StencilFuncSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
1037 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref,
1038 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask));
1039 frontIsSet = GL_TRUE;
1040 }
1041 else if (!CR_STATE_STENCIL_FUNC_BACK_MATCH())
1042 {
1043 if (activeFace == GL_BACK)
1044 {
1045 pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
1046 activeFace = GL_FRONT;
1047 }
1048
1049 CRSTATE_CHECKGLERR(pState->diff_api.StencilFuncSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].func,
1050 to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].ref,
1051 to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].mask));
1052 backIsSet = GL_TRUE;
1053 }
1054 FILLDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK].func);
1055 FILLDIRTY(b->dirty);
1056 }
1057
1058 CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK].func, nbitID);
1059 }
1060
1061 if (frontDirty)
1062 {
1063 if (!CR_STATE_STENCIL_FUNC_FRONT_MATCH())
1064 {
1065 if (CR_STATE_STENCIL_FUNC_TO_FRONT_BACK_MATCH())
1066 {
1067 if (!frontIsSet || !backIsSet)
1068 {
1069 if (activeFace == GL_BACK)
1070 {
1071 pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
1072 activeFace = GL_FRONT;
1073 }
1074
1075 CRSTATE_CHECKGLERR(pState->diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
1076 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref,
1077 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask));
1078
1079 frontIsSet = GL_TRUE;
1080 backIsSet = GL_TRUE;
1081 }
1082 }
1083 else if (!CR_STATE_STENCIL_FUNC_FRONT_MATCH())
1084 {
1085 if (!frontIsSet)
1086 {
1087 if (activeFace == GL_BACK)
1088 {
1089 pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
1090 activeFace = GL_FRONT;
1091 }
1092
1093 CRSTATE_CHECKGLERR(pState->diff_api.StencilFuncSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
1094 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref,
1095 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask));
1096 frontIsSet = GL_TRUE;
1097 }
1098 }
1099 else if (!CR_STATE_STENCIL_FUNC_BACK_MATCH())
1100 {
1101 if (!backIsSet)
1102 {
1103 if (activeFace == GL_BACK)
1104 {
1105 pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
1106 activeFace = GL_FRONT;
1107 }
1108
1109 CRSTATE_CHECKGLERR(pState->diff_api.StencilFuncSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].func,
1110 to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].ref,
1111 to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].mask));
1112 backIsSet = GL_TRUE;
1113 }
1114 }
1115 FILLDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT].func);
1116 FILLDIRTY(b->dirty);
1117 }
1118 CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT].func, nbitID);
1119 }
1120
1121
1122 if (backDirty)
1123 {
1124 if (!CR_STATE_STENCIL_FUNC_BACK_MATCH())
1125 {
1126 if (CR_STATE_STENCIL_FUNC_TO_FRONT_BACK_MATCH())
1127 {
1128 if (!frontIsSet || !backIsSet)
1129 {
1130 if (activeFace == GL_BACK)
1131 {
1132 pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
1133 activeFace = GL_FRONT;
1134 }
1135
1136 CRSTATE_CHECKGLERR(pState->diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
1137 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref,
1138 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask));
1139
1140 frontIsSet = GL_TRUE;
1141 backIsSet = GL_TRUE;
1142 }
1143 }
1144 else if (!CR_STATE_STENCIL_FUNC_FRONT_MATCH())
1145 {
1146 if (!frontIsSet)
1147 {
1148 if (activeFace == GL_BACK)
1149 {
1150 pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
1151 activeFace = GL_FRONT;
1152 }
1153
1154 CRSTATE_CHECKGLERR(pState->diff_api.StencilFuncSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func,
1155 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref,
1156 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask));
1157 frontIsSet = GL_TRUE;
1158 }
1159 }
1160 else if (!CR_STATE_STENCIL_FUNC_BACK_MATCH())
1161 {
1162 if (!backIsSet)
1163 {
1164 if (activeFace == GL_BACK)
1165 {
1166 pState->diff_api.ActiveStencilFaceEXT(GL_FRONT);
1167 activeFace = GL_FRONT;
1168 }
1169
1170 CRSTATE_CHECKGLERR(pState->diff_api.StencilFuncSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].func,
1171 to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].ref,
1172 to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].mask));
1173 backIsSet = GL_TRUE;
1174 }
1175 }
1176 FILLDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_BACK].func);
1177 FILLDIRTY(b->dirty);
1178 }
1179 CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_BACK].func, nbitID);
1180 }
1181
1182 if (CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_TWO_SIDE_BACK].func, bitID))
1183 {
1184 if (!CR_STATE_STENCIL_FUNC_MATCH(from, CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK, to, CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK))
1185 {
1186 if (activeFace == GL_FRONT)
1187 {
1188 CRSTATE_CHECKGLERR(pState->diff_api.ActiveStencilFaceEXT(GL_BACK));
1189 activeFace = GL_BACK;
1190 }
1191
1192 CRSTATE_CHECKGLERR(pState->diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].func,
1193 to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].ref,
1194 to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].mask));
1195
1196 FILLDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_TWO_SIDE_BACK].func);
1197 FILLDIRTY(b->dirty);
1198 }
1199 CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_TWO_SIDE_BACK].func, nbitID);
1200 }
1201
1202#undef CR_STATE_STENCIL_FUNC_FRONT_MATCH
1203#undef CR_STATE_STENCIL_FUNC_BACK_MATCH
1204#undef CR_STATE_STENCIL_FUNC_TO_FRONT_BACK_MATCH
1205
1206 /* op */
1207 backIsSet = GL_FALSE, frontIsSet = GL_FALSE;
1208 frontMatch = -1, backMatch = -1, toFrontBackMatch = -1;
1209 frontBackDirty = CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK].op, bitID);
1210 frontDirty = CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT].op, bitID);
1211 backDirty = CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_BACK].op, bitID);
1212
1213#define CR_STATE_STENCIL_OP_FRONT_MATCH() ( \
1214 frontMatch >= 0 ? \
1215 frontMatch \
1216 : (frontMatch = CR_STATE_STENCIL_OP_MATCH(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT)))
1217
1218#define CR_STATE_STENCIL_OP_BACK_MATCH() ( \
1219 backMatch >= 0 ? \
1220 backMatch \
1221 : (backMatch = CR_STATE_STENCIL_OP_MATCH(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_BACK)))
1222
1223#define CR_STATE_STENCIL_OP_TO_FRONT_BACK_MATCH() ( \
1224 toFrontBackMatch >= 0 ? \
1225 toFrontBackMatch \
1226 : (toFrontBackMatch = CR_STATE_STENCIL_OP_MATCH(to, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_BACK)))
1227
1228 if (frontBackDirty)
1229 {
1230 if (!CR_STATE_STENCIL_OP_FRONT_MATCH()
1231 || !CR_STATE_STENCIL_OP_BACK_MATCH())
1232 {
1233 if (CR_STATE_STENCIL_OP_TO_FRONT_BACK_MATCH())
1234 {
1235 if (activeFace == GL_BACK)
1236 {
1237 CRSTATE_CHECKGLERR(pState->diff_api.ActiveStencilFaceEXT(GL_FRONT));
1238 activeFace = GL_FRONT;
1239 }
1240
1241 CRSTATE_CHECKGLERR(pState->diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
1242 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail,
1243 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass));
1244
1245 frontIsSet = GL_TRUE;
1246 backIsSet = GL_TRUE;
1247 }
1248 else if (!CR_STATE_STENCIL_OP_FRONT_MATCH())
1249 {
1250 if (activeFace == GL_BACK)
1251 {
1252 CRSTATE_CHECKGLERR(pState->diff_api.ActiveStencilFaceEXT(GL_FRONT));
1253 activeFace = GL_FRONT;
1254 }
1255
1256 CRSTATE_CHECKGLERR(pState->diff_api.StencilOpSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
1257 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail,
1258 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass));
1259 frontIsSet = GL_TRUE;
1260 }
1261 else if (!CR_STATE_STENCIL_OP_BACK_MATCH())
1262 {
1263 if (activeFace == GL_BACK)
1264 {
1265 CRSTATE_CHECKGLERR(pState->diff_api.ActiveStencilFaceEXT(GL_FRONT));
1266 activeFace = GL_FRONT;
1267 }
1268
1269 CRSTATE_CHECKGLERR(pState->diff_api.StencilOpSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].fail,
1270 to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthFail,
1271 to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthPass));
1272 backIsSet = GL_TRUE;
1273 }
1274 FILLDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK].op);
1275 FILLDIRTY(b->dirty);
1276 }
1277
1278 CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK].op, nbitID);
1279 }
1280
1281 if (frontDirty)
1282 {
1283 if (!CR_STATE_STENCIL_OP_FRONT_MATCH())
1284 {
1285 if (CR_STATE_STENCIL_OP_TO_FRONT_BACK_MATCH())
1286 {
1287 if (!frontIsSet || !backIsSet)
1288 {
1289 if (activeFace == GL_BACK)
1290 {
1291 CRSTATE_CHECKGLERR(pState->diff_api.ActiveStencilFaceEXT(GL_FRONT));
1292 activeFace = GL_FRONT;
1293 }
1294
1295 CRSTATE_CHECKGLERR(pState->diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
1296 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail,
1297 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass));
1298
1299 frontIsSet = GL_TRUE;
1300 backIsSet = GL_TRUE;
1301 }
1302 }
1303 else if (!CR_STATE_STENCIL_OP_FRONT_MATCH())
1304 {
1305 if (!frontIsSet)
1306 {
1307 if (activeFace == GL_BACK)
1308 {
1309 CRSTATE_CHECKGLERR(pState->diff_api.ActiveStencilFaceEXT(GL_FRONT));
1310 activeFace = GL_FRONT;
1311 }
1312
1313 CRSTATE_CHECKGLERR(pState->diff_api.StencilOpSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
1314 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail,
1315 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass));
1316 frontIsSet = GL_TRUE;
1317 }
1318 }
1319 else if (!CR_STATE_STENCIL_OP_BACK_MATCH())
1320 {
1321 if (!backIsSet)
1322 {
1323 if (activeFace == GL_BACK)
1324 {
1325 CRSTATE_CHECKGLERR(pState->diff_api.ActiveStencilFaceEXT(GL_FRONT));
1326 activeFace = GL_FRONT;
1327 }
1328
1329 CRSTATE_CHECKGLERR(pState->diff_api.StencilOpSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].fail,
1330 to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthFail,
1331 to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthPass));
1332 backIsSet = GL_TRUE;
1333 }
1334 }
1335
1336 FILLDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT].op);
1337 FILLDIRTY(b->dirty);
1338 }
1339 CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT].op, nbitID);
1340 }
1341
1342
1343 if (backDirty)
1344 {
1345 if (!CR_STATE_STENCIL_OP_BACK_MATCH())
1346 {
1347 if (CR_STATE_STENCIL_OP_TO_FRONT_BACK_MATCH())
1348 {
1349 if (!frontIsSet || !backIsSet)
1350 {
1351 if (activeFace == GL_BACK)
1352 {
1353 CRSTATE_CHECKGLERR(pState->diff_api.ActiveStencilFaceEXT(GL_FRONT));
1354 activeFace = GL_FRONT;
1355 }
1356
1357 CRSTATE_CHECKGLERR(pState->diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
1358 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail,
1359 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass));
1360
1361 frontIsSet = GL_TRUE;
1362 backIsSet = GL_TRUE;
1363 }
1364 }
1365 else if (!CR_STATE_STENCIL_OP_FRONT_MATCH())
1366 {
1367 if (!frontIsSet)
1368 {
1369 if (activeFace == GL_BACK)
1370 {
1371 CRSTATE_CHECKGLERR(pState->diff_api.ActiveStencilFaceEXT(GL_FRONT));
1372 activeFace = GL_FRONT;
1373 }
1374
1375 CRSTATE_CHECKGLERR(pState->diff_api.StencilOpSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail,
1376 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail,
1377 to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass));
1378 frontIsSet = GL_TRUE;
1379 }
1380 }
1381 else if (!CR_STATE_STENCIL_OP_BACK_MATCH())
1382 {
1383 if (!backIsSet)
1384 {
1385 if (activeFace == GL_BACK)
1386 {
1387 CRSTATE_CHECKGLERR(pState->diff_api.ActiveStencilFaceEXT(GL_FRONT));
1388 activeFace = GL_FRONT;
1389 }
1390
1391 CRSTATE_CHECKGLERR(pState->diff_api.StencilOpSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].fail,
1392 to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthFail,
1393 to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthPass));
1394 backIsSet = GL_TRUE;
1395 }
1396 }
1397
1398 FILLDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_BACK].op);
1399 FILLDIRTY(b->dirty);
1400 }
1401 CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_BACK].op, nbitID);
1402 }
1403
1404 if (CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_TWO_SIDE_BACK].op, bitID))
1405 {
1406 if (!CR_STATE_STENCIL_OP_MATCH(from, CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK, to, CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK))
1407 {
1408 if (activeFace == GL_FRONT)
1409 {
1410 CRSTATE_CHECKGLERR(pState->diff_api.ActiveStencilFaceEXT(GL_BACK));
1411 activeFace = GL_BACK;
1412 }
1413
1414 CRSTATE_CHECKGLERR(pState->diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].fail,
1415 to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].passDepthFail,
1416 to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].passDepthPass));
1417
1418 FILLDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_TWO_SIDE_BACK].op);
1419 FILLDIRTY(b->dirty);
1420 }
1421 CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_TWO_SIDE_BACK].op, nbitID);
1422 }
1423
1424#undef CR_STATE_STENCIL_OP_FRONT_MATCH
1425#undef CR_STATE_STENCIL_OP_BACK_MATCH
1426#undef CR_STATE_STENCIL_OP_TO_FRONT_BACK_MATCH
1427
1428 if (activeFace != to->activeStencilFace)
1429 {
1430 CRSTATE_CHECKGLERR(pState->diff_api.ActiveStencilFaceEXT(activeFace));
1431 }
1432
1433 if (CHECKDIRTY(b->activeStencilFace, bitID))
1434 {
1435 if (from->activeStencilFace != to->activeStencilFace)
1436 {
1437 /* we already did it ( see above )*/
1438 /* diff_api.ActiveStencilFaceEXT(to->activeStencilFace); */
1439 FILLDIRTY(b->activeStencilFace);
1440 FILLDIRTY(b->dirty);
1441 }
1442 CLEARDIRTY(b->activeStencilFace, nbitID);
1443 }
1444
1445 if (CHECKDIRTY(b->writeMask, bitID))
1446 {
1447 if (from->writeMask != to->writeMask)
1448 {
1449 CRSTATE_CHECKGLERR(pState->diff_api.StencilMask (to->writeMask));
1450 FILLDIRTY(b->writeMask);
1451 FILLDIRTY(b->dirty);
1452 }
1453 CLEARDIRTY(b->writeMask, nbitID);
1454 }
1455
1456 CLEARDIRTY(b->dirty, nbitID);
1457}
1458
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette