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_buffer_range(struct gl_context
*ctx
,
204 struct gl_texture_object
*texObj
,
205 GLenum internalFormat
,
206 struct gl_buffer_object
*bufObj
,
207 GLintptr offset
, GLsizeiptr size
,
212 /** \name API entry point functions */
215 extern void GLAPIENTRY
216 _mesa_TexImage1D( GLenum target
, GLint level
, GLint internalformat
,
217 GLsizei width
, GLint border
,
218 GLenum format
, GLenum type
, const GLvoid
*pixels
);
221 extern void GLAPIENTRY
222 _mesa_TexImage2D( GLenum target
, GLint level
, GLint internalformat
,
223 GLsizei width
, GLsizei height
, GLint border
,
224 GLenum format
, GLenum type
, const GLvoid
*pixels
);
227 extern void GLAPIENTRY
228 _mesa_TexImage3D( GLenum target
, GLint level
, GLint internalformat
,
229 GLsizei width
, GLsizei height
, GLsizei depth
, GLint border
,
230 GLenum format
, GLenum type
, const GLvoid
*pixels
);
233 extern void GLAPIENTRY
234 _mesa_TexImage3DEXT( GLenum target
, GLint level
, GLenum internalformat
,
235 GLsizei width
, GLsizei height
, GLsizei depth
,
236 GLint border
, GLenum format
, GLenum type
,
237 const GLvoid
*pixels
);
239 extern void GLAPIENTRY
240 _mesa_EGLImageTargetTexture2DOES( GLenum target
, GLeglImageOES image
);
242 extern void GLAPIENTRY
243 _mesa_TexSubImage1D( GLenum target
, GLint level
, GLint xoffset
,
245 GLenum format
, GLenum type
,
246 const GLvoid
*pixels
);
249 extern void GLAPIENTRY
250 _mesa_TexSubImage2D( GLenum target
, GLint level
,
251 GLint xoffset
, GLint yoffset
,
252 GLsizei width
, GLsizei height
,
253 GLenum format
, GLenum type
,
254 const GLvoid
*pixels
);
257 extern void GLAPIENTRY
258 _mesa_TexSubImage3D( GLenum target
, GLint level
,
259 GLint xoffset
, GLint yoffset
, GLint zoffset
,
260 GLsizei width
, GLsizei height
, GLsizei depth
,
261 GLenum format
, GLenum type
,
262 const GLvoid
*pixels
);
264 extern void GLAPIENTRY
265 _mesa_TextureSubImage1D(GLuint texture
, GLint level
, GLint xoffset
,
267 GLenum format
, GLenum type
,
268 const GLvoid
*pixels
);
271 extern void GLAPIENTRY
272 _mesa_TextureSubImage2D(GLuint texture
, GLint level
,
273 GLint xoffset
, GLint yoffset
,
274 GLsizei width
, GLsizei height
,
275 GLenum format
, GLenum type
,
276 const GLvoid
*pixels
);
278 extern void GLAPIENTRY
279 _mesa_TextureSubImage3D(GLuint texture
, GLint level
,
280 GLint xoffset
, GLint yoffset
, GLint zoffset
,
281 GLsizei width
, GLsizei height
, GLsizei depth
,
282 GLenum format
, GLenum type
,
283 const GLvoid
*pixels
);
286 extern void GLAPIENTRY
287 _mesa_CopyTexImage1D(GLenum target
, GLint level
, GLenum internalformat
,
288 GLint x
, GLint y
, GLsizei width
, GLint border
);
291 extern void GLAPIENTRY
292 _mesa_CopyTexImage2D( GLenum target
, GLint level
,
293 GLenum internalformat
, GLint x
, GLint y
,
294 GLsizei width
, GLsizei height
, GLint border
);
297 extern void GLAPIENTRY
298 _mesa_CopyTexSubImage1D( GLenum target
, GLint level
, GLint xoffset
,
299 GLint x
, GLint y
, GLsizei width
);
302 extern void GLAPIENTRY
303 _mesa_CopyTexSubImage2D( GLenum target
, GLint level
,
304 GLint xoffset
, GLint yoffset
,
305 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
308 extern void GLAPIENTRY
309 _mesa_CopyTexSubImage3D( GLenum target
, GLint level
,
310 GLint xoffset
, GLint yoffset
, GLint zoffset
,
311 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
313 extern void GLAPIENTRY
314 _mesa_CopyTextureSubImage1D(GLuint texture
, GLint level
,
315 GLint xoffset
, GLint x
, GLint y
, GLsizei width
);
317 extern void GLAPIENTRY
318 _mesa_CopyTextureSubImage2D(GLuint texture
, GLint level
,
319 GLint xoffset
, GLint yoffset
,
321 GLsizei width
, GLsizei height
);
323 extern void GLAPIENTRY
324 _mesa_CopyTextureSubImage3D(GLuint texture
, GLint level
,
325 GLint xoffset
, GLint yoffset
, GLint zoffset
,
327 GLsizei width
, GLsizei height
);
329 extern void GLAPIENTRY
330 _mesa_ClearTexSubImage( GLuint texture
, GLint level
,
331 GLint xoffset
, GLint yoffset
, GLint zoffset
,
332 GLsizei width
, GLsizei height
, GLsizei depth
,
333 GLenum format
, GLenum type
, const void *data
);
335 extern void GLAPIENTRY
336 _mesa_ClearTexImage( GLuint texture
, GLint level
,
337 GLenum format
, GLenum type
, const void *data
);
339 extern void GLAPIENTRY
340 _mesa_CompressedTexImage1D(GLenum target
, GLint level
,
341 GLenum internalformat
, GLsizei width
,
342 GLint border
, GLsizei imageSize
,
345 extern void GLAPIENTRY
346 _mesa_CompressedTexImage2D(GLenum target
, GLint level
,
347 GLenum internalformat
, GLsizei width
,
348 GLsizei height
, GLint border
, GLsizei imageSize
,
351 extern void GLAPIENTRY
352 _mesa_CompressedTexImage3D(GLenum target
, GLint level
,
353 GLenum internalformat
, GLsizei width
,
354 GLsizei height
, GLsizei depth
, GLint border
,
355 GLsizei imageSize
, const GLvoid
*data
);
357 extern void GLAPIENTRY
358 _mesa_CompressedTexSubImage1D(GLenum target
, GLint level
, GLint xoffset
,
359 GLsizei width
, GLenum format
,
360 GLsizei imageSize
, const GLvoid
*data
);
362 extern void GLAPIENTRY
363 _mesa_CompressedTextureSubImage1D(GLuint texture
, GLint level
, GLint xoffset
,
364 GLsizei width
, GLenum format
,
365 GLsizei imageSize
, const GLvoid
*data
);
367 extern void GLAPIENTRY
368 _mesa_CompressedTexSubImage2D(GLenum target
, GLint level
, GLint xoffset
,
369 GLint yoffset
, GLsizei width
, GLsizei height
,
370 GLenum format
, GLsizei imageSize
,
373 extern void GLAPIENTRY
374 _mesa_CompressedTextureSubImage2D(GLuint texture
, GLint level
, GLint xoffset
,
376 GLsizei width
, GLsizei height
,
377 GLenum format
, GLsizei imageSize
,
380 extern void GLAPIENTRY
381 _mesa_CompressedTexSubImage3D(GLenum target
, GLint level
, GLint xoffset
,
382 GLint yoffset
, GLint zoffset
, GLsizei width
,
383 GLsizei height
, GLsizei depth
, GLenum format
,
384 GLsizei imageSize
, const GLvoid
*data
);
386 extern void GLAPIENTRY
387 _mesa_CompressedTextureSubImage3D(GLuint texture
, GLint level
, GLint xoffset
,
388 GLint yoffset
, GLint zoffset
,
389 GLsizei width
, GLsizei height
,
391 GLenum format
, GLsizei imageSize
,
394 extern void GLAPIENTRY
395 _mesa_TexBuffer(GLenum target
, GLenum internalFormat
, GLuint buffer
);
397 extern void GLAPIENTRY
398 _mesa_TexBufferRange(GLenum target
, GLenum internalFormat
, GLuint buffer
,
399 GLintptr offset
, GLsizeiptr size
);
401 extern void GLAPIENTRY
402 _mesa_TextureBuffer(GLuint texture
, GLenum internalFormat
, GLuint buffer
);
404 extern void GLAPIENTRY
405 _mesa_TextureBufferRange(GLuint texture
, GLenum internalFormat
, GLuint buffer
,
406 GLintptr offset
, GLsizeiptr size
);
409 extern void GLAPIENTRY
410 _mesa_TexImage2DMultisample(GLenum target
, GLsizei samples
,
411 GLenum internalformat
, GLsizei width
,
412 GLsizei height
, GLboolean fixedsamplelocations
);
414 extern void GLAPIENTRY
415 _mesa_TexImage3DMultisample(GLenum target
, GLsizei samples
,
416 GLenum internalformat
, GLsizei width
,
417 GLsizei height
, GLsizei depth
,
418 GLboolean fixedsamplelocations
);
420 extern void GLAPIENTRY
421 _mesa_TexStorage2DMultisample(GLenum target
, GLsizei samples
,
422 GLenum internalformat
, GLsizei width
,
423 GLsizei height
, GLboolean fixedsamplelocations
);
425 extern void GLAPIENTRY
426 _mesa_TexStorage3DMultisample(GLenum target
, GLsizei samples
,
427 GLenum internalformat
, GLsizei width
,
428 GLsizei height
, GLsizei depth
,
429 GLboolean fixedsamplelocations
);
432 _mesa_TextureStorage2DMultisample(GLuint texture
, GLsizei samples
,
433 GLenum internalformat
, GLsizei width
,
435 GLboolean fixedsamplelocations
);
438 _mesa_TextureStorage3DMultisample(GLuint texture
, GLsizei samples
,
439 GLenum internalformat
, GLsizei width
,
440 GLsizei height
, GLsizei depth
,
441 GLboolean fixedsamplelocations
);