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 GLenum target
, GLint level
,
185 GLint xoffset
, GLint yoffset
,
187 GLsizei width
, GLsizei height
,
189 GLenum format
, GLsizei imageSize
,
190 const GLvoid
*data
, bool dsa
);
193 _mesa_copy_texture_sub_image(struct gl_context
*ctx
, GLuint dims
,
194 struct gl_texture_object
*texObj
,
195 GLenum target
, GLint level
,
196 GLint xoffset
, GLint yoffset
, GLint zoffset
,
198 GLsizei width
, GLsizei height
, bool dsa
);
201 _mesa_texture_image_multisample(struct gl_context
*ctx
, GLuint dims
,
202 struct gl_texture_object
*texObj
,
203 GLenum target
, GLsizei samples
,
204 GLint internalformat
, GLsizei width
,
205 GLsizei height
, GLsizei depth
,
206 GLboolean fixedsamplelocations
,
207 GLboolean immutable
, const char *func
);
210 _mesa_texture_buffer_range(struct gl_context
*ctx
,
211 struct gl_texture_object
*texObj
, GLenum target
,
212 GLenum internalFormat
,
213 struct gl_buffer_object
*bufObj
,
214 GLintptr offset
, GLsizeiptr size
, bool range
,
219 /** \name API entry point functions */
222 extern void GLAPIENTRY
223 _mesa_TexImage1D( GLenum target
, GLint level
, GLint internalformat
,
224 GLsizei width
, GLint border
,
225 GLenum format
, GLenum type
, const GLvoid
*pixels
);
228 extern void GLAPIENTRY
229 _mesa_TexImage2D( GLenum target
, GLint level
, GLint internalformat
,
230 GLsizei width
, GLsizei height
, GLint border
,
231 GLenum format
, GLenum type
, const GLvoid
*pixels
);
234 extern void GLAPIENTRY
235 _mesa_TexImage3D( GLenum target
, GLint level
, GLint internalformat
,
236 GLsizei width
, GLsizei height
, GLsizei depth
, GLint border
,
237 GLenum format
, GLenum type
, const GLvoid
*pixels
);
240 extern void GLAPIENTRY
241 _mesa_TexImage3DEXT( GLenum target
, GLint level
, GLenum internalformat
,
242 GLsizei width
, GLsizei height
, GLsizei depth
,
243 GLint border
, GLenum format
, GLenum type
,
244 const GLvoid
*pixels
);
246 extern void GLAPIENTRY
247 _mesa_EGLImageTargetTexture2DOES( GLenum target
, GLeglImageOES image
);
249 extern void GLAPIENTRY
250 _mesa_TexSubImage1D( GLenum target
, GLint level
, GLint xoffset
,
252 GLenum format
, GLenum type
,
253 const GLvoid
*pixels
);
256 extern void GLAPIENTRY
257 _mesa_TexSubImage2D( GLenum target
, GLint level
,
258 GLint xoffset
, GLint yoffset
,
259 GLsizei width
, GLsizei height
,
260 GLenum format
, GLenum type
,
261 const GLvoid
*pixels
);
264 extern void GLAPIENTRY
265 _mesa_TexSubImage3D( GLenum target
, GLint level
,
266 GLint xoffset
, GLint yoffset
, GLint zoffset
,
267 GLsizei width
, GLsizei height
, GLsizei depth
,
268 GLenum format
, GLenum type
,
269 const GLvoid
*pixels
);
271 extern void GLAPIENTRY
272 _mesa_TextureSubImage1D(GLuint texture
, GLint level
, GLint xoffset
,
274 GLenum format
, GLenum type
,
275 const GLvoid
*pixels
);
278 extern void GLAPIENTRY
279 _mesa_TextureSubImage2D(GLuint texture
, GLint level
,
280 GLint xoffset
, GLint yoffset
,
281 GLsizei width
, GLsizei height
,
282 GLenum format
, GLenum type
,
283 const GLvoid
*pixels
);
285 extern void GLAPIENTRY
286 _mesa_TextureSubImage3D(GLuint texture
, GLint level
,
287 GLint xoffset
, GLint yoffset
, GLint zoffset
,
288 GLsizei width
, GLsizei height
, GLsizei depth
,
289 GLenum format
, GLenum type
,
290 const GLvoid
*pixels
);
293 extern void GLAPIENTRY
294 _mesa_CopyTexImage1D(GLenum target
, GLint level
, GLenum internalformat
,
295 GLint x
, GLint y
, GLsizei width
, GLint border
);
298 extern void GLAPIENTRY
299 _mesa_CopyTexImage2D( GLenum target
, GLint level
,
300 GLenum internalformat
, GLint x
, GLint y
,
301 GLsizei width
, GLsizei height
, GLint border
);
304 extern void GLAPIENTRY
305 _mesa_CopyTexSubImage1D( GLenum target
, GLint level
, GLint xoffset
,
306 GLint x
, GLint y
, GLsizei width
);
309 extern void GLAPIENTRY
310 _mesa_CopyTexSubImage2D( GLenum target
, GLint level
,
311 GLint xoffset
, GLint yoffset
,
312 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
315 extern void GLAPIENTRY
316 _mesa_CopyTexSubImage3D( GLenum target
, GLint level
,
317 GLint xoffset
, GLint yoffset
, GLint zoffset
,
318 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
320 extern void GLAPIENTRY
321 _mesa_CopyTextureSubImage1D(GLuint texture
, GLint level
,
322 GLint xoffset
, GLint x
, GLint y
, GLsizei width
);
324 extern void GLAPIENTRY
325 _mesa_CopyTextureSubImage2D(GLuint texture
, GLint level
,
326 GLint xoffset
, GLint yoffset
,
328 GLsizei width
, GLsizei height
);
330 extern void GLAPIENTRY
331 _mesa_CopyTextureSubImage3D(GLuint texture
, GLint level
,
332 GLint xoffset
, GLint yoffset
, GLint zoffset
,
334 GLsizei width
, GLsizei height
);
336 extern void GLAPIENTRY
337 _mesa_ClearTexSubImage( GLuint texture
, GLint level
,
338 GLint xoffset
, GLint yoffset
, GLint zoffset
,
339 GLsizei width
, GLsizei height
, GLsizei depth
,
340 GLenum format
, GLenum type
, const void *data
);
342 extern void GLAPIENTRY
343 _mesa_ClearTexImage( GLuint texture
, GLint level
,
344 GLenum format
, GLenum type
, const void *data
);
346 extern void GLAPIENTRY
347 _mesa_CompressedTexImage1D(GLenum target
, GLint level
,
348 GLenum internalformat
, GLsizei width
,
349 GLint border
, GLsizei imageSize
,
352 extern void GLAPIENTRY
353 _mesa_CompressedTexImage2D(GLenum target
, GLint level
,
354 GLenum internalformat
, GLsizei width
,
355 GLsizei height
, GLint border
, GLsizei imageSize
,
358 extern void GLAPIENTRY
359 _mesa_CompressedTexImage3D(GLenum target
, GLint level
,
360 GLenum internalformat
, GLsizei width
,
361 GLsizei height
, GLsizei depth
, GLint border
,
362 GLsizei imageSize
, const GLvoid
*data
);
364 extern void GLAPIENTRY
365 _mesa_CompressedTexSubImage1D(GLenum target
, GLint level
, GLint xoffset
,
366 GLsizei width
, GLenum format
,
367 GLsizei imageSize
, const GLvoid
*data
);
369 extern void GLAPIENTRY
370 _mesa_CompressedTextureSubImage1D(GLuint texture
, GLint level
, GLint xoffset
,
371 GLsizei width
, GLenum format
,
372 GLsizei imageSize
, const GLvoid
*data
);
374 extern void GLAPIENTRY
375 _mesa_CompressedTexSubImage2D(GLenum target
, GLint level
, GLint xoffset
,
376 GLint yoffset
, GLsizei width
, GLsizei height
,
377 GLenum format
, GLsizei imageSize
,
380 extern void GLAPIENTRY
381 _mesa_CompressedTextureSubImage2D(GLuint texture
, GLint level
, GLint xoffset
,
383 GLsizei width
, GLsizei height
,
384 GLenum format
, GLsizei imageSize
,
387 extern void GLAPIENTRY
388 _mesa_CompressedTexSubImage3D(GLenum target
, GLint level
, GLint xoffset
,
389 GLint yoffset
, GLint zoffset
, GLsizei width
,
390 GLsizei height
, GLsizei depth
, GLenum format
,
391 GLsizei imageSize
, const GLvoid
*data
);
393 extern void GLAPIENTRY
394 _mesa_CompressedTextureSubImage3D(GLuint texture
, GLint level
, GLint xoffset
,
395 GLint yoffset
, GLint zoffset
,
396 GLsizei width
, GLsizei height
,
398 GLenum format
, GLsizei imageSize
,
401 extern void GLAPIENTRY
402 _mesa_TexBuffer(GLenum target
, GLenum internalFormat
, GLuint buffer
);
404 extern void GLAPIENTRY
405 _mesa_TexBufferRange(GLenum target
, GLenum internalFormat
, GLuint buffer
,
406 GLintptr offset
, GLsizeiptr size
);
408 extern void GLAPIENTRY
409 _mesa_TextureBuffer(GLuint texture
, GLenum internalFormat
, GLuint buffer
);
412 extern void GLAPIENTRY
413 _mesa_TexImage2DMultisample(GLenum target
, GLsizei samples
,
414 GLenum internalformat
, GLsizei width
,
415 GLsizei height
, GLboolean fixedsamplelocations
);
417 extern void GLAPIENTRY
418 _mesa_TexImage3DMultisample(GLenum target
, GLsizei samples
,
419 GLenum internalformat
, GLsizei width
,
420 GLsizei height
, GLsizei depth
,
421 GLboolean fixedsamplelocations
);
423 extern void GLAPIENTRY
424 _mesa_TexStorage2DMultisample(GLenum target
, GLsizei samples
,
425 GLenum internalformat
, GLsizei width
,
426 GLsizei height
, GLboolean fixedsamplelocations
);
428 extern void GLAPIENTRY
429 _mesa_TexStorage3DMultisample(GLenum target
, GLsizei samples
,
430 GLenum internalformat
, GLsizei width
,
431 GLsizei height
, GLsizei depth
,
432 GLboolean fixedsamplelocations
);
435 _mesa_TextureStorage2DMultisample(GLuint texture
, GLsizei samples
,
436 GLenum internalformat
, GLsizei width
,
438 GLboolean fixedsamplelocations
);
441 _mesa_TextureStorage3DMultisample(GLuint texture
, GLsizei samples
,
442 GLenum internalformat
, GLsizei width
,
443 GLsizei height
, GLsizei depth
,
444 GLboolean fixedsamplelocations
);