VirtualBox

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

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

crOpenGL: render to fbo fixes

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