VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/include/cr_glstate.h@ 39578

Last change on this file since 39578 was 39568, checked in by vboxsync, 13 years ago

crOpenGL: more threading fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 7.5 KB
Line 
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 */
11struct CRContext;
12typedef 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
61extern "C" {
62#endif
63
64/**
65 * Bit vectors describing GL state
66 */
67typedef 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
98typedef void (*CRStateFlushFunc)( void *arg );
99
100
101typedef 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 */
122struct 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
199DECLEXPORT(void) crStateInit(void);
200DECLEXPORT(void) crStateDestroy(void);
201DECLEXPORT(void) crStateOnThreadAttachDetach(GLboolean attach);
202DECLEXPORT(CRContext *) crStateCreateContext(const CRLimitsState *limits, GLint visBits, CRContext *share);
203DECLEXPORT(CRContext *) crStateCreateContextEx(const CRLimitsState *limits, GLint visBits, CRContext *share, GLint presetID);
204DECLEXPORT(void) crStateMakeCurrent(CRContext *ctx);
205DECLEXPORT(void) crStateSetCurrent(CRContext *ctx);
206DECLEXPORT(CRContext *) crStateGetCurrent(void);
207DECLEXPORT(void) crStateDestroyContext(CRContext *ctx);
208
209DECLEXPORT(void) crStateFlushFunc( CRStateFlushFunc ff );
210DECLEXPORT(void) crStateFlushArg( void *arg );
211DECLEXPORT(void) crStateDiffAPI( SPUDispatchTable *api );
212DECLEXPORT(void) crStateUpdateColorBits( void );
213
214DECLEXPORT(void) crStateSetCurrentPointers( CRContext *ctx, CRCurrentStatePointers *current );
215DECLEXPORT(void) crStateResetCurrentPointers( CRCurrentStatePointers *current );
216
217DECLEXPORT(void) crStateSetExtensionString( CRContext *ctx, const GLubyte *extensions );
218
219DECLEXPORT(void) crStateDiffContext( CRContext *from, CRContext *to );
220DECLEXPORT(void) crStateSwitchContext( CRContext *from, CRContext *to );
221DECLEXPORT(void) crStateApplyFBImage(CRContext *to);
222
223#ifndef IN_GUEST
224DECLEXPORT(int32_t) crStateSaveContext(CRContext *pContext, PSSMHANDLE pSSM);
225DECLEXPORT(int32_t) crStateLoadContext(CRContext *pContext, CRHashTable * pCtxTable, PSSMHANDLE pSSM);
226DECLEXPORT(void) crStateFreeShared(CRSharedState *s);
227#endif
228
229
230 /* XXX move these! */
231
232DECLEXPORT(void) STATE_APIENTRY
233crStateChromiumParameteriCR( GLenum target, GLint value );
234
235DECLEXPORT(void) STATE_APIENTRY
236crStateChromiumParameterfCR( GLenum target, GLfloat value );
237
238DECLEXPORT(void) STATE_APIENTRY
239crStateChromiumParametervCR( GLenum target, GLenum type, GLsizei count, const GLvoid *values );
240
241DECLEXPORT(void) STATE_APIENTRY
242crStateGetChromiumParametervCR( GLenum target, GLuint index, GLenum type,
243 GLsizei count, GLvoid *values );
244
245DECLEXPORT(void) STATE_APIENTRY
246crStateReadPixels( GLint x, GLint y, GLsizei width, GLsizei height,
247 GLenum format, GLenum type, GLvoid *pixels );
248
249DECLEXPORT(void) STATE_APIENTRY crStateShareContext(GLboolean value);
250DECLEXPORT(void) STATE_APIENTRY crStateSetSharedContext(CRContext *pCtx);
251DECLEXPORT(GLboolean) STATE_APIENTRY crStateContextIsShared(CRContext *pCtx);
252
253DECLEXPORT(void) STATE_APIENTRY crStateQueryHWState();
254#ifdef __cplusplus
255}
256#endif
257
258#endif /* CR_GLSTATE_H */
Note: See TracBrowser for help on using the repository browser.

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