VirtualBox

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

Last change on this file since 32375 was 31808, checked in by vboxsync, 14 years ago

crOpenGL: resource sharing between contexts

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.6 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/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} CRSharedState;
108
109
110/**
111 * Chromium version of the state variables in OpenGL
112 */
113struct CRContext {
114 int id;
115 CRbitvalue bitid[CR_MAX_BITARRAY];
116 CRbitvalue neg_bitid[CR_MAX_BITARRAY];
117
118 CRSharedState *shared;
119
120 GLenum renderMode;
121
122 GLenum error;
123
124 CRStateFlushFunc flush_func;
125 void *flush_arg;
126
127 CRAttribState attrib;
128 CRBufferState buffer;
129#ifdef CR_ARB_vertex_buffer_object
130 CRBufferObjectState bufferobject;
131#endif
132 CRClientState client;
133 CRCurrentState current;
134 CREvaluatorState eval;
135 CRExtensionState extensions;
136 CRFeedbackState feedback;
137 CRFogState fog;
138 CRHintState hint;
139 CRLightingState lighting;
140 CRLimitsState limits;
141 CRLineState line;
142 CRListsState lists;
143 CRMultisampleState multisample;
144#if CR_ARB_occlusion_query
145 CROcclusionState occlusion;
146#endif
147 CRPixelState pixel;
148 CRPointState point;
149 CRPolygonState polygon;
150 CRProgramState program;
151 CRRegCombinerState regcombiner;
152 CRSelectionState selection;
153 CRStencilState stencil;
154 CRTextureState texture;
155 CRTransformState transform;
156 CRViewportState viewport;
157
158#ifdef CR_EXT_framebuffer_object
159 CRFramebufferObjectState framebufferobject;
160#endif
161
162#ifdef CR_OPENGL_VERSION_2_0
163 CRGLSLState glsl;
164#endif
165
166 /*@todo add back buffer, depth and fbos and move out of here*/
167 GLvoid *pImage; /*stored front buffer image*/
168
169 /** For buffering vertices for selection/feedback */
170 /*@{*/
171 GLuint vCount;
172 CRVertex vBuffer[4];
173 GLboolean lineReset;
174 GLboolean lineLoop;
175 /*@}*/
176};
177
178
179DECLEXPORT(void) crStateInit(void);
180DECLEXPORT(void) crStateDestroy(void);
181DECLEXPORT(CRContext *) crStateCreateContext(const CRLimitsState *limits, GLint visBits, CRContext *share);
182DECLEXPORT(CRContext *) crStateCreateContextEx(const CRLimitsState *limits, GLint visBits, CRContext *share, GLint presetID);
183DECLEXPORT(void) crStateMakeCurrent(CRContext *ctx);
184DECLEXPORT(void) crStateSetCurrent(CRContext *ctx);
185DECLEXPORT(CRContext *) crStateGetCurrent(void);
186DECLEXPORT(void) crStateDestroyContext(CRContext *ctx);
187
188DECLEXPORT(void) crStateFlushFunc( CRStateFlushFunc ff );
189DECLEXPORT(void) crStateFlushArg( void *arg );
190DECLEXPORT(void) crStateDiffAPI( SPUDispatchTable *api );
191DECLEXPORT(void) crStateUpdateColorBits( void );
192
193DECLEXPORT(void) crStateSetCurrentPointers( CRContext *ctx, CRCurrentStatePointers *current );
194DECLEXPORT(void) crStateResetCurrentPointers( CRCurrentStatePointers *current );
195
196DECLEXPORT(void) crStateSetExtensionString( CRContext *ctx, const GLubyte *extensions );
197
198DECLEXPORT(void) crStateDiffContext( CRContext *from, CRContext *to );
199DECLEXPORT(void) crStateSwitchContext( CRContext *from, CRContext *to );
200DECLEXPORT(void) crStateApplyFBImage(CRContext *to);
201
202#ifndef IN_GUEST
203DECLEXPORT(int32_t) crStateSaveContext(CRContext *pContext, PSSMHANDLE pSSM);
204DECLEXPORT(int32_t) crStateLoadContext(CRContext *pContext, CRHashTable * pCtxTable, PSSMHANDLE pSSM);
205DECLEXPORT(void) crStateFreeShared(CRSharedState *s);
206#endif
207
208
209 /* XXX move these! */
210
211DECLEXPORT(void) STATE_APIENTRY
212crStateChromiumParameteriCR( GLenum target, GLint value );
213
214DECLEXPORT(void) STATE_APIENTRY
215crStateChromiumParameterfCR( GLenum target, GLfloat value );
216
217DECLEXPORT(void) STATE_APIENTRY
218crStateChromiumParametervCR( GLenum target, GLenum type, GLsizei count, const GLvoid *values );
219
220DECLEXPORT(void) STATE_APIENTRY
221crStateGetChromiumParametervCR( GLenum target, GLuint index, GLenum type,
222 GLsizei count, GLvoid *values );
223
224DECLEXPORT(void) STATE_APIENTRY
225crStateReadPixels( GLint x, GLint y, GLsizei width, GLsizei height,
226 GLenum format, GLenum type, GLvoid *pixels );
227
228DECLEXPORT(void) STATE_APIENTRY crStateShareContext(GLboolean value);
229#ifdef __cplusplus
230}
231#endif
232
233#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