VirtualBox

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

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

crOpenGL: fix destroyed context refference in TLS

  • 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#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
57extern "C" {
58#endif
59
60/**
61 * Bit vectors describing GL state
62 */
63typedef 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
94typedef void (*CRStateFlushFunc)( void *arg );
95
96
97typedef 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 */
118struct CRContext {
119 int id;
120
121#ifdef CHROMIUM_THREADSAFE
122 /* we keep reference counting of context's makeCurrent for different threads
123 * this is primarily needed to avoid having an invalid memory reference in the TLS
124 * when the context is assigned to more than one threads and then destroyed from
125 * one of those, i.e.
126 * 1. Thread1 -> MakeCurrent(ctx1);
127 * 2. Thread2 -> MakeCurrent(ctx1);
128 * 3. Thread1 -> Destroy(ctx1);
129 * => Thread2 still refers to destroyed ctx1
130 * */
131 /* number of threads that have context set as current */
132 volatile int cRefs;
133#endif
134
135 CRbitvalue bitid[CR_MAX_BITARRAY];
136 CRbitvalue neg_bitid[CR_MAX_BITARRAY];
137
138 CRSharedState *shared;
139
140 GLenum renderMode;
141
142 GLenum error;
143
144 CRStateFlushFunc flush_func;
145 void *flush_arg;
146
147 CRAttribState attrib;
148 CRBufferState buffer;
149#ifdef CR_ARB_vertex_buffer_object
150 CRBufferObjectState bufferobject;
151#endif
152 CRClientState client;
153 CRCurrentState current;
154 CREvaluatorState eval;
155 CRExtensionState extensions;
156 CRFeedbackState feedback;
157 CRFogState fog;
158 CRHintState hint;
159 CRLightingState lighting;
160 CRLimitsState limits;
161 CRLineState line;
162 CRListsState lists;
163 CRMultisampleState multisample;
164#if CR_ARB_occlusion_query
165 CROcclusionState occlusion;
166#endif
167 CRPixelState pixel;
168 CRPointState point;
169 CRPolygonState polygon;
170 CRProgramState program;
171 CRRegCombinerState regcombiner;
172 CRSelectionState selection;
173 CRStencilState stencil;
174 CRTextureState texture;
175 CRTransformState transform;
176 CRViewportState viewport;
177
178#ifdef CR_EXT_framebuffer_object
179 CRFramebufferObjectState framebufferobject;
180#endif
181
182#ifdef CR_OPENGL_VERSION_2_0
183 CRGLSLState glsl;
184#endif
185
186 /** For buffering vertices for selection/feedback */
187 /*@{*/
188 GLuint vCount;
189 CRVertex vBuffer[4];
190 GLboolean lineReset;
191 GLboolean lineLoop;
192 /*@}*/
193};
194
195
196DECLEXPORT(void) crStateInit(void);
197DECLEXPORT(void) crStateDestroy(void);
198DECLEXPORT(void) crStateOnThreadAttachDetach(GLboolean attach);
199DECLEXPORT(CRContext *) crStateCreateContext(const CRLimitsState *limits, GLint visBits, CRContext *share);
200DECLEXPORT(CRContext *) crStateCreateContextEx(const CRLimitsState *limits, GLint visBits, CRContext *share, GLint presetID);
201DECLEXPORT(void) crStateMakeCurrent(CRContext *ctx);
202DECLEXPORT(void) crStateSetCurrent(CRContext *ctx);
203DECLEXPORT(CRContext *) crStateGetCurrent(void);
204DECLEXPORT(void) crStateDestroyContext(CRContext *ctx);
205
206DECLEXPORT(void) crStateFlushFunc( CRStateFlushFunc ff );
207DECLEXPORT(void) crStateFlushArg( void *arg );
208DECLEXPORT(void) crStateDiffAPI( SPUDispatchTable *api );
209DECLEXPORT(void) crStateUpdateColorBits( void );
210
211DECLEXPORT(void) crStateSetCurrentPointers( CRContext *ctx, CRCurrentStatePointers *current );
212DECLEXPORT(void) crStateResetCurrentPointers( CRCurrentStatePointers *current );
213
214DECLEXPORT(void) crStateSetExtensionString( CRContext *ctx, const GLubyte *extensions );
215
216DECLEXPORT(void) crStateDiffContext( CRContext *from, CRContext *to );
217DECLEXPORT(void) crStateSwitchContext( CRContext *from, CRContext *to );
218DECLEXPORT(void) crStateApplyFBImage(CRContext *to);
219
220#ifndef IN_GUEST
221DECLEXPORT(int32_t) crStateSaveContext(CRContext *pContext, PSSMHANDLE pSSM);
222DECLEXPORT(int32_t) crStateLoadContext(CRContext *pContext, CRHashTable * pCtxTable, PSSMHANDLE pSSM);
223DECLEXPORT(void) crStateFreeShared(CRSharedState *s);
224#endif
225
226
227 /* XXX move these! */
228
229DECLEXPORT(void) STATE_APIENTRY
230crStateChromiumParameteriCR( GLenum target, GLint value );
231
232DECLEXPORT(void) STATE_APIENTRY
233crStateChromiumParameterfCR( GLenum target, GLfloat value );
234
235DECLEXPORT(void) STATE_APIENTRY
236crStateChromiumParametervCR( GLenum target, GLenum type, GLsizei count, const GLvoid *values );
237
238DECLEXPORT(void) STATE_APIENTRY
239crStateGetChromiumParametervCR( GLenum target, GLuint index, GLenum type,
240 GLsizei count, GLvoid *values );
241
242DECLEXPORT(void) STATE_APIENTRY
243crStateReadPixels( GLint x, GLint y, GLsizei width, GLsizei height,
244 GLenum format, GLenum type, GLvoid *pixels );
245
246DECLEXPORT(void) STATE_APIENTRY crStateShareContext(GLboolean value);
247DECLEXPORT(void) STATE_APIENTRY crStateSetSharedContext(CRContext *pCtx);
248DECLEXPORT(GLboolean) STATE_APIENTRY crStateContextIsShared(CRContext *pCtx);
249
250DECLEXPORT(void) STATE_APIENTRY crStateQueryHWState();
251#ifdef __cplusplus
252}
253#endif
254
255#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