summaryrefslogtreecommitdiffstats
path: root/src/VBox/GuestHost/OpenGL/include/state
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 03:01:46 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 03:01:46 +0000
commitf8fe689a81f906d1b91bb3220acde2a4ecb14c5b (patch)
tree26484e9d7e2c67806c2d1760196ff01aaa858e8c /src/VBox/GuestHost/OpenGL/include/state
parentInitial commit. (diff)
downloadvirtualbox-f8fe689a81f906d1b91bb3220acde2a4ecb14c5b.tar.xz
virtualbox-f8fe689a81f906d1b91bb3220acde2a4ecb14c5b.zip
Adding upstream version 6.0.4-dfsg.upstream/6.0.4-dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/VBox/GuestHost/OpenGL/include/state')
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_attrib.h405
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_buffer.h95
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_bufferobject.h71
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_client.h143
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_current.h107
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_evaluators.h91
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_feedback.h56
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_fog.h62
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_framebuffer.h108
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_glsl.h122
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_hint.h62
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_lighting.h92
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_limits.h285
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_line.h44
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_lists.h45
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_multisample.h47
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_occlude.h58
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_pixel.h74
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_point.h62
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_polygon.h53
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_program.h142
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_regcombiner.h71
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_stateerror.h16
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_statetypes.h209
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_stencil.h107
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_texture.h250
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_transform.h91
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_viewport.h57
28 files changed, 3025 insertions, 0 deletions
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_attrib.h b/src/VBox/GuestHost/OpenGL/include/state/cr_attrib.h
new file mode 100644
index 00000000..579e71dd
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_attrib.h
@@ -0,0 +1,405 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved.
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#ifndef CR_STATE_ATTRIB_H
+#define CR_STATE_ATTRIB_H
+
+#include "state/cr_limits.h"
+#include "state/cr_statetypes.h"
+
+#include <iprt/cdefs.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+} CRAttribBits;
+
+typedef struct {
+ GLcolorf accumClearValue;
+} CRAccumBufferStack;
+
+typedef struct {
+ GLboolean blend;
+ GLboolean alphaTest;
+ GLboolean logicOp;
+ GLboolean indexLogicOp;
+ GLboolean dither;
+
+ GLenum alphaTestFunc;
+ GLfloat alphaTestRef;
+ GLenum blendSrcRGB;
+ GLenum blendDstRGB;
+ GLenum blendSrcA;
+ GLenum blendDstA;
+ GLcolorf blendColor;
+ GLenum blendEquation;
+ GLenum logicOpMode;
+ GLenum drawBuffer;
+ GLint indexWriteMask;
+ GLcolorb colorWriteMask;
+ GLcolorf colorClearValue;
+ GLfloat indexClearValue;
+} CRColorBufferStack;
+
+typedef struct {
+ GLboolean rasterValid;
+ GLfloat attrib[CR_MAX_VERTEX_ATTRIBS][4];
+ GLfloat rasterAttrib[CR_MAX_VERTEX_ATTRIBS][4];
+ GLboolean edgeFlag;
+ GLfloat colorIndex;
+} CRCurrentStack;
+
+typedef struct {
+ GLboolean depthTest;
+ GLboolean depthMask;
+ GLenum depthFunc;
+ GLdefault depthClearValue;
+} CRDepthBufferStack;
+
+typedef struct {
+ GLboolean alphaTest;
+ GLboolean autoNormal;
+ GLboolean blend;
+ GLboolean *clip;
+ GLboolean colorMaterial;
+ GLboolean cullFace;
+ GLboolean depthTest;
+ GLboolean dither;
+ GLboolean fog;
+ GLboolean *light;
+ GLboolean lighting;
+ GLboolean lineSmooth;
+ GLboolean lineStipple;
+ GLboolean logicOp;
+ GLboolean indexLogicOp;
+ GLboolean map1[GLEVAL_TOT];
+ GLboolean map2[GLEVAL_TOT];
+ GLboolean normalize;
+ GLboolean pointSmooth;
+#ifdef CR_ARB_point_sprite
+ GLboolean pointSprite;
+ GLboolean coordReplacement[CR_MAX_TEXTURE_UNITS];
+#endif
+ GLboolean polygonOffsetLine;
+ GLboolean polygonOffsetFill;
+ GLboolean polygonOffsetPoint;
+ GLboolean polygonSmooth;
+ GLboolean polygonStipple;
+#ifdef CR_OPENGL_VERSION_1_2
+ GLboolean rescaleNormals;
+#endif
+ GLboolean scissorTest;
+ GLboolean stencilTest;
+ GLboolean texture1D[CR_MAX_TEXTURE_UNITS];
+ GLboolean texture2D[CR_MAX_TEXTURE_UNITS];
+ GLboolean texture3D[CR_MAX_TEXTURE_UNITS];
+#ifdef CR_ARB_texture_cube_map
+ GLboolean textureCubeMap[CR_MAX_TEXTURE_UNITS];
+#endif
+#ifdef CR_NV_texture_rectangle
+ GLboolean textureRect[CR_MAX_TEXTURE_UNITS];
+#endif
+ GLboolean textureGenS[CR_MAX_TEXTURE_UNITS];
+ GLboolean textureGenT[CR_MAX_TEXTURE_UNITS];
+ GLboolean textureGenR[CR_MAX_TEXTURE_UNITS];
+ GLboolean textureGenQ[CR_MAX_TEXTURE_UNITS];
+} CREnableStack;
+
+typedef struct {
+ GLboolean enable1D[GLEVAL_TOT];
+ GLboolean enable2D[GLEVAL_TOT];
+ GLboolean autoNormal;
+ CREvaluator1D eval1D[GLEVAL_TOT];
+ CREvaluator2D eval2D[GLEVAL_TOT];
+ GLint un1D;
+ GLfloat u11D, u21D;
+ GLint un2D;
+ GLint vn2D;
+ GLfloat u12D, u22D;
+ GLfloat v12D, v22D;
+} CREvalStack;
+
+typedef struct {
+ GLboolean lighting;
+ GLboolean colorMaterial;
+ GLenum shadeModel;
+ GLenum colorMaterialMode;
+ GLenum colorMaterialFace;
+ GLcolorf ambient[2];
+ GLcolorf diffuse[2];
+ GLcolorf specular[2];
+ GLcolorf emission[2];
+ GLfloat shininess[2];
+ GLint indexes[2][3];
+ GLcolorf lightModelAmbient;
+ GLboolean lightModelLocalViewer;
+ GLboolean lightModelTwoSide;
+#if defined(CR_EXT_separate_specular_color) || defined(CR_OPENGL_VERSION_1_2)
+ GLenum lightModelColorControlEXT;
+#endif
+ CRLight *light;
+} CRLightingStack;
+
+typedef struct {
+ GLcolorf color;
+ GLint index;
+ GLfloat density;
+ GLfloat start;
+ GLfloat end;
+ GLint mode;
+ GLboolean enable;
+} CRFogStack;
+
+typedef struct {
+ GLenum perspectiveCorrection;
+ GLenum pointSmooth;
+ GLenum lineSmooth;
+ GLenum polygonSmooth;
+ GLenum fog;
+#ifdef CR_EXT_clip_volume_hint
+ GLenum clipVolumeClipping;
+#endif
+#ifdef CR_ARB_texture_compression
+ GLenum textureCompression;
+#endif
+#ifdef CR_SGIS_generate_mipmap
+ GLenum generateMipmap;
+#endif
+} CRHintStack;
+
+typedef struct {
+ GLboolean lineSmooth;
+ GLboolean lineStipple;
+ GLfloat width;
+ GLushort pattern;
+ GLint repeat;
+} CRLineStack;
+
+typedef struct {
+ GLuint base;
+} CRListStack;
+
+typedef struct {
+ GLboolean mapColor;
+ GLboolean mapStencil;
+ GLint indexShift;
+ GLint indexOffset;
+ GLcolorf scale;
+ GLfloat depthScale;
+ GLcolorf bias;
+ GLfloat depthBias;
+ GLfloat xZoom;
+ GLfloat yZoom;
+ GLenum readBuffer;
+} CRPixelModeStack;
+
+typedef struct {
+ GLboolean pointSmooth;
+ GLfloat pointSize;
+#if CR_ARB_point_sprite
+ GLboolean pointSprite;
+ GLboolean coordReplacement[CR_MAX_TEXTURE_UNITS];
+#endif
+} CRPointStack;
+
+typedef struct {
+ GLboolean polygonSmooth;
+ GLboolean polygonOffsetFill;
+ GLboolean polygonOffsetLine;
+ GLboolean polygonOffsetPoint;
+ GLboolean polygonStipple;
+ GLboolean cullFace;
+ GLfloat offsetFactor;
+ GLfloat offsetUnits;
+ GLenum cullFaceMode;
+ GLenum frontFace;
+ GLenum frontMode;
+ GLenum backMode;
+} CRPolygonStack;
+
+typedef struct {
+ GLint pattern[32];
+} CRPolygonStippleStack;
+
+typedef struct {
+ GLboolean scissorTest;
+ GLint scissorX;
+ GLint scissorY;
+ GLsizei scissorW;
+ GLsizei scissorH;
+} CRScissorStack;
+
+typedef struct {
+ GLboolean stencilTest;
+ GLenum func;
+ GLint mask;
+ GLint ref;
+ GLenum fail;
+ GLenum passDepthFail;
+ GLenum passDepthPass;
+ GLint clearValue;
+ GLint writeMask;
+} CRStencilBufferStack_v_33;
+
+typedef struct {
+ /* true if stencil test is enabled */
+ GLboolean stencilTest;
+ /* true if GL_EXT_stencil_two_side is enabled (glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT)) */
+ GLboolean stencilTwoSideEXT;
+ /* GL_FRONT or GL_BACK */
+ GLenum activeStencilFace;
+ GLint clearValue;
+ GLint writeMask;
+ CRStencilBufferState buffers[CRSTATE_STENCIL_BUFFER_COUNT];
+} CRStencilBufferStack;
+
+typedef struct {
+#if 111
+ GLuint curTextureUnit;
+ CRTextureUnit unit[CR_MAX_TEXTURE_UNITS];
+
+#else
+ GLboolean enabled1D[CR_MAX_TEXTURE_UNITS];
+ GLboolean enabled2D[CR_MAX_TEXTURE_UNITS];
+ GLboolean enabled3D[CR_MAX_TEXTURE_UNITS];
+# ifdef CR_ARB_texture_cube_map
+ GLboolean enabledCubeMap[CR_MAX_TEXTURE_UNITS];
+# endif
+ CRTextureObj *current1D[CR_MAX_TEXTURE_UNITS];
+ CRTextureObj *current2D[CR_MAX_TEXTURE_UNITS];
+ CRTextureObj *current3D[CR_MAX_TEXTURE_UNITS];
+# ifdef CR_ARB_texture_cube_map
+ CRTextureObj *currentCubeMap[CR_MAX_TEXTURE_UNITS];
+# endif
+ GLcolorf borderColor[4]; /* 4 = 1D, 2D, 3D and cube map textures */
+ GLenum minFilter[4];
+ GLenum magFilter[4];
+ GLenum wrapS[4];
+ GLenum wrapT[4];
+# ifdef CR_OPENGL_VERSION_1_2
+ GLenum wrapR[4];
+ GLfloat priority[4];
+ GLfloat minLod[4];
+ GLfloat maxLod[4];
+ GLint baseLevel[4];
+ GLint maxLevel[4];
+# endif
+
+ GLuint curTextureUnit;
+ GLenum envMode[CR_MAX_TEXTURE_UNITS];
+ GLcolorf envColor[CR_MAX_TEXTURE_UNITS];
+
+ GLtexcoordb textureGen[CR_MAX_TEXTURE_UNITS];
+ GLvectorf objSCoeff[CR_MAX_TEXTURE_UNITS];
+ GLvectorf objTCoeff[CR_MAX_TEXTURE_UNITS];
+ GLvectorf objRCoeff[CR_MAX_TEXTURE_UNITS];
+ GLvectorf objQCoeff[CR_MAX_TEXTURE_UNITS];
+ GLvectorf eyeSCoeff[CR_MAX_TEXTURE_UNITS];
+ GLvectorf eyeTCoeff[CR_MAX_TEXTURE_UNITS];
+ GLvectorf eyeRCoeff[CR_MAX_TEXTURE_UNITS];
+ GLvectorf eyeQCoeff[CR_MAX_TEXTURE_UNITS];
+ GLtexcoorde gen[CR_MAX_TEXTURE_UNITS];
+#endif
+} CRTextureStack;
+
+typedef struct {
+ GLenum matrixMode;
+ GLvectord *clipPlane;
+ GLboolean *clip;
+ GLboolean normalize;
+#ifdef CR_OPENGL_VERSION_1_2
+ GLboolean rescaleNormals;
+#endif
+} CRTransformStack;
+
+typedef struct {
+ GLint viewportX;
+ GLint viewportY;
+ GLint viewportW;
+ GLint viewportH;
+ GLclampd nearClip;
+ GLclampd farClip;
+} CRViewportStack;
+
+typedef struct {
+ GLint attribStackDepth;
+ CRbitvalue pushMaskStack[CR_MAX_ATTRIB_STACK_DEPTH];
+
+ GLint accumBufferStackDepth;
+ CRAccumBufferStack accumBufferStack[CR_MAX_ATTRIB_STACK_DEPTH];
+
+ GLint colorBufferStackDepth;
+ CRColorBufferStack colorBufferStack[CR_MAX_ATTRIB_STACK_DEPTH];
+
+ GLint currentStackDepth;
+ CRCurrentStack currentStack[CR_MAX_ATTRIB_STACK_DEPTH];
+
+ GLint depthBufferStackDepth;
+ CRDepthBufferStack depthBufferStack[CR_MAX_ATTRIB_STACK_DEPTH];
+
+ GLint enableStackDepth;
+ CREnableStack enableStack[CR_MAX_ATTRIB_STACK_DEPTH];
+
+ GLint evalStackDepth;
+ CREvalStack evalStack[CR_MAX_ATTRIB_STACK_DEPTH];
+
+ GLint fogStackDepth;
+ CRFogStack fogStack[CR_MAX_ATTRIB_STACK_DEPTH];
+
+ GLint hintStackDepth;
+ CRHintStack hintStack[CR_MAX_ATTRIB_STACK_DEPTH];
+
+ GLint lightingStackDepth;
+ CRLightingStack lightingStack[CR_MAX_ATTRIB_STACK_DEPTH];
+
+ GLint lineStackDepth;
+ CRLineStack lineStack[CR_MAX_ATTRIB_STACK_DEPTH];
+
+ GLint listStackDepth;
+ CRListStack listStack[CR_MAX_ATTRIB_STACK_DEPTH];
+
+ GLint pixelModeStackDepth;
+ CRPixelModeStack pixelModeStack[CR_MAX_ATTRIB_STACK_DEPTH];
+
+ GLint pointStackDepth;
+ CRPointStack pointStack[CR_MAX_ATTRIB_STACK_DEPTH];
+
+ GLint polygonStackDepth;
+ CRPolygonStack polygonStack[CR_MAX_ATTRIB_STACK_DEPTH];
+
+ GLint polygonStippleStackDepth;
+ CRPolygonStippleStack polygonStippleStack[CR_MAX_ATTRIB_STACK_DEPTH];
+
+ GLint scissorStackDepth;
+ CRScissorStack scissorStack[CR_MAX_ATTRIB_STACK_DEPTH];
+
+ GLint stencilBufferStackDepth;
+ CRStencilBufferStack stencilBufferStack[CR_MAX_ATTRIB_STACK_DEPTH];
+
+ GLint textureStackDepth;
+ CRTextureStack textureStack[CR_MAX_ATTRIB_STACK_DEPTH];
+
+ GLint transformStackDepth;
+ CRTransformStack transformStack[CR_MAX_ATTRIB_STACK_DEPTH];
+
+ GLint viewportStackDepth;
+ CRViewportStack viewportStack[CR_MAX_ATTRIB_STACK_DEPTH];
+} CRAttribState;
+
+DECLEXPORT(void) crStateAttribInit(CRAttribState *a);
+
+/* No diff! */
+DECLEXPORT(void) crStateAttribSwitch(CRAttribBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CR_STATE_ATTRIB_H */
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_buffer.h b/src/VBox/GuestHost/OpenGL/include/state/cr_buffer.h
new file mode 100644
index 00000000..7a57aae9
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_buffer.h
@@ -0,0 +1,95 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved.
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#ifndef CR_STATE_BUFFER_H
+#define CR_STATE_BUFFER_H
+
+#include "state/cr_statetypes.h"
+
+#include <iprt/cdefs.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+ CRbitvalue enable[CR_MAX_BITARRAY];
+ CRbitvalue alphaFunc[CR_MAX_BITARRAY];
+ CRbitvalue depthFunc[CR_MAX_BITARRAY];
+ CRbitvalue blendFunc[CR_MAX_BITARRAY];
+ CRbitvalue logicOp[CR_MAX_BITARRAY];
+ CRbitvalue indexLogicOp[CR_MAX_BITARRAY];
+ CRbitvalue drawBuffer[CR_MAX_BITARRAY];
+ CRbitvalue readBuffer[CR_MAX_BITARRAY];
+ CRbitvalue indexMask[CR_MAX_BITARRAY];
+ CRbitvalue colorWriteMask[CR_MAX_BITARRAY];
+ CRbitvalue clearColor[CR_MAX_BITARRAY];
+ CRbitvalue clearIndex[CR_MAX_BITARRAY];
+ CRbitvalue clearDepth[CR_MAX_BITARRAY];
+ CRbitvalue clearAccum[CR_MAX_BITARRAY];
+ CRbitvalue depthMask[CR_MAX_BITARRAY];
+#ifdef CR_EXT_blend_color
+ CRbitvalue blendColor[CR_MAX_BITARRAY];
+#endif
+#if defined(CR_EXT_blend_minmax) || defined(CR_EXT_blend_subtract) || defined(CR_EXT_blend_logic_op)
+ CRbitvalue blendEquation[CR_MAX_BITARRAY];
+#endif
+#if defined(CR_EXT_blend_func_separate)
+ CRbitvalue blendFuncSeparate[CR_MAX_BITARRAY];
+#endif
+} CRBufferBits;
+
+typedef struct {
+ GLboolean depthTest;
+ GLboolean blend;
+ GLboolean alphaTest;
+ GLboolean logicOp;
+ GLboolean indexLogicOp;
+ GLboolean dither;
+ GLboolean depthMask;
+
+ GLenum alphaTestFunc;
+ GLfloat alphaTestRef;
+ GLenum depthFunc;
+ GLenum blendSrcRGB;
+ GLenum blendDstRGB;
+ GLenum blendSrcA;
+ GLenum blendDstA;
+ GLenum logicOpMode;
+ GLenum drawBuffer;
+ GLenum readBuffer;
+ GLint indexWriteMask;
+ GLcolorb colorWriteMask;
+ GLcolorf colorClearValue;
+ GLfloat indexClearValue;
+ GLdefault depthClearValue;
+ GLcolorf accumClearValue;
+#ifdef CR_EXT_blend_color
+ GLcolorf blendColor;
+#endif
+#if defined(CR_EXT_blend_minmax) || defined(CR_EXT_blend_subtract)
+ GLenum blendEquation;
+#endif
+
+ GLint width, height;
+ GLint storedWidth, storedHeight;
+ GLvoid *pFrontImg;
+ GLvoid *pBackImg;
+} CRBufferState;
+
+DECLEXPORT(void) crStateBufferInit(CRContext *ctx);
+
+DECLEXPORT(void) crStateBufferDiff(CRBufferBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+DECLEXPORT(void) crStateBufferSwitch(CRBufferBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CR_STATE_BUFFER_H */
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_bufferobject.h b/src/VBox/GuestHost/OpenGL/include/state/cr_bufferobject.h
new file mode 100644
index 00000000..8584adc0
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_bufferobject.h
@@ -0,0 +1,71 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved.
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#ifndef CR_STATE_BUFFEROBJECT_H
+#define CR_STATE_BUFFEROBJECT_H
+
+#include "cr_hash.h"
+#include "state/cr_statetypes.h"
+#include "state/cr_statefuncs.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+ CRbitvalue arrayBinding[CR_MAX_BITARRAY];
+ CRbitvalue elementsBinding[CR_MAX_BITARRAY];
+ CRbitvalue packBinding[CR_MAX_BITARRAY];
+ CRbitvalue unpackBinding[CR_MAX_BITARRAY];
+} CRBufferObjectBits;
+
+
+/*
+ * Buffer object, like a texture object, but encapsulates arbitrary
+ * data (vertex, image, etc).
+ */
+typedef struct {
+ GLuint refCount;
+ GLuint id;
+ GLuint hwid;
+ GLenum usage;
+ GLenum access;
+ GLuint size; /* buffer size in bytes */
+ GLvoid *pointer; /* only valid while buffer is mapped */
+ GLvoid *data; /* the buffer data, if retainBufferData is true */
+ GLboolean bResyncOnRead; /* buffer data could be changed on server side,
+ so we need to resync every time guest wants to read from it*/
+ CRbitvalue dirty[CR_MAX_BITARRAY]; /* dirty data or state */
+ GLintptrARB dirtyStart, dirtyLength; /* dirty region */
+ /* bitfield representing the object usage. 1 means the object is used by the context with the given bitid */
+ CRbitvalue ctxUsage[CR_MAX_BITARRAY];
+} CRBufferObject;
+
+typedef struct {
+ GLboolean retainBufferData; /* should state tracker retain buffer data? */
+ CRBufferObject *arrayBuffer;
+ CRBufferObject *elementsBuffer;
+ CRBufferObject *packBuffer;
+ CRBufferObject *unpackBuffer;
+
+ CRBufferObject *nullBuffer; /* name = 0 */
+} CRBufferObjectState;
+
+DECLEXPORT(CRBufferObject *) crStateGetBoundBufferObject(GLenum target, CRBufferObjectState *b);
+DECLEXPORT(GLboolean) crStateIsBufferBound(GLenum target);
+struct CRContext;
+DECLEXPORT(GLboolean) crStateIsBufferBoundForCtx(struct CRContext *g, GLenum target);
+
+DECLEXPORT(GLuint) STATE_APIENTRY crStateBufferHWIDtoID(GLuint hwid);
+DECLEXPORT(GLuint) STATE_APIENTRY crStateGetBufferHWID(GLuint id);
+
+DECLEXPORT(void) crStateRegBuffers(GLsizei n, GLuint *buffers);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CR_STATE_BUFFEROBJECT_H */
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_client.h b/src/VBox/GuestHost/OpenGL/include/state/cr_client.h
new file mode 100644
index 00000000..a727f260
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_client.h
@@ -0,0 +1,143 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved.
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#ifndef CR_STATE_CLIENT_H
+#define CR_STATE_CLIENT_H
+
+#include "state/cr_statetypes.h"
+#include "state/cr_limits.h"
+#include "state/cr_bufferobject.h"
+#include "cr_bits.h"
+
+#include <iprt/cdefs.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+ /* pixel pack/unpack */
+ CRbitvalue pack[CR_MAX_BITARRAY];
+ CRbitvalue unpack[CR_MAX_BITARRAY];
+ /* vertex array */
+ CRbitvalue enableClientState[CR_MAX_BITARRAY];
+ CRbitvalue clientPointer[CR_MAX_BITARRAY];
+ CRbitvalue *v; /* vertex */
+ CRbitvalue *n; /* normal */
+ CRbitvalue *c; /* color */
+ CRbitvalue *i; /* index */
+ CRbitvalue *t[CR_MAX_TEXTURE_UNITS]; /* texcoord */
+ CRbitvalue *e; /* edgeflag */
+ CRbitvalue *s; /* secondary color */
+ CRbitvalue *f; /* fog coord */
+#ifdef CR_NV_vertex_program
+ CRbitvalue *a[CR_MAX_VERTEX_ATTRIBS]; /* NV_vertex_program */
+#endif
+} CRClientBits;
+
+/*
+ * NOTE!!!! If you change this structure, search through the code for
+ * occurrences of 'defaultPacking' and fix the static initializations!!!!
+ */
+typedef struct {
+ GLint rowLength;
+ GLint skipRows;
+ GLint skipPixels;
+ GLint alignment;
+ GLint imageHeight;
+ GLint skipImages;
+ GLboolean swapBytes;
+ GLboolean psLSBFirst; /* don't conflict with crap from Xlib.h */
+} CRPixelPackState;
+
+typedef struct {
+ unsigned char *p;
+ GLint size;
+ GLint type;
+ GLint stride;
+ GLboolean enabled;
+ GLboolean normalized; /* Added with GL_ARB_vertex_program */
+ int bytesPerIndex;
+#ifdef CR_ARB_vertex_buffer_object
+ CRBufferObject *buffer;
+#endif
+#ifdef CR_EXT_compiled_vertex_array
+ GLboolean locked;
+ unsigned char *prevPtr;
+ GLint prevStride;
+#endif
+} CRClientPointer;
+
+typedef struct {
+ CRClientPointer v; /* vertex */
+ CRClientPointer n; /* normal */
+ CRClientPointer c; /* color */
+ CRClientPointer i; /* color index */
+ CRClientPointer t[CR_MAX_TEXTURE_UNITS]; /* texcoords */
+ CRClientPointer e; /* edge flags */
+ CRClientPointer s; /* secondary color */
+ CRClientPointer f; /* fog coord */
+#ifdef CR_NV_vertex_program
+ CRClientPointer a[CR_MAX_VERTEX_ATTRIBS]; /* vertex attribs */
+#endif
+#ifdef CR_NV_vertex_array_range
+ GLboolean arrayRange;
+ GLboolean arrayRangeValid;
+ void *arrayRangePointer;
+ GLuint arrayRangeLength;
+#endif
+#ifdef CR_EXT_compiled_vertex_array
+ GLint lockFirst;
+ GLint lockCount;
+ GLboolean locked;
+# ifdef IN_GUEST
+ GLboolean synced;
+# endif
+#endif
+} CRVertexArrays;
+
+#define CRSTATECLIENT_MAX_VERTEXARRAYS (7+CR_MAX_TEXTURE_UNITS+CR_MAX_VERTEX_ATTRIBS)
+
+typedef struct {
+ /* pixel pack/unpack */
+ CRPixelPackState pack;
+ CRPixelPackState unpack;
+
+ CRVertexArrays array;
+
+ GLint curClientTextureUnit;
+
+ /* state stacks (glPush/PopClientState) */
+ GLint attribStackDepth;
+ CRbitvalue pushMaskStack[CR_MAX_CLIENT_ATTRIB_STACK_DEPTH];
+
+ GLint pixelStoreStackDepth;
+ CRPixelPackState pixelPackStoreStack[CR_MAX_CLIENT_ATTRIB_STACK_DEPTH];
+ CRPixelPackState pixelUnpackStoreStack[CR_MAX_CLIENT_ATTRIB_STACK_DEPTH];
+
+ GLint vertexArrayStackDepth;
+ CRVertexArrays vertexArrayStack[CR_MAX_CLIENT_ATTRIB_STACK_DEPTH];
+} CRClientState;
+
+extern const CRPixelPackState crStateNativePixelPacking;
+
+struct CRContext;
+
+DECLEXPORT(void) crStateClientInitBits(CRClientBits *c);
+DECLEXPORT(void) crStateClientDestroyBits(CRClientBits *c);
+DECLEXPORT(void) crStateClientInit(struct CRContext *g);
+DECLEXPORT(void) crStateClientDestroy(struct CRContext *g);
+
+DECLEXPORT(GLboolean) crStateUseServerArrays(void);
+DECLEXPORT(GLboolean) crStateUseServerArrayElements(void);
+DECLEXPORT(CRClientPointer*) crStateGetClientPointerByIndex(int index, CRVertexArrays *array);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CR_CLIENT_H */
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_current.h b/src/VBox/GuestHost/OpenGL/include/state/cr_current.h
new file mode 100644
index 00000000..d4a05708
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_current.h
@@ -0,0 +1,107 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved.
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#ifndef CR_STATE_CURRENT_H
+#define CR_STATE_CURRENT_H
+
+#include "state/cr_currentpointers.h"
+
+#include <iprt/cdefs.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define VERT_ATTRIB_POS 0
+#define VERT_ATTRIB_WEIGHT 1
+#define VERT_ATTRIB_NORMAL 2
+#define VERT_ATTRIB_COLOR0 3
+#define VERT_ATTRIB_COLOR1 4
+#define VERT_ATTRIB_FOG 5
+#define VERT_ATTRIB_SIX 6
+#define VERT_ATTRIB_SEVEN 7
+#define VERT_ATTRIB_TEX0 8
+#define VERT_ATTRIB_TEX1 9
+#define VERT_ATTRIB_TEX2 10
+#define VERT_ATTRIB_TEX3 11
+#define VERT_ATTRIB_TEX4 12
+#define VERT_ATTRIB_TEX5 13
+#define VERT_ATTRIB_TEX6 14
+#define VERT_ATTRIB_TEX7 15
+#define VERT_ATTRIB_MAX 16
+
+
+typedef struct {
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+ /* Regardless of NV_vertex_program, we use this array */
+ CRbitvalue vertexAttrib[CR_MAX_VERTEX_ATTRIBS][CR_MAX_BITARRAY];
+ CRbitvalue edgeFlag[CR_MAX_BITARRAY];
+ CRbitvalue colorIndex[CR_MAX_BITARRAY];
+ CRbitvalue rasterPos[CR_MAX_BITARRAY];
+} CRCurrentBits;
+
+
+typedef struct {
+ /* Pre-transform values */
+ /* Regardless of NV_vertex_program, we use this array */
+ GLfloat attrib[CR_MAX_VERTEX_ATTRIBS][4];
+ GLboolean edgeFlag;
+ GLfloat colorIndex;
+ /* Post-transform values */
+ GLvectorf eyePos;
+ GLvectorf clipPos;
+ GLvectorf winPos;
+} CRVertex;
+
+
+typedef struct {
+ /* Regardless of NV_vertex_program, we use this array */
+ GLfloat vertexAttrib[CR_MAX_VERTEX_ATTRIBS][4];
+ GLfloat vertexAttribPre[CR_MAX_VERTEX_ATTRIBS][4];
+
+ CRCurrentStatePointers *current;
+
+ GLboolean rasterValid;
+ GLfloat rasterAttrib[CR_MAX_VERTEX_ATTRIBS][4];
+ GLfloat rasterAttribPre[CR_MAX_VERTEX_ATTRIBS][4];
+
+ GLdouble rasterIndex;
+ GLboolean edgeFlag;
+ GLboolean edgeFlagPre;
+ GLfloat colorIndex;
+ GLfloat colorIndexPre;
+
+ /* XXX this isn't really "current" state - move someday */
+ GLuint attribsUsedMask; /* for ARB_vertex_program */
+ GLboolean inBeginEnd;
+ GLenum mode;
+ GLuint beginEndMax;
+ GLuint beginEndNum;
+ GLuint flushOnEnd;
+
+} CRCurrentState;
+
+DECLEXPORT(void) crStateCurrentInit( CRContext *ctx );
+
+DECLEXPORT(void) crStateCurrentRecover( void );
+
+DECLEXPORT(void) crStateCurrentRecoverNew(CRContext *g, CRCurrentStatePointers *current);
+
+DECLEXPORT(void) crStateCurrentDiff(CRCurrentBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+DECLEXPORT(void) crStateCurrentSwitch(CRCurrentBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+
+DECLEXPORT(void) crStateRasterPosUpdate(GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+
+DECLEXPORT(GLuint) crStateNeedDummyZeroVertexArray(CRContext *g, CRCurrentStatePointers *current, GLfloat *pZva);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CR_STATE_CURRENT_H */
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_evaluators.h b/src/VBox/GuestHost/OpenGL/include/state/cr_evaluators.h
new file mode 100644
index 00000000..2a3d7836
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_evaluators.h
@@ -0,0 +1,91 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved.
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#ifndef CR_STATE_EVALUATORS
+#define CR_STATE_EVALUATORS
+
+#include "state/cr_statetypes.h"
+
+#include <iprt/cdefs.h>
+
+#define GLEVAL_TOT 9
+#define MAX_EVAL_ORDER 30
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ CRbitvalue eval1D[GLEVAL_TOT][CR_MAX_BITARRAY];
+ CRbitvalue eval2D[GLEVAL_TOT][CR_MAX_BITARRAY];
+ CRbitvalue enable[CR_MAX_BITARRAY];
+ CRbitvalue enable1D[GLEVAL_TOT][CR_MAX_BITARRAY];
+ CRbitvalue enable2D[GLEVAL_TOT][CR_MAX_BITARRAY];
+ CRbitvalue grid1D[CR_MAX_BITARRAY];
+ CRbitvalue grid2D[CR_MAX_BITARRAY];
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+#ifdef CR_NV_vertex_program
+ CRbitvalue enableAttrib1D[CR_MAX_VERTEX_ATTRIBS];
+ CRbitvalue enableAttrib2D[CR_MAX_VERTEX_ATTRIBS];
+#endif
+} CREvaluatorBits;
+
+typedef struct {
+ GLfloat u1, u2;
+ GLfloat du;
+ GLint order;
+ GLfloat *coeff;
+} CREvaluator1D;
+
+typedef struct {
+ GLfloat u1, u2;
+ GLfloat v1, v2;
+ GLfloat du, dv;
+ GLint uorder;
+ GLint vorder;
+ GLfloat *coeff;
+} CREvaluator2D;
+
+typedef struct {
+ GLboolean enable1D[GLEVAL_TOT];
+ GLboolean enable2D[GLEVAL_TOT];
+#ifdef CR_NV_vertex_program
+ GLboolean enableAttrib1D[CR_MAX_VERTEX_ATTRIBS];
+ GLboolean enableAttrib2D[CR_MAX_VERTEX_ATTRIBS];
+#endif
+ GLboolean autoNormal;
+
+ CREvaluator1D eval1D[GLEVAL_TOT];
+ CREvaluator2D eval2D[GLEVAL_TOT];
+#ifdef CR_NV_vertex_program
+ CREvaluator1D attribEval1D[CR_MAX_VERTEX_ATTRIBS];
+ CREvaluator2D attribEval2D[CR_MAX_VERTEX_ATTRIBS];
+#endif
+
+ GLint un1D; /* GL_MAP1_GRID_SEGMENTS */
+ GLfloat u11D, u21D; /* GL_MAP1_GRID_DOMAIN */
+
+ GLint un2D; /* GL_MAP2_GRID_SEGMENTS (u) */
+ GLint vn2D; /* GL_MAP2_GRID_SEGMENTS (v) */
+ GLfloat u12D, u22D; /* GL_MAP2_GRID_DOMAIN (u) */
+ GLfloat v12D, v22D; /* GL_MAP2_GRID_DOMAIN (v) */
+} CREvaluatorState;
+
+extern const int gleval_sizes[];
+
+DECLEXPORT(void) crStateEvaluatorInit (CRContext *ctx);
+DECLEXPORT(void) crStateEvaluatorDestroy (CRContext *ctx);
+
+DECLEXPORT(void) crStateEvaluatorDiff(CREvaluatorBits *e, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+DECLEXPORT(void) crStateEvaluatorSwitch(CREvaluatorBits *e, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CR_STATE_EVALUATORS */
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_feedback.h b/src/VBox/GuestHost/OpenGL/include/state/cr_feedback.h
new file mode 100644
index 00000000..168f20eb
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_feedback.h
@@ -0,0 +1,56 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved.
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#ifndef CR_STATE_FEEDBACK_H
+#define CR_STATE_FEEDBACK_H
+
+#include "state/cr_statetypes.h"
+
+#include <iprt/cdefs.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MAX_NAME_STACK_DEPTH 64
+
+typedef struct {
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+} CRFeedbackBits;
+
+typedef struct {
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+} CRSelectionBits;
+
+typedef struct {
+ GLenum type;
+ GLuint mask;
+ GLfloat *buffer;
+ GLuint bufferSize;
+ GLuint count;
+} CRFeedbackState;
+
+typedef struct {
+ GLuint *buffer;
+ GLuint bufferSize;
+ GLuint bufferCount;
+ GLuint hits;
+ GLuint nameStackDepth;
+ GLuint nameStack[MAX_NAME_STACK_DEPTH];
+ GLboolean hitFlag;
+ GLfloat hitMinZ, hitMaxZ;
+} CRSelectionState;
+
+extern DECLEXPORT(void) crStateFeedbackDiff(CRFeedbackState *from, CRFeedbackState *to,
+ CRFeedbackBits *bb, CRbitvalue *bitID);
+extern DECLEXPORT(void) crStateFeedbackSwitch(CRFeedbackBits *bb, CRbitvalue *bitID,
+ CRFeedbackState *from, CRFeedbackState *to);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CR_STATE_FEEDBACK_H */
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_fog.h b/src/VBox/GuestHost/OpenGL/include/state/cr_fog.h
new file mode 100644
index 00000000..f0f85129
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_fog.h
@@ -0,0 +1,62 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved.
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#ifndef CR_STATE_FOG_H
+#define CR_STATE_FOG_H
+
+#include "state/cr_statetypes.h"
+
+#include <iprt/cdefs.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+ CRbitvalue color[CR_MAX_BITARRAY];
+ CRbitvalue index[CR_MAX_BITARRAY];
+ CRbitvalue density[CR_MAX_BITARRAY];
+ CRbitvalue start[CR_MAX_BITARRAY];
+ CRbitvalue end[CR_MAX_BITARRAY];
+ CRbitvalue mode[CR_MAX_BITARRAY];
+ CRbitvalue enable[CR_MAX_BITARRAY];
+#ifdef CR_NV_fog_distance
+ CRbitvalue fogDistanceMode[CR_MAX_BITARRAY];
+#endif
+#ifdef CR_EXT_fog_coord
+ CRbitvalue fogCoordinateSource[CR_MAX_BITARRAY];
+#endif
+} CRFogBits;
+
+typedef struct {
+ GLcolorf color;
+ GLint index;
+ GLfloat density;
+ GLfloat start;
+ GLfloat end;
+ GLint mode;
+ GLboolean enable;
+#ifdef CR_NV_fog_distance
+ GLenum fogDistanceMode;
+#endif
+#ifdef CR_EXT_fog_coord
+ GLenum fogCoordinateSource;
+#endif
+} CRFogState;
+
+DECLEXPORT(void) crStateFogInit(CRContext *ctx);
+
+DECLEXPORT(void) crStateFogDiff(CRFogBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+DECLEXPORT(void) crStateFogSwitch(CRFogBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CR_STATE_FOG_H */
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_framebuffer.h b/src/VBox/GuestHost/OpenGL/include/state/cr_framebuffer.h
new file mode 100644
index 00000000..13dd6e02
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_framebuffer.h
@@ -0,0 +1,108 @@
+/* $Id: cr_framebuffer.h $ */
+
+/** @file
+ * VBox crOpenGL: FBO related state info
+ */
+
+/*
+ * Copyright (C) 2009-2019 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+
+#ifndef CR_STATE_FRAMEBUFFEROBJECT_H
+#define CR_STATE_FRAMEBUFFEROBJECT_H
+
+#include "cr_hash.h"
+#include "state/cr_statetypes.h"
+#include "state/cr_statefuncs.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CR_MAX_COLOR_ATTACHMENTS 16
+
+typedef struct {
+ GLenum type; /*one of GL_NONE GL_TEXTURE GL_RENDERBUFFER_EXT*/
+ GLuint name;
+ GLint level;
+ GLint face;
+ GLint zoffset;
+} CRFBOAttachmentPoint;
+
+typedef struct {
+ GLuint id, hwid;
+ CRFBOAttachmentPoint color[CR_MAX_COLOR_ATTACHMENTS];
+ CRFBOAttachmentPoint depth;
+ CRFBOAttachmentPoint stencil;
+ GLenum readbuffer;
+ /*@todo: we don't support drawbufferS yet, so it's a stub*/
+ GLenum drawbuffer[1];
+#ifdef IN_GUEST
+ GLenum status;
+#endif
+ /* bitfield representing the object usage. 1 means the object is used by the context with the given bitid */
+ CRbitvalue ctxUsage[CR_MAX_BITARRAY];
+} CRFramebufferObject;
+
+typedef struct {
+ GLuint id, hwid;
+ GLsizei width, height;
+ GLenum internalformat;
+ GLuint redBits, greenBits, blueBits, alphaBits, depthBits, stencilBits;
+ /* bitfield representing the object usage. 1 means the object is used by the context with the given bitid */
+ CRbitvalue ctxUsage[CR_MAX_BITARRAY];
+} CRRenderbufferObject;
+
+typedef struct {
+ CRFramebufferObject *readFB, *drawFB;
+ CRRenderbufferObject *renderbuffer;
+} CRFramebufferObjectState;
+
+DECLEXPORT(void) STATE_APIENTRY crStateFramebufferObjectInit(CRContext *ctx);
+DECLEXPORT(void) STATE_APIENTRY crStateFramebufferObjectDestroy(CRContext *ctx);
+DECLEXPORT(void) STATE_APIENTRY crStateFramebufferObjectSwitch(CRContext *from, CRContext *to);
+
+DECLEXPORT(void) STATE_APIENTRY crStateFramebufferObjectDisableHW(CRContext *ctx, GLuint idDrawFBO, GLuint idReadFBO);
+DECLEXPORT(void) STATE_APIENTRY crStateFramebufferObjectReenableHW(CRContext *fromCtx, CRContext *toCtx, GLuint idDrawFBO, GLuint idReadFBO);
+
+DECLEXPORT(GLuint) STATE_APIENTRY crStateGetFramebufferHWID(GLuint id);
+DECLEXPORT(GLuint) STATE_APIENTRY crStateGetRenderbufferHWID(GLuint id);
+
+DECLEXPORT(void) STATE_APIENTRY crStateBindRenderbufferEXT(GLenum target, GLuint renderbuffer);
+DECLEXPORT(void) STATE_APIENTRY crStateDeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers);
+DECLEXPORT(void) STATE_APIENTRY crStateRenderbufferStorageEXT(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+DECLEXPORT(void) STATE_APIENTRY crStateGetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params);
+DECLEXPORT(void) STATE_APIENTRY crStateBindFramebufferEXT(GLenum target, GLuint framebuffer);
+DECLEXPORT(void) STATE_APIENTRY crStateDeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers);
+DECLEXPORT(void) STATE_APIENTRY crStateFramebufferTexture1DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+DECLEXPORT(void) STATE_APIENTRY crStateFramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+DECLEXPORT(void) STATE_APIENTRY crStateFramebufferTexture3DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+DECLEXPORT(void) STATE_APIENTRY crStateFramebufferRenderbufferEXT(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+DECLEXPORT(void) STATE_APIENTRY crStateGetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, GLenum pname, GLint *params);
+DECLEXPORT(void) STATE_APIENTRY crStateGenerateMipmapEXT(GLenum target);
+
+DECLEXPORT(GLuint) STATE_APIENTRY crStateFBOHWIDtoID(GLuint hwid);
+DECLEXPORT(GLuint) STATE_APIENTRY crStateRBOHWIDtoID(GLuint hwid);
+
+DECLEXPORT(void) crStateRegFramebuffers(GLsizei n, GLuint *buffers);
+DECLEXPORT(void) crStateRegRenderbuffers(GLsizei n, GLuint *buffers);
+
+#ifdef IN_GUEST
+DECLEXPORT(GLenum) STATE_APIENTRY crStateCheckFramebufferStatusEXT(GLenum target);
+DECLEXPORT(GLenum) STATE_APIENTRY crStateSetFramebufferStatus(GLenum target, GLenum status);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CR_STATE_FRAMEBUFFEROBJECT_H */
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_glsl.h b/src/VBox/GuestHost/OpenGL/include/state/cr_glsl.h
new file mode 100644
index 00000000..32c3a80c
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_glsl.h
@@ -0,0 +1,122 @@
+/* $Id: cr_glsl.h $ */
+
+/** @file
+ * VBox crOpenGL: GLSL related state info
+ */
+
+/*
+ * Copyright (C) 2009-2019 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#ifndef CR_STATE_GLSL_H
+#define CR_STATE_GLSL_H
+
+#include "cr_hash.h"
+#include "state/cr_statetypes.h"
+#include "state/cr_statefuncs.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* We can't go the "easy" way of just extracting all the required data when taking snapshots.
+ Shader objects might be modified *after* program linkage and wouldn't affect program until it's relinked.
+ So we have to keep track of shaders statuses right before each program was linked as well as their "current" status.
+*/
+
+/*@todo: check rare case when successfully linked and active program is relinked with failure*/
+
+typedef struct {
+ GLuint id, hwid;
+ GLenum type; /*GL_VERTEX_SHADER or GL_FRAGMENT_SHADER*/
+ GLchar* source; /*NULL after context loading unless in program's "active" hash*/
+ GLboolean compiled, deleted;
+ GLuint refCount; /*valid only for shaders in CRGLSLState's hash*/
+} CRGLSLShader;
+
+typedef struct {
+ GLchar* name;
+ GLuint index;
+} CRGLSLAttrib;
+
+/*Note: active state will hold copies of shaders while current state references shaders in the CRGLSLState hashtable*/
+/*@todo: probably don't need a hashtable here*/
+typedef struct {
+ CRHashTable *attachedShaders;
+ CRGLSLAttrib *pAttribs; /*several names could be bound to the same index*/
+ GLuint cAttribs;
+} CRGLSLProgramState;
+
+typedef struct{
+ GLchar *name;
+ GLenum type;
+ GLvoid *data;
+#ifdef IN_GUEST
+ GLint location;
+#endif
+} CRGLSLUniform;
+
+typedef struct {
+ GLuint id, hwid;
+ GLboolean validated, linked, deleted;
+ CRGLSLProgramState activeState, currentState;
+ CRGLSLUniform *pUniforms;
+ GLuint cUniforms;
+#ifdef IN_GUEST
+ CRGLSLAttrib *pAttribs;
+ GLuint cAttribs;
+ GLboolean bUniformsSynced; /*uniforms info is updated since last link program call.*/
+ GLboolean bAttribsSynced; /*attribs info is updated since last link program call.*/
+#endif
+} CRGLSLProgram;
+
+typedef struct {
+ CRHashTable *shaders;
+ CRHashTable *programs;
+
+ CRGLSLProgram *activeProgram;
+
+ /* Indicates that we have to resend GLSL data to GPU on first glMakeCurrent call with owning context */
+ GLboolean bResyncNeeded;
+} CRGLSLState;
+
+DECLEXPORT(void) STATE_APIENTRY crStateGLSLInit(CRContext *ctx);
+DECLEXPORT(void) STATE_APIENTRY crStateGLSLDestroy(CRContext *ctx);
+DECLEXPORT(void) STATE_APIENTRY crStateGLSLSwitch(CRContext *from, CRContext *to);
+
+DECLEXPORT(GLuint) STATE_APIENTRY crStateGetShaderHWID(GLuint id);
+DECLEXPORT(GLuint) STATE_APIENTRY crStateGetProgramHWID(GLuint id);
+DECLEXPORT(GLuint) STATE_APIENTRY crStateGLSLProgramHWIDtoID(GLuint hwid);
+DECLEXPORT(GLuint) STATE_APIENTRY crStateGLSLShaderHWIDtoID(GLuint hwid);
+
+DECLEXPORT(GLint) STATE_APIENTRY crStateGetUniformSize(GLenum type);
+DECLEXPORT(GLboolean) STATE_APIENTRY crStateIsIntUniform(GLenum type);
+
+DECLEXPORT(GLuint) STATE_APIENTRY crStateCreateShader(GLuint id, GLenum type);
+DECLEXPORT(GLuint) STATE_APIENTRY crStateCreateProgram(GLuint id);
+DECLEXPORT(GLuint) STATE_APIENTRY crStateDeleteObjectARB( VBoxGLhandleARB obj );
+
+DECLEXPORT(GLboolean) STATE_APIENTRY crStateIsProgramUniformsCached(GLuint program);
+DECLEXPORT(GLboolean) STATE_APIENTRY crStateIsProgramAttribsCached(GLuint program);
+
+#ifdef IN_GUEST
+DECLEXPORT(void) STATE_APIENTRY crStateGLSLProgramCacheUniforms(GLuint program, GLsizei cbData, GLvoid *pData);
+DECLEXPORT(void) STATE_APIENTRY crStateGLSLProgramCacheAttribs(GLuint program, GLsizei cbData, GLvoid *pData);
+#else
+DECLEXPORT(void) STATE_APIENTRY crStateGLSLProgramCacheUniforms(GLuint program, GLsizei maxcbData, GLsizei *cbData, GLvoid *pData);
+DECLEXPORT(void) STATE_APIENTRY crStateGLSLProgramCacheAttribs(GLuint program, GLsizei maxcbData, GLsizei *cbData, GLvoid *pData);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CR_STATE_GLSL_H */
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_hint.h b/src/VBox/GuestHost/OpenGL/include/state/cr_hint.h
new file mode 100644
index 00000000..f6b64492
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_hint.h
@@ -0,0 +1,62 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved.
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#ifndef CR_STATE_HINT_H
+#define CR_STATE_HINT_H
+
+#include "state/cr_statetypes.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+ CRbitvalue perspectiveCorrection[CR_MAX_BITARRAY];
+ CRbitvalue pointSmooth[CR_MAX_BITARRAY];
+ CRbitvalue lineSmooth[CR_MAX_BITARRAY];
+ CRbitvalue polygonSmooth[CR_MAX_BITARRAY];
+ CRbitvalue fog[CR_MAX_BITARRAY];
+#ifdef CR_EXT_clip_volume_hint
+ CRbitvalue clipVolumeClipping[CR_MAX_BITARRAY];
+#endif
+#ifdef CR_ARB_texture_compression
+ CRbitvalue textureCompression[CR_MAX_BITARRAY];
+#endif
+#ifdef CR_SGIS_generate_mipmap
+ CRbitvalue generateMipmap[CR_MAX_BITARRAY];
+#endif
+} CRHintBits;
+
+typedef struct {
+ GLenum perspectiveCorrection;
+ GLenum pointSmooth;
+ GLenum lineSmooth;
+ GLenum polygonSmooth;
+ GLenum fog;
+#ifdef CR_EXT_clip_volume_hint
+ GLenum clipVolumeClipping;
+#endif
+#ifdef CR_ARB_texture_compression
+ GLenum textureCompression;
+#endif
+#ifdef CR_SGIS_generate_mipmap
+ GLenum generateMipmap;
+#endif
+} CRHintState;
+
+DECLEXPORT(void) crStateHintInit(CRContext *ctx);
+
+DECLEXPORT(void) crStateHintDiff(CRHintBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+DECLEXPORT(void) crStateHintSwitch(CRHintBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CR_STATE_HINT_H */
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_lighting.h b/src/VBox/GuestHost/OpenGL/include/state/cr_lighting.h
new file mode 100644
index 00000000..f10f10ec
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_lighting.h
@@ -0,0 +1,92 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved.
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#ifndef CR_STATE_LIGHTING_H
+#define CR_STATE_LIGHTING_H
+
+#include "state/cr_statetypes.h"
+
+#include <iprt/cdefs.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+ CRbitvalue enable[CR_MAX_BITARRAY];
+ CRbitvalue ambient[CR_MAX_BITARRAY];
+ CRbitvalue diffuse[CR_MAX_BITARRAY];
+ CRbitvalue specular[CR_MAX_BITARRAY];
+ CRbitvalue position[CR_MAX_BITARRAY];
+ CRbitvalue attenuation[CR_MAX_BITARRAY];
+ CRbitvalue spot[CR_MAX_BITARRAY];
+} CRLightBits;
+
+typedef struct {
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+ CRbitvalue shadeModel[CR_MAX_BITARRAY];
+ CRbitvalue colorMaterial[CR_MAX_BITARRAY];
+ CRbitvalue lightModel[CR_MAX_BITARRAY];
+ CRbitvalue material[CR_MAX_BITARRAY];
+ CRbitvalue enable[CR_MAX_BITARRAY];
+ CRLightBits *light;
+} CRLightingBits;
+
+typedef struct {
+ GLboolean enable;
+ GLcolorf ambient;
+ GLcolorf diffuse;
+ GLcolorf specular;
+ GLvectorf position;
+ GLvectorf objPosition;
+ GLfloat constantAttenuation;
+ GLfloat linearAttenuation;
+ GLfloat quadraticAttenuation;
+ GLvectorf spotDirection;
+ GLfloat spotExponent;
+ GLfloat spotCutoff;
+} CRLight;
+
+typedef struct {
+ GLboolean lighting;
+ GLboolean colorMaterial;
+ GLenum shadeModel;
+ GLenum colorMaterialMode;
+ GLenum colorMaterialFace;
+ GLcolorf ambient[2]; /* material front/back */
+ GLcolorf diffuse[2]; /* material front/back */
+ GLcolorf specular[2]; /* material front/back */
+ GLcolorf emission[2]; /* material front/back */
+ GLfloat shininess[2]; /* material front/back */
+ GLint indexes[2][3]; /* material front/back amb/diff/spec */
+ GLcolorf lightModelAmbient;
+ GLboolean lightModelLocalViewer;
+ GLboolean lightModelTwoSide;
+#if defined(CR_EXT_separate_specular_color) || defined(CR_OPENGL_VERSION_1_2)
+ GLenum lightModelColorControlEXT; /* CR_EXT_separate_specular_color */
+#endif
+ GLboolean colorSumEXT; /* CR_EXT_secondary_color */
+ CRLight *light;
+} CRLightingState;
+
+DECLEXPORT(void) crStateLightingInitBits (CRLightingBits *l);
+DECLEXPORT(void) crStateLightingDestroyBits (CRLightingBits *l);
+DECLEXPORT(void) crStateLightingInit (CRContext *ctx);
+DECLEXPORT(void) crStateLightingDestroy (CRContext *ctx);
+
+DECLEXPORT(void) crStateLightingDiff(CRLightingBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+DECLEXPORT(void) crStateLightingSwitch(CRLightingBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+
+DECLEXPORT(void) crStateColorMaterialRecover( void );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CR_STATE_LIGHTING_H */
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_limits.h b/src/VBox/GuestHost/OpenGL/include/state/cr_limits.h
new file mode 100644
index 00000000..0378ff07
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_limits.h
@@ -0,0 +1,285 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved.
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#ifndef CR_LIMITS_H
+#define CR_LIMITS_H
+
+#include "chromium.h"
+#include "cr_version.h"
+
+#include <iprt/cdefs.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* glGetString strings */
+#define CR_RENDERER "Chromium"
+#define CR_VENDOR "Humper"
+
+
+#define CR_MAX_TEXTURE_UNITS 8
+#define CR_MAX_GENERAL_COMBINERS 8
+#define CR_MAX_TEXTURE_SIZE 8192
+#define CR_MAX_3D_TEXTURE_SIZE 512
+#define CR_MAX_CUBE_TEXTURE_SIZE 4096
+#define CR_MAX_RECTANGLE_TEXTURE_SIZE 4096
+#define CR_MAX_TEXTURE_ANISOTROPY 8.0
+#define CR_MAX_LIGHTS 8
+#define CR_MAX_CLIP_PLANES 8
+#define CR_MAX_PROJECTION_STACK_DEPTH 32
+#define CR_MAX_MODELVIEW_STACK_DEPTH 32
+#define CR_MAX_TEXTURE_STACK_DEPTH 10
+#define CR_MAX_COLOR_STACK_DEPTH 2
+#define CR_MAX_ATTRIB_STACK_DEPTH 16
+#define CR_MAX_CLIENT_ATTRIB_STACK_DEPTH 16
+#define CR_MAX_NAME_STACK_DEPTH 64
+#define CR_MAX_ELEMENTS_INDICES 16384
+#define CR_MAX_ELEMENTS_VERTICES 16384
+#define CR_MAX_EVAL_ORDER 8
+#define CR_MAX_LIST_NESTING 64
+#define CR_MAX_PIXEL_MAP_TABLE 256
+#define CR_MAX_VIEWPORT_DIM 16384
+#define CR_SUBPIXEL_BITS 8
+#define CR_ALIASED_POINT_SIZE_MIN 1.0
+#define CR_ALIASED_POINT_SIZE_MAX 64.0
+#define CR_SMOOTH_POINT_SIZE_MIN 1.0
+#define CR_SMOOTH_POINT_SIZE_MAX 64.0
+#define CR_POINT_SIZE_GRANULARITY 0.5
+#define CR_ALIASED_LINE_WIDTH_MIN 1.0
+#define CR_ALIASED_LINE_WIDTH_MAX 64.0
+#define CR_SMOOTH_LINE_WIDTH_MIN 1.0
+#define CR_SMOOTH_LINE_WIDTH_MAX 64.0
+#define CR_LINE_WIDTH_GRANULARITY 0.5
+#define CR_MAX_VERTEX_ATTRIBS 16
+#define CR_MAX_TEXTURE_LOD_BIAS 8.0
+#ifdef CR_NV_fragment_program
+#define CR_MAX_TEXTURE_COORDS 2
+#define CR_MAX_TEXTURE_IMAGE_UNITS 2
+#define CR_MAX_FRAGMENT_LOCAL_PARAMS 64
+#endif
+#ifdef CR_NV_vertex_program
+#define CR_MAX_PROGRAM_MATRICES 8
+#define CR_MAX_PROGRAM_MATRIX_STACK_DEPTH 4
+#endif
+#ifdef CR_ARB_fragment_program
+#define CR_MAX_FRAGMENT_PROGRAM_INSTRUCTIONS 72
+#define CR_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMS 24
+#define CR_MAX_FRAGMENT_PROGRAM_ENV_PARAMS 256
+#define CR_MAX_FRAGMENT_PROGRAM_TEMPS 16
+#define CR_MAX_FRAGMENT_PROGRAM_ATTRIBS 10
+#define CR_MAX_FRAGMENT_PROGRAM_ADDRESS_REGS 1
+#define CR_MAX_FRAGMENT_PROGRAM_ALU_INSTRUCTIONS 48
+#define CR_MAX_FRAGMENT_PROGRAM_TEX_INSTRUCTIONS 24
+#define CR_MAX_FRAGMENT_PROGRAM_TEX_INDIRECTIONS 4
+#endif
+#ifdef CR_ARB_vertex_program
+#define CR_MAX_VERTEX_PROGRAM_INSTRUCTIONS 128
+#define CR_MAX_VERTEX_PROGRAM_LOCAL_PARAMS 96
+#define CR_MAX_VERTEX_PROGRAM_ENV_PARAMS 256 /* for GL_NV_vertex_program2 */
+#define CR_MAX_VERTEX_PROGRAM_TEMPS 12
+#define CR_MAX_VERTEX_PROGRAM_ATTRIBS 16
+#define CR_MAX_VERTEX_PROGRAM_ADDRESS_REGS 1
+#endif
+
+#if defined(CR_ARB_vertex_program) || defined(CR_ARB_fragment_program)
+/* These must be the max of the fragment and vertex program limits */
+#define CR_MAX_PROGRAM_LOCAL_PARAMS (CR_MAX_VERTEX_PROGRAM_LOCAL_PARAMS > CR_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMS ? CR_MAX_VERTEX_PROGRAM_LOCAL_PARAMS : CR_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMS)
+
+#define CR_MAX_PROGRAM_ENV_PARAMS (CR_MAX_VERTEX_PROGRAM_ENV_PARAMS > CR_MAX_FRAGMENT_PROGRAM_ENV_PARAMS ? CR_MAX_VERTEX_PROGRAM_ENV_PARAMS : CR_MAX_FRAGMENT_PROGRAM_ENV_PARAMS)
+#endif
+
+
+/* Just need these for autogenerated code in state_get.c, etc */
+#if defined(CR_ARB_vertex_program) || defined(CR_NV_vertex_program)
+#define CR_any_vertex_program 1
+#endif
+
+#if defined(CR_ARB_fragment_program) || defined(CR_NV_fragment_program)
+#define CR_any_fragment_program 1
+#endif
+
+#if defined(CR_any_vertex_program) || defined(CR_any_fragment_program)
+#define CR_any_program 1
+#endif
+
+
+
+/*
+ * OpenGL's implementation-dependent values (not part of any attribute group).
+ */
+typedef struct {
+ GLuint maxTextureUnits;
+ GLuint maxTextureSize;
+ GLuint max3DTextureSize; /* OpenGL 1.2 */
+#ifdef CR_ARB_texture_cube_map
+ GLuint maxCubeMapTextureSize;
+#endif
+ GLuint maxLights;
+ GLuint maxClipPlanes;
+ GLuint maxProjectionStackDepth;
+ GLuint maxModelviewStackDepth;
+ GLuint maxTextureStackDepth;
+ GLuint maxColorStackDepth; /* OpenGL 1.2 */
+ GLuint maxAttribStackDepth;
+ GLuint maxClientAttribStackDepth;
+ GLuint maxNameStackDepth;
+ GLuint maxElementsIndices;
+ GLuint maxElementsVertices;
+ GLuint maxEvalOrder;
+ GLuint maxListNesting;
+ GLuint maxPixelMapTable;
+ GLint maxViewportDims[2];
+ GLuint subpixelBits;
+ GLfloat aliasedPointSizeRange[2];
+ GLfloat smoothPointSizeRange[2];
+ GLfloat pointSizeGranularity;
+ GLfloat aliasedLineWidthRange[2];
+ GLfloat smoothLineWidthRange[2];
+ GLfloat lineWidthGranularity;
+#ifdef CR_EXT_texture_lod_bias
+ GLfloat maxTextureLodBias;
+#endif
+#ifdef CR_EXT_texture_filter_anisotropic
+ GLfloat maxTextureAnisotropy;
+#endif
+#ifdef CR_ARB_texture_compression
+ GLuint numCompressedFormats;
+ GLenum compressedFormats[10];
+#endif
+#ifdef CR_NV_register_combiners
+ GLuint maxGeneralCombiners;
+#endif
+#ifdef CR_NV_texture_rectangle
+ GLuint maxRectTextureSize;
+#endif
+#ifdef CR_NV_fragment_program
+ GLuint maxTextureCoords;
+ GLuint maxTextureImageUnits;
+ /*GLuint maxFragmentProgramLocalParams;*/
+#endif
+#ifdef CR_NV_vertex_program
+ GLuint maxProgramMatrixStackDepth;
+ GLuint maxProgramMatrices;
+#endif
+#ifdef CR_ARB_fragment_program
+ GLuint maxFragmentProgramInstructions;
+ GLuint maxFragmentProgramLocalParams;
+ GLuint maxFragmentProgramEnvParams;
+ GLuint maxFragmentProgramTemps;
+ GLuint maxFragmentProgramAttribs;
+ GLuint maxFragmentProgramAddressRegs;
+ GLuint maxFragmentProgramAluInstructions;
+ GLuint maxFragmentProgramTexInstructions;
+ GLuint maxFragmentProgramTexIndirections;
+#endif
+#ifdef CR_ARB_vertex_program
+ GLuint maxVertexProgramInstructions;
+ GLuint maxVertexProgramLocalParams;
+ GLuint maxVertexProgramEnvParams;
+ GLuint maxVertexProgramTemps;
+ GLuint maxVertexProgramAttribs;
+ GLuint maxVertexProgramAddressRegs;
+#endif
+ const GLubyte *extensions;
+
+ /* Framebuffer/visual attributes */
+ GLuint redBits, greenBits, blueBits, alphaBits;
+ GLuint depthBits, stencilBits, indexBits;
+ GLuint accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits;
+ GLuint auxBuffers;
+ GLboolean rgbaMode;
+ GLboolean doubleBuffer;
+ GLboolean stereo;
+ GLuint sampleBuffers;
+ GLuint samples;
+ GLuint level;
+
+} CRLimitsState;
+
+
+/* Booleans to indicate which OpenGL extensions are supported at runtime.
+ * XXX might merge this into the above structure someday.
+ */
+typedef struct {
+ GLboolean ARB_depth_texture;
+ GLboolean ARB_fragment_program;
+ GLboolean ARB_imaging;
+ GLboolean ARB_multisample;
+ GLboolean ARB_multitexture;
+ GLboolean ARB_occlusion_query;
+ GLboolean ARB_point_parameters;
+ GLboolean ARB_point_sprite;
+ GLboolean ARB_shadow;
+ GLboolean ARB_shadow_ambient;
+ GLboolean ARB_texture_border_clamp; /* or SGIS_texture_border_clamp */
+ GLboolean ARB_texture_compression;
+ GLboolean ARB_texture_cube_map; /* or EXT_texture_cube_map */
+ GLboolean ARB_texture_env_add; /* standard in OpenGL 1.3 */
+ GLboolean ARB_texture_env_combine; /* standard in OpenGL 1.3 */
+ GLboolean ARB_texture_env_crossbar; /* standard in OpenGL 1.4 */
+ GLboolean ARB_texture_env_dot3; /* standard in OpenGL 1.3 */
+ GLboolean ARB_texture_mirrored_repeat;
+ GLboolean ARB_texture_non_power_of_two; /* standard in 1.5 */
+ GLboolean ARB_transpose_matrix;
+ GLboolean ARB_vertex_buffer_object;
+ GLboolean ARB_pixel_buffer_object;
+ GLboolean ARB_vertex_program;
+ GLboolean ARB_window_pos;
+ GLboolean EXT_blend_color;
+ GLboolean EXT_blend_logic_op;
+ GLboolean EXT_blend_func_separate;
+ GLboolean EXT_blend_minmax;
+ GLboolean EXT_blend_subtract;
+ GLboolean EXT_clip_volume_hint;
+ GLboolean EXT_fog_coord;
+ GLboolean EXT_multi_draw_arrays;
+ GLboolean EXT_secondary_color;
+ GLboolean EXT_separate_specular_color;
+ GLboolean EXT_shadow_funcs;
+ GLboolean EXT_stencil_wrap;
+ GLboolean EXT_texture_edge_clamp; /* or SGIS_texture_edge_clamp */
+ GLboolean EXT_texture_filter_anisotropic;
+ GLboolean EXT_texture_lod_bias;
+ GLboolean EXT_texture3D;
+ GLboolean IBM_rasterpos_clip;
+ GLboolean NV_fog_distance;
+ GLboolean NV_fragment_program;
+ GLboolean NV_register_combiners;
+ GLboolean NV_register_combiners2;
+ GLboolean NV_texgen_reflection;
+ GLboolean NV_texture_rectangle;
+ GLboolean NV_vertex_program;
+ GLboolean NV_vertex_program1_1;
+ GLboolean NV_vertex_program2;
+ GLboolean SGIS_generate_mipmap;
+ GLboolean EXT_texture_from_pixmap;
+ GLboolean ATI_texture_mirror_once;
+
+ /* derived from above */
+ GLboolean any_vertex_program; /* NV or ARB */
+ GLboolean any_fragment_program; /* NV or ARB */
+ GLboolean any_program; /* vertex or fragment */
+} CRExtensionState;
+
+extern DECLEXPORT(void) crStateLimitsInit(CRLimitsState *limits);
+extern DECLEXPORT(void) crStateLimitsDestroy(CRLimitsState *limits);
+
+extern DECLEXPORT(void) crStateLimitsPrint(const CRLimitsState *limits);
+
+extern DECLEXPORT(GLfloat) crStateComputeVersion(float minVersion);
+
+extern DECLEXPORT(GLubyte *) crStateMergeExtensions(GLuint n, const GLubyte **extensions);
+
+extern DECLEXPORT(void) crStateExtensionsInit( CRLimitsState *limits, CRExtensionState *extensions );
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CR_STATE_FOG_H */
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_line.h b/src/VBox/GuestHost/OpenGL/include/state/cr_line.h
new file mode 100644
index 00000000..98a0bd26
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_line.h
@@ -0,0 +1,44 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved.
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#ifndef CR_STATE_LINE_H
+#define CR_STATE_LINE_H
+
+#include "state/cr_statetypes.h"
+
+#include <iprt/cdefs.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ CRbitvalue enable[CR_MAX_BITARRAY];
+ CRbitvalue width[CR_MAX_BITARRAY];
+ CRbitvalue stipple[CR_MAX_BITARRAY];
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+} CRLineBits;
+
+typedef struct {
+ GLboolean lineSmooth;
+ GLboolean lineStipple;
+ GLfloat width;
+ GLushort pattern;
+ GLint repeat;
+} CRLineState;
+
+DECLEXPORT(void) crStateLineInit (CRContext *ctx);
+
+DECLEXPORT(void) crStateLineDiff(CRLineBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+DECLEXPORT(void) crStateLineSwitch(CRLineBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CR_STATE_LINE_H */
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_lists.h b/src/VBox/GuestHost/OpenGL/include/state/cr_lists.h
new file mode 100644
index 00000000..f8608db7
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_lists.h
@@ -0,0 +1,45 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved.
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#ifndef CR_STATE_LISTS_H
+#define CR_STATE_LISTS_H
+
+#include "cr_hash.h"
+#include "state/cr_statetypes.h"
+
+#include <iprt/cdefs.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+typedef struct {
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+ CRbitvalue base[CR_MAX_BITARRAY];
+} CRListsBits;
+
+typedef struct {
+ GLboolean newEnd;
+ GLuint base; /* set by glListBase */
+ GLuint currentIndex; /* list currently being built (or zero) */
+ GLenum mode; /* GL_COMPILE, GL_COMPILE_AND_EXECUTE or zero */
+} CRListsState;
+
+
+DECLEXPORT(void) crStateListsInit(CRContext *ctx);
+DECLEXPORT(void) crStateListsDestroy(CRContext *ctx);
+
+DECLEXPORT(void) crStateListsDiff(CRListsBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+DECLEXPORT(void) crStateListsSwitch(CRListsBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_multisample.h b/src/VBox/GuestHost/OpenGL/include/state/cr_multisample.h
new file mode 100644
index 00000000..38634ed0
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_multisample.h
@@ -0,0 +1,47 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved.
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#ifndef CR_STATE_MULTISAMPLE_H
+#define CR_STATE_MULTISAMPLE_H
+
+#include "state/cr_statetypes.h"
+
+#include <iprt/cdefs.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+ CRbitvalue enable[CR_MAX_BITARRAY];
+ CRbitvalue sampleAlphaToCoverage[CR_MAX_BITARRAY];
+ CRbitvalue sampleAlphaToOne[CR_MAX_BITARRAY];
+ CRbitvalue sampleCoverage[CR_MAX_BITARRAY];
+ CRbitvalue sampleCoverageValue[CR_MAX_BITARRAY]; /* and invert */
+} CRMultisampleBits;
+
+typedef struct {
+ GLboolean enabled;
+ GLboolean sampleAlphaToCoverage;
+ GLboolean sampleAlphaToOne;
+ GLboolean sampleCoverage;
+ GLfloat sampleCoverageValue;
+ GLboolean sampleCoverageInvert;
+} CRMultisampleState;
+
+DECLEXPORT(void) crStateMultisampleInit(CRContext *ctx);
+
+DECLEXPORT(void) crStateMultisampleDiff(CRMultisampleBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+DECLEXPORT(void) crStateMultisampleSwitch(CRMultisampleBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CR_STATE_MULTISAMPLE_H */
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_occlude.h b/src/VBox/GuestHost/OpenGL/include/state/cr_occlude.h
new file mode 100644
index 00000000..9791ec6a
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_occlude.h
@@ -0,0 +1,58 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved.
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#ifndef CR_OCCLUSION_H
+#define CR_OCCLUSION_H
+
+#include "cr_hash.h"
+#include "state/cr_statetypes.h"
+
+#include <iprt/cdefs.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+} CROcclusionBits;
+
+
+/*
+ * Occlusion query object.
+ */
+typedef struct {
+ GLenum target;
+ GLuint name;
+ GLuint refCount;
+ GLuint passedCounter;
+ GLboolean active;
+ CRbitvalue dirty[CR_MAX_BITARRAY]; /* dirty data or state */
+ GLintptrARB dirtyStart, dirtyLength; /* dirty region */
+} CROcclusionObject;
+
+
+typedef struct {
+ CRHashTable *objects;
+ GLuint currentQueryObject;
+} CROcclusionState;
+
+
+DECLEXPORT(void) crStateOcclusionInit(CRContext *ctx);
+
+DECLEXPORT(void) crStateOcclusionDestroy(CRContext *ctx);
+
+DECLEXPORT(void) crStateOcclusionDiff(CROcclusionBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+DECLEXPORT(void) crStateOcclusionSwitch(CROcclusionBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CR_OCCLUSION_H */
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_pixel.h b/src/VBox/GuestHost/OpenGL/include/state/cr_pixel.h
new file mode 100644
index 00000000..1afed66e
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_pixel.h
@@ -0,0 +1,74 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved.
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#ifndef CR_STATE_PIXEL_H
+#define CR_STATE_PIXEL_H
+
+#include "state/cr_statetypes.h"
+#include "state/cr_limits.h"
+#include "cr_bits.h"
+
+#include <iprt/cdefs.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+ CRbitvalue transfer[CR_MAX_BITARRAY];
+ CRbitvalue zoom[CR_MAX_BITARRAY];
+ CRbitvalue maps[CR_MAX_BITARRAY];
+} CRPixelBits;
+
+typedef struct {
+ GLboolean mapColor;
+ GLboolean mapStencil;
+ GLint indexShift;
+ GLint indexOffset;
+ GLcolorf scale;
+ GLfloat depthScale;
+ GLcolorf bias;
+ GLfloat depthBias;
+ GLfloat xZoom;
+ GLfloat yZoom;
+
+ GLint mapItoI[CR_MAX_PIXEL_MAP_TABLE];
+ GLint mapStoS[CR_MAX_PIXEL_MAP_TABLE];
+ GLfloat mapItoR[CR_MAX_PIXEL_MAP_TABLE];
+ GLfloat mapItoG[CR_MAX_PIXEL_MAP_TABLE];
+ GLfloat mapItoB[CR_MAX_PIXEL_MAP_TABLE];
+ GLfloat mapItoA[CR_MAX_PIXEL_MAP_TABLE];
+ GLfloat mapRtoR[CR_MAX_PIXEL_MAP_TABLE];
+ GLfloat mapGtoG[CR_MAX_PIXEL_MAP_TABLE];
+ GLfloat mapBtoB[CR_MAX_PIXEL_MAP_TABLE];
+ GLfloat mapAtoA[CR_MAX_PIXEL_MAP_TABLE];
+
+ GLint mapItoIsize;
+ GLint mapStoSsize;
+ GLint mapItoRsize;
+ GLint mapItoGsize;
+ GLint mapItoBsize;
+ GLint mapItoAsize;
+ GLint mapRtoRsize;
+ GLint mapGtoGsize;
+ GLint mapBtoBsize;
+ GLint mapAtoAsize;
+} CRPixelState;
+
+DECLEXPORT(void) crStatePixelInit( CRContext *ctx );
+
+DECLEXPORT(void) crStatePixelDiff(CRPixelBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+DECLEXPORT(void) crStatePixelSwitch(CRPixelBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* CR_STATE_PIXEL_H */
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_point.h b/src/VBox/GuestHost/OpenGL/include/state/cr_point.h
new file mode 100644
index 00000000..1db3f7a1
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_point.h
@@ -0,0 +1,62 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved.
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#ifndef CR_STATE_POINT_H
+#define CR_STATE_POINT_H
+
+#include "state/cr_statetypes.h"
+
+#include <iprt/cdefs.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ CRbitvalue enableSmooth[CR_MAX_BITARRAY];
+ CRbitvalue size[CR_MAX_BITARRAY];
+#ifdef CR_ARB_point_parameters
+ CRbitvalue minSize[CR_MAX_BITARRAY];
+ CRbitvalue maxSize[CR_MAX_BITARRAY];
+ CRbitvalue fadeThresholdSize[CR_MAX_BITARRAY];
+ CRbitvalue distanceAttenuation[CR_MAX_BITARRAY];
+#endif
+#ifdef CR_ARB_point_sprite
+ CRbitvalue enableSprite[CR_MAX_BITARRAY];
+ CRbitvalue coordReplacement[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
+#endif
+ CRbitvalue spriteCoordOrigin[CR_MAX_BITARRAY];
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+} CRPointBits;
+
+typedef struct {
+ GLboolean pointSmooth;
+ GLfloat pointSize;
+#ifdef CR_ARB_point_parameters
+ GLfloat minSize, maxSize;
+ GLfloat fadeThresholdSize;
+ GLfloat distanceAttenuation[3];
+#endif
+#ifdef CR_ARB_point_sprite
+ GLboolean pointSprite;
+ GLboolean coordReplacement[CR_MAX_TEXTURE_UNITS];
+#endif
+ GLfloat spriteCoordOrigin;
+ GLfloat reserved; /* added to make sure alignment of sttructures following CRPointState in CRContext does not change */
+} CRPointState;
+
+DECLEXPORT(void) crStatePointInit (CRContext *ctx);
+
+DECLEXPORT(void) crStatePointDiff(CRPointBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+DECLEXPORT(void) crStatePointSwitch(CRPointBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CR_STATE_POINT_H */
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_polygon.h b/src/VBox/GuestHost/OpenGL/include/state/cr_polygon.h
new file mode 100644
index 00000000..33cdf79d
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_polygon.h
@@ -0,0 +1,53 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved.
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#ifndef CR_STATE_POLYGON_H
+#define CR_STATE_POLYGON_H
+
+#include "state/cr_statetypes.h"
+
+#include <iprt/cdefs.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ CRbitvalue enable[CR_MAX_BITARRAY];
+ CRbitvalue offset[CR_MAX_BITARRAY];
+ CRbitvalue mode[CR_MAX_BITARRAY];
+ CRbitvalue stipple[CR_MAX_BITARRAY];
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+} CRPolygonBits;
+
+typedef struct {
+ GLboolean polygonSmooth;
+ GLboolean polygonOffsetFill;
+ GLboolean polygonOffsetLine;
+ GLboolean polygonOffsetPoint;
+ GLboolean polygonStipple;
+ GLboolean cullFace;
+ GLfloat offsetFactor;
+ GLfloat offsetUnits;
+ GLenum cullFaceMode;
+ GLenum frontFace;
+ GLenum frontMode;
+ GLenum backMode;
+ GLint stipple[32];
+} CRPolygonState;
+
+DECLEXPORT(void) crStatePolygonInit(CRContext *ctx);
+
+DECLEXPORT(void) crStatePolygonDiff(CRPolygonBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+DECLEXPORT(void) crStatePolygonSwitch(CRPolygonBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_program.h b/src/VBox/GuestHost/OpenGL/include/state/cr_program.h
new file mode 100644
index 00000000..e43dcacd
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_program.h
@@ -0,0 +1,142 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved.
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#ifndef CR_STATE_PROGRAM_H
+#define CR_STATE_PROGRAM_H
+
+#include "cr_hash.h"
+#include "state/cr_statetypes.h"
+#include "state/cr_limits.h"
+
+#include <iprt/cdefs.h>
+
+/*
+ * Dirty bits for per-context program state. Per-program dirty bits
+ * are in the CRProgram structure.
+ */
+typedef struct {
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+ CRbitvalue vpEnable[CR_MAX_BITARRAY];
+ CRbitvalue fpEnable[CR_MAX_BITARRAY];
+ CRbitvalue vpBinding[CR_MAX_BITARRAY];
+ CRbitvalue fpBinding[CR_MAX_BITARRAY];
+ CRbitvalue vertexAttribArrayEnable[CR_MAX_VERTEX_ATTRIBS][CR_MAX_BITARRAY];
+ CRbitvalue map1AttribArrayEnable[CR_MAX_VERTEX_ATTRIBS][CR_MAX_BITARRAY];
+ CRbitvalue map2AttribArrayEnable[CR_MAX_VERTEX_ATTRIBS][CR_MAX_BITARRAY];
+ /* per-param flags: */
+ CRbitvalue vertexEnvParameter[CR_MAX_VERTEX_PROGRAM_ENV_PARAMS][CR_MAX_BITARRAY];
+ CRbitvalue fragmentEnvParameter[CR_MAX_FRAGMENT_PROGRAM_ENV_PARAMS][CR_MAX_BITARRAY];
+ /* any param flags: */
+ CRbitvalue vertexEnvParameters[CR_MAX_BITARRAY];
+ CRbitvalue fragmentEnvParameters[CR_MAX_BITARRAY];
+ CRbitvalue trackMatrix[CR_MAX_VERTEX_PROGRAM_ENV_PARAMS / 4][CR_MAX_BITARRAY];
+} CRProgramBits;
+
+
+/*
+ * Fragment programs have named symbols which are defined/declared
+ * within the fragment program that can also be set with the
+ * glProgramNamedParameter4*NV() functions.
+ * We keep a linked list of these CRProgramSymbol structures to implement
+ * a symbol table. A simple linked list is sufficient since a fragment
+ * program typically has just a few symbols.
+ */
+typedef struct CRProgramSymbol {
+ const char *name;
+ GLuint cbName;
+ GLfloat value[4];
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+ struct CRProgramSymbol *next;
+} CRProgramSymbol;
+
+
+/*
+ * A vertex or fragment program.
+ */
+typedef struct {
+ GLenum target;
+ GLuint id;
+ GLboolean isARBprogram; /* to distinguish between NV and ARB programs */
+ const GLubyte *string;
+ GLsizei length;
+ GLboolean resident;
+ GLenum format;
+
+ /* Set with ProgramNamedParameterNV */
+ struct CRProgramSymbol *symbolTable;
+
+ /* Set with ProgramLocalParameterARB: */
+ GLfloat parameters[CR_MAX_PROGRAM_LOCAL_PARAMS][4];
+
+ /* ARB info (this could be impossible to implement without parsing */
+ GLint numInstructions;
+ GLint numTemporaries;
+ GLint numParameters;
+ GLint numAttributes;
+ GLint numAddressRegs;
+ GLint numAluInstructions;
+ GLint numTexInstructions;
+ GLint numTexIndirections;
+
+ CRbitvalue dirtyNamedParams[CR_MAX_BITARRAY];
+ CRbitvalue dirtyParam[CR_MAX_PROGRAM_LOCAL_PARAMS][CR_MAX_BITARRAY];
+ CRbitvalue dirtyParams[CR_MAX_BITARRAY];
+ CRbitvalue dirtyProgram[CR_MAX_BITARRAY];
+} CRProgram;
+
+
+
+typedef struct {
+ CRProgram *currentVertexProgram;
+ CRProgram *currentFragmentProgram;
+ GLint errorPos;
+ const GLubyte *errorString;
+ GLboolean loadedProgram; /* XXX temporary */
+
+ CRProgram *defaultVertexProgram;
+ CRProgram *defaultFragmentProgram;
+
+ /* tracking matrices for vertex programs */
+#ifdef VBOX /* see state_program.c */
+ GLenum TrackMatrix[CR_MAX_VERTEX_PROGRAM_ENV_PARAMS / 4];
+ GLenum TrackMatrixTransform[CR_MAX_VERTEX_PROGRAM_ENV_PARAMS / 4];
+#else
+ GLenum TrackMatrix[CR_MAX_VERTEX_PROGRAM_LOCAL_PARAMS / 4];
+ GLenum TrackMatrixTransform[CR_MAX_VERTEX_PROGRAM_LOCAL_PARAMS / 4];
+#endif
+
+ /* global/env params shared by all programs */
+ GLfloat fragmentParameters[CR_MAX_FRAGMENT_PROGRAM_ENV_PARAMS][4];
+ GLfloat vertexParameters[CR_MAX_VERTEX_PROGRAM_ENV_PARAMS][4];
+
+ CRHashTable *programHash; /* XXX belongs in shared state, actually */
+
+ GLuint vpProgramBinding;
+ GLuint fpProgramBinding;
+ GLboolean vpEnabled; /* GL_VERTEX_PROGRAM_NV / ARB*/
+ GLboolean fpEnabled; /* GL_FRAGMENT_PROGRAM_NV */
+ GLboolean fpEnabledARB; /* GL_FRAGMENT_PROGRAM_ARB */
+ GLboolean vpPointSize; /* GL_VERTEX_PROGRAM_NV */
+ GLboolean vpTwoSide; /* GL_VERTEX_PROGRAM_NV */
+
+ /* Indicates that we have to resend program data to GPU on first glMakeCurrent call with owning context */
+ GLboolean bResyncNeeded;
+
+} CRProgramState;
+
+
+
+extern DECLEXPORT(void) crStateProgramInit(CRContext *ctx);
+extern DECLEXPORT(void) crStateProgramDestroy(CRContext *ctx);
+
+extern DECLEXPORT(void) crStateProgramDiff(CRProgramBits *b, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+extern DECLEXPORT(void) crStateProgramSwitch(CRProgramBits *b, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+
+DECLEXPORT(void) crStateDiffAllPrograms(CRContext *g, CRbitvalue *bitID, GLboolean bForceUpdate);
+
+#endif /* CR_STATE_PROGRAM_H */
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_regcombiner.h b/src/VBox/GuestHost/OpenGL/include/state/cr_regcombiner.h
new file mode 100644
index 00000000..69af2a93
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_regcombiner.h
@@ -0,0 +1,71 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved.
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#ifndef CR_STATE_REGCOMBINER_H
+#define CR_STATE_REGCOMBINER_H
+
+#include "state/cr_statetypes.h"
+#include "state/cr_limits.h"
+
+#include <iprt/cdefs.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ GLenum a, b, c, d;
+ GLenum aMapping, bMapping, cMapping, dMapping;
+ GLenum aPortion, bPortion, cPortion, dPortion;
+ GLenum scale, bias;
+ GLenum abOutput, cdOutput, sumOutput;
+ GLboolean abDotProduct, cdDotProduct, muxSum;
+} CRRegCombinerPortionState;
+
+typedef struct {
+ GLboolean enabledRegCombiners;
+ GLboolean enabledPerStageConstants;
+
+ GLcolorf constantColor0;
+ GLcolorf constantColor1;
+ GLcolorf stageConstantColor0[CR_MAX_GENERAL_COMBINERS];
+ GLcolorf stageConstantColor1[CR_MAX_GENERAL_COMBINERS];
+ GLboolean colorSumClamp;
+ GLint numGeneralCombiners;
+
+ CRRegCombinerPortionState rgb[CR_MAX_GENERAL_COMBINERS];
+ CRRegCombinerPortionState alpha[CR_MAX_GENERAL_COMBINERS];
+
+ GLenum a, b, c, d, e, f, g;
+ GLenum aMapping, bMapping, cMapping, dMapping, eMapping, fMapping, gMapping;
+ GLenum aPortion, bPortion, cPortion, dPortion, ePortion, fPortion, gPortion;
+} CRRegCombinerState;
+
+typedef struct {
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+ CRbitvalue enable[CR_MAX_BITARRAY];
+ CRbitvalue regCombinerVars[CR_MAX_BITARRAY]; /* numGeneralCombiners, colorSumClamp */
+ CRbitvalue regCombinerColor0[CR_MAX_BITARRAY];
+ CRbitvalue regCombinerColor1[CR_MAX_BITARRAY];
+ CRbitvalue regCombinerStageColor0[CR_MAX_GENERAL_COMBINERS][CR_MAX_BITARRAY];
+ CRbitvalue regCombinerStageColor1[CR_MAX_GENERAL_COMBINERS][CR_MAX_BITARRAY];
+ CRbitvalue regCombinerInput[CR_MAX_GENERAL_COMBINERS][CR_MAX_BITARRAY]; /* rgb/alpha[].a/b/c/d, .aMapping, .aPortion */
+ CRbitvalue regCombinerOutput[CR_MAX_GENERAL_COMBINERS][CR_MAX_BITARRAY]; /* rgb/alpha[].abOutput, .cdOutput, .sumOutput, .scale, .bias, .abDotProduct, .cdDotProduct, .muxSum */
+ CRbitvalue regCombinerFinalInput[CR_MAX_BITARRAY]; /* a/b/c/d/e/f/g, aMapping, aPortion */
+} CRRegCombinerBits;
+
+DECLEXPORT(void) crStateRegCombinerInit( CRContext *ctx );
+
+DECLEXPORT(void) crStateRegCombinerDiff(CRRegCombinerBits *b, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+DECLEXPORT(void) crStateRegCombinerSwitch( CRRegCombinerBits *b, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CR_STATE_REGCOMBINER_H */
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_stateerror.h b/src/VBox/GuestHost/OpenGL/include/state/cr_stateerror.h
new file mode 100644
index 00000000..d903e8a9
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_stateerror.h
@@ -0,0 +1,16 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved.
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#ifndef CR_STATE_ERROR_H
+#define CR_STATE_ERROR_H
+
+#include "chromium.h"
+
+#include <iprt/cdefs.h>
+
+DECLEXPORT(void) crStateError( int line, const char *file, GLenum err, const char *format, ... );
+
+#endif /* CR_STATE_ERROR_H */
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_statetypes.h b/src/VBox/GuestHost/OpenGL/include/state/cr_statetypes.h
new file mode 100644
index 00000000..4dad5ca6
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_statetypes.h
@@ -0,0 +1,209 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved.
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#ifndef CR_STATE_TYPES_H
+#define CR_STATE_TYPES_H
+
+#include "chromium.h"
+#include "cr_bits.h"
+#include "cr_matrix.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef GLfloat GLdefault;
+#define CR_DEFAULTTYPE_FLOAT
+
+#define CR_MAXBYTE ((GLbyte) 0x7F)
+#define CR_MAXUBYTE ((GLubyte) 0xFF)
+#define CR_MAXSHORT ((GLshort) 0x7FFF)
+#define CR_MAXUSHORT ((GLushort) 0xFFFF)
+#define CR_MAXINT ((GLint) 0x7FFFFFFF)
+#define CR_MAXUINT ((GLuint) 0xFFFFFFFF)
+#define CR_MAXFLOAT 1.0f
+#define CR_MAXDOUBLE 1.0
+
+#define CRBITS_LENGTH 32
+#define CRBITS_ONES 0xFFFFFFFF
+typedef unsigned int CRbitvalue;
+
+typedef struct {
+ GLfloat x1, x2, y1, y2;
+} CRrectf;
+
+typedef struct {
+ GLint x1, y1, x2, y2;
+} CRrecti;
+
+#define VECTOR(type, name) typedef struct { type x,y,z,w; } name
+#define COLOR(type, name) typedef struct { type r,g,b,a; } name
+#define TEXCOORD(type, name) typedef struct { type s,t,r,q; } name
+
+VECTOR(GLdefault,GLvector);
+VECTOR(GLenum,GLvectore);
+VECTOR(GLubyte,GLvectorub);
+VECTOR(GLbyte,GLvectorb);
+VECTOR(GLushort,GLvectorus);
+VECTOR(GLshort,GLvectors);
+VECTOR(GLint,GLvectori);
+VECTOR(GLuint,GLvectorui);
+/* These two are defined in cr_matrix.h */
+/* VECTOR(GLfloat,GLvectorf); */
+/* VECTOR(GLdouble,GLvectord); */
+COLOR(GLdefault,GLcolor);
+COLOR(GLenum,GLcolore);
+COLOR(GLubyte,GLcolorub);
+COLOR(GLbyte,GLcolorb);
+COLOR(GLushort,GLcolorus);
+COLOR(GLshort,GLcolors);
+COLOR(GLint,GLcolori);
+COLOR(GLuint,GLcolorui);
+COLOR(GLfloat,GLcolorf);
+COLOR(GLdouble,GLcolord);
+TEXCOORD(GLdefault,GLtexcoord);
+TEXCOORD(GLenum,GLtexcoorde);
+TEXCOORD(GLubyte,GLtexcoordub);
+TEXCOORD(GLbyte,GLtexcoordb);
+TEXCOORD(GLushort,GLtexcoordus);
+TEXCOORD(GLshort,GLtexcoords);
+TEXCOORD(GLint,GLtexcoordi);
+TEXCOORD(GLuint,GLtexcoordui);
+TEXCOORD(GLfloat,GLtexcoordf);
+TEXCOORD(GLdouble,GLtexcoordd);
+
+#undef VECTOR
+#undef COLOR
+#undef TEXCOORD
+
+#define COMPARE_VECTOR(a,b) ((a)[0] != (b)[0] || (a)[1] != (b)[1] || (a)[2] != (b)[2] || (a)[3] != (b)[3])
+#define COMPARE_TEXCOORD(a,b) ((a)[0] != (b)[0] || (a)[1] != (b)[1] || (a)[2] != (b)[2] || (a)[3] != (b)[3])
+#define COMPARE_COLOR(x,y) ((x)[0] != (y)[0] || (x)[1] != (y)[1] || (x)[2] != (y)[2] || (x)[3] != (y)[3])
+
+/* Assign scalers to short vectors: */
+#define ASSIGN_2V( V, V0, V1 ) \
+do { \
+ (V)[0] = V0; \
+ (V)[1] = V1; \
+} while(0)
+
+#define ASSIGN_3V( V, V0, V1, V2 ) \
+do { \
+ (V)[0] = V0; \
+ (V)[1] = V1; \
+ (V)[2] = V2; \
+} while(0)
+
+#define ASSIGN_4V( V, V0, V1, V2, V3 ) \
+do { \
+ (V)[0] = V0; \
+ (V)[1] = V1; \
+ (V)[2] = V2; \
+ (V)[3] = V3; \
+} while(0)
+
+
+/* Copy short vectors: */
+#define COPY_2V( DST, SRC ) \
+do { \
+ (DST)[0] = (SRC)[0]; \
+ (DST)[1] = (SRC)[1]; \
+} while (0)
+
+#define COPY_3V( DST, SRC ) \
+do { \
+ (DST)[0] = (SRC)[0]; \
+ (DST)[1] = (SRC)[1]; \
+ (DST)[2] = (SRC)[2]; \
+} while (0)
+
+#define COPY_4V( DST, SRC ) \
+do { \
+ (DST)[0] = (SRC)[0]; \
+ (DST)[1] = (SRC)[1]; \
+ (DST)[2] = (SRC)[2]; \
+ (DST)[3] = (SRC)[3]; \
+} while (0)
+
+#define COPY_2V_CAST( DST, SRC, CAST ) \
+do { \
+ (DST)[0] = (CAST)(SRC)[0]; \
+ (DST)[1] = (CAST)(SRC)[1]; \
+} while (0)
+
+#define COPY_3V_CAST( DST, SRC, CAST ) \
+do { \
+ (DST)[0] = (CAST)(SRC)[0]; \
+ (DST)[1] = (CAST)(SRC)[1]; \
+ (DST)[2] = (CAST)(SRC)[2]; \
+} while (0)
+
+#define COPY_4V_CAST( DST, SRC, CAST ) \
+do { \
+ (DST)[0] = (CAST)(SRC)[0]; \
+ (DST)[1] = (CAST)(SRC)[1]; \
+ (DST)[2] = (CAST)(SRC)[2]; \
+ (DST)[3] = (CAST)(SRC)[3]; \
+} while (0)
+
+#if defined(__i386__)
+#define COPY_4UBV(DST, SRC) \
+do { \
+ *((GLuint*)(DST)) = *((GLuint*)(SRC)); \
+} while (0)
+#else
+/* The GLuint cast might fail if DST or SRC are not dword-aligned (RISC) */
+#define COPY_4UBV(DST, SRC) \
+do { \
+ (DST)[0] = (SRC)[0]; \
+ (DST)[1] = (SRC)[1]; \
+ (DST)[2] = (SRC)[2]; \
+ (DST)[3] = (SRC)[3]; \
+} while (0)
+#endif
+
+#define COPY_2FV( DST, SRC ) \
+do { \
+ const GLfloat *_tmp = (SRC); \
+ (DST)[0] = _tmp[0]; \
+ (DST)[1] = _tmp[1]; \
+} while (0)
+
+#define COPY_3FV( DST, SRC ) \
+do { \
+ const GLfloat *_tmp = (SRC); \
+ (DST)[0] = _tmp[0]; \
+ (DST)[1] = _tmp[1]; \
+ (DST)[2] = _tmp[2]; \
+} while (0)
+
+#define COPY_4FV( DST, SRC ) \
+do { \
+ const GLfloat *_tmp = (SRC); \
+ (DST)[0] = _tmp[0]; \
+ (DST)[1] = _tmp[1]; \
+ (DST)[2] = _tmp[2]; \
+ (DST)[3] = _tmp[3]; \
+} while (0)
+
+
+
+#define COPY_SZ_4V(DST, SZ, SRC) \
+do { \
+ switch (SZ) { \
+ case 4: (DST)[3] = (SRC)[3]; \
+ case 3: (DST)[2] = (SRC)[2]; \
+ case 2: (DST)[1] = (SRC)[1]; \
+ case 1: (DST)[0] = (SRC)[0]; \
+ } \
+} while(0)
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CR_STATE_TYPES_H */
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_stencil.h b/src/VBox/GuestHost/OpenGL/include/state/cr_stencil.h
new file mode 100644
index 00000000..27823eb2
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_stencil.h
@@ -0,0 +1,107 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved.
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#ifndef CR_STATE_STENCIL_H
+#define CR_STATE_STENCIL_H
+
+#include "cr_glstate.h"
+#include "state/cr_statetypes.h"
+
+#include <iprt/cdefs.h>
+#include <iprt/assert.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define CRSTATE_STENCIL_BUFFER_ID_FRONT 0
+#define CRSTATE_STENCIL_BUFFER_ID_BACK 1
+#define CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK 2
+#define CRSTATE_STENCIL_BUFFER_COUNT 3
+
+/* stencil buffer settings were accessed with StencilXxx with ActiveStencilFaceEXT == GL_FRONT or StencilXxxSeparate(GL_FRONT_AND_BACK) */
+#define CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK 0
+/* stencil buffer settings were accessed with StencilXxxSeparate(GL_FRONT_FRONT) */
+#define CRSTATE_STENCIL_BUFFER_REF_ID_FRONT 1
+/* stencil buffer settings were accessed with StencilXxxSeparate(GL_FRONT_BACK) */
+#define CRSTATE_STENCIL_BUFFER_REF_ID_BACK 2
+/* stencil buffer settings were accessed with StencilXxx with ActiveStencilFaceEXT == GL_BACK */
+#define CRSTATE_STENCIL_BUFFER_REF_ID_TWO_SIDE_BACK 3
+#define CRSTATE_STENCIL_BUFFER_REF_COUNT 4
+
+typedef struct {
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+ CRbitvalue enable[CR_MAX_BITARRAY];
+ CRbitvalue func[CR_MAX_BITARRAY];
+ CRbitvalue op[CR_MAX_BITARRAY];
+ CRbitvalue clearValue[CR_MAX_BITARRAY];
+ CRbitvalue writeMask[CR_MAX_BITARRAY];
+} CRStencilBits_v_33;
+
+typedef struct {
+ CRbitvalue func[CR_MAX_BITARRAY];
+ CRbitvalue op[CR_MAX_BITARRAY];
+} CRStencilBufferRefBits;
+
+typedef struct {
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+ CRbitvalue enable[CR_MAX_BITARRAY];
+ CRbitvalue enableTwoSideEXT[CR_MAX_BITARRAY];
+ CRbitvalue activeStencilFace[CR_MAX_BITARRAY];
+ CRbitvalue clearValue[CR_MAX_BITARRAY];
+ CRbitvalue writeMask[CR_MAX_BITARRAY];
+ /* note: here we use _BUFFER_REF_ rather than _REF_ because we track the way buffers are accessed here,
+ * to ensure the correct function is called on hw->chromium state restoration,
+ * i.e. we want to avoid always calling StencilXxxSeparate, but call StencilXxx when it was actually called */
+ CRStencilBufferRefBits bufferRefs[CRSTATE_STENCIL_BUFFER_REF_COUNT];
+} CRStencilBits;
+
+typedef struct {
+ GLboolean stencilTest;
+ GLenum func;
+ GLint mask;
+ GLint ref;
+ GLenum fail;
+ GLenum passDepthFail;
+ GLenum passDepthPass;
+ GLint clearValue;
+ GLint writeMask;
+} CRStencilState_v_33;
+
+typedef struct {
+ GLenum func;
+ GLint mask;
+ GLint ref;
+ GLenum fail;
+ GLenum passDepthFail;
+ GLenum passDepthPass;
+} CRStencilBufferState;
+
+typedef struct {
+ /* true if stencil test is enabled */
+ GLboolean stencilTest;
+ /* true if GL_EXT_stencil_two_side is enabled (glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT)) */
+ GLboolean stencilTwoSideEXT;
+ /* GL_FRONT or GL_BACK */
+ GLenum activeStencilFace;
+ GLint clearValue;
+ GLint writeMask;
+ CRStencilBufferState buffers[CRSTATE_STENCIL_BUFFER_COUNT];
+} CRStencilState;
+
+DECLEXPORT(void) crStateStencilInit(CRContext *ctx);
+DECLEXPORT(void) crStateStencilBufferInit(CRStencilBufferState *s);
+
+DECLEXPORT(void) crStateStencilDiff(CRStencilBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+DECLEXPORT(void) crStateStencilSwitch(CRStencilBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CR_STATE_STENCIL_H */
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_texture.h b/src/VBox/GuestHost/OpenGL/include/state/cr_texture.h
new file mode 100644
index 00000000..707db996
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_texture.h
@@ -0,0 +1,250 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved.
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#ifndef CR_STATE_TEXTURE_H
+#define CR_STATE_TEXTURE_H
+
+#include "cr_hash.h"
+#include "state/cr_statetypes.h"
+#include "state/cr_limits.h"
+
+#include <iprt/cdefs.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Tells state tracker to rely on diff_api to store/load texture images
+ * and avoid host memory allocation.
+ */
+#define CR_STATE_NO_TEXTURE_IMAGE_STORE
+
+#if defined(CR_ARB_pixel_buffer_object) && !defined(CR_STATE_NO_TEXTURE_IMAGE_STORE)
+#error CR_ARB_pixel_buffer_object not supported without CR_STATE_NO_TEXTURE_IMAGE_STORE
+#endif
+
+#define CR_MAX_MIPMAP_LEVELS 20
+
+typedef struct {
+ GLubyte redbits;
+ GLubyte greenbits;
+ GLubyte bluebits;
+ GLubyte alphabits;
+ GLubyte luminancebits;
+ GLubyte intensitybits;
+ GLubyte indexbits;
+} CRTextureFormat;
+
+typedef struct {
+ GLubyte *img;
+ int bytes;
+ GLint width; /* width, height, depth includes the border */
+ GLint height;
+ GLint depth;
+ GLint internalFormat;
+ GLint border;
+ GLenum format;
+ GLenum type;
+ int bytesPerPixel;
+#if CR_ARB_texture_compression
+ GLboolean compressed;
+#endif
+ GLboolean generateMipmap;
+ const CRTextureFormat *texFormat;
+
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+} CRTextureLevel;
+
+typedef struct {
+ GLenum target;
+ GLuint id;
+ GLuint hwid;
+
+ /* The mipmap levels */
+ CRTextureLevel *level[6]; /* 6 cube faces */
+
+ GLcolorf borderColor;
+ GLenum minFilter, magFilter;
+ GLenum wrapS, wrapT;
+#ifdef CR_OPENGL_VERSION_1_2
+ GLenum wrapR;
+ GLfloat priority;
+ GLfloat minLod;
+ GLfloat maxLod;
+ GLint baseLevel;
+ GLint maxLevel;
+#endif
+#ifdef CR_EXT_texture_filter_anisotropic
+ GLfloat maxAnisotropy;
+#endif
+#ifdef CR_ARB_depth_texture
+ GLenum depthMode;
+#endif
+#ifdef CR_ARB_shadow
+ GLenum compareMode;
+ GLenum compareFunc;
+#endif
+#ifdef CR_ARB_shadow_ambient
+ GLfloat compareFailValue;
+#endif
+#ifdef CR_SGIS_generate_mipmap
+ GLboolean generateMipmap;
+#endif
+ GLboolean pinned; /* <- keep the texture alive if its ctxUsage reaches zero */
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+ CRbitvalue imageBit[CR_MAX_BITARRAY];
+ CRbitvalue paramsBit[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
+ /* bitfield representing the object usage. 1 means the object is used by the context with the given bitid */
+ CRbitvalue ctxUsage[CR_MAX_BITARRAY];
+} CRTextureObj;
+
+typedef struct {
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+ CRbitvalue enable[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
+ CRbitvalue current[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
+ CRbitvalue objGen[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
+ CRbitvalue eyeGen[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
+ CRbitvalue genMode[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
+ /* XXX someday create more bits for texture env state */
+ CRbitvalue envBit[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
+} CRTextureBits;
+
+typedef struct {
+ /* Current texture objects (in terms of glBindTexture and glActiveTexture) */
+ CRTextureObj *currentTexture1D;
+ CRTextureObj *currentTexture2D;
+ CRTextureObj *currentTexture3D;
+#ifdef CR_ARB_texture_cube_map
+ CRTextureObj *currentTextureCubeMap;
+#endif
+#ifdef CR_NV_texture_rectangle
+ CRTextureObj *currentTextureRect;
+#endif
+
+ GLboolean enabled1D;
+ GLboolean enabled2D;
+ GLboolean enabled3D;
+#ifdef CR_ARB_texture_cube_map
+ GLboolean enabledCubeMap;
+#endif
+#ifdef CR_NV_texture_rectangle
+ GLboolean enabledRect;
+#endif
+#ifdef CR_EXT_texture_lod_bias
+ GLfloat lodBias;
+#endif
+
+ GLenum envMode;
+ GLcolorf envColor;
+
+ /* GL_ARB_texture_env_combine */
+ GLenum combineModeRGB; /* GL_REPLACE, GL_DECAL, GL_ADD, etc. */
+ GLenum combineModeA; /* GL_REPLACE, GL_DECAL, GL_ADD, etc. */
+ GLenum combineSourceRGB[3]; /* GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
+ GLenum combineSourceA[3]; /* GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
+ GLenum combineOperandRGB[3]; /* SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
+ GLenum combineOperandA[3]; /* SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
+ GLfloat combineScaleRGB; /* 1 or 2 or 4 */
+ GLfloat combineScaleA; /* 1 or 2 or 4 */
+
+ GLtexcoordb textureGen;
+ GLvectorf objSCoeff;
+ GLvectorf objTCoeff;
+ GLvectorf objRCoeff;
+ GLvectorf objQCoeff;
+ GLvectorf eyeSCoeff;
+ GLvectorf eyeTCoeff;
+ GLvectorf eyeRCoeff;
+ GLvectorf eyeQCoeff;
+ GLtexcoorde gen;
+
+ /* These are only used for glPush/PopAttrib */
+ CRTextureObj Saved1D;
+ CRTextureObj Saved2D;
+ CRTextureObj Saved3D;
+#ifdef CR_ARB_texture_cube_map
+ CRTextureObj SavedCubeMap;
+#endif
+#ifdef CR_NV_texture_rectangle
+ CRTextureObj SavedRect;
+#endif
+} CRTextureUnit;
+
+typedef struct {
+ /* Default texture objects (name = 0) */
+ CRTextureObj base1D;
+ CRTextureObj base2D;
+ CRTextureObj base3D;
+#ifdef CR_ARB_texture_cube_map
+ CRTextureObj baseCubeMap;
+#endif
+#ifdef CR_NV_texture_rectangle
+ CRTextureObj baseRect;
+#endif
+
+ /* Proxy texture objects */
+ CRTextureObj proxy1D;
+ CRTextureObj proxy2D;
+ CRTextureObj proxy3D;
+#ifdef CR_ARB_texture_cube_map
+ CRTextureObj proxyCubeMap;
+#endif
+#ifdef CR_NV_texture_rectangle
+ CRTextureObj proxyRect;
+#endif
+
+ GLuint curTextureUnit; /* GL_ACTIVE_TEXTURE */
+
+ GLint maxLevel; /* number of mipmap levels possible: [0..max] */
+ GLint max3DLevel;
+ GLint maxCubeMapLevel;
+ GLint maxRectLevel;
+
+ GLboolean broadcastTextures; /*@todo what is it for?*/
+
+ /* Per-texture unit state: */
+ CRTextureUnit unit[CR_MAX_TEXTURE_UNITS];
+} CRTextureState;
+
+DECLEXPORT(void) crStateTextureInit(CRContext *ctx);
+DECLEXPORT(void) crStateTextureDestroy(CRContext *ctx);
+DECLEXPORT(void) crStateTextureFree(CRContext *ctx);
+
+DECLEXPORT(void) crStateTextureInitTexture(GLuint name);
+DECLEXPORT(CRTextureObj *) crStateTextureAllocate(GLuint name);
+ /*void crStateTextureDelete(GLuint name);*/
+DECLEXPORT(CRTextureObj *) crStateTextureGet(GLenum target, GLuint textureid);
+DECLEXPORT(int) crStateTextureGetSize(GLenum target, GLenum level);
+DECLEXPORT(const GLvoid *) crStateTextureGetData(GLenum target, GLenum level);
+
+DECLEXPORT(int) crStateTextureCheckDirtyImages(CRContext *from, CRContext *to, GLenum target, int textureUnit);
+
+DECLEXPORT(void) crStateTextureDiff(CRTextureBits *t, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+DECLEXPORT(void) crStateTextureSwitch(CRTextureBits *t, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+
+DECLEXPORT(void) crStateTextureObjectDiff(CRContext *fromCtx,
+ const CRbitvalue *bitID,
+ const CRbitvalue *nbitID,
+ CRTextureObj *tobj, GLboolean alwaysDirty);
+
+DECLEXPORT(void) crStateDiffAllTextureObjects( CRContext *g, CRbitvalue *bitID, GLboolean bForceUpdate );
+
+DECLEXPORT(void) crStateDeleteTextureObjectData(CRTextureObj *tobj);
+DECLEXPORT(void) crStateDeleteTextureObject(CRTextureObj *tobj);
+
+DECLEXPORT(GLuint) STATE_APIENTRY crStateTextureHWIDtoID(GLuint hwid);
+DECLEXPORT(GLuint) STATE_APIENTRY crStateGetTextureHWID(GLuint id);
+DECLEXPORT(GLuint) STATE_APIENTRY crStateGetTextureObjHWID(CRTextureObj *tobj);
+
+void crStateRegTextures(GLsizei n, GLuint *names);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CR_STATE_TEXTURE_H */
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_transform.h b/src/VBox/GuestHost/OpenGL/include/state/cr_transform.h
new file mode 100644
index 00000000..66e4709e
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_transform.h
@@ -0,0 +1,91 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved.
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#ifndef GLTRANS_H
+#define GLTRANS_H
+
+#include "state/cr_statetypes.h"
+
+#include <iprt/cdefs.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define NUM_MATRICES 4
+
+typedef struct {
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+ CRbitvalue *currentMatrix; /* points to one of the following */
+ CRbitvalue matrixMode[CR_MAX_BITARRAY];
+ CRbitvalue modelviewMatrix[CR_MAX_BITARRAY];
+ CRbitvalue projectionMatrix[CR_MAX_BITARRAY];
+ CRbitvalue colorMatrix[CR_MAX_BITARRAY];
+ CRbitvalue textureMatrix[CR_MAX_BITARRAY];
+ CRbitvalue programMatrix[CR_MAX_BITARRAY];
+ CRbitvalue clipPlane[CR_MAX_BITARRAY];
+ CRbitvalue enable[CR_MAX_BITARRAY];
+ CRbitvalue base[CR_MAX_BITARRAY];
+} CRTransformBits;
+
+typedef struct {
+ CRmatrix *top; /* points into stack */
+ CRmatrix *stack; /* array [maxDepth] of CRmatrix */
+ GLuint depth; /* 0 <= depth < maxDepth */
+ GLuint maxDepth; /* size of stack[] array */
+} CRMatrixStack;
+
+typedef struct {
+ GLvectord *clipPlane;
+ GLboolean *clip;
+
+ GLenum matrixMode;
+
+ /* matrix stacks */
+ CRMatrixStack modelViewStack;
+ CRMatrixStack projectionStack;
+ CRMatrixStack colorStack;
+ CRMatrixStack textureStack[CR_MAX_TEXTURE_UNITS];
+ CRMatrixStack programStack[CR_MAX_PROGRAM_MATRICES];
+ CRMatrixStack *currentStack;
+
+ GLboolean modelViewProjectionValid;
+ CRmatrix modelViewProjection; /* product of modelview and projection */
+
+#ifdef CR_OPENGL_VERSION_1_2
+ GLboolean rescaleNormals;
+#endif
+#ifdef CR_IBM_rasterpos_clip
+ GLboolean rasterPositionUnclipped;
+#endif
+ GLboolean normalize;
+} CRTransformState;
+
+
+DECLEXPORT(void) crStateTransformInit(CRContext *ctx);
+DECLEXPORT(void) crStateTransformDestroy(CRContext *ctx);
+
+DECLEXPORT(void) crStateInitMatrixStack(CRMatrixStack *stack, int maxDepth);
+
+DECLEXPORT(void) crStateLoadMatrix(const CRmatrix *m);
+
+DECLEXPORT(void) crStateTransformUpdateTransform(CRTransformState *t);
+DECLEXPORT(void) crStateTransformXformPoint(CRTransformState *t, GLvectorf *p);
+
+DECLEXPORT(void) crStateTransformXformPointMatrixf(const CRmatrix *m, GLvectorf *p);
+DECLEXPORT(void) crStateTransformXformPointMatrixd(const CRmatrix *m, GLvectord *p);
+
+DECLEXPORT(void) crStateTransformDiff(CRTransformBits *t, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+
+DECLEXPORT(void) crStateTransformSwitch(CRTransformBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CR_STATE_TRANSFORM_H */
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_viewport.h b/src/VBox/GuestHost/OpenGL/include/state/cr_viewport.h
new file mode 100644
index 00000000..6ea7b7a2
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_viewport.h
@@ -0,0 +1,57 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved.
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#ifndef CR_STATE_VIEWPORT_H
+#define CR_STATE_VIEWPORT_H
+
+#include "state/cr_statetypes.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+ CRbitvalue v_dims[CR_MAX_BITARRAY];
+ CRbitvalue s_dims[CR_MAX_BITARRAY];
+ CRbitvalue enable[CR_MAX_BITARRAY];
+ CRbitvalue depth[CR_MAX_BITARRAY];
+} CRViewportBits;
+
+typedef struct {
+ /* Viewport state */
+ GLint viewportX;
+ GLint viewportY;
+ GLint viewportW;
+ GLint viewportH;
+ GLclampd nearClip;
+ GLclampd farClip;
+ GLboolean viewportValid;
+
+ /* Scissor state */
+ GLboolean scissorTest;
+ GLint scissorX;
+ GLint scissorY;
+ GLsizei scissorW;
+ GLsizei scissorH;
+ GLboolean scissorValid;
+} CRViewportState;
+
+DECLEXPORT(void) crStateViewportInit(CRContext *ctx);
+
+DECLEXPORT(void) crStateViewportApply( CRViewportState *v, GLvectorf *p );
+DECLEXPORT(void) crStateViewportMakeCurrent(CRViewportState *v, CRViewportBits *vb);
+
+DECLEXPORT(void) crStateViewportDiff(CRViewportBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+DECLEXPORT(void) crStateViewportSwitch(CRViewportBits *bb, CRbitvalue *bitID,
+ CRContext *fromCtx, CRContext *toCtx);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CR_STATE_VIEWPORT_H */