VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/include/state/cr_texture.h@ 16969

Last change on this file since 16969 was 16969, checked in by vboxsync, 16 years ago

crOpenGL: don't allocate memory for textures on host side (#3461)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 7.1 KB
Line 
1/* Copyright (c) 2001, Stanford University
2 * All rights reserved.
3 *
4 * See the file LICENSE.txt for information on redistributing this software.
5 */
6
7#ifndef CR_STATE_TEXTURE_H
8#define CR_STATE_TEXTURE_H
9
10#include "cr_hash.h"
11#include "state/cr_statetypes.h"
12#include "state/cr_limits.h"
13
14#include <iprt/cdefs.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20/* Tells state tracker to rely on diff_api to store/load texture images
21 * and avoid host memory allocation.
22 */
23#define CR_STATE_NO_TEXTURE_IMAGE_STORE
24
25typedef struct {
26 GLubyte redbits;
27 GLubyte greenbits;
28 GLubyte bluebits;
29 GLubyte alphabits;
30 GLubyte luminancebits;
31 GLubyte intensitybits;
32 GLubyte indexbits;
33} CRTextureFormat;
34
35typedef struct {
36 GLubyte *img;
37 int bytes;
38 GLint width; /* width, height, depth includes the border */
39 GLint height;
40 GLint depth;
41 GLint internalFormat;
42 GLint border;
43 GLenum format;
44 GLenum type;
45 int bytesPerPixel;
46#if CR_ARB_texture_compression
47 GLboolean compressed;
48#endif
49 GLboolean generateMipmap;
50 const CRTextureFormat *texFormat;
51
52 CRbitvalue dirty[CR_MAX_BITARRAY];
53} CRTextureLevel;
54
55typedef struct {
56 GLenum target;
57 GLuint name;
58
59 /* The mipmap levels */
60 CRTextureLevel *level[6]; /* 6 cube faces */
61
62 GLcolorf borderColor;
63 GLenum minFilter, magFilter;
64 GLenum wrapS, wrapT;
65#ifdef CR_OPENGL_VERSION_1_2
66 GLenum wrapR;
67 GLfloat priority;
68 GLfloat minLod;
69 GLfloat maxLod;
70 GLint baseLevel;
71 GLint maxLevel;
72#endif
73#ifdef CR_EXT_texture_filter_anisotropic
74 GLfloat maxAnisotropy;
75#endif
76#ifdef CR_ARB_depth_texture
77 GLenum depthMode;
78#endif
79#ifdef CR_ARB_shadow
80 GLenum compareMode;
81 GLenum compareFunc;
82#endif
83#ifdef CR_ARB_shadow_ambient
84 GLfloat compareFailValue;
85#endif
86#ifdef CR_SGIS_generate_mipmap
87 GLboolean generateMipmap;
88#endif
89 CRbitvalue dirty[CR_MAX_BITARRAY];
90 CRbitvalue imageBit[CR_MAX_BITARRAY];
91 CRbitvalue paramsBit[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
92} CRTextureObj;
93
94typedef struct {
95 CRbitvalue dirty[CR_MAX_BITARRAY];
96 CRbitvalue enable[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
97 CRbitvalue current[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
98 CRbitvalue objGen[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
99 CRbitvalue eyeGen[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
100 CRbitvalue genMode[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
101 /* XXX someday create more bits for texture env state */
102 CRbitvalue envBit[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
103} CRTextureBits;
104
105typedef struct {
106 /* Current texture objects (in terms of glBindTexture and glActiveTexture) */
107 CRTextureObj *currentTexture1D;
108 CRTextureObj *currentTexture2D;
109 CRTextureObj *currentTexture3D;
110#ifdef CR_ARB_texture_cube_map
111 CRTextureObj *currentTextureCubeMap;
112#endif
113#ifdef CR_NV_texture_rectangle
114 CRTextureObj *currentTextureRect;
115#endif
116
117 GLboolean enabled1D;
118 GLboolean enabled2D;
119 GLboolean enabled3D;
120#ifdef CR_ARB_texture_cube_map
121 GLboolean enabledCubeMap;
122#endif
123#ifdef CR_NV_texture_rectangle
124 GLboolean enabledRect;
125#endif
126#ifdef CR_EXT_texture_lod_bias
127 GLfloat lodBias;
128#endif
129
130 GLenum envMode;
131 GLcolorf envColor;
132
133 /* GL_ARB_texture_env_combine */
134 GLenum combineModeRGB; /* GL_REPLACE, GL_DECAL, GL_ADD, etc. */
135 GLenum combineModeA; /* GL_REPLACE, GL_DECAL, GL_ADD, etc. */
136 GLenum combineSourceRGB[3]; /* GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
137 GLenum combineSourceA[3]; /* GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
138 GLenum combineOperandRGB[3]; /* SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
139 GLenum combineOperandA[3]; /* SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
140 GLfloat combineScaleRGB; /* 1 or 2 or 4 */
141 GLfloat combineScaleA; /* 1 or 2 or 4 */
142
143 GLtexcoordb textureGen;
144 GLvectorf objSCoeff;
145 GLvectorf objTCoeff;
146 GLvectorf objRCoeff;
147 GLvectorf objQCoeff;
148 GLvectorf eyeSCoeff;
149 GLvectorf eyeTCoeff;
150 GLvectorf eyeRCoeff;
151 GLvectorf eyeQCoeff;
152 GLtexcoorde gen;
153
154 /* These are only used for glPush/PopAttrib */
155 CRTextureObj Saved1D;
156 CRTextureObj Saved2D;
157 CRTextureObj Saved3D;
158#ifdef CR_ARB_texture_cube_map
159 CRTextureObj SavedCubeMap;
160#endif
161#ifdef CR_NV_texture_rectangle
162 CRTextureObj SavedRect;
163#endif
164} CRTextureUnit;
165
166typedef struct {
167 /* Default texture objects (name = 0) */
168 CRTextureObj base1D;
169 CRTextureObj base2D;
170 CRTextureObj base3D;
171#ifdef CR_ARB_texture_cube_map
172 CRTextureObj baseCubeMap;
173#endif
174#ifdef CR_NV_texture_rectangle
175 CRTextureObj baseRect;
176#endif
177
178 /* Proxy texture objects */
179 CRTextureObj proxy1D;
180 CRTextureObj proxy2D;
181 CRTextureObj proxy3D;
182#ifdef CR_ARB_texture_cube_map
183 CRTextureObj proxyCubeMap;
184#endif
185#ifdef CR_NV_texture_rectangle
186 CRTextureObj proxyRect;
187#endif
188
189 GLuint curTextureUnit; /* GL_ACTIVE_TEXTURE */
190
191 GLint maxLevel; /* number of mipmap levels possible: [0..max] */
192 GLint max3DLevel;
193 GLint maxCubeMapLevel;
194 GLint maxRectLevel;
195
196 GLboolean broadcastTextures; /*@todo what is it for?*/
197
198 /* Indicates that we have to resend texture data to GPU on first glMakeCurrent call with owning context */
199 GLboolean bResyncNeeded;
200
201 /* Per-texture unit state: */
202 CRTextureUnit unit[CR_MAX_TEXTURE_UNITS];
203} CRTextureState;
204
205DECLEXPORT(void) crStateTextureInit(CRContext *ctx);
206DECLEXPORT(void) crStateTextureDestroy(CRContext *ctx);
207DECLEXPORT(void) crStateTextureFree(CRContext *ctx);
208
209DECLEXPORT(void) crStateTextureInitTexture(GLuint name);
210DECLEXPORT(CRTextureObj *) crStateTextureAllocate(GLuint name);
211 /*void crStateTextureDelete(GLuint name);*/
212DECLEXPORT(CRTextureObj *) crStateTextureGet(GLenum target, GLuint textureid);
213DECLEXPORT(int) crStateTextureGetSize(GLenum target, GLenum level);
214DECLEXPORT(const GLvoid *) crStateTextureGetData(GLenum target, GLenum level);
215
216DECLEXPORT(int) crStateTextureCheckDirtyImages(CRContext *from, CRContext *to, GLenum target, int textureUnit);
217
218DECLEXPORT(void) crStateTextureDiff(CRTextureBits *t, CRbitvalue *bitID,
219 CRContext *fromCtx, CRContext *toCtx);
220DECLEXPORT(void) crStateTextureSwitch(CRTextureBits *t, CRbitvalue *bitID,
221 CRContext *fromCtx, CRContext *toCtx);
222
223DECLEXPORT(void) crStateTextureObjectDiff(CRContext *fromCtx,
224 const CRbitvalue *bitID,
225 const CRbitvalue *nbitID,
226 CRTextureObj *tobj, GLboolean alwaysDirty);
227
228DECLEXPORT(void) crStateDiffAllTextureObjects( CRContext *g, CRbitvalue *bitID, GLboolean bForceUpdate );
229
230DECLEXPORT(void) crStateDeleteTextureObjectData(CRTextureObj *tobj);
231DECLEXPORT(void) crStateDeleteTextureObject(CRTextureObj *tobj);
232
233
234#ifdef __cplusplus
235}
236#endif
237
238#endif /* CR_STATE_TEXTURE_H */
Note: See TracBrowser for help on using the repository browser.

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