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_is_proxy_texture(GLenum target
);
66 _mesa_is_array_texture(GLenum target
);
68 extern struct gl_texture_image
*
69 _mesa_new_texture_image( struct gl_context
*ctx
);
73 _mesa_delete_texture_image( struct gl_context
*ctx
,
74 struct gl_texture_image
*teximage
);
78 _mesa_init_teximage_fields(struct gl_context
*ctx
,
79 struct gl_texture_image
*img
,
80 GLsizei width
, GLsizei height
, GLsizei depth
,
81 GLint border
, GLenum internalFormat
,
86 _mesa_choose_texture_format(struct gl_context
*ctx
,
87 struct gl_texture_object
*texObj
,
88 GLenum target
, GLint level
,
89 GLenum internalFormat
, GLenum format
, GLenum type
);
92 _mesa_update_fbo_texture(struct gl_context
*ctx
,
93 struct gl_texture_object
*texObj
,
94 GLuint face
, GLuint level
);
97 _mesa_clear_texture_image(struct gl_context
*ctx
,
98 struct gl_texture_image
*texImage
);
101 extern struct gl_texture_image
*
102 _mesa_select_tex_image(const struct gl_texture_object
*texObj
,
103 GLenum target
, GLint level
);
106 extern struct gl_texture_image
*
107 _mesa_get_tex_image(struct gl_context
*ctx
, struct gl_texture_object
*texObj
,
108 GLenum target
, GLint level
);
112 * Return the base-level texture image for the given texture object.
114 static inline const struct gl_texture_image
*
115 _mesa_base_tex_image(const struct gl_texture_object
*texObj
)
117 return texObj
->Image
[0][texObj
->BaseLevel
];
122 _mesa_max_texture_levels(struct gl_context
*ctx
, GLenum target
);
126 _mesa_test_proxy_teximage(struct gl_context
*ctx
, GLenum target
, GLint level
,
128 GLint width
, GLint height
, GLint depth
, GLint border
);
131 _mesa_target_can_be_compressed(const struct gl_context
*ctx
, GLenum target
,
132 GLenum intFormat
, GLenum
*error
);
135 _mesa_tex_target_to_face(GLenum target
);
138 _mesa_get_texture_dimensions(GLenum target
);
141 _mesa_tex_target_is_layered(GLenum target
);
144 _mesa_get_texture_layers(const struct gl_texture_object
*texObj
, GLint level
);
147 _mesa_get_tex_max_num_levels(GLenum target
, GLsizei width
, GLsizei height
,
151 _mesa_legal_texture_dimensions(struct gl_context
*ctx
, GLenum target
,
152 GLint level
, GLint width
, GLint height
,
153 GLint depth
, GLint border
);
156 _mesa_validate_texbuffer_format(const struct gl_context
*ctx
,
157 GLenum internalFormat
);
161 _mesa_legal_texture_base_format_for_target(struct gl_context
*ctx
,
163 GLenum internalFormat
,
168 _mesa_texture_sub_image(struct gl_context
*ctx
, GLuint dims
,
169 struct gl_texture_object
*texObj
,
170 struct gl_texture_image
*texImage
,
171 GLenum target
, GLint level
,
172 GLint xoffset
, GLint yoffset
, GLint zoffset
,
173 GLsizei width
, GLsizei height
, GLsizei depth
,
174 GLenum format
, GLenum type
, const GLvoid
*pixels
,
178 _mesa_compressed_texture_sub_image(struct gl_context
*ctx
, GLuint dims
,
179 struct gl_texture_object
*texObj
,
180 struct gl_texture_image
*texImage
,
181 GLenum target
, GLint level
,
182 GLint xoffset
, GLint yoffset
,
184 GLsizei width
, GLsizei height
,
186 GLenum format
, GLsizei imageSize
,
190 _mesa_copy_texture_sub_image(struct gl_context
*ctx
, GLuint dims
,
191 struct gl_texture_object
*texObj
,
192 GLenum target
, GLint level
,
193 GLint xoffset
, GLint yoffset
, GLint zoffset
,
195 GLsizei width
, GLsizei height
,
199 _mesa_texture_buffer_range(struct gl_context
*ctx
,
200 struct gl_texture_object
*texObj
,
201 GLenum internalFormat
,
202 struct gl_buffer_object
*bufObj
,
203 GLintptr offset
, GLsizeiptr size
,
208 /** \name API entry point functions */
211 extern void GLAPIENTRY
212 _mesa_TexImage1D( GLenum target
, GLint level
, GLint internalformat
,
213 GLsizei width
, GLint border
,
214 GLenum format
, GLenum type
, const GLvoid
*pixels
);
217 extern void GLAPIENTRY
218 _mesa_TexImage2D( GLenum target
, GLint level
, GLint internalformat
,
219 GLsizei width
, GLsizei height
, GLint border
,
220 GLenum format
, GLenum type
, const GLvoid
*pixels
);
223 extern void GLAPIENTRY
224 _mesa_TexImage3D( GLenum target
, GLint level
, GLint internalformat
,
225 GLsizei width
, GLsizei height
, GLsizei depth
, GLint border
,
226 GLenum format
, GLenum type
, const GLvoid
*pixels
);
229 extern void GLAPIENTRY
230 _mesa_TexImage3DEXT( GLenum target
, GLint level
, GLenum internalformat
,
231 GLsizei width
, GLsizei height
, GLsizei depth
,
232 GLint border
, GLenum format
, GLenum type
,
233 const GLvoid
*pixels
);
235 extern void GLAPIENTRY
236 _mesa_EGLImageTargetTexture2DOES( GLenum target
, GLeglImageOES image
);
238 extern void GLAPIENTRY
239 _mesa_TexSubImage1D( GLenum target
, GLint level
, GLint xoffset
,
241 GLenum format
, GLenum type
,
242 const GLvoid
*pixels
);
245 extern void GLAPIENTRY
246 _mesa_TexSubImage2D( GLenum target
, GLint level
,
247 GLint xoffset
, GLint yoffset
,
248 GLsizei width
, GLsizei height
,
249 GLenum format
, GLenum type
,
250 const GLvoid
*pixels
);
253 extern void GLAPIENTRY
254 _mesa_TexSubImage3D( GLenum target
, GLint level
,
255 GLint xoffset
, GLint yoffset
, GLint zoffset
,
256 GLsizei width
, GLsizei height
, GLsizei depth
,
257 GLenum format
, GLenum type
,
258 const GLvoid
*pixels
);
260 extern void GLAPIENTRY
261 _mesa_TextureSubImage1D(GLuint texture
, GLint level
, GLint xoffset
,
263 GLenum format
, GLenum type
,
264 const GLvoid
*pixels
);
267 extern void GLAPIENTRY
268 _mesa_TextureSubImage2D(GLuint texture
, GLint level
,
269 GLint xoffset
, GLint yoffset
,
270 GLsizei width
, GLsizei height
,
271 GLenum format
, GLenum type
,
272 const GLvoid
*pixels
);
274 extern void GLAPIENTRY
275 _mesa_TextureSubImage3D(GLuint texture
, GLint level
,
276 GLint xoffset
, GLint yoffset
, GLint zoffset
,
277 GLsizei width
, GLsizei height
, GLsizei depth
,
278 GLenum format
, GLenum type
,
279 const GLvoid
*pixels
);
282 extern void GLAPIENTRY
283 _mesa_CopyTexImage1D(GLenum target
, GLint level
, GLenum internalformat
,
284 GLint x
, GLint y
, GLsizei width
, GLint border
);
287 extern void GLAPIENTRY
288 _mesa_CopyTexImage2D( GLenum target
, GLint level
,
289 GLenum internalformat
, GLint x
, GLint y
,
290 GLsizei width
, GLsizei height
, GLint border
);
293 extern void GLAPIENTRY
294 _mesa_CopyTexSubImage1D( GLenum target
, GLint level
, GLint xoffset
,
295 GLint x
, GLint y
, GLsizei width
);
298 extern void GLAPIENTRY
299 _mesa_CopyTexSubImage2D( GLenum target
, GLint level
,
300 GLint xoffset
, GLint yoffset
,
301 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
304 extern void GLAPIENTRY
305 _mesa_CopyTexSubImage3D( GLenum target
, GLint level
,
306 GLint xoffset
, GLint yoffset
, GLint zoffset
,
307 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
309 extern void GLAPIENTRY
310 _mesa_CopyTextureSubImage1D(GLuint texture
, GLint level
,
311 GLint xoffset
, GLint x
, GLint y
, GLsizei width
);
313 extern void GLAPIENTRY
314 _mesa_CopyTextureSubImage2D(GLuint texture
, GLint level
,
315 GLint xoffset
, GLint yoffset
,
317 GLsizei width
, GLsizei height
);
319 extern void GLAPIENTRY
320 _mesa_CopyTextureSubImage3D(GLuint texture
, GLint level
,
321 GLint xoffset
, GLint yoffset
, GLint zoffset
,
323 GLsizei width
, GLsizei height
);
325 extern void GLAPIENTRY
326 _mesa_ClearTexSubImage( GLuint texture
, GLint level
,
327 GLint xoffset
, GLint yoffset
, GLint zoffset
,
328 GLsizei width
, GLsizei height
, GLsizei depth
,
329 GLenum format
, GLenum type
, const void *data
);
331 extern void GLAPIENTRY
332 _mesa_ClearTexImage( GLuint texture
, GLint level
,
333 GLenum format
, GLenum type
, const void *data
);
335 extern void GLAPIENTRY
336 _mesa_CompressedTexImage1D(GLenum target
, GLint level
,
337 GLenum internalformat
, GLsizei width
,
338 GLint border
, GLsizei imageSize
,
341 extern void GLAPIENTRY
342 _mesa_CompressedTexImage2D(GLenum target
, GLint level
,
343 GLenum internalformat
, GLsizei width
,
344 GLsizei height
, GLint border
, GLsizei imageSize
,
347 extern void GLAPIENTRY
348 _mesa_CompressedTexImage3D(GLenum target
, GLint level
,
349 GLenum internalformat
, GLsizei width
,
350 GLsizei height
, GLsizei depth
, GLint border
,
351 GLsizei imageSize
, const GLvoid
*data
);
353 extern void GLAPIENTRY
354 _mesa_CompressedTexSubImage1D(GLenum target
, GLint level
, GLint xoffset
,
355 GLsizei width
, GLenum format
,
356 GLsizei imageSize
, const GLvoid
*data
);
358 extern void GLAPIENTRY
359 _mesa_CompressedTextureSubImage1D(GLuint texture
, GLint level
, GLint xoffset
,
360 GLsizei width
, GLenum format
,
361 GLsizei imageSize
, const GLvoid
*data
);
363 extern void GLAPIENTRY
364 _mesa_CompressedTexSubImage2D(GLenum target
, GLint level
, GLint xoffset
,
365 GLint yoffset
, GLsizei width
, GLsizei height
,
366 GLenum format
, GLsizei imageSize
,
369 extern void GLAPIENTRY
370 _mesa_CompressedTextureSubImage2D(GLuint texture
, GLint level
, GLint xoffset
,
372 GLsizei width
, GLsizei height
,
373 GLenum format
, GLsizei imageSize
,
376 extern void GLAPIENTRY
377 _mesa_CompressedTexSubImage3D(GLenum target
, GLint level
, GLint xoffset
,
378 GLint yoffset
, GLint zoffset
, GLsizei width
,
379 GLsizei height
, GLsizei depth
, GLenum format
,
380 GLsizei imageSize
, const GLvoid
*data
);
382 extern void GLAPIENTRY
383 _mesa_CompressedTextureSubImage3D(GLuint texture
, GLint level
, GLint xoffset
,
384 GLint yoffset
, GLint zoffset
,
385 GLsizei width
, GLsizei height
,
387 GLenum format
, GLsizei imageSize
,
390 extern void GLAPIENTRY
391 _mesa_TexBuffer(GLenum target
, GLenum internalFormat
, GLuint buffer
);
393 extern void GLAPIENTRY
394 _mesa_TexBufferRange(GLenum target
, GLenum internalFormat
, GLuint buffer
,
395 GLintptr offset
, GLsizeiptr size
);
397 extern void GLAPIENTRY
398 _mesa_TextureBuffer(GLuint texture
, GLenum internalFormat
, GLuint buffer
);
400 extern void GLAPIENTRY
401 _mesa_TextureBufferRange(GLuint texture
, GLenum internalFormat
, GLuint buffer
,
402 GLintptr offset
, GLsizeiptr size
);
405 extern void GLAPIENTRY
406 _mesa_TexImage2DMultisample(GLenum target
, GLsizei samples
,
407 GLenum internalformat
, GLsizei width
,
408 GLsizei height
, GLboolean fixedsamplelocations
);
410 extern void GLAPIENTRY
411 _mesa_TexImage3DMultisample(GLenum target
, GLsizei samples
,
412 GLenum internalformat
, GLsizei width
,
413 GLsizei height
, GLsizei depth
,
414 GLboolean fixedsamplelocations
);
416 extern void GLAPIENTRY
417 _mesa_TexStorage2DMultisample(GLenum target
, GLsizei samples
,
418 GLenum internalformat
, GLsizei width
,
419 GLsizei height
, GLboolean fixedsamplelocations
);
421 extern void GLAPIENTRY
422 _mesa_TexStorage3DMultisample(GLenum target
, GLsizei samples
,
423 GLenum internalformat
, GLsizei width
,
424 GLsizei height
, GLsizei depth
,
425 GLboolean fixedsamplelocations
);
428 _mesa_TextureStorage2DMultisample(GLuint texture
, GLsizei samples
,
429 GLenum internalformat
, GLsizei width
,
431 GLboolean fixedsamplelocations
);
434 _mesa_TextureStorage3DMultisample(GLuint texture
, GLsizei samples
,
435 GLenum internalformat
, GLsizei width
,
436 GLsizei height
, GLsizei depth
,
437 GLboolean fixedsamplelocations
);