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(const struct gl_texture_object
*texObj
,
108 GLenum target
, GLint level
);
111 extern struct gl_texture_image
*
112 _mesa_get_tex_image(struct gl_context
*ctx
, struct gl_texture_object
*texObj
,
113 GLenum target
, GLint level
);
117 * Return the base-level texture image for the given texture object.
119 static inline const struct gl_texture_image
*
120 _mesa_base_tex_image(const struct gl_texture_object
*texObj
)
122 return texObj
->Image
[0][texObj
->BaseLevel
];
127 _mesa_max_texture_levels(struct gl_context
*ctx
, GLenum target
);
131 _mesa_test_proxy_teximage(struct gl_context
*ctx
, GLenum target
, GLint level
,
133 GLint width
, GLint height
, GLint depth
, GLint border
);
136 _mesa_target_can_be_compressed(const struct gl_context
*ctx
, GLenum target
,
140 _mesa_tex_target_to_face(GLenum target
);
143 _mesa_get_texture_dimensions(GLenum target
);
146 _mesa_tex_target_is_layered(GLenum target
);
149 _mesa_get_texture_layers(const struct gl_texture_object
*texObj
, GLint level
);
152 _mesa_get_tex_max_num_levels(GLenum target
, GLsizei width
, GLsizei height
,
156 _mesa_legal_texture_dimensions(struct gl_context
*ctx
, GLenum target
,
157 GLint level
, GLint width
, GLint height
,
158 GLint depth
, GLint border
);
161 _mesa_validate_texbuffer_format(const struct gl_context
*ctx
,
162 GLenum internalFormat
);
166 _mesa_legal_texture_base_format_for_target(struct gl_context
*ctx
,
168 GLenum internalFormat
,
173 * Lock a texture for updating. See also _mesa_lock_context_textures().
176 _mesa_lock_texture(struct gl_context
*ctx
, struct gl_texture_object
*texObj
)
178 mtx_lock(&ctx
->Shared
->TexMutex
);
179 ctx
->Shared
->TextureStateStamp
++;
184 _mesa_unlock_texture(struct gl_context
*ctx
, struct gl_texture_object
*texObj
)
187 mtx_unlock(&ctx
->Shared
->TexMutex
);
193 /** \name API entry point functions */
196 extern void GLAPIENTRY
197 _mesa_TexImage1D( GLenum target
, GLint level
, GLint internalformat
,
198 GLsizei width
, GLint border
,
199 GLenum format
, GLenum type
, const GLvoid
*pixels
);
202 extern void GLAPIENTRY
203 _mesa_TexImage2D( GLenum target
, GLint level
, GLint internalformat
,
204 GLsizei width
, GLsizei height
, GLint border
,
205 GLenum format
, GLenum type
, const GLvoid
*pixels
);
208 extern void GLAPIENTRY
209 _mesa_TexImage3D( GLenum target
, GLint level
, GLint internalformat
,
210 GLsizei width
, GLsizei height
, GLsizei depth
, GLint border
,
211 GLenum format
, GLenum type
, const GLvoid
*pixels
);
214 extern void GLAPIENTRY
215 _mesa_TexImage3DEXT( GLenum target
, GLint level
, GLenum internalformat
,
216 GLsizei width
, GLsizei height
, GLsizei depth
,
217 GLint border
, GLenum format
, GLenum type
,
218 const GLvoid
*pixels
);
220 extern void GLAPIENTRY
221 _mesa_EGLImageTargetTexture2DOES( GLenum target
, GLeglImageOES image
);
223 extern void GLAPIENTRY
224 _mesa_TexSubImage1D( GLenum target
, GLint level
, GLint xoffset
,
226 GLenum format
, GLenum type
,
227 const GLvoid
*pixels
);
230 extern void GLAPIENTRY
231 _mesa_TexSubImage2D( GLenum target
, GLint level
,
232 GLint xoffset
, GLint yoffset
,
233 GLsizei width
, GLsizei height
,
234 GLenum format
, GLenum type
,
235 const GLvoid
*pixels
);
238 extern void GLAPIENTRY
239 _mesa_TexSubImage3D( GLenum target
, GLint level
,
240 GLint xoffset
, GLint yoffset
, GLint zoffset
,
241 GLsizei width
, GLsizei height
, GLsizei depth
,
242 GLenum format
, GLenum type
,
243 const GLvoid
*pixels
);
246 extern void GLAPIENTRY
247 _mesa_CopyTexImage1D( GLenum target
, GLint level
, GLenum internalformat
,
248 GLint x
, GLint y
, GLsizei width
, GLint border
);
251 extern void GLAPIENTRY
252 _mesa_CopyTexImage2D( GLenum target
, GLint level
,
253 GLenum internalformat
, GLint x
, GLint y
,
254 GLsizei width
, GLsizei height
, GLint border
);
257 extern void GLAPIENTRY
258 _mesa_CopyTexSubImage1D( GLenum target
, GLint level
, GLint xoffset
,
259 GLint x
, GLint y
, GLsizei width
);
262 extern void GLAPIENTRY
263 _mesa_CopyTexSubImage2D( GLenum target
, GLint level
,
264 GLint xoffset
, GLint yoffset
,
265 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
268 extern void GLAPIENTRY
269 _mesa_CopyTexSubImage3D( GLenum target
, GLint level
,
270 GLint xoffset
, GLint yoffset
, GLint zoffset
,
271 GLint x
, GLint y
, GLsizei width
, GLsizei height
);
275 extern void GLAPIENTRY
276 _mesa_ClearTexSubImage( GLuint texture
, GLint level
,
277 GLint xoffset
, GLint yoffset
, GLint zoffset
,
278 GLsizei width
, GLsizei height
, GLsizei depth
,
279 GLenum format
, GLenum type
, const void *data
);
281 extern void GLAPIENTRY
282 _mesa_ClearTexImage( GLuint texture
, GLint level
,
283 GLenum format
, GLenum type
, const void *data
);
285 extern void GLAPIENTRY
286 _mesa_CompressedTexImage1D(GLenum target
, GLint level
,
287 GLenum internalformat
, GLsizei width
,
288 GLint border
, GLsizei imageSize
,
291 extern void GLAPIENTRY
292 _mesa_CompressedTexImage2D(GLenum target
, GLint level
,
293 GLenum internalformat
, GLsizei width
,
294 GLsizei height
, GLint border
, GLsizei imageSize
,
297 extern void GLAPIENTRY
298 _mesa_CompressedTexImage3D(GLenum target
, GLint level
,
299 GLenum internalformat
, GLsizei width
,
300 GLsizei height
, GLsizei depth
, GLint border
,
301 GLsizei imageSize
, const GLvoid
*data
);
303 extern void GLAPIENTRY
304 _mesa_CompressedTexSubImage1D(GLenum target
, GLint level
, GLint xoffset
,
305 GLsizei width
, GLenum format
,
306 GLsizei imageSize
, const GLvoid
*data
);
308 extern void GLAPIENTRY
309 _mesa_CompressedTexSubImage2D(GLenum target
, GLint level
, GLint xoffset
,
310 GLint yoffset
, GLsizei width
, GLsizei height
,
311 GLenum format
, GLsizei imageSize
,
314 extern void GLAPIENTRY
315 _mesa_CompressedTexSubImage3D(GLenum target
, GLint level
, GLint xoffset
,
316 GLint yoffset
, GLint zoffset
, GLsizei width
,
317 GLsizei height
, GLsizei depth
, GLenum format
,
318 GLsizei imageSize
, const GLvoid
*data
);
321 extern void GLAPIENTRY
322 _mesa_TexBuffer(GLenum target
, GLenum internalFormat
, GLuint buffer
);
324 extern void GLAPIENTRY
325 _mesa_TexBufferRange(GLenum target
, GLenum internalFormat
, GLuint buffer
,
326 GLintptr offset
, GLsizeiptr size
);
329 extern void GLAPIENTRY
330 _mesa_TexImage2DMultisample(GLenum target
, GLsizei samples
,
331 GLenum internalformat
, GLsizei width
,
332 GLsizei height
, GLboolean fixedsamplelocations
);
334 extern void GLAPIENTRY
335 _mesa_TexImage3DMultisample(GLenum target
, GLsizei samples
,
336 GLenum internalformat
, GLsizei width
,
337 GLsizei height
, GLsizei depth
,
338 GLboolean fixedsamplelocations
);
340 extern void GLAPIENTRY
341 _mesa_TexStorage2DMultisample(GLenum target
, GLsizei samples
,
342 GLenum internalformat
, GLsizei width
,
343 GLsizei height
, GLboolean fixedsamplelocations
);
345 extern void GLAPIENTRY
346 _mesa_TexStorage3DMultisample(GLenum target
, GLsizei samples
,
347 GLenum internalformat
, GLsizei width
,
348 GLsizei height
, GLsizei depth
,
349 GLboolean fixedsamplelocations
);