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 | #ifdef CHROMIUM_THREADSAFE
|
---|
49 | #include "cr_threads.h"
|
---|
50 | #endif
|
---|
51 |
|
---|
52 | #include <iprt/cdefs.h>
|
---|
53 |
|
---|
54 | #ifndef IN_GUEST
|
---|
55 | # include <VBox/vmm/ssm.h>
|
---|
56 | #endif
|
---|
57 |
|
---|
58 | #define CR_MAX_EXTENTS 256
|
---|
59 |
|
---|
60 | #ifdef __cplusplus
|
---|
61 | extern "C" {
|
---|
62 | #endif
|
---|
63 |
|
---|
64 | /**
|
---|
65 | * Bit vectors describing GL state
|
---|
66 | */
|
---|
67 | typedef struct {
|
---|
68 | CRAttribBits attrib;
|
---|
69 | CRBufferBits buffer;
|
---|
70 | #ifdef CR_ARB_vertex_buffer_object
|
---|
71 | CRBufferObjectBits bufferobject;
|
---|
72 | #endif
|
---|
73 | CRClientBits client;
|
---|
74 | CRCurrentBits current;
|
---|
75 | CREvaluatorBits eval;
|
---|
76 | CRFeedbackBits feedback;
|
---|
77 | CRFogBits fog;
|
---|
78 | CRHintBits hint;
|
---|
79 | CRLightingBits lighting;
|
---|
80 | CRLineBits line;
|
---|
81 | CRListsBits lists;
|
---|
82 | CRMultisampleBits multisample;
|
---|
83 | #if CR_ARB_occlusion_query
|
---|
84 | CROcclusionBits occlusion;
|
---|
85 | #endif
|
---|
86 | CRPixelBits pixel;
|
---|
87 | CRPointBits point;
|
---|
88 | CRPolygonBits polygon;
|
---|
89 | CRProgramBits program;
|
---|
90 | CRRegCombinerBits regcombiner;
|
---|
91 | CRSelectionBits selection;
|
---|
92 | CRStencilBits stencil;
|
---|
93 | CRTextureBits texture;
|
---|
94 | CRTransformBits transform;
|
---|
95 | CRViewportBits viewport;
|
---|
96 | } CRStateBits;
|
---|
97 |
|
---|
98 | typedef void (*CRStateFlushFunc)( void *arg );
|
---|
99 |
|
---|
100 |
|
---|
101 | typedef struct _CRSharedState {
|
---|
102 | CRHashTable *textureTable; /* all texture objects */
|
---|
103 | CRHashTable *dlistTable; /* all display lists */
|
---|
104 | CRHashTable *buffersTable; /* vbo/pbo */
|
---|
105 | CRHashTable *fbTable; /* frame buffers */
|
---|
106 | CRHashTable *rbTable; /* render buffers */
|
---|
107 |
|
---|
108 | GLint refCount;
|
---|
109 | GLint id; /*unique shared state id, it's not always matching some existing context id!*/
|
---|
110 | GLint saveCount;
|
---|
111 |
|
---|
112 | /* Indicates that we have to resend data to GPU on first glMakeCurrent call with owning context */
|
---|
113 | GLboolean bTexResyncNeeded;
|
---|
114 | GLboolean bVBOResyncNeeded;
|
---|
115 | GLboolean bFBOResyncNeeded;
|
---|
116 | } CRSharedState;
|
---|
117 |
|
---|
118 |
|
---|
119 | /**
|
---|
120 | * Chromium version of the state variables in OpenGL
|
---|
121 | */
|
---|
122 | struct CRContext {
|
---|
123 | int id;
|
---|
124 |
|
---|
125 | #ifdef CHROMIUM_THREADSAFE
|
---|
126 | /* we keep reference counting of context's makeCurrent for different threads
|
---|
127 | * this is primarily needed to avoid having an invalid memory reference in the TLS
|
---|
128 | * when the context is assigned to more than one threads and then destroyed from
|
---|
129 | * one of those, i.e.
|
---|
130 | * 1. Thread1 -> MakeCurrent(ctx1);
|
---|
131 | * 2. Thread2 -> MakeCurrent(ctx1);
|
---|
132 | * 3. Thread1 -> Destroy(ctx1);
|
---|
133 | * => Thread2 still refers to destroyed ctx1
|
---|
134 | * */
|
---|
135 | CRTSDREFDATA
|
---|
136 | #endif
|
---|
137 |
|
---|
138 | CRbitvalue bitid[CR_MAX_BITARRAY];
|
---|
139 | CRbitvalue neg_bitid[CR_MAX_BITARRAY];
|
---|
140 |
|
---|
141 | CRSharedState *shared;
|
---|
142 |
|
---|
143 | GLenum renderMode;
|
---|
144 |
|
---|
145 | GLenum error;
|
---|
146 |
|
---|
147 | CRStateFlushFunc flush_func;
|
---|
148 | void *flush_arg;
|
---|
149 |
|
---|
150 | CRAttribState attrib;
|
---|
151 | CRBufferState buffer;
|
---|
152 | #ifdef CR_ARB_vertex_buffer_object
|
---|
153 | CRBufferObjectState bufferobject;
|
---|
154 | #endif
|
---|
155 | CRClientState client;
|
---|
156 | CRCurrentState current;
|
---|
157 | CREvaluatorState eval;
|
---|
158 | CRExtensionState extensions;
|
---|
159 | CRFeedbackState feedback;
|
---|
160 | CRFogState fog;
|
---|
161 | CRHintState hint;
|
---|
162 | CRLightingState lighting;
|
---|
163 | CRLimitsState limits;
|
---|
164 | CRLineState line;
|
---|
165 | CRListsState lists;
|
---|
166 | CRMultisampleState multisample;
|
---|
167 | #if CR_ARB_occlusion_query
|
---|
168 | CROcclusionState occlusion;
|
---|
169 | #endif
|
---|
170 | CRPixelState pixel;
|
---|
171 | CRPointState point;
|
---|
172 | CRPolygonState polygon;
|
---|
173 | CRProgramState program;
|
---|
174 | CRRegCombinerState regcombiner;
|
---|
175 | CRSelectionState selection;
|
---|
176 | CRStencilState stencil;
|
---|
177 | CRTextureState texture;
|
---|
178 | CRTransformState transform;
|
---|
179 | CRViewportState viewport;
|
---|
180 |
|
---|
181 | #ifdef CR_EXT_framebuffer_object
|
---|
182 | CRFramebufferObjectState framebufferobject;
|
---|
183 | #endif
|
---|
184 |
|
---|
185 | #ifdef CR_OPENGL_VERSION_2_0
|
---|
186 | CRGLSLState glsl;
|
---|
187 | #endif
|
---|
188 |
|
---|
189 | /** For buffering vertices for selection/feedback */
|
---|
190 | /*@{*/
|
---|
191 | GLuint vCount;
|
---|
192 | CRVertex vBuffer[4];
|
---|
193 | GLboolean lineReset;
|
---|
194 | GLboolean lineLoop;
|
---|
195 | /*@}*/
|
---|
196 | };
|
---|
197 |
|
---|
198 |
|
---|
199 | DECLEXPORT(void) crStateInit(void);
|
---|
200 | DECLEXPORT(void) crStateDestroy(void);
|
---|
201 | DECLEXPORT(void) crStateOnThreadAttachDetach(GLboolean attach);
|
---|
202 | DECLEXPORT(CRContext *) crStateCreateContext(const CRLimitsState *limits, GLint visBits, CRContext *share);
|
---|
203 | DECLEXPORT(CRContext *) crStateCreateContextEx(const CRLimitsState *limits, GLint visBits, CRContext *share, GLint presetID);
|
---|
204 | DECLEXPORT(void) crStateMakeCurrent(CRContext *ctx);
|
---|
205 | DECLEXPORT(void) crStateSetCurrent(CRContext *ctx);
|
---|
206 | DECLEXPORT(CRContext *) crStateGetCurrent(void);
|
---|
207 | DECLEXPORT(void) crStateDestroyContext(CRContext *ctx);
|
---|
208 |
|
---|
209 | DECLEXPORT(void) crStateFlushFunc( CRStateFlushFunc ff );
|
---|
210 | DECLEXPORT(void) crStateFlushArg( void *arg );
|
---|
211 | DECLEXPORT(void) crStateDiffAPI( SPUDispatchTable *api );
|
---|
212 | DECLEXPORT(void) crStateUpdateColorBits( void );
|
---|
213 |
|
---|
214 | DECLEXPORT(void) crStateSetCurrentPointers( CRContext *ctx, CRCurrentStatePointers *current );
|
---|
215 | DECLEXPORT(void) crStateResetCurrentPointers( CRCurrentStatePointers *current );
|
---|
216 |
|
---|
217 | DECLEXPORT(void) crStateSetExtensionString( CRContext *ctx, const GLubyte *extensions );
|
---|
218 |
|
---|
219 | DECLEXPORT(void) crStateDiffContext( CRContext *from, CRContext *to );
|
---|
220 | DECLEXPORT(void) crStateSwitchContext( CRContext *from, CRContext *to );
|
---|
221 | DECLEXPORT(void) crStateApplyFBImage(CRContext *to);
|
---|
222 |
|
---|
223 | #ifndef IN_GUEST
|
---|
224 | DECLEXPORT(int32_t) crStateSaveContext(CRContext *pContext, PSSMHANDLE pSSM);
|
---|
225 | DECLEXPORT(int32_t) crStateLoadContext(CRContext *pContext, CRHashTable * pCtxTable, PSSMHANDLE pSSM);
|
---|
226 | DECLEXPORT(void) crStateFreeShared(CRSharedState *s);
|
---|
227 | #endif
|
---|
228 |
|
---|
229 |
|
---|
230 | /* XXX move these! */
|
---|
231 |
|
---|
232 | DECLEXPORT(void) STATE_APIENTRY
|
---|
233 | crStateChromiumParameteriCR( GLenum target, GLint value );
|
---|
234 |
|
---|
235 | DECLEXPORT(void) STATE_APIENTRY
|
---|
236 | crStateChromiumParameterfCR( GLenum target, GLfloat value );
|
---|
237 |
|
---|
238 | DECLEXPORT(void) STATE_APIENTRY
|
---|
239 | crStateChromiumParametervCR( GLenum target, GLenum type, GLsizei count, const GLvoid *values );
|
---|
240 |
|
---|
241 | DECLEXPORT(void) STATE_APIENTRY
|
---|
242 | crStateGetChromiumParametervCR( GLenum target, GLuint index, GLenum type,
|
---|
243 | GLsizei count, GLvoid *values );
|
---|
244 |
|
---|
245 | DECLEXPORT(void) STATE_APIENTRY
|
---|
246 | crStateReadPixels( GLint x, GLint y, GLsizei width, GLsizei height,
|
---|
247 | GLenum format, GLenum type, GLvoid *pixels );
|
---|
248 |
|
---|
249 | DECLEXPORT(void) STATE_APIENTRY crStateShareContext(GLboolean value);
|
---|
250 | DECLEXPORT(void) STATE_APIENTRY crStateSetSharedContext(CRContext *pCtx);
|
---|
251 | DECLEXPORT(GLboolean) STATE_APIENTRY crStateContextIsShared(CRContext *pCtx);
|
---|
252 |
|
---|
253 | DECLEXPORT(void) STATE_APIENTRY crStateQueryHWState();
|
---|
254 | #ifdef __cplusplus
|
---|
255 | }
|
---|
256 | #endif
|
---|
257 |
|
---|
258 | #endif /* CR_GLSTATE_H */
|
---|