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
, bool dsa
);
202 _mesa_texture_image_multisample(struct gl_context
*ctx
, GLuint dims
,
203 struct gl_texture_object
*texObj
,
204 GLenum target
, GLsizei samples
,
205 GLint internalformat
, GLsizei width
,
206 GLsizei height
, GLsizei depth
,
207 GLboolean fixedsamplelocations
,
208 GLboolean immutable
, const char *func
);
211 _mesa_texture_buffer_range(struct gl_context
*ctx
,
212 struct gl_texture_object
*texObj
, GLenum target
,
213 GLenum internalFormat
,
214 struct gl_buffer_object
*bufObj
,
215 GLintptr offset
, GLsizeiptr size
, bool range
,
220 /** \name API entry point functions */
223 extern void GLAPIENTRY
224 _mesa_TexImage1D( GLenum target
, GLint level
, GLint internalformat
,
225 GLsizei width
, GLint border
,
226 GLenum format
, GLenum type
, const GLvoid
*pixels
);
229 extern void GLAPIENTRY
230 _mesa_TexImage2D( GLenum target
, GLint level
, GLint internalformat
,
231 GLsizei width
, GLsizei height
, GLint border
,
232 GLenum format
, GLenum type
, const GLvoid
*pixels
);
235 extern void GLAPIENTRY
236 _mesa_TexImage3D( GLenum target
, GLint level
, GLint internalformat
,
237 GLsizei width
, GLsizei height
, GLsizei depth
, GLint border
,
238 GLenum format
, GLenum type
, const GLvoid
*pixels
);
241 extern void GLAPIENTRY
242 _mesa_TexImage3DEXT( GLenum target
, GLint level
, GLenum internalformat
,
243 GLsizei width
, GLsizei height
, GLsizei depth
,
244 GLint border
, GLenum format
, GLenum type
,
245 const GLvoid
*pixels
);
247 extern void GLAPIENTRY
248 _mesa_EGLImageTargetTexture2DOES( GLenum target
, GLeglImageOES image
);
250 extern void GLAPIENTRY
251 _mesa_TexSubImage1D( GLenum target
, GLint level
, GLint xoffset
,
253 GLenum format
, GLenum type
,
254 const GLvoid
*pixels
);
257 extern void GLAPIENTRY
258 _mesa_TexSubImage2D( GLenum target
, GLint level
,
259 GLint xoffset
, GLint yoffset
,
260 GLsizei width
, GLsizei height
,
261 GLenum format
, GLenum type
,
262 const GLvoid
*pixels
);
265 extern void GLAPIENTRY
266 _mesa_TexSubImage3D( GLenum target
, GLint level
,
267 GLint xoffset
, GLint yoffset
, GLint zoffset
,
268 GLsizei width
, GLsizei height
, GLsizei depth
,
269 GLenum format
, GLenum type
,
270 const GLvoid
*pixels
);
272 extern void GLAPIENTRY
273 _mesa_TextureSubImage1D(GLuint texture
, GLint level
, GLint xoffset
,
275 GLenum format
, GLenum type
,
276 const GLvoid
*pixels
);
279 extern void GLAPIENTRY
280 _mesa_TextureSubImage2D(GLuint texture
, GLint level
,
281 GLint xoffset
, GLint yoffset
,
282 GLsizei width
, GLsizei height
,
283 GLenum format
, GLenum type
,
284 const GLvoid
*pixels
);
286 extern void GLAPIENTRY
287 _mesa_TextureSubImage3D(GLuint texture
, GLint level
,
288 GLint xoffset
, GLint yoffset
, GLint zoffset
,
289 GLsizei width
, GLsizei height
, GLsizei depth
,
290 GLenum format
, GLenum type
,
291 const GLvoid
*pixels
);
294 extern void GLAPIENTRY
295 _mesa_CopyTexImage1D(GLenum target
, GLint level
, GLenum internalformat
,
296 GLint x
, GLint y
, GLsizei width
, GLint border
);
299 extern void GLAPIENTRY
300 _mesa_CopyTexImage2D( GLenum target
, GLint level
,
301 GLenum internalformat
, GLint x
, GLint y
,
302 GLsizei width
, GLsizei height
, GLint border
);
305 extern void GLAPIENTRY
306 _mesa_CopyTexSubImage1D( GLenum target
, GLint level
, GLint xoffset
,
307 GLint x
, GLint y
, GLsizei width
);
310 extern void GLAPIENTRY
311 _mesa_CopyTexSubImage2D( GLenum target
, GLint level
,
312 GLint xoffset
, GLint yoffset
,
313 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
316 extern void GLAPIENTRY
317 _mesa_CopyTexSubImage3D( GLenum target
, GLint level
,
318 GLint xoffset
, GLint yoffset
, GLint zoffset
,
319 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
321 extern void GLAPIENTRY
322 _mesa_CopyTextureSubImage1D(GLuint texture
, GLint level
,
323 GLint xoffset
, GLint x
, GLint y
, GLsizei width
);
325 extern void GLAPIENTRY
326 _mesa_CopyTextureSubImage2D(GLuint texture
, GLint level
,
327 GLint xoffset
, GLint yoffset
,
329 GLsizei width
, GLsizei height
);
331 extern void GLAPIENTRY
332 _mesa_CopyTextureSubImage3D(GLuint texture
, GLint level
,
333 GLint xoffset
, GLint yoffset
, GLint zoffset
,
335 GLsizei width
, GLsizei height
);
337 extern void GLAPIENTRY
338 _mesa_ClearTexSubImage( GLuint texture
, GLint level
,
339 GLint xoffset
, GLint yoffset
, GLint zoffset
,
340 GLsizei width
, GLsizei height
, GLsizei depth
,
341 GLenum format
, GLenum type
, const void *data
);
343 extern void GLAPIENTRY
344 _mesa_ClearTexImage( GLuint texture
, GLint level
,
345 GLenum format
, GLenum type
, const void *data
);
347 extern void GLAPIENTRY
348 _mesa_CompressedTexImage1D(GLenum target
, GLint level
,
349 GLenum internalformat
, GLsizei width
,
350 GLint border
, GLsizei imageSize
,
353 extern void GLAPIENTRY
354 _mesa_CompressedTexImage2D(GLenum target
, GLint level
,
355 GLenum internalformat
, GLsizei width
,
356 GLsizei height
, GLint border
, GLsizei imageSize
,
359 extern void GLAPIENTRY
360 _mesa_CompressedTexImage3D(GLenum target
, GLint level
,
361 GLenum internalformat
, GLsizei width
,
362 GLsizei height
, GLsizei depth
, GLint border
,
363 GLsizei imageSize
, const GLvoid
*data
);
365 extern void GLAPIENTRY
366 _mesa_CompressedTexSubImage1D(GLenum target
, GLint level
, GLint xoffset
,
367 GLsizei width
, GLenum format
,
368 GLsizei imageSize
, const GLvoid
*data
);
370 extern void GLAPIENTRY
371 _mesa_CompressedTextureSubImage1D(GLuint texture
, GLint level
, GLint xoffset
,
372 GLsizei width
, GLenum format
,
373 GLsizei imageSize
, const GLvoid
*data
);
375 extern void GLAPIENTRY
376 _mesa_CompressedTexSubImage2D(GLenum target
, GLint level
, GLint xoffset
,
377 GLint yoffset
, GLsizei width
, GLsizei height
,
378 GLenum format
, GLsizei imageSize
,
381 extern void GLAPIENTRY
382 _mesa_CompressedTextureSubImage2D(GLuint texture
, GLint level
, GLint xoffset
,
384 GLsizei width
, GLsizei height
,
385 GLenum format
, GLsizei imageSize
,
388 extern void GLAPIENTRY
389 _mesa_CompressedTexSubImage3D(GLenum target
, GLint level
, GLint xoffset
,
390 GLint yoffset
, GLint zoffset
, GLsizei width
,
391 GLsizei height
, GLsizei depth
, GLenum format
,
392 GLsizei imageSize
, const GLvoid
*data
);
394 extern void GLAPIENTRY
395 _mesa_CompressedTextureSubImage3D(GLuint texture
, GLint level
, GLint xoffset
,
396 GLint yoffset
, GLint zoffset
,
397 GLsizei width
, GLsizei height
,
399 GLenum format
, GLsizei imageSize
,
402 extern void GLAPIENTRY
403 _mesa_TexBuffer(GLenum target
, GLenum internalFormat
, GLuint buffer
);
405 extern void GLAPIENTRY
406 _mesa_TexBufferRange(GLenum target
, GLenum internalFormat
, GLuint buffer
,
407 GLintptr offset
, GLsizeiptr size
);
409 extern void GLAPIENTRY
410 _mesa_TextureBuffer(GLuint texture
, GLenum internalFormat
, GLuint buffer
);
413 extern void GLAPIENTRY
414 _mesa_TexImage2DMultisample(GLenum target
, GLsizei samples
,
415 GLenum internalformat
, GLsizei width
,
416 GLsizei height
, GLboolean fixedsamplelocations
);
418 extern void GLAPIENTRY
419 _mesa_TexImage3DMultisample(GLenum target
, GLsizei samples
,
420 GLenum internalformat
, GLsizei width
,
421 GLsizei height
, GLsizei depth
,
422 GLboolean fixedsamplelocations
);
424 extern void GLAPIENTRY
425 _mesa_TexStorage2DMultisample(GLenum target
, GLsizei samples
,
426 GLenum internalformat
, GLsizei width
,
427 GLsizei height
, GLboolean fixedsamplelocations
);
429 extern void GLAPIENTRY
430 _mesa_TexStorage3DMultisample(GLenum target
, GLsizei samples
,
431 GLenum internalformat
, GLsizei width
,
432 GLsizei height
, GLsizei depth
,
433 GLboolean fixedsamplelocations
);
436 _mesa_TextureStorage2DMultisample(GLuint texture
, GLsizei samples
,
437 GLenum internalformat
, GLsizei width
,
439 GLboolean fixedsamplelocations
);
442 _mesa_TextureStorage3DMultisample(GLuint texture
, GLsizei samples
,
443 GLenum internalformat
, GLsizei width
,
444 GLsizei height
, GLsizei depth
,
445 GLboolean fixedsamplelocations
);