VirtualBox

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

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

crOpenGL: fix gl resource leaking (server part)

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

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