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 /** Is 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_object
*
103 _mesa_get_current_tex_object(struct gl_context
*ctx
, GLenum target
);
106 extern struct gl_texture_image
*
107 _mesa_select_tex_image(struct gl_context
*ctx
,
108 const struct gl_texture_object
*texObj
,
109 GLenum target
, GLint level
);
112 extern struct gl_texture_image
*
113 _mesa_get_tex_image(struct gl_context
*ctx
, struct gl_texture_object
*texObj
,
114 GLenum target
, GLint level
);
118 _mesa_max_texture_levels(struct gl_context
*ctx
, GLenum target
);
122 _mesa_test_proxy_teximage(struct gl_context
*ctx
, GLenum target
, GLint level
,
124 GLint width
, GLint height
, GLint depth
, GLint border
);
128 _mesa_tex_target_to_face(GLenum target
);
131 _mesa_get_texture_dimensions(GLenum target
);
134 _mesa_tex_target_is_layered(GLenum target
);
137 _mesa_get_texture_layers(const struct gl_texture_object
*texObj
, GLint level
);
140 _mesa_get_tex_max_num_levels(GLenum target
, GLsizei width
, GLsizei height
,
144 _mesa_legal_texture_dimensions(struct gl_context
*ctx
, GLenum target
,
145 GLint level
, GLint width
, GLint height
,
146 GLint depth
, GLint border
);
149 _mesa_validate_texbuffer_format(const struct gl_context
*ctx
,
150 GLenum internalFormat
);
154 _mesa_legal_texture_base_format_for_target(struct gl_context
*ctx
,
156 GLenum internalFormat
,
161 * Lock a texture for updating. See also _mesa_lock_context_textures().
164 _mesa_lock_texture(struct gl_context
*ctx
, struct gl_texture_object
*texObj
)
166 mtx_lock(&ctx
->Shared
->TexMutex
);
167 ctx
->Shared
->TextureStateStamp
++;
172 _mesa_unlock_texture(struct gl_context
*ctx
, struct gl_texture_object
*texObj
)
175 mtx_unlock(&ctx
->Shared
->TexMutex
);
181 /** \name API entry point functions */
184 extern void GLAPIENTRY
185 _mesa_TexImage1D( GLenum target
, GLint level
, GLint internalformat
,
186 GLsizei width
, GLint border
,
187 GLenum format
, GLenum type
, const GLvoid
*pixels
);
190 extern void GLAPIENTRY
191 _mesa_TexImage2D( GLenum target
, GLint level
, GLint internalformat
,
192 GLsizei width
, GLsizei height
, GLint border
,
193 GLenum format
, GLenum type
, const GLvoid
*pixels
);
196 extern void GLAPIENTRY
197 _mesa_TexImage3D( GLenum target
, GLint level
, GLint internalformat
,
198 GLsizei width
, GLsizei height
, GLsizei depth
, GLint border
,
199 GLenum format
, GLenum type
, const GLvoid
*pixels
);
202 extern void GLAPIENTRY
203 _mesa_TexImage3DEXT( GLenum target
, GLint level
, GLenum internalformat
,
204 GLsizei width
, GLsizei height
, GLsizei depth
,
205 GLint border
, GLenum format
, GLenum type
,
206 const GLvoid
*pixels
);
208 extern void GLAPIENTRY
209 _mesa_EGLImageTargetTexture2DOES( GLenum target
, GLeglImageOES image
);
211 extern void GLAPIENTRY
212 _mesa_TexSubImage1D( GLenum target
, GLint level
, GLint xoffset
,
214 GLenum format
, GLenum type
,
215 const GLvoid
*pixels
);
218 extern void GLAPIENTRY
219 _mesa_TexSubImage2D( GLenum target
, GLint level
,
220 GLint xoffset
, GLint yoffset
,
221 GLsizei width
, GLsizei height
,
222 GLenum format
, GLenum type
,
223 const GLvoid
*pixels
);
226 extern void GLAPIENTRY
227 _mesa_TexSubImage3D( GLenum target
, GLint level
,
228 GLint xoffset
, GLint yoffset
, GLint zoffset
,
229 GLsizei width
, GLsizei height
, GLsizei depth
,
230 GLenum format
, GLenum type
,
231 const GLvoid
*pixels
);
234 extern void GLAPIENTRY
235 _mesa_CopyTexImage1D( GLenum target
, GLint level
, GLenum internalformat
,
236 GLint x
, GLint y
, GLsizei width
, GLint border
);
239 extern void GLAPIENTRY
240 _mesa_CopyTexImage2D( GLenum target
, GLint level
,
241 GLenum internalformat
, GLint x
, GLint y
,
242 GLsizei width
, GLsizei height
, GLint border
);
245 extern void GLAPIENTRY
246 _mesa_CopyTexSubImage1D( GLenum target
, GLint level
, GLint xoffset
,
247 GLint x
, GLint y
, GLsizei width
);
250 extern void GLAPIENTRY
251 _mesa_CopyTexSubImage2D( GLenum target
, GLint level
,
252 GLint xoffset
, GLint yoffset
,
253 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
256 extern void GLAPIENTRY
257 _mesa_CopyTexSubImage3D( GLenum target
, GLint level
,
258 GLint xoffset
, GLint yoffset
, GLint zoffset
,
259 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
263 extern void GLAPIENTRY
264 _mesa_ClearTexSubImage( GLuint texture
, GLint level
,
265 GLint xoffset
, GLint yoffset
, GLint zoffset
,
266 GLsizei width
, GLsizei height
, GLsizei depth
,
267 GLenum format
, GLenum type
, const void *data
);
269 extern void GLAPIENTRY
270 _mesa_ClearTexImage( GLuint texture
, GLint level
,
271 GLenum format
, GLenum type
, const void *data
);
273 extern void GLAPIENTRY
274 _mesa_CompressedTexImage1D(GLenum target
, GLint level
,
275 GLenum internalformat
, GLsizei width
,
276 GLint border
, GLsizei imageSize
,
279 extern void GLAPIENTRY
280 _mesa_CompressedTexImage2D(GLenum target
, GLint level
,
281 GLenum internalformat
, GLsizei width
,
282 GLsizei height
, GLint border
, GLsizei imageSize
,
285 extern void GLAPIENTRY
286 _mesa_CompressedTexImage3D(GLenum target
, GLint level
,
287 GLenum internalformat
, GLsizei width
,
288 GLsizei height
, GLsizei depth
, GLint border
,
289 GLsizei imageSize
, const GLvoid
*data
);
291 extern void GLAPIENTRY
292 _mesa_CompressedTexSubImage1D(GLenum target
, GLint level
, GLint xoffset
,
293 GLsizei width
, GLenum format
,
294 GLsizei imageSize
, const GLvoid
*data
);
296 extern void GLAPIENTRY
297 _mesa_CompressedTexSubImage2D(GLenum target
, GLint level
, GLint xoffset
,
298 GLint yoffset
, GLsizei width
, GLsizei height
,
299 GLenum format
, GLsizei imageSize
,
302 extern void GLAPIENTRY
303 _mesa_CompressedTexSubImage3D(GLenum target
, GLint level
, GLint xoffset
,
304 GLint yoffset
, GLint zoffset
, GLsizei width
,
305 GLsizei height
, GLsizei depth
, GLenum format
,
306 GLsizei imageSize
, const GLvoid
*data
);
309 extern void GLAPIENTRY
310 _mesa_TexBuffer(GLenum target
, GLenum internalFormat
, GLuint buffer
);
312 extern void GLAPIENTRY
313 _mesa_TexBufferRange(GLenum target
, GLenum internalFormat
, GLuint buffer
,
314 GLintptr offset
, GLsizeiptr size
);
317 extern void GLAPIENTRY
318 _mesa_TexImage2DMultisample(GLenum target
, GLsizei samples
,
319 GLenum internalformat
, GLsizei width
,
320 GLsizei height
, GLboolean fixedsamplelocations
);
322 extern void GLAPIENTRY
323 _mesa_TexImage3DMultisample(GLenum target
, GLsizei samples
,
324 GLenum internalformat
, GLsizei width
,
325 GLsizei height
, GLsizei depth
,
326 GLboolean fixedsamplelocations
);
328 extern void GLAPIENTRY
329 _mesa_TexStorage2DMultisample(GLenum target
, GLsizei samples
,
330 GLenum internalformat
, GLsizei width
,
331 GLsizei height
, GLboolean fixedsamplelocations
);
333 extern void GLAPIENTRY
334 _mesa_TexStorage3DMultisample(GLenum target
, GLsizei samples
,
335 GLenum internalformat
, GLsizei width
,
336 GLsizei height
, GLsizei depth
,
337 GLboolean fixedsamplelocations
);
339 extern void GLAPIENTRY
340 _mesa_ClearTexImage(GLuint texture
, GLint level
,
341 GLenum format
, GLenum type
,
344 extern void GLAPIENTRY
345 _mesa_ClearTexSubImage(GLuint texture
, GLint level
,
346 GLint xoffset
, GLint yoffset
, GLint zoffset
,
347 GLsizei width
, GLsizei height
, GLsizei depth
,
348 GLenum format
, GLenum type
,
352 _mesa_compressed_texture_pixel_storage_error_check(struct gl_context
*ctx
,
354 struct gl_pixelstore_attrib
*packing
,