VirtualBox

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

Last change on this file since 63942 was 52329, checked in by vboxsync, 10 years ago

wddm/crOpenGL: prevent shared objects from being deleted till they can be used

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 7.8 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 GLboolean pinned; /* <- keep the texture alive if its ctxUsage reaches zero */
97 CRbitvalue dirty[CR_MAX_BITARRAY];
98 CRbitvalue imageBit[CR_MAX_BITARRAY];
99 CRbitvalue paramsBit[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
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} CRTextureObj;
103
104typedef struct {
105 CRbitvalue dirty[CR_MAX_BITARRAY];
106 CRbitvalue enable[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
107 CRbitvalue current[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
108 CRbitvalue objGen[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
109 CRbitvalue eyeGen[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
110 CRbitvalue genMode[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
111 /* XXX someday create more bits for texture env state */
112 CRbitvalue envBit[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
113} CRTextureBits;
114
115typedef struct {
116 /* Current texture objects (in terms of glBindTexture and glActiveTexture) */
117 CRTextureObj *currentTexture1D;
118 CRTextureObj *currentTexture2D;
119 CRTextureObj *currentTexture3D;
120#ifdef CR_ARB_texture_cube_map
121 CRTextureObj *currentTextureCubeMap;
122#endif
123#ifdef CR_NV_texture_rectangle
124 CRTextureObj *currentTextureRect;
125#endif
126
127 GLboolean enabled1D;
128 GLboolean enabled2D;
129 GLboolean enabled3D;
130#ifdef CR_ARB_texture_cube_map
131 GLboolean enabledCubeMap;
132#endif
133#ifdef CR_NV_texture_rectangle
134 GLboolean enabledRect;
135#endif
136#ifdef CR_EXT_texture_lod_bias
137 GLfloat lodBias;
138#endif
139
140 GLenum envMode;
141 GLcolorf envColor;
142
143 /* GL_ARB_texture_env_combine */
144 GLenum combineModeRGB; /* GL_REPLACE, GL_DECAL, GL_ADD, etc. */
145 GLenum combineModeA; /* GL_REPLACE, GL_DECAL, GL_ADD, etc. */
146 GLenum combineSourceRGB[3]; /* GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
147 GLenum combineSourceA[3]; /* GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
148 GLenum combineOperandRGB[3]; /* SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
149 GLenum combineOperandA[3]; /* SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
150 GLfloat combineScaleRGB; /* 1 or 2 or 4 */
151 GLfloat combineScaleA; /* 1 or 2 or 4 */
152
153 GLtexcoordb textureGen;
154 GLvectorf objSCoeff;
155 GLvectorf objTCoeff;
156 GLvectorf objRCoeff;
157 GLvectorf objQCoeff;
158 GLvectorf eyeSCoeff;
159 GLvectorf eyeTCoeff;
160 GLvectorf eyeRCoeff;
161 GLvectorf eyeQCoeff;
162 GLtexcoorde gen;
163
164 /* These are only used for glPush/PopAttrib */
165 CRTextureObj Saved1D;
166 CRTextureObj Saved2D;
167 CRTextureObj Saved3D;
168#ifdef CR_ARB_texture_cube_map
169 CRTextureObj SavedCubeMap;
170#endif
171#ifdef CR_NV_texture_rectangle
172 CRTextureObj SavedRect;
173#endif
174} CRTextureUnit;
175
176typedef struct {
177 /* Default texture objects (name = 0) */
178 CRTextureObj base1D;
179 CRTextureObj base2D;
180 CRTextureObj base3D;
181#ifdef CR_ARB_texture_cube_map
182 CRTextureObj baseCubeMap;
183#endif
184#ifdef CR_NV_texture_rectangle
185 CRTextureObj baseRect;
186#endif
187
188 /* Proxy texture objects */
189 CRTextureObj proxy1D;
190 CRTextureObj proxy2D;
191 CRTextureObj proxy3D;
192#ifdef CR_ARB_texture_cube_map
193 CRTextureObj proxyCubeMap;
194#endif
195#ifdef CR_NV_texture_rectangle
196 CRTextureObj proxyRect;
197#endif
198
199 GLuint curTextureUnit; /* GL_ACTIVE_TEXTURE */
200
201 GLint maxLevel; /* number of mipmap levels possible: [0..max] */
202 GLint max3DLevel;
203 GLint maxCubeMapLevel;
204 GLint maxRectLevel;
205
206 GLboolean broadcastTextures; /*@todo what is it for?*/
207
208 /* Per-texture unit state: */
209 CRTextureUnit unit[CR_MAX_TEXTURE_UNITS];
210} CRTextureState;
211
212DECLEXPORT(void) crStateTextureInit(CRContext *ctx);
213DECLEXPORT(void) crStateTextureDestroy(CRContext *ctx);
214DECLEXPORT(void) crStateTextureFree(CRContext *ctx);
215
216DECLEXPORT(void) crStateTextureInitTexture(GLuint name);
217DECLEXPORT(CRTextureObj *) crStateTextureAllocate(GLuint name);
218 /*void crStateTextureDelete(GLuint name);*/
219DECLEXPORT(CRTextureObj *) crStateTextureGet(GLenum target, GLuint textureid);
220DECLEXPORT(int) crStateTextureGetSize(GLenum target, GLenum level);
221DECLEXPORT(const GLvoid *) crStateTextureGetData(GLenum target, GLenum level);
222
223DECLEXPORT(int) crStateTextureCheckDirtyImages(CRContext *from, CRContext *to, GLenum target, int textureUnit);
224
225DECLEXPORT(void) crStateTextureDiff(CRTextureBits *t, CRbitvalue *bitID,
226 CRContext *fromCtx, CRContext *toCtx);
227DECLEXPORT(void) crStateTextureSwitch(CRTextureBits *t, CRbitvalue *bitID,
228 CRContext *fromCtx, CRContext *toCtx);
229
230DECLEXPORT(void) crStateTextureObjectDiff(CRContext *fromCtx,
231 const CRbitvalue *bitID,
232 const CRbitvalue *nbitID,
233 CRTextureObj *tobj, GLboolean alwaysDirty);
234
235DECLEXPORT(void) crStateDiffAllTextureObjects( CRContext *g, CRbitvalue *bitID, GLboolean bForceUpdate );
236
237DECLEXPORT(void) crStateDeleteTextureObjectData(CRTextureObj *tobj);
238DECLEXPORT(void) crStateDeleteTextureObject(CRTextureObj *tobj);
239
240DECLEXPORT(GLuint) STATE_APIENTRY crStateTextureHWIDtoID(GLuint hwid);
241DECLEXPORT(GLuint) STATE_APIENTRY crStateGetTextureHWID(GLuint id);
242DECLEXPORT(GLuint) STATE_APIENTRY crStateGetTextureObjHWID(CRTextureObj *tobj);
243
244void crStateRegTextures(GLsizei n, GLuint *names);
245
246#ifdef __cplusplus
247}
248#endif
249
250#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