mesa: Make validate_texbuffer_format function available externally
[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 *
9 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be included
19 * in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE.
28 */
29
30
31 #ifndef TEXIMAGE_H
32 #define TEXIMAGE_H
33
34
35 #include "mtypes.h"
36 #include "formats.h"
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41
42 /** Is the given value one of the 6 cube faces? */
43 static inline GLboolean
44 _mesa_is_cube_face(GLenum target)
45 {
46 return (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
47 target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB);
48 }
49
50 /** Is any of the dimensions of given texture equal to zero? */
51 static inline GLboolean
52 _mesa_is_zero_size_texture(const struct gl_texture_image *texImage)
53 {
54 return (texImage->Width == 0 ||
55 texImage->Height == 0 ||
56 texImage->Depth == 0);
57 }
58
59 /** \name Internal functions */
60 /*@{*/
61
62 extern GLint
63 _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat );
64
65
66 extern GLboolean
67 _mesa_is_proxy_texture(GLenum target);
68
69 extern GLenum
70 _mesa_get_proxy_target(GLenum target);
71
72 extern struct gl_texture_image *
73 _mesa_new_texture_image( struct gl_context *ctx );
74
75
76 extern void
77 _mesa_delete_texture_image( struct gl_context *ctx,
78 struct gl_texture_image *teximage );
79
80
81 extern void
82 _mesa_init_teximage_fields(struct gl_context *ctx,
83 struct gl_texture_image *img,
84 GLsizei width, GLsizei height, GLsizei depth,
85 GLint border, GLenum internalFormat,
86 gl_format format);
87
88
89 extern gl_format
90 _mesa_choose_texture_format(struct gl_context *ctx,
91 struct gl_texture_object *texObj,
92 GLenum target, GLint level,
93 GLenum internalFormat, GLenum format, GLenum type);
94
95 extern void
96 _mesa_update_fbo_texture(struct gl_context *ctx,
97 struct gl_texture_object *texObj,
98 GLuint face, GLuint level);
99
100 extern void
101 _mesa_clear_texture_image(struct gl_context *ctx,
102 struct gl_texture_image *texImage);
103
104
105 extern struct gl_texture_object *
106 _mesa_select_tex_object(struct gl_context *ctx,
107 const struct gl_texture_unit *texUnit,
108 GLenum target);
109
110 extern struct gl_texture_object *
111 _mesa_get_current_tex_object(struct gl_context *ctx, GLenum target);
112
113
114 extern struct gl_texture_image *
115 _mesa_select_tex_image(struct gl_context *ctx,
116 const struct gl_texture_object *texObj,
117 GLenum target, GLint level);
118
119
120 extern struct gl_texture_image *
121 _mesa_get_tex_image(struct gl_context *ctx, struct gl_texture_object *texObj,
122 GLenum target, GLint level);
123
124
125 extern GLint
126 _mesa_max_texture_levels(struct gl_context *ctx, GLenum target);
127
128
129 extern GLboolean
130 _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level,
131 gl_format format,
132 GLint width, GLint height, GLint depth, GLint border);
133
134
135 extern GLuint
136 _mesa_tex_target_to_face(GLenum target);
137
138 extern GLint
139 _mesa_get_texture_dimensions(GLenum target);
140
141 extern GLsizei
142 _mesa_get_tex_max_num_levels(GLenum target, GLsizei width, GLsizei height,
143 GLsizei depth);
144
145 extern GLboolean
146 _mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target,
147 GLint level, GLint width, GLint height,
148 GLint depth, GLint border);
149
150 extern gl_format
151 _mesa_validate_texbuffer_format(const struct gl_context *ctx,
152 GLenum internalFormat);
153
154 /**
155 * Lock a texture for updating. See also _mesa_lock_context_textures().
156 */
157 static inline void
158 _mesa_lock_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
159 {
160 _glthread_LOCK_MUTEX(ctx->Shared->TexMutex);
161 ctx->Shared->TextureStateStamp++;
162 (void) texObj;
163 }
164
165 static inline void
166 _mesa_unlock_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
167 {
168 (void) texObj;
169 _glthread_UNLOCK_MUTEX(ctx->Shared->TexMutex);
170 }
171
172 /*@}*/
173
174
175 /** \name API entry point functions */
176 /*@{*/
177
178 extern void GLAPIENTRY
179 _mesa_TexImage1D( GLenum target, GLint level, GLint internalformat,
180 GLsizei width, GLint border,
181 GLenum format, GLenum type, const GLvoid *pixels );
182
183
184 extern void GLAPIENTRY
185 _mesa_TexImage2D( GLenum target, GLint level, GLint internalformat,
186 GLsizei width, GLsizei height, GLint border,
187 GLenum format, GLenum type, const GLvoid *pixels );
188
189
190 extern void GLAPIENTRY
191 _mesa_TexImage3D( GLenum target, GLint level, GLint internalformat,
192 GLsizei width, GLsizei height, GLsizei depth, GLint border,
193 GLenum format, GLenum type, const GLvoid *pixels );
194
195
196 extern void GLAPIENTRY
197 _mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalformat,
198 GLsizei width, GLsizei height, GLsizei depth,
199 GLint border, GLenum format, GLenum type,
200 const GLvoid *pixels );
201
202 extern void GLAPIENTRY
203 _mesa_EGLImageTargetTexture2DOES( GLenum target, GLeglImageOES image );
204
205 extern void GLAPIENTRY
206 _mesa_TexSubImage1D( GLenum target, GLint level, GLint xoffset,
207 GLsizei width,
208 GLenum format, GLenum type,
209 const GLvoid *pixels );
210
211
212 extern void GLAPIENTRY
213 _mesa_TexSubImage2D( GLenum target, GLint level,
214 GLint xoffset, GLint yoffset,
215 GLsizei width, GLsizei height,
216 GLenum format, GLenum type,
217 const GLvoid *pixels );
218
219
220 extern void GLAPIENTRY
221 _mesa_TexSubImage3D( GLenum target, GLint level,
222 GLint xoffset, GLint yoffset, GLint zoffset,
223 GLsizei width, GLsizei height, GLsizei depth,
224 GLenum format, GLenum type,
225 const GLvoid *pixels );
226
227
228 extern void GLAPIENTRY
229 _mesa_CopyTexImage1D( GLenum target, GLint level, GLenum internalformat,
230 GLint x, GLint y, GLsizei width, GLint border );
231
232
233 extern void GLAPIENTRY
234 _mesa_CopyTexImage2D( GLenum target, GLint level,
235 GLenum internalformat, GLint x, GLint y,
236 GLsizei width, GLsizei height, GLint border );
237
238
239 extern void GLAPIENTRY
240 _mesa_CopyTexSubImage1D( GLenum target, GLint level, GLint xoffset,
241 GLint x, GLint y, GLsizei width );
242
243
244 extern void GLAPIENTRY
245 _mesa_CopyTexSubImage2D( GLenum target, GLint level,
246 GLint xoffset, GLint yoffset,
247 GLint x, GLint y, GLsizei width, GLsizei height );
248
249
250 extern void GLAPIENTRY
251 _mesa_CopyTexSubImage3D( GLenum target, GLint level,
252 GLint xoffset, GLint yoffset, GLint zoffset,
253 GLint x, GLint y, GLsizei width, GLsizei height );
254
255
256
257 extern void GLAPIENTRY
258 _mesa_CompressedTexImage1D(GLenum target, GLint level,
259 GLenum internalformat, GLsizei width,
260 GLint border, GLsizei imageSize,
261 const GLvoid *data);
262
263 extern void GLAPIENTRY
264 _mesa_CompressedTexImage2D(GLenum target, GLint level,
265 GLenum internalformat, GLsizei width,
266 GLsizei height, GLint border, GLsizei imageSize,
267 const GLvoid *data);
268
269 extern void GLAPIENTRY
270 _mesa_CompressedTexImage3D(GLenum target, GLint level,
271 GLenum internalformat, GLsizei width,
272 GLsizei height, GLsizei depth, GLint border,
273 GLsizei imageSize, const GLvoid *data);
274
275 extern void GLAPIENTRY
276 _mesa_CompressedTexSubImage1D(GLenum target, GLint level, GLint xoffset,
277 GLsizei width, GLenum format,
278 GLsizei imageSize, const GLvoid *data);
279
280 extern void GLAPIENTRY
281 _mesa_CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset,
282 GLint yoffset, GLsizei width, GLsizei height,
283 GLenum format, GLsizei imageSize,
284 const GLvoid *data);
285
286 extern void GLAPIENTRY
287 _mesa_CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset,
288 GLint yoffset, GLint zoffset, GLsizei width,
289 GLsizei height, GLsizei depth, GLenum format,
290 GLsizei imageSize, const GLvoid *data);
291
292
293 extern void GLAPIENTRY
294 _mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer);
295
296 extern void GLAPIENTRY
297 _mesa_TexBufferRange(GLenum target, GLenum internalFormat, GLuint buffer,
298 GLintptr offset, GLsizeiptr size);
299
300
301 extern void GLAPIENTRY
302 _mesa_TexImage2DMultisample(GLenum target, GLsizei samples,
303 GLenum internalformat, GLsizei width,
304 GLsizei height, GLboolean fixedsamplelocations);
305
306 extern void GLAPIENTRY
307 _mesa_TexImage3DMultisample(GLenum target, GLsizei samples,
308 GLenum internalformat, GLsizei width,
309 GLsizei height, GLsizei depth,
310 GLboolean fixedsamplelocations);
311
312 extern void GLAPIENTRY
313 _mesa_TexStorage2DMultisample(GLenum target, GLsizei samples,
314 GLenum internalformat, GLsizei width,
315 GLsizei height, GLboolean fixedsamplelocations);
316
317 extern void GLAPIENTRY
318 _mesa_TexStorage3DMultisample(GLenum target, GLsizei samples,
319 GLenum internalformat, GLsizei width,
320 GLsizei height, GLsizei depth,
321 GLboolean fixedsamplelocations);
322
323 /*@}*/
324
325 #ifdef __cplusplus
326 }
327 #endif
328
329 #endif