st/mesa: call glthread_destroy() before _vbo_DestroyContext()
[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 &&
47 target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z);
48 }
49
50
51 /**
52 * Return number of faces for a texture target. This will be 6 for
53 * cube maps and 1 otherwise.
54 * NOTE: this function is not used for cube map arrays which operate
55 * more like 2D arrays than cube maps.
56 */
57 static inline GLuint
58 _mesa_num_tex_faces(GLenum target)
59 {
60 switch (target) {
61 case GL_TEXTURE_CUBE_MAP:
62 case GL_PROXY_TEXTURE_CUBE_MAP:
63 return 6;
64 default:
65 return 1;
66 }
67 }
68
69
70 /**
71 * If the target is GL_TEXTURE_CUBE_MAP, return one of the
72 * GL_TEXTURE_CUBE_MAP_POSITIVE/NEGATIVE_X/Y/Z targets corresponding to
73 * the face parameter.
74 * Else, return target as-is.
75 */
76 static inline GLenum
77 _mesa_cube_face_target(GLenum target, unsigned face)
78 {
79 if (target == GL_TEXTURE_CUBE_MAP) {
80 assert(face < 6);
81 return GL_TEXTURE_CUBE_MAP_POSITIVE_X + face;
82 }
83 else {
84 return target;
85 }
86 }
87
88
89 /**
90 * For cube map faces, return a face index in [0,5].
91 * For other targets return 0;
92 */
93 static inline GLuint
94 _mesa_tex_target_to_face(GLenum target)
95 {
96 if (_mesa_is_cube_face(target))
97 return (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
98 else
99 return 0;
100 }
101
102
103 /** Are any of the dimensions of given texture equal to zero? */
104 static inline GLboolean
105 _mesa_is_zero_size_texture(const struct gl_texture_image *texImage)
106 {
107 return (texImage->Width == 0 ||
108 texImage->Height == 0 ||
109 texImage->Depth == 0);
110 }
111
112 /** \name Internal functions */
113 /*@{*/
114
115 extern GLboolean
116 _mesa_is_proxy_texture(GLenum target);
117
118 extern bool
119 _mesa_is_array_texture(GLenum target);
120
121
122 extern void
123 _mesa_delete_texture_image( struct gl_context *ctx,
124 struct gl_texture_image *teximage );
125
126
127 extern void
128 _mesa_init_teximage_fields(struct gl_context *ctx,
129 struct gl_texture_image *img,
130 GLsizei width, GLsizei height, GLsizei depth,
131 GLint border, GLenum internalFormat,
132 mesa_format format);
133
134
135 extern mesa_format
136 _mesa_choose_texture_format(struct gl_context *ctx,
137 struct gl_texture_object *texObj,
138 GLenum target, GLint level,
139 GLenum internalFormat, GLenum format, GLenum type);
140
141 extern void
142 _mesa_update_fbo_texture(struct gl_context *ctx,
143 struct gl_texture_object *texObj,
144 GLuint face, GLuint level);
145
146 extern void
147 _mesa_clear_texture_image(struct gl_context *ctx,
148 struct gl_texture_image *texImage);
149
150
151 extern struct gl_texture_image *
152 _mesa_select_tex_image(const struct gl_texture_object *texObj,
153 GLenum target, GLint level);
154
155
156 extern struct gl_texture_image *
157 _mesa_get_tex_image(struct gl_context *ctx, struct gl_texture_object *texObj,
158 GLenum target, GLint level);
159
160
161 /**
162 * Return the base-level texture image for the given texture object.
163 */
164 static inline const struct gl_texture_image *
165 _mesa_base_tex_image(const struct gl_texture_object *texObj)
166 {
167 return texObj->Image[0][texObj->BaseLevel];
168 }
169
170
171 extern GLint
172 _mesa_max_texture_levels(struct gl_context *ctx, GLenum target);
173
174
175 extern GLboolean
176 _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target,
177 GLuint numLevels, GLint level,
178 mesa_format format, GLuint numSamples,
179 GLint width, GLint height, GLint depth);
180
181 extern GLboolean
182 _mesa_target_can_be_compressed(const struct gl_context *ctx, GLenum target,
183 GLenum intFormat, GLenum *error);
184
185 extern GLint
186 _mesa_get_texture_dimensions(GLenum target);
187
188 extern GLboolean
189 _mesa_tex_target_is_layered(GLenum target);
190
191 extern GLuint
192 _mesa_get_texture_layers(const struct gl_texture_object *texObj, GLint level);
193
194 extern GLsizei
195 _mesa_get_tex_max_num_levels(GLenum target, GLsizei width, GLsizei height,
196 GLsizei depth);
197
198 extern GLboolean
199 _mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target,
200 GLint level, GLint width, GLint height,
201 GLint depth, GLint border);
202
203 extern mesa_format
204 _mesa_validate_texbuffer_format(const struct gl_context *ctx,
205 GLenum internalFormat);
206
207
208 bool
209 _mesa_legal_texture_base_format_for_target(struct gl_context *ctx,
210 GLenum target,
211 GLenum internalFormat);
212
213 bool
214 _mesa_format_no_online_compression(const struct gl_context *ctx, GLenum format);
215
216 GLboolean
217 _mesa_is_renderable_texture_format(struct gl_context *ctx, GLenum internalformat);
218
219 extern void
220 _mesa_texture_sub_image(struct gl_context *ctx, GLuint dims,
221 struct gl_texture_object *texObj,
222 struct gl_texture_image *texImage,
223 GLenum target, GLint level,
224 GLint xoffset, GLint yoffset, GLint zoffset,
225 GLsizei width, GLsizei height, GLsizei depth,
226 GLenum format, GLenum type, const GLvoid *pixels,
227 bool dsa);
228
229 extern void
230 _mesa_compressed_texture_sub_image(struct gl_context *ctx, GLuint dims,
231 struct gl_texture_object *texObj,
232 struct gl_texture_image *texImage,
233 GLenum target, GLint level,
234 GLint xoffset, GLint yoffset,
235 GLint zoffset,
236 GLsizei width, GLsizei height,
237 GLsizei depth,
238 GLenum format, GLsizei imageSize,
239 const GLvoid *data);
240
241 extern void
242 _mesa_copy_texture_sub_image(struct gl_context *ctx, GLuint dims,
243 struct gl_texture_object *texObj,
244 GLenum target, GLint level,
245 GLint xoffset, GLint yoffset, GLint zoffset,
246 GLint x, GLint y,
247 GLsizei width, GLsizei height,
248 const char *caller);
249
250 bool
251 _mesa_is_cube_map_texture(GLenum target);
252
253 /*@}*/
254
255
256 /** \name API entry point functions */
257 /*@{*/
258
259 extern void GLAPIENTRY
260 _mesa_TexImage1D( GLenum target, GLint level, GLint internalformat,
261 GLsizei width, GLint border,
262 GLenum format, GLenum type, const GLvoid *pixels );
263
264
265 extern void GLAPIENTRY
266 _mesa_TexImage2D( GLenum target, GLint level, GLint internalformat,
267 GLsizei width, GLsizei height, GLint border,
268 GLenum format, GLenum type, const GLvoid *pixels );
269
270
271 extern void GLAPIENTRY
272 _mesa_TexImage3D( GLenum target, GLint level, GLint internalformat,
273 GLsizei width, GLsizei height, GLsizei depth, GLint border,
274 GLenum format, GLenum type, const GLvoid *pixels );
275
276
277 extern void GLAPIENTRY
278 _mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalformat,
279 GLsizei width, GLsizei height, GLsizei depth,
280 GLint border, GLenum format, GLenum type,
281 const GLvoid *pixels );
282
283 extern void GLAPIENTRY
284 _mesa_EGLImageTargetTexture2DOES( GLenum target, GLeglImageOES image );
285
286 extern void GLAPIENTRY
287 _mesa_TexSubImage1D( GLenum target, GLint level, GLint xoffset,
288 GLsizei width,
289 GLenum format, GLenum type,
290 const GLvoid *pixels );
291
292
293 extern void GLAPIENTRY
294 _mesa_TexSubImage2D( GLenum target, GLint level,
295 GLint xoffset, GLint yoffset,
296 GLsizei width, GLsizei height,
297 GLenum format, GLenum type,
298 const GLvoid *pixels );
299
300
301 extern void GLAPIENTRY
302 _mesa_TexSubImage3D( GLenum target, GLint level,
303 GLint xoffset, GLint yoffset, GLint zoffset,
304 GLsizei width, GLsizei height, GLsizei depth,
305 GLenum format, GLenum type,
306 const GLvoid *pixels );
307
308 extern void GLAPIENTRY
309 _mesa_TextureSubImage1D(GLuint texture, GLint level, GLint xoffset,
310 GLsizei width,
311 GLenum format, GLenum type,
312 const GLvoid *pixels);
313
314
315 extern void GLAPIENTRY
316 _mesa_TextureSubImage2D(GLuint texture, GLint level,
317 GLint xoffset, GLint yoffset,
318 GLsizei width, GLsizei height,
319 GLenum format, GLenum type,
320 const GLvoid *pixels);
321
322 extern void GLAPIENTRY
323 _mesa_TextureSubImage3D(GLuint texture, GLint level,
324 GLint xoffset, GLint yoffset, GLint zoffset,
325 GLsizei width, GLsizei height, GLsizei depth,
326 GLenum format, GLenum type,
327 const GLvoid *pixels);
328
329
330 extern void GLAPIENTRY
331 _mesa_CopyTexImage1D(GLenum target, GLint level, GLenum internalformat,
332 GLint x, GLint y, GLsizei width, GLint border);
333
334
335 extern void GLAPIENTRY
336 _mesa_CopyTexImage2D( GLenum target, GLint level,
337 GLenum internalformat, GLint x, GLint y,
338 GLsizei width, GLsizei height, GLint border );
339
340
341 extern void GLAPIENTRY
342 _mesa_CopyTexSubImage1D( GLenum target, GLint level, GLint xoffset,
343 GLint x, GLint y, GLsizei width );
344
345
346 extern void GLAPIENTRY
347 _mesa_CopyTexSubImage2D( GLenum target, GLint level,
348 GLint xoffset, GLint yoffset,
349 GLint x, GLint y, GLsizei width, GLsizei height );
350
351
352 extern void GLAPIENTRY
353 _mesa_CopyTexSubImage3D( GLenum target, GLint level,
354 GLint xoffset, GLint yoffset, GLint zoffset,
355 GLint x, GLint y, GLsizei width, GLsizei height );
356
357 extern void GLAPIENTRY
358 _mesa_CopyTextureSubImage1D(GLuint texture, GLint level,
359 GLint xoffset, GLint x, GLint y, GLsizei width);
360
361 extern void GLAPIENTRY
362 _mesa_CopyTextureSubImage2D(GLuint texture, GLint level,
363 GLint xoffset, GLint yoffset,
364 GLint x, GLint y,
365 GLsizei width, GLsizei height);
366
367 extern void GLAPIENTRY
368 _mesa_CopyTextureSubImage3D(GLuint texture, GLint level,
369 GLint xoffset, GLint yoffset, GLint zoffset,
370 GLint x, GLint y,
371 GLsizei width, GLsizei height);
372
373 extern void GLAPIENTRY
374 _mesa_ClearTexSubImage( GLuint texture, GLint level,
375 GLint xoffset, GLint yoffset, GLint zoffset,
376 GLsizei width, GLsizei height, GLsizei depth,
377 GLenum format, GLenum type, const void *data );
378
379 extern void GLAPIENTRY
380 _mesa_ClearTexImage( GLuint texture, GLint level,
381 GLenum format, GLenum type, const void *data );
382
383 extern void GLAPIENTRY
384 _mesa_CompressedTexImage1D(GLenum target, GLint level,
385 GLenum internalformat, GLsizei width,
386 GLint border, GLsizei imageSize,
387 const GLvoid *data);
388
389 extern void GLAPIENTRY
390 _mesa_CompressedTexImage2D(GLenum target, GLint level,
391 GLenum internalformat, GLsizei width,
392 GLsizei height, GLint border, GLsizei imageSize,
393 const GLvoid *data);
394
395 extern void GLAPIENTRY
396 _mesa_CompressedTexImage3D(GLenum target, GLint level,
397 GLenum internalformat, GLsizei width,
398 GLsizei height, GLsizei depth, GLint border,
399 GLsizei imageSize, const GLvoid *data);
400
401 extern void GLAPIENTRY
402 _mesa_CompressedTexSubImage1D(GLenum target, GLint level, GLint xoffset,
403 GLsizei width, GLenum format,
404 GLsizei imageSize, const GLvoid *data);
405
406 extern void GLAPIENTRY
407 _mesa_CompressedTextureSubImage1D(GLuint texture, GLint level, GLint xoffset,
408 GLsizei width, GLenum format,
409 GLsizei imageSize, const GLvoid *data);
410
411 extern void GLAPIENTRY
412 _mesa_CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset,
413 GLint yoffset, GLsizei width, GLsizei height,
414 GLenum format, GLsizei imageSize,
415 const GLvoid *data);
416
417 extern void GLAPIENTRY
418 _mesa_CompressedTextureSubImage2D(GLuint texture, GLint level, GLint xoffset,
419 GLint yoffset,
420 GLsizei width, GLsizei height,
421 GLenum format, GLsizei imageSize,
422 const GLvoid *data);
423
424 extern void GLAPIENTRY
425 _mesa_CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset,
426 GLint yoffset, GLint zoffset, GLsizei width,
427 GLsizei height, GLsizei depth, GLenum format,
428 GLsizei imageSize, const GLvoid *data);
429
430 extern void GLAPIENTRY
431 _mesa_CompressedTextureSubImage3D(GLuint texture, GLint level, GLint xoffset,
432 GLint yoffset, GLint zoffset,
433 GLsizei width, GLsizei height,
434 GLsizei depth,
435 GLenum format, GLsizei imageSize,
436 const GLvoid *data);
437
438 extern void GLAPIENTRY
439 _mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer);
440
441 extern void GLAPIENTRY
442 _mesa_TexBufferRange(GLenum target, GLenum internalFormat, GLuint buffer,
443 GLintptr offset, GLsizeiptr size);
444
445 extern void GLAPIENTRY
446 _mesa_TextureBuffer(GLuint texture, GLenum internalFormat, GLuint buffer);
447
448 extern void GLAPIENTRY
449 _mesa_TextureBufferRange(GLuint texture, GLenum internalFormat, GLuint buffer,
450 GLintptr offset, GLsizeiptr size);
451
452
453 extern void GLAPIENTRY
454 _mesa_TexImage2DMultisample(GLenum target, GLsizei samples,
455 GLenum internalformat, GLsizei width,
456 GLsizei height, GLboolean fixedsamplelocations);
457
458 extern void GLAPIENTRY
459 _mesa_TexImage3DMultisample(GLenum target, GLsizei samples,
460 GLenum internalformat, GLsizei width,
461 GLsizei height, GLsizei depth,
462 GLboolean fixedsamplelocations);
463
464 extern void GLAPIENTRY
465 _mesa_TexStorage2DMultisample(GLenum target, GLsizei samples,
466 GLenum internalformat, GLsizei width,
467 GLsizei height, GLboolean fixedsamplelocations);
468
469 extern void GLAPIENTRY
470 _mesa_TexStorage3DMultisample(GLenum target, GLsizei samples,
471 GLenum internalformat, GLsizei width,
472 GLsizei height, GLsizei depth,
473 GLboolean fixedsamplelocations);
474
475 void GLAPIENTRY
476 _mesa_TextureStorage2DMultisample(GLuint texture, GLsizei samples,
477 GLenum internalformat, GLsizei width,
478 GLsizei height,
479 GLboolean fixedsamplelocations);
480
481 void GLAPIENTRY
482 _mesa_TextureStorage3DMultisample(GLuint texture, GLsizei samples,
483 GLenum internalformat, GLsizei width,
484 GLsizei height, GLsizei depth,
485 GLboolean fixedsamplelocations);
486 /*@}*/
487
488 #ifdef __cplusplus
489 }
490 #endif
491
492 #endif