3 * Texture images manipulation functions.
7 * Mesa 3-D graphics library
9 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
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:
18 * The above copyright notice and this permission notice shall be included
19 * in all copies or substantial portions of the Software.
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.
42 /** Is the given value one of the 6 cube faces? */
43 static inline GLboolean
44 _mesa_is_cube_face(GLenum target
)
46 return (target
>= GL_TEXTURE_CUBE_MAP_POSITIVE_X
&&
47 target
<= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
);
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.
58 _mesa_num_tex_faces(GLenum target
)
61 case GL_TEXTURE_CUBE_MAP
:
62 case GL_PROXY_TEXTURE_CUBE_MAP
:
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
74 * Else, return target as-is.
77 _mesa_cube_face_target(GLenum target
, unsigned face
)
79 if (target
== GL_TEXTURE_CUBE_MAP
) {
81 return GL_TEXTURE_CUBE_MAP_POSITIVE_X
+ face
;
90 * For cube map faces, return a face index in [0,5].
91 * For other targets return 0;
94 _mesa_tex_target_to_face(GLenum target
)
96 if (_mesa_is_cube_face(target
))
97 return (GLuint
) target
- (GLuint
) GL_TEXTURE_CUBE_MAP_POSITIVE_X
;
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
)
107 return (texImage
->Width
== 0 ||
108 texImage
->Height
== 0 ||
109 texImage
->Depth
== 0);
112 /** \name Internal functions */
116 _mesa_is_proxy_texture(GLenum target
);
119 _mesa_is_array_texture(GLenum target
);
123 _mesa_delete_texture_image( struct gl_context
*ctx
,
124 struct gl_texture_image
*teximage
);
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
,
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
);
142 _mesa_update_fbo_texture(struct gl_context
*ctx
,
143 struct gl_texture_object
*texObj
,
144 GLuint face
, GLuint level
);
147 _mesa_clear_texture_image(struct gl_context
*ctx
,
148 struct gl_texture_image
*texImage
);
151 extern struct gl_texture_image
*
152 _mesa_select_tex_image(const struct gl_texture_object
*texObj
,
153 GLenum target
, GLint level
);
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
);
161 _mesa_get_texbuffer_format(const struct gl_context
*ctx
, GLenum internalFormat
);
164 * Return the base-level texture image for the given texture object.
166 static inline const struct gl_texture_image
*
167 _mesa_base_tex_image(const struct gl_texture_object
*texObj
)
169 return texObj
->Image
[0][texObj
->BaseLevel
];
174 _mesa_max_texture_levels(struct gl_context
*ctx
, GLenum target
);
178 _mesa_test_proxy_teximage(struct gl_context
*ctx
, GLenum target
,
179 GLuint numLevels
, GLint level
,
180 mesa_format format
, GLuint numSamples
,
181 GLint width
, GLint height
, GLint depth
);
184 _mesa_target_can_be_compressed(const struct gl_context
*ctx
, GLenum target
,
185 GLenum intFormat
, GLenum
*error
);
188 _mesa_get_texture_dimensions(GLenum target
);
191 _mesa_tex_target_is_layered(GLenum target
);
194 _mesa_get_texture_layers(const struct gl_texture_object
*texObj
, GLint level
);
197 _mesa_get_tex_max_num_levels(GLenum target
, GLsizei width
, GLsizei height
,
201 _mesa_legal_texture_dimensions(struct gl_context
*ctx
, GLenum target
,
202 GLint level
, GLint width
, GLint height
,
203 GLint depth
, GLint border
);
206 _mesa_validate_texbuffer_format(const struct gl_context
*ctx
,
207 GLenum internalFormat
);
211 _mesa_legal_texture_base_format_for_target(struct gl_context
*ctx
,
213 GLenum internalFormat
);
216 _mesa_format_no_online_compression(const struct gl_context
*ctx
, GLenum format
);
219 _mesa_is_renderable_texture_format(const struct gl_context
*ctx
,
220 GLenum internalformat
);
223 _mesa_texture_sub_image(struct gl_context
*ctx
, GLuint dims
,
224 struct gl_texture_object
*texObj
,
225 struct gl_texture_image
*texImage
,
226 GLenum target
, GLint level
,
227 GLint xoffset
, GLint yoffset
, GLint zoffset
,
228 GLsizei width
, GLsizei height
, GLsizei depth
,
229 GLenum format
, GLenum type
, const GLvoid
*pixels
,
233 _mesa_texture_storage_ms_memory(struct gl_context
*ctx
, GLuint dims
,
234 struct gl_texture_object
*texObj
,
235 struct gl_memory_object
*memObj
,
236 GLenum target
, GLsizei samples
,
237 GLenum internalFormat
, GLsizei width
,
238 GLsizei height
, GLsizei depth
,
239 GLboolean fixedSampleLocations
,
240 GLuint64 offset
, const char* func
);
243 _mesa_is_cube_map_texture(GLenum target
);
248 /** \name API entry point functions */
251 extern void GLAPIENTRY
252 _mesa_TexImage1D( GLenum target
, GLint level
, GLint internalformat
,
253 GLsizei width
, GLint border
,
254 GLenum format
, GLenum type
, const GLvoid
*pixels
);
257 extern void GLAPIENTRY
258 _mesa_TexImage2D( GLenum target
, GLint level
, GLint internalformat
,
259 GLsizei width
, GLsizei height
, GLint border
,
260 GLenum format
, GLenum type
, const GLvoid
*pixels
);
263 extern void GLAPIENTRY
264 _mesa_TexImage3D( GLenum target
, GLint level
, GLint internalformat
,
265 GLsizei width
, GLsizei height
, GLsizei depth
, GLint border
,
266 GLenum format
, GLenum type
, const GLvoid
*pixels
);
269 extern void GLAPIENTRY
270 _mesa_TexImage3DEXT( GLenum target
, GLint level
, GLenum internalformat
,
271 GLsizei width
, GLsizei height
, GLsizei depth
,
272 GLint border
, GLenum format
, GLenum type
,
273 const GLvoid
*pixels
);
275 extern void GLAPIENTRY
276 _mesa_TexImage1D_no_error(GLenum target
, GLint level
, GLint internalformat
,
277 GLsizei width
, GLint border
,
278 GLenum format
, GLenum type
, const GLvoid
*pixels
);
280 extern void GLAPIENTRY
281 _mesa_TexImage2D_no_error(GLenum target
, GLint level
, GLint internalformat
,
282 GLsizei width
, GLsizei height
, GLint border
,
283 GLenum format
, GLenum type
, const GLvoid
*pixels
);
285 extern void GLAPIENTRY
286 _mesa_TexImage3D_no_error(GLenum target
, GLint level
, GLint internalformat
,
287 GLsizei width
, GLsizei height
, GLsizei depth
,
288 GLint border
, GLenum format
, GLenum type
,
289 const GLvoid
*pixels
);
291 extern void GLAPIENTRY
292 _mesa_EGLImageTargetTexture2DOES( GLenum target
, GLeglImageOES image
);
295 _mesa_TexSubImage1D_no_error(GLenum target
, GLint level
, GLint xoffset
,
297 GLenum format
, GLenum type
,
298 const GLvoid
*pixels
);
300 extern void GLAPIENTRY
301 _mesa_TexSubImage1D( GLenum target
, GLint level
, GLint xoffset
,
303 GLenum format
, GLenum type
,
304 const GLvoid
*pixels
);
307 _mesa_TexSubImage2D_no_error(GLenum target
, GLint level
,
308 GLint xoffset
, GLint yoffset
,
309 GLsizei width
, GLsizei height
,
310 GLenum format
, GLenum type
,
311 const GLvoid
*pixels
);
313 extern void GLAPIENTRY
314 _mesa_TexSubImage2D( GLenum target
, GLint level
,
315 GLint xoffset
, GLint yoffset
,
316 GLsizei width
, GLsizei height
,
317 GLenum format
, GLenum type
,
318 const GLvoid
*pixels
);
321 _mesa_TexSubImage3D_no_error(GLenum target
, GLint level
,
322 GLint xoffset
, GLint yoffset
, GLint zoffset
,
323 GLsizei width
, GLsizei height
, GLsizei depth
,
324 GLenum format
, GLenum type
,
325 const GLvoid
*pixels
);
327 extern void GLAPIENTRY
328 _mesa_TexSubImage3D( GLenum target
, GLint level
,
329 GLint xoffset
, GLint yoffset
, GLint zoffset
,
330 GLsizei width
, GLsizei height
, GLsizei depth
,
331 GLenum format
, GLenum type
,
332 const GLvoid
*pixels
);
335 _mesa_TextureSubImage1D_no_error(GLuint texture
, GLint level
, GLint xoffset
,
336 GLsizei width
, GLenum format
, GLenum type
,
337 const GLvoid
*pixels
);
339 extern void GLAPIENTRY
340 _mesa_TextureSubImage1D(GLuint texture
, GLint level
, GLint xoffset
,
342 GLenum format
, GLenum type
,
343 const GLvoid
*pixels
);
346 _mesa_TextureSubImage2D_no_error(GLuint texture
, GLint level
, GLint xoffset
,
347 GLint yoffset
, GLsizei width
, GLsizei height
,
348 GLenum format
, GLenum type
,
349 const GLvoid
*pixels
);
351 extern void GLAPIENTRY
352 _mesa_TextureSubImage2D(GLuint texture
, GLint level
,
353 GLint xoffset
, GLint yoffset
,
354 GLsizei width
, GLsizei height
,
355 GLenum format
, GLenum type
,
356 const GLvoid
*pixels
);
359 _mesa_TextureSubImage3D_no_error(GLuint texture
, GLint level
, GLint xoffset
,
360 GLint yoffset
, GLint zoffset
, GLsizei width
,
361 GLsizei height
, GLsizei depth
, GLenum format
,
362 GLenum type
, const GLvoid
*pixels
);
364 extern void GLAPIENTRY
365 _mesa_TextureSubImage3D(GLuint texture
, GLint level
,
366 GLint xoffset
, GLint yoffset
, GLint zoffset
,
367 GLsizei width
, GLsizei height
, GLsizei depth
,
368 GLenum format
, GLenum type
,
369 const GLvoid
*pixels
);
372 extern void GLAPIENTRY
373 _mesa_CopyTexImage1D(GLenum target
, GLint level
, GLenum internalformat
,
374 GLint x
, GLint y
, GLsizei width
, GLint border
);
377 extern void GLAPIENTRY
378 _mesa_CopyTexImage2D( GLenum target
, GLint level
,
379 GLenum internalformat
, GLint x
, GLint y
,
380 GLsizei width
, GLsizei height
, GLint border
);
383 extern void GLAPIENTRY
384 _mesa_CopyTexImage1D_no_error(GLenum target
, GLint level
, GLenum internalformat
,
385 GLint x
, GLint y
, GLsizei width
, GLint border
);
388 extern void GLAPIENTRY
389 _mesa_CopyTexImage2D_no_error(GLenum target
, GLint level
, GLenum internalformat
,
390 GLint x
, GLint y
, GLsizei width
, GLsizei height
,
394 extern void GLAPIENTRY
395 _mesa_CopyTexSubImage1D( GLenum target
, GLint level
, GLint xoffset
,
396 GLint x
, GLint y
, GLsizei width
);
399 extern void GLAPIENTRY
400 _mesa_CopyTexSubImage2D( GLenum target
, GLint level
,
401 GLint xoffset
, GLint yoffset
,
402 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
405 extern void GLAPIENTRY
406 _mesa_CopyTexSubImage3D( GLenum target
, GLint level
,
407 GLint xoffset
, GLint yoffset
, GLint zoffset
,
408 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
410 extern void GLAPIENTRY
411 _mesa_CopyTextureSubImage1D(GLuint texture
, GLint level
,
412 GLint xoffset
, GLint x
, GLint y
, GLsizei width
);
414 extern void GLAPIENTRY
415 _mesa_CopyTextureSubImage2D(GLuint texture
, GLint level
,
416 GLint xoffset
, GLint yoffset
,
418 GLsizei width
, GLsizei height
);
420 extern void GLAPIENTRY
421 _mesa_CopyTextureSubImage3D(GLuint texture
, GLint level
,
422 GLint xoffset
, GLint yoffset
, GLint zoffset
,
424 GLsizei width
, GLsizei height
);
426 extern void GLAPIENTRY
427 _mesa_CopyTexSubImage1D_no_error(GLenum target
, GLint level
, GLint xoffset
,
428 GLint x
, GLint y
, GLsizei width
);
430 extern void GLAPIENTRY
431 _mesa_CopyTexSubImage2D_no_error(GLenum target
, GLint level
, GLint xoffset
,
432 GLint yoffset
, GLint x
, GLint y
, GLsizei width
,
435 extern void GLAPIENTRY
436 _mesa_CopyTexSubImage3D_no_error(GLenum target
, GLint level
, GLint xoffset
,
437 GLint yoffset
, GLint zoffset
, GLint x
, GLint y
,
438 GLsizei width
, GLsizei height
);
440 extern void GLAPIENTRY
441 _mesa_CopyTextureSubImage1D_no_error(GLuint texture
, GLint level
, GLint xoffset
,
442 GLint x
, GLint y
, GLsizei width
);
444 extern void GLAPIENTRY
445 _mesa_CopyTextureSubImage2D_no_error(GLuint texture
, GLint level
, GLint xoffset
,
446 GLint yoffset
, GLint x
, GLint y
,
447 GLsizei width
, GLsizei height
);
449 extern void GLAPIENTRY
450 _mesa_CopyTextureSubImage3D_no_error(GLuint texture
, GLint level
, GLint xoffset
,
451 GLint yoffset
, GLint zoffset
, GLint x
,
452 GLint y
, GLsizei width
, GLsizei height
);
454 extern void GLAPIENTRY
455 _mesa_ClearTexSubImage( GLuint texture
, GLint level
,
456 GLint xoffset
, GLint yoffset
, GLint zoffset
,
457 GLsizei width
, GLsizei height
, GLsizei depth
,
458 GLenum format
, GLenum type
, const void *data
);
460 extern void GLAPIENTRY
461 _mesa_ClearTexImage( GLuint texture
, GLint level
,
462 GLenum format
, GLenum type
, const void *data
);
464 extern void GLAPIENTRY
465 _mesa_CompressedTexImage1D(GLenum target
, GLint level
,
466 GLenum internalformat
, GLsizei width
,
467 GLint border
, GLsizei imageSize
,
470 extern void GLAPIENTRY
471 _mesa_CompressedTexImage2D(GLenum target
, GLint level
,
472 GLenum internalformat
, GLsizei width
,
473 GLsizei height
, GLint border
, GLsizei imageSize
,
476 extern void GLAPIENTRY
477 _mesa_CompressedTexImage3D(GLenum target
, GLint level
,
478 GLenum internalformat
, GLsizei width
,
479 GLsizei height
, GLsizei depth
, GLint border
,
480 GLsizei imageSize
, const GLvoid
*data
);
482 extern void GLAPIENTRY
483 _mesa_CompressedTexImage1D_no_error(GLenum target
, GLint level
,
484 GLenum internalformat
, GLsizei width
,
485 GLint border
, GLsizei imageSize
,
488 extern void GLAPIENTRY
489 _mesa_CompressedTexImage2D_no_error(GLenum target
, GLint level
,
490 GLenum internalformat
, GLsizei width
,
491 GLsizei height
, GLint border
,
492 GLsizei imageSize
, const GLvoid
*data
);
494 extern void GLAPIENTRY
495 _mesa_CompressedTexImage3D_no_error(GLenum target
, GLint level
,
496 GLenum internalformat
, GLsizei width
,
497 GLsizei height
, GLsizei depth
, GLint border
,
498 GLsizei imageSize
, const GLvoid
*data
);
501 extern void GLAPIENTRY
502 _mesa_CompressedTexSubImage1D_no_error(GLenum target
, GLint level
,
503 GLint xoffset
, GLsizei width
,
504 GLenum format
, GLsizei imageSize
,
506 extern void GLAPIENTRY
507 _mesa_CompressedTexSubImage1D(GLenum target
, GLint level
, GLint xoffset
,
508 GLsizei width
, GLenum format
,
509 GLsizei imageSize
, const GLvoid
*data
);
511 extern void GLAPIENTRY
512 _mesa_CompressedTextureSubImage1D_no_error(GLuint texture
, GLint level
,
513 GLint xoffset
, GLsizei width
,
514 GLenum format
, GLsizei imageSize
,
516 extern void GLAPIENTRY
517 _mesa_CompressedTextureSubImage1D(GLuint texture
, GLint level
, GLint xoffset
,
518 GLsizei width
, GLenum format
,
519 GLsizei imageSize
, const GLvoid
*data
);
521 extern void GLAPIENTRY
522 _mesa_CompressedTexSubImage2D_no_error(GLenum target
, GLint level
,
523 GLint xoffset
, GLint yoffset
,
524 GLsizei width
, GLsizei height
,
525 GLenum format
, GLsizei imageSize
,
527 extern void GLAPIENTRY
528 _mesa_CompressedTexSubImage2D(GLenum target
, GLint level
, GLint xoffset
,
529 GLint yoffset
, GLsizei width
, GLsizei height
,
530 GLenum format
, GLsizei imageSize
,
533 extern void GLAPIENTRY
534 _mesa_CompressedTextureSubImage2D_no_error(GLuint texture
, GLint level
,
535 GLint xoffset
, GLint yoffset
,
536 GLsizei width
, GLsizei height
,
537 GLenum format
, GLsizei imageSize
,
539 extern void GLAPIENTRY
540 _mesa_CompressedTextureSubImage2D(GLuint texture
, GLint level
, GLint xoffset
,
542 GLsizei width
, GLsizei height
,
543 GLenum format
, GLsizei imageSize
,
546 extern void GLAPIENTRY
547 _mesa_CompressedTexSubImage3D_no_error(GLenum target
, GLint level
,
548 GLint xoffset
, GLint yoffset
,
549 GLint zoffset
, GLsizei width
,
550 GLsizei height
, GLsizei depth
,
551 GLenum format
, GLsizei imageSize
,
553 extern void GLAPIENTRY
554 _mesa_CompressedTexSubImage3D(GLenum target
, GLint level
, GLint xoffset
,
555 GLint yoffset
, GLint zoffset
, GLsizei width
,
556 GLsizei height
, GLsizei depth
, GLenum format
,
557 GLsizei imageSize
, const GLvoid
*data
);
559 extern void GLAPIENTRY
560 _mesa_CompressedTextureSubImage3D_no_error(GLuint texture
, GLint level
,
561 GLint xoffset
, GLint yoffset
,
562 GLint zoffset
, GLsizei width
,
563 GLsizei height
, GLsizei depth
,
564 GLenum format
, GLsizei imageSize
,
566 extern void GLAPIENTRY
567 _mesa_CompressedTextureSubImage3D(GLuint texture
, GLint level
, GLint xoffset
,
568 GLint yoffset
, GLint zoffset
,
569 GLsizei width
, GLsizei height
,
571 GLenum format
, GLsizei imageSize
,
574 extern void GLAPIENTRY
575 _mesa_TexBuffer(GLenum target
, GLenum internalFormat
, GLuint buffer
);
577 extern void GLAPIENTRY
578 _mesa_TexBufferRange(GLenum target
, GLenum internalFormat
, GLuint buffer
,
579 GLintptr offset
, GLsizeiptr size
);
581 extern void GLAPIENTRY
582 _mesa_TextureBuffer(GLuint texture
, GLenum internalFormat
, GLuint buffer
);
584 extern void GLAPIENTRY
585 _mesa_TextureBufferRange(GLuint texture
, GLenum internalFormat
, GLuint buffer
,
586 GLintptr offset
, GLsizeiptr size
);
589 extern void GLAPIENTRY
590 _mesa_TexImage2DMultisample(GLenum target
, GLsizei samples
,
591 GLenum internalformat
, GLsizei width
,
592 GLsizei height
, GLboolean fixedsamplelocations
);
594 extern void GLAPIENTRY
595 _mesa_TexImage3DMultisample(GLenum target
, GLsizei samples
,
596 GLenum internalformat
, GLsizei width
,
597 GLsizei height
, GLsizei depth
,
598 GLboolean fixedsamplelocations
);
600 extern void GLAPIENTRY
601 _mesa_TexStorage2DMultisample(GLenum target
, GLsizei samples
,
602 GLenum internalformat
, GLsizei width
,
603 GLsizei height
, GLboolean fixedsamplelocations
);
605 extern void GLAPIENTRY
606 _mesa_TexStorage3DMultisample(GLenum target
, GLsizei samples
,
607 GLenum internalformat
, GLsizei width
,
608 GLsizei height
, GLsizei depth
,
609 GLboolean fixedsamplelocations
);
612 _mesa_TextureStorage2DMultisample(GLuint texture
, GLsizei samples
,
613 GLenum internalformat
, GLsizei width
,
615 GLboolean fixedsamplelocations
);
618 _mesa_TextureStorage3DMultisample(GLuint texture
, GLsizei samples
,
619 GLenum internalformat
, GLsizei width
,
620 GLsizei height
, GLsizei depth
,
621 GLboolean fixedsamplelocations
);