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
);
127 _mesa_target_can_be_compressed(const struct gl_context
*ctx
, GLenum target
,
131 _mesa_tex_target_to_face(GLenum target
);
134 _mesa_get_texture_dimensions(GLenum target
);
137 _mesa_tex_target_is_layered(GLenum target
);
140 _mesa_get_texture_layers(const struct gl_texture_object
*texObj
, GLint level
);
143 _mesa_get_tex_max_num_levels(GLenum target
, GLsizei width
, GLsizei height
,
147 _mesa_legal_texture_dimensions(struct gl_context
*ctx
, GLenum target
,
148 GLint level
, GLint width
, GLint height
,
149 GLint depth
, GLint border
);
152 _mesa_validate_texbuffer_format(const struct gl_context
*ctx
,
153 GLenum internalFormat
);
157 _mesa_legal_texture_base_format_for_target(struct gl_context
*ctx
,
159 GLenum internalFormat
,
164 * Lock a texture for updating. See also _mesa_lock_context_textures().
167 _mesa_lock_texture(struct gl_context
*ctx
, struct gl_texture_object
*texObj
)
169 mtx_lock(&ctx
->Shared
->TexMutex
);
170 ctx
->Shared
->TextureStateStamp
++;
175 _mesa_unlock_texture(struct gl_context
*ctx
, struct gl_texture_object
*texObj
)
178 mtx_unlock(&ctx
->Shared
->TexMutex
);
184 /** \name API entry point functions */
187 extern void GLAPIENTRY
188 _mesa_TexImage1D( GLenum target
, GLint level
, GLint internalformat
,
189 GLsizei width
, GLint border
,
190 GLenum format
, GLenum type
, const GLvoid
*pixels
);
193 extern void GLAPIENTRY
194 _mesa_TexImage2D( GLenum target
, GLint level
, GLint internalformat
,
195 GLsizei width
, GLsizei height
, GLint border
,
196 GLenum format
, GLenum type
, const GLvoid
*pixels
);
199 extern void GLAPIENTRY
200 _mesa_TexImage3D( GLenum target
, GLint level
, GLint internalformat
,
201 GLsizei width
, GLsizei height
, GLsizei depth
, GLint border
,
202 GLenum format
, GLenum type
, const GLvoid
*pixels
);
205 extern void GLAPIENTRY
206 _mesa_TexImage3DEXT( GLenum target
, GLint level
, GLenum internalformat
,
207 GLsizei width
, GLsizei height
, GLsizei depth
,
208 GLint border
, GLenum format
, GLenum type
,
209 const GLvoid
*pixels
);
211 extern void GLAPIENTRY
212 _mesa_EGLImageTargetTexture2DOES( GLenum target
, GLeglImageOES image
);
214 extern void GLAPIENTRY
215 _mesa_TexSubImage1D( GLenum target
, GLint level
, GLint xoffset
,
217 GLenum format
, GLenum type
,
218 const GLvoid
*pixels
);
221 extern void GLAPIENTRY
222 _mesa_TexSubImage2D( GLenum target
, GLint level
,
223 GLint xoffset
, GLint yoffset
,
224 GLsizei width
, GLsizei height
,
225 GLenum format
, GLenum type
,
226 const GLvoid
*pixels
);
229 extern void GLAPIENTRY
230 _mesa_TexSubImage3D( GLenum target
, GLint level
,
231 GLint xoffset
, GLint yoffset
, GLint zoffset
,
232 GLsizei width
, GLsizei height
, GLsizei depth
,
233 GLenum format
, GLenum type
,
234 const GLvoid
*pixels
);
237 extern void GLAPIENTRY
238 _mesa_CopyTexImage1D( GLenum target
, GLint level
, GLenum internalformat
,
239 GLint x
, GLint y
, GLsizei width
, GLint border
);
242 extern void GLAPIENTRY
243 _mesa_CopyTexImage2D( GLenum target
, GLint level
,
244 GLenum internalformat
, GLint x
, GLint y
,
245 GLsizei width
, GLsizei height
, GLint border
);
248 extern void GLAPIENTRY
249 _mesa_CopyTexSubImage1D( GLenum target
, GLint level
, GLint xoffset
,
250 GLint x
, GLint y
, GLsizei width
);
253 extern void GLAPIENTRY
254 _mesa_CopyTexSubImage2D( GLenum target
, GLint level
,
255 GLint xoffset
, GLint yoffset
,
256 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
259 extern void GLAPIENTRY
260 _mesa_CopyTexSubImage3D( GLenum target
, GLint level
,
261 GLint xoffset
, GLint yoffset
, GLint zoffset
,
262 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
266 extern void GLAPIENTRY
267 _mesa_ClearTexSubImage( GLuint texture
, GLint level
,
268 GLint xoffset
, GLint yoffset
, GLint zoffset
,
269 GLsizei width
, GLsizei height
, GLsizei depth
,
270 GLenum format
, GLenum type
, const void *data
);
272 extern void GLAPIENTRY
273 _mesa_ClearTexImage( GLuint texture
, GLint level
,
274 GLenum format
, GLenum type
, const void *data
);
276 extern void GLAPIENTRY
277 _mesa_CompressedTexImage1D(GLenum target
, GLint level
,
278 GLenum internalformat
, GLsizei width
,
279 GLint border
, GLsizei imageSize
,
282 extern void GLAPIENTRY
283 _mesa_CompressedTexImage2D(GLenum target
, GLint level
,
284 GLenum internalformat
, GLsizei width
,
285 GLsizei height
, GLint border
, GLsizei imageSize
,
288 extern void GLAPIENTRY
289 _mesa_CompressedTexImage3D(GLenum target
, GLint level
,
290 GLenum internalformat
, GLsizei width
,
291 GLsizei height
, GLsizei depth
, GLint border
,
292 GLsizei imageSize
, const GLvoid
*data
);
294 extern void GLAPIENTRY
295 _mesa_CompressedTexSubImage1D(GLenum target
, GLint level
, GLint xoffset
,
296 GLsizei width
, GLenum format
,
297 GLsizei imageSize
, const GLvoid
*data
);
299 extern void GLAPIENTRY
300 _mesa_CompressedTexSubImage2D(GLenum target
, GLint level
, GLint xoffset
,
301 GLint yoffset
, GLsizei width
, GLsizei height
,
302 GLenum format
, GLsizei imageSize
,
305 extern void GLAPIENTRY
306 _mesa_CompressedTexSubImage3D(GLenum target
, GLint level
, GLint xoffset
,
307 GLint yoffset
, GLint zoffset
, GLsizei width
,
308 GLsizei height
, GLsizei depth
, GLenum format
,
309 GLsizei imageSize
, const GLvoid
*data
);
312 extern void GLAPIENTRY
313 _mesa_TexBuffer(GLenum target
, GLenum internalFormat
, GLuint buffer
);
315 extern void GLAPIENTRY
316 _mesa_TexBufferRange(GLenum target
, GLenum internalFormat
, GLuint buffer
,
317 GLintptr offset
, GLsizeiptr size
);
320 extern void GLAPIENTRY
321 _mesa_TexImage2DMultisample(GLenum target
, GLsizei samples
,
322 GLenum internalformat
, GLsizei width
,
323 GLsizei height
, GLboolean fixedsamplelocations
);
325 extern void GLAPIENTRY
326 _mesa_TexImage3DMultisample(GLenum target
, GLsizei samples
,
327 GLenum internalformat
, GLsizei width
,
328 GLsizei height
, GLsizei depth
,
329 GLboolean fixedsamplelocations
);
331 extern void GLAPIENTRY
332 _mesa_TexStorage2DMultisample(GLenum target
, GLsizei samples
,
333 GLenum internalformat
, GLsizei width
,
334 GLsizei height
, GLboolean fixedsamplelocations
);
336 extern void GLAPIENTRY
337 _mesa_TexStorage3DMultisample(GLenum target
, GLsizei samples
,
338 GLenum internalformat
, GLsizei width
,
339 GLsizei height
, GLsizei depth
,
340 GLboolean fixedsamplelocations
);