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
);
69 extern struct gl_texture_image
*
70 _mesa_new_texture_image( struct gl_context
*ctx
);
74 _mesa_delete_texture_image( struct gl_context
*ctx
,
75 struct gl_texture_image
*teximage
);
79 _mesa_init_teximage_fields(struct gl_context
*ctx
,
80 struct gl_texture_image
*img
,
81 GLsizei width
, GLsizei height
, GLsizei depth
,
82 GLint border
, GLenum internalFormat
,
87 _mesa_choose_texture_format(struct gl_context
*ctx
,
88 struct gl_texture_object
*texObj
,
89 GLenum target
, GLint level
,
90 GLenum internalFormat
, GLenum format
, GLenum type
);
93 _mesa_update_fbo_texture(struct gl_context
*ctx
,
94 struct gl_texture_object
*texObj
,
95 GLuint face
, GLuint level
);
98 _mesa_clear_texture_image(struct gl_context
*ctx
,
99 struct gl_texture_image
*texImage
);
102 extern struct gl_texture_image
*
103 _mesa_select_tex_image(const struct gl_texture_object
*texObj
,
104 GLenum target
, GLint level
);
107 extern struct gl_texture_image
*
108 _mesa_get_tex_image(struct gl_context
*ctx
, struct gl_texture_object
*texObj
,
109 GLenum target
, GLint level
);
113 * Return the base-level texture image for the given texture object.
115 static inline const struct gl_texture_image
*
116 _mesa_base_tex_image(const struct gl_texture_object
*texObj
)
118 return texObj
->Image
[0][texObj
->BaseLevel
];
123 _mesa_max_texture_levels(struct gl_context
*ctx
, GLenum target
);
127 _mesa_test_proxy_teximage(struct gl_context
*ctx
, GLenum target
, GLint level
,
129 GLint width
, GLint height
, GLint depth
, GLint border
);
132 _mesa_target_can_be_compressed(const struct gl_context
*ctx
, GLenum target
,
136 _mesa_tex_target_to_face(GLenum target
);
139 _mesa_get_texture_dimensions(GLenum target
);
142 _mesa_tex_target_is_layered(GLenum target
);
145 _mesa_get_texture_layers(const struct gl_texture_object
*texObj
, GLint level
);
148 _mesa_get_tex_max_num_levels(GLenum target
, GLsizei width
, GLsizei height
,
152 _mesa_legal_texture_dimensions(struct gl_context
*ctx
, GLenum target
,
153 GLint level
, GLint width
, GLint height
,
154 GLint depth
, GLint border
);
157 _mesa_validate_texbuffer_format(const struct gl_context
*ctx
,
158 GLenum internalFormat
);
162 _mesa_legal_texture_base_format_for_target(struct gl_context
*ctx
,
164 GLenum internalFormat
,
169 _mesa_texture_sub_image(struct gl_context
*ctx
, GLuint dims
,
170 struct gl_texture_object
*texObj
,
171 struct gl_texture_image
*texImage
,
172 GLenum target
, GLint level
,
173 GLint xoffset
, GLint yoffset
, GLint zoffset
,
174 GLsizei width
, GLsizei height
, GLsizei depth
,
175 GLenum format
, GLenum type
, const GLvoid
*pixels
,
179 _mesa_compressed_texture_sub_image(struct gl_context
*ctx
, GLuint dims
,
180 struct gl_texture_object
*texObj
,
181 GLenum target
, GLint level
,
182 GLint xoffset
, GLint yoffset
,
184 GLsizei width
, GLsizei height
,
186 GLenum format
, GLsizei imageSize
,
187 const GLvoid
*data
, bool dsa
);
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
, bool dsa
);
198 _mesa_texture_image_multisample(struct gl_context
*ctx
, GLuint dims
,
199 struct gl_texture_object
*texObj
,
200 GLenum target
, GLsizei samples
,
201 GLint internalformat
, GLsizei width
,
202 GLsizei height
, GLsizei depth
,
203 GLboolean fixedsamplelocations
,
204 GLboolean immutable
, const char *func
);
207 _mesa_texture_buffer_range(struct gl_context
*ctx
,
208 struct gl_texture_object
*texObj
, GLenum target
,
209 GLenum internalFormat
,
210 struct gl_buffer_object
*bufObj
,
211 GLintptr offset
, GLsizeiptr size
, bool range
,
216 /** \name API entry point functions */
219 extern void GLAPIENTRY
220 _mesa_TexImage1D( GLenum target
, GLint level
, GLint internalformat
,
221 GLsizei width
, GLint border
,
222 GLenum format
, GLenum type
, const GLvoid
*pixels
);
225 extern void GLAPIENTRY
226 _mesa_TexImage2D( GLenum target
, GLint level
, GLint internalformat
,
227 GLsizei width
, GLsizei height
, GLint border
,
228 GLenum format
, GLenum type
, const GLvoid
*pixels
);
231 extern void GLAPIENTRY
232 _mesa_TexImage3D( GLenum target
, GLint level
, GLint internalformat
,
233 GLsizei width
, GLsizei height
, GLsizei depth
, GLint border
,
234 GLenum format
, GLenum type
, const GLvoid
*pixels
);
237 extern void GLAPIENTRY
238 _mesa_TexImage3DEXT( GLenum target
, GLint level
, GLenum internalformat
,
239 GLsizei width
, GLsizei height
, GLsizei depth
,
240 GLint border
, GLenum format
, GLenum type
,
241 const GLvoid
*pixels
);
243 extern void GLAPIENTRY
244 _mesa_EGLImageTargetTexture2DOES( GLenum target
, GLeglImageOES image
);
246 extern void GLAPIENTRY
247 _mesa_TexSubImage1D( GLenum target
, GLint level
, GLint xoffset
,
249 GLenum format
, GLenum type
,
250 const GLvoid
*pixels
);
253 extern void GLAPIENTRY
254 _mesa_TexSubImage2D( GLenum target
, GLint level
,
255 GLint xoffset
, GLint yoffset
,
256 GLsizei width
, GLsizei height
,
257 GLenum format
, GLenum type
,
258 const GLvoid
*pixels
);
261 extern void GLAPIENTRY
262 _mesa_TexSubImage3D( GLenum target
, GLint level
,
263 GLint xoffset
, GLint yoffset
, GLint zoffset
,
264 GLsizei width
, GLsizei height
, GLsizei depth
,
265 GLenum format
, GLenum type
,
266 const GLvoid
*pixels
);
268 extern void GLAPIENTRY
269 _mesa_TextureSubImage1D(GLuint texture
, GLint level
, GLint xoffset
,
271 GLenum format
, GLenum type
,
272 const GLvoid
*pixels
);
275 extern void GLAPIENTRY
276 _mesa_TextureSubImage2D(GLuint texture
, GLint level
,
277 GLint xoffset
, GLint yoffset
,
278 GLsizei width
, GLsizei height
,
279 GLenum format
, GLenum type
,
280 const GLvoid
*pixels
);
282 extern void GLAPIENTRY
283 _mesa_TextureSubImage3D(GLuint texture
, GLint level
,
284 GLint xoffset
, GLint yoffset
, GLint zoffset
,
285 GLsizei width
, GLsizei height
, GLsizei depth
,
286 GLenum format
, GLenum type
,
287 const GLvoid
*pixels
);
290 extern void GLAPIENTRY
291 _mesa_CopyTexImage1D(GLenum target
, GLint level
, GLenum internalformat
,
292 GLint x
, GLint y
, GLsizei width
, GLint border
);
295 extern void GLAPIENTRY
296 _mesa_CopyTexImage2D( GLenum target
, GLint level
,
297 GLenum internalformat
, GLint x
, GLint y
,
298 GLsizei width
, GLsizei height
, GLint border
);
301 extern void GLAPIENTRY
302 _mesa_CopyTexSubImage1D( GLenum target
, GLint level
, GLint xoffset
,
303 GLint x
, GLint y
, GLsizei width
);
306 extern void GLAPIENTRY
307 _mesa_CopyTexSubImage2D( GLenum target
, GLint level
,
308 GLint xoffset
, GLint yoffset
,
309 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
312 extern void GLAPIENTRY
313 _mesa_CopyTexSubImage3D( GLenum target
, GLint level
,
314 GLint xoffset
, GLint yoffset
, GLint zoffset
,
315 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
317 extern void GLAPIENTRY
318 _mesa_CopyTextureSubImage1D(GLuint texture
, GLint level
,
319 GLint xoffset
, GLint x
, GLint y
, GLsizei width
);
321 extern void GLAPIENTRY
322 _mesa_CopyTextureSubImage2D(GLuint texture
, GLint level
,
323 GLint xoffset
, GLint yoffset
,
325 GLsizei width
, GLsizei height
);
327 extern void GLAPIENTRY
328 _mesa_CopyTextureSubImage3D(GLuint texture
, GLint level
,
329 GLint xoffset
, GLint yoffset
, GLint zoffset
,
331 GLsizei width
, GLsizei height
);
333 extern void GLAPIENTRY
334 _mesa_ClearTexSubImage( GLuint texture
, GLint level
,
335 GLint xoffset
, GLint yoffset
, GLint zoffset
,
336 GLsizei width
, GLsizei height
, GLsizei depth
,
337 GLenum format
, GLenum type
, const void *data
);
339 extern void GLAPIENTRY
340 _mesa_ClearTexImage( GLuint texture
, GLint level
,
341 GLenum format
, GLenum type
, const void *data
);
343 extern void GLAPIENTRY
344 _mesa_CompressedTexImage1D(GLenum target
, GLint level
,
345 GLenum internalformat
, GLsizei width
,
346 GLint border
, GLsizei imageSize
,
349 extern void GLAPIENTRY
350 _mesa_CompressedTexImage2D(GLenum target
, GLint level
,
351 GLenum internalformat
, GLsizei width
,
352 GLsizei height
, GLint border
, GLsizei imageSize
,
355 extern void GLAPIENTRY
356 _mesa_CompressedTexImage3D(GLenum target
, GLint level
,
357 GLenum internalformat
, GLsizei width
,
358 GLsizei height
, GLsizei depth
, GLint border
,
359 GLsizei imageSize
, const GLvoid
*data
);
361 extern void GLAPIENTRY
362 _mesa_CompressedTexSubImage1D(GLenum target
, GLint level
, GLint xoffset
,
363 GLsizei width
, GLenum format
,
364 GLsizei imageSize
, const GLvoid
*data
);
366 extern void GLAPIENTRY
367 _mesa_CompressedTextureSubImage1D(GLuint texture
, GLint level
, GLint xoffset
,
368 GLsizei width
, GLenum format
,
369 GLsizei imageSize
, const GLvoid
*data
);
371 extern void GLAPIENTRY
372 _mesa_CompressedTexSubImage2D(GLenum target
, GLint level
, GLint xoffset
,
373 GLint yoffset
, GLsizei width
, GLsizei height
,
374 GLenum format
, GLsizei imageSize
,
377 extern void GLAPIENTRY
378 _mesa_CompressedTextureSubImage2D(GLuint texture
, GLint level
, GLint xoffset
,
380 GLsizei width
, GLsizei height
,
381 GLenum format
, GLsizei imageSize
,
384 extern void GLAPIENTRY
385 _mesa_CompressedTexSubImage3D(GLenum target
, GLint level
, GLint xoffset
,
386 GLint yoffset
, GLint zoffset
, GLsizei width
,
387 GLsizei height
, GLsizei depth
, GLenum format
,
388 GLsizei imageSize
, const GLvoid
*data
);
390 extern void GLAPIENTRY
391 _mesa_CompressedTextureSubImage3D(GLuint texture
, GLint level
, GLint xoffset
,
392 GLint yoffset
, GLint zoffset
,
393 GLsizei width
, GLsizei height
,
395 GLenum format
, GLsizei imageSize
,
398 extern void GLAPIENTRY
399 _mesa_TexBuffer(GLenum target
, GLenum internalFormat
, GLuint buffer
);
401 extern void GLAPIENTRY
402 _mesa_TexBufferRange(GLenum target
, GLenum internalFormat
, GLuint buffer
,
403 GLintptr offset
, GLsizeiptr size
);
405 extern void GLAPIENTRY
406 _mesa_TextureBuffer(GLuint texture
, GLenum internalFormat
, GLuint buffer
);
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
);