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_GLSTATE_H
|
---|
8 | #define CR_GLSTATE_H
|
---|
9 |
|
---|
10 | /* Forward declaration since some of the state/cr_*.h files need the CRContext type */
|
---|
11 | struct CRContext;
|
---|
12 | typedef struct CRContext CRContext;
|
---|
13 |
|
---|
14 | #include "cr_version.h"
|
---|
15 |
|
---|
16 | #include "state/cr_buffer.h"
|
---|
17 | #include "state/cr_bufferobject.h"
|
---|
18 | #include "state/cr_client.h"
|
---|
19 | #include "state/cr_current.h"
|
---|
20 | #include "state/cr_evaluators.h"
|
---|
21 | #include "state/cr_feedback.h"
|
---|
22 | #include "state/cr_fog.h"
|
---|
23 | #include "state/cr_hint.h"
|
---|
24 | #include "state/cr_lighting.h"
|
---|
25 | #include "state/cr_limits.h"
|
---|
26 | #include "state/cr_line.h"
|
---|
27 | #include "state/cr_lists.h"
|
---|
28 | #include "state/cr_multisample.h"
|
---|
29 | #include "state/cr_occlude.h"
|
---|
30 | #include "state/cr_pixel.h"
|
---|
31 | #include "state/cr_point.h"
|
---|
32 | #include "state/cr_polygon.h"
|
---|
33 | #include "state/cr_program.h"
|
---|
34 | #include "state/cr_regcombiner.h"
|
---|
35 | #include "state/cr_stencil.h"
|
---|
36 | #include "state/cr_texture.h"
|
---|
37 | #include "state/cr_transform.h"
|
---|
38 | #include "state/cr_viewport.h"
|
---|
39 | #include "state/cr_attrib.h"
|
---|
40 | #include "state/cr_framebuffer.h"
|
---|
41 | #include "state/cr_glsl.h"
|
---|
42 |
|
---|
43 | #include "state/cr_statefuncs.h"
|
---|
44 | #include "state/cr_stateerror.h"
|
---|
45 |
|
---|
46 | #include "spu_dispatch_table.h"
|
---|
47 |
|
---|
48 | #include <iprt/cdefs.h>
|
---|
49 |
|
---|
50 | #ifndef IN_GUEST
|
---|
51 | # include <VBox/vmm/ssm.h>
|
---|
52 | #endif
|
---|
53 |
|
---|
54 | #define CR_MAX_EXTENTS 256
|
---|
55 |
|
---|
56 | #ifdef __cplusplus
|
---|
57 | extern "C" {
|
---|
58 | #endif
|
---|
59 |
|
---|
60 | /**
|
---|
61 | * Bit vectors describing GL state
|
---|
62 | */
|
---|
63 | typedef struct {
|
---|
64 | CRAttribBits attrib;
|
---|
65 | CRBufferBits buffer;
|
---|
66 | #ifdef CR_ARB_vertex_buffer_object
|
---|
67 | CRBufferObjectBits bufferobject;
|
---|
68 | #endif
|
---|
69 | CRClientBits client;
|
---|
70 | CRCurrentBits current;
|
---|
71 | CREvaluatorBits eval;
|
---|
72 | CRFeedbackBits feedback;
|
---|
73 | CRFogBits fog;
|
---|
74 | CRHintBits hint;
|
---|
75 | CRLightingBits lighting;
|
---|
76 | CRLineBits line;
|
---|
77 | CRListsBits lists;
|
---|
78 | CRMultisampleBits multisample;
|
---|
79 | #if CR_ARB_occlusion_query
|
---|
80 | CROcclusionBits occlusion;
|
---|
81 | #endif
|
---|
82 | CRPixelBits pixel;
|
---|
83 | CRPointBits point;
|
---|
84 | CRPolygonBits polygon;
|
---|
85 | CRProgramBits program;
|
---|
86 | CRRegCombinerBits regcombiner;
|
---|
87 | CRSelectionBits selection;
|
---|
88 | CRStencilBits stencil;
|
---|
89 | CRTextureBits texture;
|
---|
90 | CRTransformBits transform;
|
---|
91 | CRViewportBits viewport;
|
---|
92 | } CRStateBits;
|
---|
93 |
|
---|
94 | typedef void (*CRStateFlushFunc)( void *arg );
|
---|
95 |
|
---|
96 |
|
---|
97 | typedef struct _CRSharedState {
|
---|
98 | CRHashTable *textureTable; /* all texture objects */
|
---|
99 | CRHashTable *dlistTable; /* all display lists */
|
---|
100 | CRHashTable *buffersTable; /* vbo/pbo */
|
---|
101 | CRHashTable *fbTable; /* frame buffers */
|
---|
102 | CRHashTable *rbTable; /* render buffers */
|
---|
103 |
|
---|
104 | GLint refCount;
|
---|
105 | GLint id; /*unique shared state id, it's not always matching some existing context id!*/
|
---|
106 | GLint saveCount;
|
---|
107 |
|
---|
108 | /* Indicates that we have to resend data to GPU on first glMakeCurrent call with owning context */
|
---|
109 | GLboolean bTexResyncNeeded;
|
---|
110 | GLboolean bVBOResyncNeeded;
|
---|
111 | GLboolean bFBOResyncNeeded;
|
---|
112 | } CRSharedState;
|
---|
113 |
|
---|
114 |
|
---|
115 | /**
|
---|
116 | * Chromium version of the state variables in OpenGL
|
---|
117 | */
|
---|
118 | struct CRContext {
|
---|
119 | int id;
|
---|
120 | CRbitvalue bitid[CR_MAX_BITARRAY];
|
---|
121 | CRbitvalue neg_bitid[CR_MAX_BITARRAY];
|
---|
122 |
|
---|
123 | CRSharedState *shared;
|
---|
124 |
|
---|
125 | GLenum renderMode;
|
---|
126 |
|
---|
127 | GLenum error;
|
---|
128 |
|
---|
129 | CRStateFlushFunc flush_func;
|
---|
130 | void *flush_arg;
|
---|
131 |
|
---|
132 | CRAttribState attrib;
|
---|
133 | CRBufferState buffer;
|
---|
134 | #ifdef CR_ARB_vertex_buffer_object
|
---|
135 | CRBufferObjectState bufferobject;
|
---|
136 | #endif
|
---|
137 | CRClientState client;
|
---|
138 | CRCurrentState current;
|
---|
139 | CREvaluatorState eval;
|
---|
140 | CRExtensionState extensions;
|
---|
141 | CRFeedbackState feedback;
|
---|
142 | CRFogState fog;
|
---|
143 | CRHintState hint;
|
---|
144 | CRLightingState lighting;
|
---|
145 | CRLimitsState limits;
|
---|
146 | CRLineState line;
|
---|
147 | CRListsState lists;
|
---|
148 | CRMultisampleState multisample;
|
---|
149 | #if CR_ARB_occlusion_query
|
---|
150 | CROcclusionState occlusion;
|
---|
151 | #endif
|
---|
152 | CRPixelState pixel;
|
---|
153 | CRPointState point;
|
---|
154 | CRPolygonState polygon;
|
---|
155 | CRProgramState program;
|
---|
156 | CRRegCombinerState regcombiner;
|
---|
157 | CRSelectionState selection;
|
---|
158 | CRStencilState stencil;
|
---|
159 | CRTextureState texture;
|
---|
160 | CRTransformState transform;
|
---|
161 | CRViewportState viewport;
|
---|
162 |
|
---|
163 | #ifdef CR_EXT_framebuffer_object
|
---|
164 | CRFramebufferObjectState framebufferobject;
|
---|
165 | #endif
|
---|
166 |
|
---|
167 | #ifdef CR_OPENGL_VERSION_2_0
|
---|
168 | CRGLSLState glsl;
|
---|
169 | #endif
|
---|
170 |
|
---|
171 | /*@todo add back buffer, depth and fbos and move out of here*/
|
---|
172 | GLvoid *pImage; /*stored front buffer image*/
|
---|
173 |
|
---|
174 | /** For buffering vertices for selection/feedback */
|
---|
175 | /*@{*/
|
---|
176 | GLuint vCount;
|
---|
177 | CRVertex vBuffer[4];
|
---|
178 | GLboolean lineReset;
|
---|
179 | GLboolean lineLoop;
|
---|
180 | /*@}*/
|
---|
181 | };
|
---|
182 |
|
---|
183 |
|
---|
184 | DECLEXPORT(void) crStateInit(void);
|
---|
185 | DECLEXPORT(void) crStateDestroy(void);
|
---|
186 | DECLEXPORT(CRContext *) crStateCreateContext(const CRLimitsState *limits, GLint visBits, CRContext *share);
|
---|
187 | DECLEXPORT(CRContext *) crStateCreateContextEx(const CRLimitsState *limits, GLint visBits, CRContext *share, GLint presetID);
|
---|
188 | DECLEXPORT(void) crStateMakeCurrent(CRContext *ctx);
|
---|
189 | DECLEXPORT(void) crStateSetCurrent(CRContext *ctx);
|
---|
190 | DECLEXPORT(CRContext *) crStateGetCurrent(void);
|
---|
191 | DECLEXPORT(void) crStateDestroyContext(CRContext *ctx);
|
---|
192 |
|
---|
193 | DECLEXPORT(void) crStateFlushFunc( CRStateFlushFunc ff );
|
---|
194 | DECLEXPORT(void) crStateFlushArg( void *arg );
|
---|
195 | DECLEXPORT(void) crStateDiffAPI( SPUDispatchTable *api );
|
---|
196 | DECLEXPORT(void) crStateUpdateColorBits( void );
|
---|
197 |
|
---|
198 | DECLEXPORT(void) crStateSetCurrentPointers( CRContext *ctx, CRCurrentStatePointers *current );
|
---|
199 | DECLEXPORT(void) crStateResetCurrentPointers( CRCurrentStatePointers *current );
|
---|
200 |
|
---|
201 | DECLEXPORT(void) crStateSetExtensionString( CRContext *ctx, const GLubyte *extensions );
|
---|
202 |
|
---|
203 | DECLEXPORT(void) crStateDiffContext( CRContext *from, CRContext *to );
|
---|
204 | DECLEXPORT(void) crStateSwitchContext( CRContext *from, CRContext *to );
|
---|
205 | DECLEXPORT(void) crStateApplyFBImage(CRContext *to);
|
---|
206 |
|
---|
207 | #ifndef IN_GUEST
|
---|
208 | DECLEXPORT(int32_t) crStateSaveContext(CRContext *pContext, PSSMHANDLE pSSM);
|
---|
209 | DECLEXPORT(int32_t) crStateLoadContext(CRContext *pContext, CRHashTable * pCtxTable, PSSMHANDLE pSSM);
|
---|
210 | DECLEXPORT(void) crStateFreeShared(CRSharedState *s);
|
---|
211 | #endif
|
---|
212 |
|
---|
213 |
|
---|
214 | /* XXX move these! */
|
---|
215 |
|
---|
216 | DECLEXPORT(void) STATE_APIENTRY
|
---|
217 | crStateChromiumParameteriCR( GLenum target, GLint value );
|
---|
218 |
|
---|
219 | DECLEXPORT(void) STATE_APIENTRY
|
---|
220 | crStateChromiumParameterfCR( GLenum target, GLfloat value );
|
---|
221 |
|
---|
222 | DECLEXPORT(void) STATE_APIENTRY
|
---|
223 | crStateChromiumParametervCR( GLenum target, GLenum type, GLsizei count, const GLvoid *values );
|
---|
224 |
|
---|
225 | DECLEXPORT(void) STATE_APIENTRY
|
---|
226 | crStateGetChromiumParametervCR( GLenum target, GLuint index, GLenum type,
|
---|
227 | GLsizei count, GLvoid *values );
|
---|
228 |
|
---|
229 | DECLEXPORT(void) STATE_APIENTRY
|
---|
230 | crStateReadPixels( GLint x, GLint y, GLsizei width, GLsizei height,
|
---|
231 | GLenum format, GLenum type, GLvoid *pixels );
|
---|
232 |
|
---|
233 | DECLEXPORT(void) STATE_APIENTRY crStateShareContext(GLboolean value);
|
---|
234 | DECLEXPORT(void) STATE_APIENTRY crStateSetSharedContext(CRContext *pCtx);
|
---|
235 | DECLEXPORT(GLboolean) STATE_APIENTRY crStateContextIsShared(CRContext *pCtx);
|
---|
236 |
|
---|
237 | DECLEXPORT(void) STATE_APIENTRY crStateQueryHWState();
|
---|
238 | #ifdef __cplusplus
|
---|
239 | }
|
---|
240 | #endif
|
---|
241 |
|
---|
242 | #endif /* CR_GLSTATE_H */
|
---|