Merge remote branch 'origin/master' into lp-setup-llvm
[mesa.git] / src / mesa / main / teximage.h
1 /**
2 * \file teximage.h
3 * Texture images manipulation functions.
4 */
5
6 /*
7 * Mesa 3-D graphics library
8 * Version: 6.5
9 *
10 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
26 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 */
29
30
31 #ifndef TEXIMAGE_H
32 #define TEXIMAGE_H
33
34
35 #include "mtypes.h"
36
37
38 extern void *
39 _mesa_alloc_texmemory(GLsizei bytes);
40
41 extern void
42 _mesa_free_texmemory(void *m);
43
44
45 /** \name Internal functions */
46 /*@{*/
47
48 extern GLint
49 _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat );
50
51
52 extern GLboolean
53 _mesa_is_proxy_texture(GLenum target);
54
55
56 extern struct gl_texture_image *
57 _mesa_new_texture_image( struct gl_context *ctx );
58
59
60 extern void
61 _mesa_delete_texture_image( struct gl_context *ctx, struct gl_texture_image *teximage );
62
63 extern void
64 _mesa_free_texture_image_data( struct gl_context *ctx,
65 struct gl_texture_image *texImage );
66
67
68 extern void
69 _mesa_init_teximage_fields(struct gl_context *ctx, GLenum target,
70 struct gl_texture_image *img,
71 GLsizei width, GLsizei height, GLsizei depth,
72 GLint border, GLenum internalFormat);
73
74
75 extern void
76 _mesa_choose_texture_format(struct gl_context *ctx,
77 struct gl_texture_object *texObj,
78 struct gl_texture_image *texImage,
79 GLenum target, GLint level,
80 GLenum internalFormat, GLenum format, GLenum type);
81
82
83 extern void
84 _mesa_clear_texture_image(struct gl_context *ctx, struct gl_texture_image *texImage);
85
86
87 extern void
88 _mesa_set_tex_image(struct gl_texture_object *tObj,
89 GLenum target, GLint level,
90 struct gl_texture_image *texImage);
91
92
93 extern struct gl_texture_object *
94 _mesa_select_tex_object(struct gl_context *ctx, const struct gl_texture_unit *texUnit,
95 GLenum target);
96
97 extern struct gl_texture_object *
98 _mesa_get_current_tex_object(struct gl_context *ctx, GLenum target);
99
100
101 extern struct gl_texture_image *
102 _mesa_select_tex_image(struct gl_context *ctx, const struct gl_texture_object *texObj,
103 GLenum target, GLint level);
104
105
106 extern struct gl_texture_image *
107 _mesa_get_tex_image(struct gl_context *ctx, struct gl_texture_object *texObj,
108 GLenum target, GLint level);
109
110
111 extern struct gl_texture_image *
112 _mesa_get_proxy_tex_image(struct gl_context *ctx, GLenum target, GLint level);
113
114
115 extern GLint
116 _mesa_max_texture_levels(struct gl_context *ctx, GLenum target);
117
118
119 extern GLboolean
120 _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level,
121 GLint internalFormat, GLenum format, GLenum type,
122 GLint width, GLint height, GLint depth, GLint border);
123
124
125 extern GLuint
126 _mesa_tex_target_to_face(GLenum target);
127
128
129 /**
130 * Lock a texture for updating. See also _mesa_lock_context_textures().
131 */
132 static INLINE void
133 _mesa_lock_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
134 {
135 _glthread_LOCK_MUTEX(ctx->Shared->TexMutex);
136 ctx->Shared->TextureStateStamp++;
137 (void) texObj;
138 }
139
140 static INLINE void
141 _mesa_unlock_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
142 {
143 _glthread_UNLOCK_MUTEX(ctx->Shared->TexMutex);
144 }
145
146 /*@}*/
147
148
149 /** \name API entry point functions */
150 /*@{*/
151
152 extern void GLAPIENTRY
153 _mesa_TexImage1D( GLenum target, GLint level, GLint internalformat,
154 GLsizei width, GLint border,
155 GLenum format, GLenum type, const GLvoid *pixels );
156
157
158 extern void GLAPIENTRY
159 _mesa_TexImage2D( GLenum target, GLint level, GLint internalformat,
160 GLsizei width, GLsizei height, GLint border,
161 GLenum format, GLenum type, const GLvoid *pixels );
162
163
164 extern void GLAPIENTRY
165 _mesa_TexImage3D( GLenum target, GLint level, GLint internalformat,
166 GLsizei width, GLsizei height, GLsizei depth, GLint border,
167 GLenum format, GLenum type, const GLvoid *pixels );
168
169
170 extern void GLAPIENTRY
171 _mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalformat,
172 GLsizei width, GLsizei height, GLsizei depth,
173 GLint border, GLenum format, GLenum type,
174 const GLvoid *pixels );
175
176 extern void GLAPIENTRY
177 _mesa_EGLImageTargetTexture2DOES( GLenum target, GLeglImageOES image );
178
179 extern void GLAPIENTRY
180 _mesa_TexSubImage1D( GLenum target, GLint level, GLint xoffset,
181 GLsizei width,
182 GLenum format, GLenum type,
183 const GLvoid *pixels );
184
185
186 extern void GLAPIENTRY
187 _mesa_TexSubImage2D( GLenum target, GLint level,
188 GLint xoffset, GLint yoffset,
189 GLsizei width, GLsizei height,
190 GLenum format, GLenum type,
191 const GLvoid *pixels );
192
193
194 extern void GLAPIENTRY
195 _mesa_TexSubImage3D( GLenum target, GLint level,
196 GLint xoffset, GLint yoffset, GLint zoffset,
197 GLsizei width, GLsizei height, GLsizei depth,
198 GLenum format, GLenum type,
199 const GLvoid *pixels );
200
201
202 extern void GLAPIENTRY
203 _mesa_CopyTexImage1D( GLenum target, GLint level, GLenum internalformat,
204 GLint x, GLint y, GLsizei width, GLint border );
205
206
207 extern void GLAPIENTRY
208 _mesa_CopyTexImage2D( GLenum target, GLint level,
209 GLenum internalformat, GLint x, GLint y,
210 GLsizei width, GLsizei height, GLint border );
211
212
213 extern void GLAPIENTRY
214 _mesa_CopyTexSubImage1D( GLenum target, GLint level, GLint xoffset,
215 GLint x, GLint y, GLsizei width );
216
217
218 extern void GLAPIENTRY
219 _mesa_CopyTexSubImage2D( GLenum target, GLint level,
220 GLint xoffset, GLint yoffset,
221 GLint x, GLint y, GLsizei width, GLsizei height );
222
223
224 extern void GLAPIENTRY
225 _mesa_CopyTexSubImage3D( GLenum target, GLint level,
226 GLint xoffset, GLint yoffset, GLint zoffset,
227 GLint x, GLint y, GLsizei width, GLsizei height );
228
229
230
231 extern void GLAPIENTRY
232 _mesa_CompressedTexImage1DARB(GLenum target, GLint level,
233 GLenum internalformat, GLsizei width,
234 GLint border, GLsizei imageSize,
235 const GLvoid *data);
236
237 extern void GLAPIENTRY
238 _mesa_CompressedTexImage2DARB(GLenum target, GLint level,
239 GLenum internalformat, GLsizei width,
240 GLsizei height, GLint border, GLsizei imageSize,
241 const GLvoid *data);
242
243 extern void GLAPIENTRY
244 _mesa_CompressedTexImage3DARB(GLenum target, GLint level,
245 GLenum internalformat, GLsizei width,
246 GLsizei height, GLsizei depth, GLint border,
247 GLsizei imageSize, const GLvoid *data);
248
249 #ifdef VMS
250 #define _mesa_CompressedTexSubImage1DARB _mesa_CompressedTexSubImage1DAR
251 #define _mesa_CompressedTexSubImage2DARB _mesa_CompressedTexSubImage2DAR
252 #define _mesa_CompressedTexSubImage3DARB _mesa_CompressedTexSubImage3DAR
253 #endif
254 extern void GLAPIENTRY
255 _mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
256 GLsizei width, GLenum format,
257 GLsizei imageSize, const GLvoid *data);
258
259 extern void GLAPIENTRY
260 _mesa_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
261 GLint yoffset, GLsizei width, GLsizei height,
262 GLenum format, GLsizei imageSize,
263 const GLvoid *data);
264
265 extern void GLAPIENTRY
266 _mesa_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
267 GLint yoffset, GLint zoffset, GLsizei width,
268 GLsizei height, GLsizei depth, GLenum format,
269 GLsizei imageSize, const GLvoid *data);
270
271 /*@}*/
272
273 #endif