3 * Texture images manipulation functions.
7 * Mesa 3-D graphics library
10 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
26 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR 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
);
70 _mesa_get_proxy_target(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_object
*
106 _mesa_select_tex_object(struct gl_context
*ctx
,
107 const struct gl_texture_unit
*texUnit
,
110 extern struct gl_texture_object
*
111 _mesa_get_current_tex_object(struct gl_context
*ctx
, GLenum target
);
114 extern struct gl_texture_image
*
115 _mesa_select_tex_image(struct gl_context
*ctx
,
116 const struct gl_texture_object
*texObj
,
117 GLenum target
, GLint level
);
120 extern struct gl_texture_image
*
121 _mesa_get_tex_image(struct gl_context
*ctx
, struct gl_texture_object
*texObj
,
122 GLenum target
, GLint level
);
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
);
136 _mesa_tex_target_to_face(GLenum target
);
139 _mesa_get_texture_dimensions(GLenum target
);
142 _mesa_get_tex_max_num_levels(GLenum target
, GLsizei width
, GLsizei height
,
146 _mesa_legal_texture_dimensions(struct gl_context
*ctx
, GLenum target
,
147 GLint level
, GLint width
, GLint height
,
148 GLint depth
, GLint border
);
151 * Lock a texture for updating. See also _mesa_lock_context_textures().
154 _mesa_lock_texture(struct gl_context
*ctx
, struct gl_texture_object
*texObj
)
156 _glthread_LOCK_MUTEX(ctx
->Shared
->TexMutex
);
157 ctx
->Shared
->TextureStateStamp
++;
162 _mesa_unlock_texture(struct gl_context
*ctx
, struct gl_texture_object
*texObj
)
165 _glthread_UNLOCK_MUTEX(ctx
->Shared
->TexMutex
);
171 /** \name API entry point functions */
174 extern void GLAPIENTRY
175 _mesa_TexImage1D( GLenum target
, GLint level
, GLint internalformat
,
176 GLsizei width
, GLint border
,
177 GLenum format
, GLenum type
, const GLvoid
*pixels
);
180 extern void GLAPIENTRY
181 _mesa_TexImage2D( GLenum target
, GLint level
, GLint internalformat
,
182 GLsizei width
, GLsizei height
, GLint border
,
183 GLenum format
, GLenum type
, const GLvoid
*pixels
);
186 extern void GLAPIENTRY
187 _mesa_TexImage3D( GLenum target
, GLint level
, GLint internalformat
,
188 GLsizei width
, GLsizei height
, GLsizei depth
, GLint border
,
189 GLenum format
, GLenum type
, const GLvoid
*pixels
);
192 extern void GLAPIENTRY
193 _mesa_TexImage3DEXT( GLenum target
, GLint level
, GLenum internalformat
,
194 GLsizei width
, GLsizei height
, GLsizei depth
,
195 GLint border
, GLenum format
, GLenum type
,
196 const GLvoid
*pixels
);
198 extern void GLAPIENTRY
199 _mesa_EGLImageTargetTexture2DOES( GLenum target
, GLeglImageOES image
);
201 extern void GLAPIENTRY
202 _mesa_TexSubImage1D( GLenum target
, GLint level
, GLint xoffset
,
204 GLenum format
, GLenum type
,
205 const GLvoid
*pixels
);
208 extern void GLAPIENTRY
209 _mesa_TexSubImage2D( GLenum target
, GLint level
,
210 GLint xoffset
, GLint yoffset
,
211 GLsizei width
, GLsizei height
,
212 GLenum format
, GLenum type
,
213 const GLvoid
*pixels
);
216 extern void GLAPIENTRY
217 _mesa_TexSubImage3D( GLenum target
, GLint level
,
218 GLint xoffset
, GLint yoffset
, GLint zoffset
,
219 GLsizei width
, GLsizei height
, GLsizei depth
,
220 GLenum format
, GLenum type
,
221 const GLvoid
*pixels
);
224 extern void GLAPIENTRY
225 _mesa_CopyTexImage1D( GLenum target
, GLint level
, GLenum internalformat
,
226 GLint x
, GLint y
, GLsizei width
, GLint border
);
229 extern void GLAPIENTRY
230 _mesa_CopyTexImage2D( GLenum target
, GLint level
,
231 GLenum internalformat
, GLint x
, GLint y
,
232 GLsizei width
, GLsizei height
, GLint border
);
235 extern void GLAPIENTRY
236 _mesa_CopyTexSubImage1D( GLenum target
, GLint level
, GLint xoffset
,
237 GLint x
, GLint y
, GLsizei width
);
240 extern void GLAPIENTRY
241 _mesa_CopyTexSubImage2D( GLenum target
, GLint level
,
242 GLint xoffset
, GLint yoffset
,
243 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
246 extern void GLAPIENTRY
247 _mesa_CopyTexSubImage3D( GLenum target
, GLint level
,
248 GLint xoffset
, GLint yoffset
, GLint zoffset
,
249 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
253 extern void GLAPIENTRY
254 _mesa_CompressedTexImage1D(GLenum target
, GLint level
,
255 GLenum internalformat
, GLsizei width
,
256 GLint border
, GLsizei imageSize
,
259 extern void GLAPIENTRY
260 _mesa_CompressedTexImage2D(GLenum target
, GLint level
,
261 GLenum internalformat
, GLsizei width
,
262 GLsizei height
, GLint border
, GLsizei imageSize
,
265 extern void GLAPIENTRY
266 _mesa_CompressedTexImage3D(GLenum target
, GLint level
,
267 GLenum internalformat
, GLsizei width
,
268 GLsizei height
, GLsizei depth
, GLint border
,
269 GLsizei imageSize
, const GLvoid
*data
);
271 extern void GLAPIENTRY
272 _mesa_CompressedTexSubImage1D(GLenum target
, GLint level
, GLint xoffset
,
273 GLsizei width
, GLenum format
,
274 GLsizei imageSize
, const GLvoid
*data
);
276 extern void GLAPIENTRY
277 _mesa_CompressedTexSubImage2D(GLenum target
, GLint level
, GLint xoffset
,
278 GLint yoffset
, GLsizei width
, GLsizei height
,
279 GLenum format
, GLsizei imageSize
,
282 extern void GLAPIENTRY
283 _mesa_CompressedTexSubImage3D(GLenum target
, GLint level
, GLint xoffset
,
284 GLint yoffset
, GLint zoffset
, GLsizei width
,
285 GLsizei height
, GLsizei depth
, GLenum format
,
286 GLsizei imageSize
, const GLvoid
*data
);
289 extern void GLAPIENTRY
290 _mesa_TexBuffer(GLenum target
, GLenum internalFormat
, GLuint buffer
);
292 extern void GLAPIENTRY
293 _mesa_TexBufferRange(GLenum target
, GLenum internalFormat
, GLuint buffer
,
294 GLintptr offset
, GLsizeiptr size
);
297 extern void GLAPIENTRY
298 _mesa_TexImage2DMultisample(GLenum target
, GLsizei samples
,
299 GLint internalformat
, GLsizei width
,
300 GLsizei height
, GLboolean fixedsamplelocations
);
302 extern void GLAPIENTRY
303 _mesa_TexImage3DMultisample(GLenum target
, GLsizei samples
,
304 GLint internalformat
, GLsizei width
,
305 GLsizei height
, GLsizei depth
,
306 GLboolean fixedsamplelocations
);
308 extern void GLAPIENTRY
309 _mesa_TexStorage2DMultisample(GLenum target
, GLsizei samples
,
310 GLenum internalformat
, GLsizei width
,
311 GLsizei height
, GLboolean fixedsamplelocations
);
313 extern void GLAPIENTRY
314 _mesa_TexStorage3DMultisample(GLenum target
, GLsizei samples
,
315 GLenum internalformat
, GLsizei width
,
316 GLsizei height
, GLsizei depth
,
317 GLboolean fixedsamplelocations
);