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 | #ifndef CR_STATE_STENCIL_H
|
---|
8 | #define CR_STATE_STENCIL_H
|
---|
9 |
|
---|
10 | #include "cr_glstate.h"
|
---|
11 | #include "state/cr_statetypes.h"
|
---|
12 |
|
---|
13 | #include <iprt/cdefs.h>
|
---|
14 | #include <iprt/assert.h>
|
---|
15 |
|
---|
16 | #ifdef __cplusplus
|
---|
17 | extern "C" {
|
---|
18 | #endif
|
---|
19 |
|
---|
20 | #define CRSTATE_STENCIL_BUFFER_ID_FRONT 0
|
---|
21 | #define CRSTATE_STENCIL_BUFFER_ID_BACK 1
|
---|
22 | #define CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK 2
|
---|
23 | #define CRSTATE_STENCIL_BUFFER_COUNT 3
|
---|
24 |
|
---|
25 | /* stencil buffer settings were accessed with StencilXxx with ActiveStencilFaceEXT == GL_FRONT or StencilXxxSeparate(GL_FRONT_AND_BACK) */
|
---|
26 | #define CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK 0
|
---|
27 | /* stencil buffer settings were accessed with StencilXxxSeparate(GL_FRONT_FRONT) */
|
---|
28 | #define CRSTATE_STENCIL_BUFFER_REF_ID_FRONT 1
|
---|
29 | /* stencil buffer settings were accessed with StencilXxxSeparate(GL_FRONT_BACK) */
|
---|
30 | #define CRSTATE_STENCIL_BUFFER_REF_ID_BACK 2
|
---|
31 | /* stencil buffer settings were accessed with StencilXxx with ActiveStencilFaceEXT == GL_BACK */
|
---|
32 | #define CRSTATE_STENCIL_BUFFER_REF_ID_TWO_SIDE_BACK 3
|
---|
33 | #define CRSTATE_STENCIL_BUFFER_REF_COUNT 4
|
---|
34 |
|
---|
35 | typedef struct {
|
---|
36 | CRbitvalue dirty[CR_MAX_BITARRAY];
|
---|
37 | CRbitvalue enable[CR_MAX_BITARRAY];
|
---|
38 | CRbitvalue func[CR_MAX_BITARRAY];
|
---|
39 | CRbitvalue op[CR_MAX_BITARRAY];
|
---|
40 | CRbitvalue clearValue[CR_MAX_BITARRAY];
|
---|
41 | CRbitvalue writeMask[CR_MAX_BITARRAY];
|
---|
42 | } CRStencilBits_v_33;
|
---|
43 |
|
---|
44 | typedef struct {
|
---|
45 | CRbitvalue func[CR_MAX_BITARRAY];
|
---|
46 | CRbitvalue op[CR_MAX_BITARRAY];
|
---|
47 | } CRStencilBufferRefBits;
|
---|
48 |
|
---|
49 | typedef struct {
|
---|
50 | CRbitvalue dirty[CR_MAX_BITARRAY];
|
---|
51 | CRbitvalue enable[CR_MAX_BITARRAY];
|
---|
52 | CRbitvalue enableTwoSideEXT[CR_MAX_BITARRAY];
|
---|
53 | CRbitvalue activeStencilFace[CR_MAX_BITARRAY];
|
---|
54 | CRbitvalue clearValue[CR_MAX_BITARRAY];
|
---|
55 | CRbitvalue writeMask[CR_MAX_BITARRAY];
|
---|
56 | /* note: here we use _BUFFER_REF_ rather than _REF_ because we track the way buffers are accessed here,
|
---|
57 | * to ensure the correct function is called on hw->chromium state restoration,
|
---|
58 | * i.e. we want to avoid always calling StencilXxxSeparate, but call StencilXxx when it was actually called */
|
---|
59 | CRStencilBufferRefBits bufferRefs[CRSTATE_STENCIL_BUFFER_REF_COUNT];
|
---|
60 | } CRStencilBits;
|
---|
61 |
|
---|
62 | typedef struct {
|
---|
63 | GLboolean stencilTest;
|
---|
64 | GLenum func;
|
---|
65 | GLint mask;
|
---|
66 | GLint ref;
|
---|
67 | GLenum fail;
|
---|
68 | GLenum passDepthFail;
|
---|
69 | GLenum passDepthPass;
|
---|
70 | GLint clearValue;
|
---|
71 | GLint writeMask;
|
---|
72 | } CRStencilState_v_33;
|
---|
73 |
|
---|
74 | typedef struct {
|
---|
75 | GLenum func;
|
---|
76 | GLint mask;
|
---|
77 | GLint ref;
|
---|
78 | GLenum fail;
|
---|
79 | GLenum passDepthFail;
|
---|
80 | GLenum passDepthPass;
|
---|
81 | } CRStencilBufferState;
|
---|
82 |
|
---|
83 | typedef struct {
|
---|
84 | /* true if stencil test is enabled */
|
---|
85 | GLboolean stencilTest;
|
---|
86 | /* true if GL_EXT_stencil_two_side is enabled (glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT)) */
|
---|
87 | GLboolean stencilTwoSideEXT;
|
---|
88 | /* GL_FRONT or GL_BACK */
|
---|
89 | GLenum activeStencilFace;
|
---|
90 | GLint clearValue;
|
---|
91 | GLint writeMask;
|
---|
92 | CRStencilBufferState buffers[CRSTATE_STENCIL_BUFFER_COUNT];
|
---|
93 | } CRStencilState;
|
---|
94 |
|
---|
95 | DECLEXPORT(void) crStateStencilInit(CRContext *ctx);
|
---|
96 | DECLEXPORT(void) crStateStencilBufferInit(CRStencilBufferState *s);
|
---|
97 |
|
---|
98 | DECLEXPORT(void) crStateStencilDiff(CRStencilBits *bb, CRbitvalue *bitID,
|
---|
99 | CRContext *fromCtx, CRContext *toCtx);
|
---|
100 | DECLEXPORT(void) crStateStencilSwitch(CRStencilBits *bb, CRbitvalue *bitID,
|
---|
101 | CRContext *fromCtx, CRContext *toCtx);
|
---|
102 |
|
---|
103 | #ifdef __cplusplus
|
---|
104 | }
|
---|
105 | #endif
|
---|
106 |
|
---|
107 | #endif /* CR_STATE_STENCIL_H */
|
---|