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_ARB
&&
47 target
<= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
);
50 /** Are 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
)
54 return (texImage
->Width
== 0 ||
55 texImage
->Height
== 0 ||
56 texImage
->Depth
== 0);
59 /** \name Internal functions */
63 _mesa_base_tex_format( struct gl_context
*ctx
, GLint internalFormat
);
67 _mesa_is_proxy_texture(GLenum target
);
70 _mesa_is_array_texture(GLenum target
);
72 extern struct gl_texture_image
*
73 _mesa_new_texture_image( struct gl_context
*ctx
);
77 _mesa_delete_texture_image( struct gl_context
*ctx
,
78 struct gl_texture_image
*teximage
);
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
,
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
);
96 _mesa_update_fbo_texture(struct gl_context
*ctx
,
97 struct gl_texture_object
*texObj
,
98 GLuint face
, GLuint level
);
101 _mesa_clear_texture_image(struct gl_context
*ctx
,
102 struct gl_texture_image
*texImage
);
105 extern struct gl_texture_image
*
106 _mesa_select_tex_image(const struct gl_texture_object
*texObj
,
107 GLenum target
, GLint level
);
110 extern struct gl_texture_image
*
111 _mesa_get_tex_image(struct gl_context
*ctx
, struct gl_texture_object
*texObj
,
112 GLenum target
, GLint level
);
116 * Return the base-level texture image for the given texture object.
118 static inline const struct gl_texture_image
*
119 _mesa_base_tex_image(const struct gl_texture_object
*texObj
)
121 return texObj
->Image
[0][texObj
->BaseLevel
];
126 _mesa_max_texture_levels(struct gl_context
*ctx
, GLenum target
);
130 _mesa_test_proxy_teximage(struct gl_context
*ctx
, GLenum target
, GLint level
,
132 GLint width
, GLint height
, GLint depth
, GLint border
);
135 _mesa_target_can_be_compressed(const struct gl_context
*ctx
, GLenum target
,
139 _mesa_tex_target_to_face(GLenum target
);
142 _mesa_get_texture_dimensions(GLenum target
);
145 _mesa_tex_target_is_layered(GLenum target
);
148 _mesa_get_texture_layers(const struct gl_texture_object
*texObj
, GLint level
);
151 _mesa_get_tex_max_num_levels(GLenum target
, GLsizei width
, GLsizei height
,
155 _mesa_legal_texture_dimensions(struct gl_context
*ctx
, GLenum target
,
156 GLint level
, GLint width
, GLint height
,
157 GLint depth
, GLint border
);
160 _mesa_validate_texbuffer_format(const struct gl_context
*ctx
,
161 GLenum internalFormat
);
165 _mesa_legal_texture_base_format_for_target(struct gl_context
*ctx
,
167 GLenum internalFormat
,
172 _mesa_texture_sub_image(struct gl_context
*ctx
, GLuint dims
,
173 struct gl_texture_object
*texObj
,
174 struct gl_texture_image
*texImage
,
175 GLenum target
, GLint level
,
176 GLint xoffset
, GLint yoffset
, GLint zoffset
,
177 GLsizei width
, GLsizei height
, GLsizei depth
,
178 GLenum format
, GLenum type
, const GLvoid
*pixels
,
182 _mesa_compressed_texture_sub_image(struct gl_context
*ctx
, GLuint dims
,
183 struct gl_texture_object
*texObj
,
184 struct gl_texture_image
*texImage
,
185 GLenum target
, GLint level
,
186 GLint xoffset
, GLint yoffset
,
188 GLsizei width
, GLsizei height
,
190 GLenum format
, GLsizei imageSize
,
194 _mesa_copy_texture_sub_image(struct gl_context
*ctx
, GLuint dims
,
195 struct gl_texture_object
*texObj
,
196 GLenum target
, GLint level
,
197 GLint xoffset
, GLint yoffset
, GLint zoffset
,
199 GLsizei width
, GLsizei height
,
203 _mesa_texture_image_multisample(struct gl_context
*ctx
, GLuint dims
,
204 struct gl_texture_object
*texObj
,
205 GLenum target
, GLsizei samples
,
206 GLint internalformat
, GLsizei width
,
207 GLsizei height
, GLsizei depth
,
208 GLboolean fixedsamplelocations
,
209 GLboolean immutable
, const char *func
);
212 _mesa_texture_buffer_range(struct gl_context
*ctx
,
213 struct gl_texture_object
*texObj
,
214 GLenum internalFormat
,
215 struct gl_buffer_object
*bufObj
,
216 GLintptr offset
, GLsizeiptr size
,
221 /** \name API entry point functions */
224 extern void GLAPIENTRY
225 _mesa_TexImage1D( GLenum target
, GLint level
, GLint internalformat
,
226 GLsizei width
, GLint border
,
227 GLenum format
, GLenum type
, const GLvoid
*pixels
);
230 extern void GLAPIENTRY
231 _mesa_TexImage2D( GLenum target
, GLint level
, GLint internalformat
,
232 GLsizei width
, GLsizei height
, GLint border
,
233 GLenum format
, GLenum type
, const GLvoid
*pixels
);
236 extern void GLAPIENTRY
237 _mesa_TexImage3D( GLenum target
, GLint level
, GLint internalformat
,
238 GLsizei width
, GLsizei height
, GLsizei depth
, GLint border
,
239 GLenum format
, GLenum type
, const GLvoid
*pixels
);
242 extern void GLAPIENTRY
243 _mesa_TexImage3DEXT( GLenum target
, GLint level
, GLenum internalformat
,
244 GLsizei width
, GLsizei height
, GLsizei depth
,
245 GLint border
, GLenum format
, GLenum type
,
246 const GLvoid
*pixels
);
248 extern void GLAPIENTRY
249 _mesa_EGLImageTargetTexture2DOES( GLenum target
, GLeglImageOES image
);
251 extern void GLAPIENTRY
252 _mesa_TexSubImage1D( GLenum target
, GLint level
, GLint xoffset
,
254 GLenum format
, GLenum type
,
255 const GLvoid
*pixels
);
258 extern void GLAPIENTRY
259 _mesa_TexSubImage2D( GLenum target
, GLint level
,
260 GLint xoffset
, GLint yoffset
,
261 GLsizei width
, GLsizei height
,
262 GLenum format
, GLenum type
,
263 const GLvoid
*pixels
);
266 extern void GLAPIENTRY
267 _mesa_TexSubImage3D( GLenum target
, GLint level
,
268 GLint xoffset
, GLint yoffset
, GLint zoffset
,
269 GLsizei width
, GLsizei height
, GLsizei depth
,
270 GLenum format
, GLenum type
,
271 const GLvoid
*pixels
);
273 extern void GLAPIENTRY
274 _mesa_TextureSubImage1D(GLuint texture
, GLint level
, GLint xoffset
,
276 GLenum format
, GLenum type
,
277 const GLvoid
*pixels
);
280 extern void GLAPIENTRY
281 _mesa_TextureSubImage2D(GLuint texture
, GLint level
,
282 GLint xoffset
, GLint yoffset
,
283 GLsizei width
, GLsizei height
,
284 GLenum format
, GLenum type
,
285 const GLvoid
*pixels
);
287 extern void GLAPIENTRY
288 _mesa_TextureSubImage3D(GLuint texture
, GLint level
,
289 GLint xoffset
, GLint yoffset
, GLint zoffset
,
290 GLsizei width
, GLsizei height
, GLsizei depth
,
291 GLenum format
, GLenum type
,
292 const GLvoid
*pixels
);
295 extern void GLAPIENTRY
296 _mesa_CopyTexImage1D(GLenum target
, GLint level
, GLenum internalformat
,
297 GLint x
, GLint y
, GLsizei width
, GLint border
);
300 extern void GLAPIENTRY
301 _mesa_CopyTexImage2D( GLenum target
, GLint level
,
302 GLenum internalformat
, GLint x
, GLint y
,
303 GLsizei width
, GLsizei height
, GLint border
);
306 extern void GLAPIENTRY
307 _mesa_CopyTexSubImage1D( GLenum target
, GLint level
, GLint xoffset
,
308 GLint x
, GLint y
, GLsizei width
);
311 extern void GLAPIENTRY
312 _mesa_CopyTexSubImage2D( GLenum target
, GLint level
,
313 GLint xoffset
, GLint yoffset
,
314 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
317 extern void GLAPIENTRY
318 _mesa_CopyTexSubImage3D( GLenum target
, GLint level
,
319 GLint xoffset
, GLint yoffset
, GLint zoffset
,
320 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
322 extern void GLAPIENTRY
323 _mesa_CopyTextureSubImage1D(GLuint texture
, GLint level
,
324 GLint xoffset
, GLint x
, GLint y
, GLsizei width
);
326 extern void GLAPIENTRY
327 _mesa_CopyTextureSubImage2D(GLuint texture
, GLint level
,
328 GLint xoffset
, GLint yoffset
,
330 GLsizei width
, GLsizei height
);
332 extern void GLAPIENTRY
333 _mesa_CopyTextureSubImage3D(GLuint texture
, GLint level
,
334 GLint xoffset
, GLint yoffset
, GLint zoffset
,
336 GLsizei width
, GLsizei height
);
338 extern void GLAPIENTRY
339 _mesa_ClearTexSubImage( GLuint texture
, GLint level
,
340 GLint xoffset
, GLint yoffset
, GLint zoffset
,
341 GLsizei width
, GLsizei height
, GLsizei depth
,
342 GLenum format
, GLenum type
, const void *data
);
344 extern void GLAPIENTRY
345 _mesa_ClearTexImage( GLuint texture
, GLint level
,
346 GLenum format
, GLenum type
, const void *data
);
348 extern void GLAPIENTRY
349 _mesa_CompressedTexImage1D(GLenum target
, GLint level
,
350 GLenum internalformat
, GLsizei width
,
351 GLint border
, GLsizei imageSize
,
354 extern void GLAPIENTRY
355 _mesa_CompressedTexImage2D(GLenum target
, GLint level
,
356 GLenum internalformat
, GLsizei width
,
357 GLsizei height
, GLint border
, GLsizei imageSize
,
360 extern void GLAPIENTRY
361 _mesa_CompressedTexImage3D(GLenum target
, GLint level
,
362 GLenum internalformat
, GLsizei width
,
363 GLsizei height
, GLsizei depth
, GLint border
,
364 GLsizei imageSize
, const GLvoid
*data
);
366 extern void GLAPIENTRY
367 _mesa_CompressedTexSubImage1D(GLenum target
, GLint level
, GLint xoffset
,
368 GLsizei width
, GLenum format
,
369 GLsizei imageSize
, const GLvoid
*data
);
371 extern void GLAPIENTRY
372 _mesa_CompressedTextureSubImage1D(GLuint texture
, GLint level
, GLint xoffset
,
373 GLsizei width
, GLenum format
,
374 GLsizei imageSize
, const GLvoid
*data
);
376 extern void GLAPIENTRY
377 _mesa_CompressedTexSubImage2D(GLenum target
, GLint level
, GLint xoffset
,
378 GLint yoffset
, GLsizei width
, GLsizei height
,
379 GLenum format
, GLsizei imageSize
,
382 extern void GLAPIENTRY
383 _mesa_CompressedTextureSubImage2D(GLuint texture
, GLint level
, GLint xoffset
,
385 GLsizei width
, GLsizei height
,
386 GLenum format
, GLsizei imageSize
,
389 extern void GLAPIENTRY
390 _mesa_CompressedTexSubImage3D(GLenum target
, GLint level
, GLint xoffset
,
391 GLint yoffset
, GLint zoffset
, GLsizei width
,
392 GLsizei height
, GLsizei depth
, GLenum format
,
393 GLsizei imageSize
, const GLvoid
*data
);
395 extern void GLAPIENTRY
396 _mesa_CompressedTextureSubImage3D(GLuint texture
, GLint level
, GLint xoffset
,
397 GLint yoffset
, GLint zoffset
,
398 GLsizei width
, GLsizei height
,
400 GLenum format
, GLsizei imageSize
,
403 extern void GLAPIENTRY
404 _mesa_TexBuffer(GLenum target
, GLenum internalFormat
, GLuint buffer
);
406 extern void GLAPIENTRY
407 _mesa_TexBufferRange(GLenum target
, GLenum internalFormat
, GLuint buffer
,
408 GLintptr offset
, GLsizeiptr size
);
410 extern void GLAPIENTRY
411 _mesa_TextureBuffer(GLuint texture
, GLenum internalFormat
, GLuint buffer
);
413 extern void GLAPIENTRY
414 _mesa_TextureBufferRange(GLuint texture
, GLenum internalFormat
, GLuint buffer
,
415 GLintptr offset
, GLsizeiptr size
);
418 extern void GLAPIENTRY
419 _mesa_TexImage2DMultisample(GLenum target
, GLsizei samples
,
420 GLenum internalformat
, GLsizei width
,
421 GLsizei height
, GLboolean fixedsamplelocations
);
423 extern void GLAPIENTRY
424 _mesa_TexImage3DMultisample(GLenum target
, GLsizei samples
,
425 GLenum internalformat
, GLsizei width
,
426 GLsizei height
, GLsizei depth
,
427 GLboolean fixedsamplelocations
);
429 extern void GLAPIENTRY
430 _mesa_TexStorage2DMultisample(GLenum target
, GLsizei samples
,
431 GLenum internalformat
, GLsizei width
,
432 GLsizei height
, GLboolean fixedsamplelocations
);
434 extern void GLAPIENTRY
435 _mesa_TexStorage3DMultisample(GLenum target
, GLsizei samples
,
436 GLenum internalformat
, GLsizei width
,
437 GLsizei height
, GLsizei depth
,
438 GLboolean fixedsamplelocations
);
441 _mesa_TextureStorage2DMultisample(GLuint texture
, GLsizei samples
,
442 GLenum internalformat
, GLsizei width
,
444 GLboolean fixedsamplelocations
);
447 _mesa_TextureStorage3DMultisample(GLuint texture
, GLsizei samples
,
448 GLenum internalformat
, GLsizei width
,
449 GLsizei height
, GLsizei depth
,
450 GLboolean fixedsamplelocations
);