mesa: make _mesa_get_proxy_target() static
[mesa.git] / src / mesa / main / teximage.h
1 /**
2 * \file teximage.h
3 * Texture images manipulation functions.
4 */
5
6 /*
7 * Mesa 3-D graphics library
8 *
9 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
10 *
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:
17 *
18 * The above copyright notice and this permission notice shall be included
19 * in all copies or substantial portions of the Software.
20 *
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.
28 */
29
30
31 #ifndef TEXIMAGE_H
32 #define TEXIMAGE_H
33
34
35 #include "mtypes.h"
36 #include "formats.h"
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41
42 /** Is the given value one of the 6 cube faces? */
43 static inline GLboolean
44 _mesa_is_cube_face(GLenum target)
45 {
46 return (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
47 target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB);
48 }
49
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)
53 {
54 return (texImage->Width == 0 ||
55 texImage->Height == 0 ||
56 texImage->Depth == 0);
57 }
58
59 /** \name Internal functions */
60 /*@{*/
61
62 extern GLint
63 _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat );
64
65
66 extern GLboolean
67 _mesa_is_proxy_texture(GLenum target);
68
69 extern struct gl_texture_image *
70 _mesa_new_texture_image( struct gl_context *ctx );
71
72
73 extern void
74 _mesa_delete_texture_image( struct gl_context *ctx,
75 struct gl_texture_image *teximage );
76
77
78 extern void
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,
83 mesa_format format);
84
85
86 extern mesa_format
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);
91
92 extern void
93 _mesa_update_fbo_texture(struct gl_context *ctx,
94 struct gl_texture_object *texObj,
95 GLuint face, GLuint level);
96
97 extern void
98 _mesa_clear_texture_image(struct gl_context *ctx,
99 struct gl_texture_image *texImage);
100
101
102 extern struct gl_texture_object *
103 _mesa_get_current_tex_object(struct gl_context *ctx, GLenum target);
104
105
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);
110
111
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);
115
116
117 extern GLint
118 _mesa_max_texture_levels(struct gl_context *ctx, GLenum target);
119
120
121 extern GLboolean
122 _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level,
123 mesa_format format,
124 GLint width, GLint height, GLint depth, GLint border);
125
126
127 extern GLuint
128 _mesa_tex_target_to_face(GLenum target);
129
130 extern GLint
131 _mesa_get_texture_dimensions(GLenum target);
132
133 extern GLboolean
134 _mesa_tex_target_is_layered(GLenum target);
135
136 extern GLuint
137 _mesa_get_texture_layers(const struct gl_texture_object *texObj, GLint level);
138
139 extern GLsizei
140 _mesa_get_tex_max_num_levels(GLenum target, GLsizei width, GLsizei height,
141 GLsizei depth);
142
143 extern GLboolean
144 _mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target,
145 GLint level, GLint width, GLint height,
146 GLint depth, GLint border);
147
148 extern mesa_format
149 _mesa_validate_texbuffer_format(const struct gl_context *ctx,
150 GLenum internalFormat);
151
152
153 bool
154 _mesa_legal_texture_base_format_for_target(struct gl_context *ctx,
155 GLenum target,
156 GLenum internalFormat,
157 unsigned dimensions,
158 const char *caller);
159
160 /**
161 * Lock a texture for updating. See also _mesa_lock_context_textures().
162 */
163 static inline void
164 _mesa_lock_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
165 {
166 _glthread_LOCK_MUTEX(ctx->Shared->TexMutex);
167 ctx->Shared->TextureStateStamp++;
168 (void) texObj;
169 }
170
171 static inline void
172 _mesa_unlock_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
173 {
174 (void) texObj;
175 _glthread_UNLOCK_MUTEX(ctx->Shared->TexMutex);
176 }
177
178 /*@}*/
179
180
181 /** \name API entry point functions */
182 /*@{*/
183
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 );
188
189
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 );
194
195
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 );
200
201
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 );
207
208 extern void GLAPIENTRY
209 _mesa_EGLImageTargetTexture2DOES( GLenum target, GLeglImageOES image );
210
211 extern void GLAPIENTRY
212 _mesa_TexSubImage1D( GLenum target, GLint level, GLint xoffset,
213 GLsizei width,
214 GLenum format, GLenum type,
215 const GLvoid *pixels );
216
217
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 );
224
225
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 );
232
233
234 extern void GLAPIENTRY
235 _mesa_CopyTexImage1D( GLenum target, GLint level, GLenum internalformat,
236 GLint x, GLint y, GLsizei width, GLint border );
237
238
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 );
243
244
245 extern void GLAPIENTRY
246 _mesa_CopyTexSubImage1D( GLenum target, GLint level, GLint xoffset,
247 GLint x, GLint y, GLsizei width );
248
249
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 );
254
255
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 );
260
261
262
263 extern void GLAPIENTRY
264 _mesa_CompressedTexImage1D(GLenum target, GLint level,
265 GLenum internalformat, GLsizei width,
266 GLint border, GLsizei imageSize,
267 const GLvoid *data);
268
269 extern void GLAPIENTRY
270 _mesa_CompressedTexImage2D(GLenum target, GLint level,
271 GLenum internalformat, GLsizei width,
272 GLsizei height, GLint border, GLsizei imageSize,
273 const GLvoid *data);
274
275 extern void GLAPIENTRY
276 _mesa_CompressedTexImage3D(GLenum target, GLint level,
277 GLenum internalformat, GLsizei width,
278 GLsizei height, GLsizei depth, GLint border,
279 GLsizei imageSize, const GLvoid *data);
280
281 extern void GLAPIENTRY
282 _mesa_CompressedTexSubImage1D(GLenum target, GLint level, GLint xoffset,
283 GLsizei width, GLenum format,
284 GLsizei imageSize, const GLvoid *data);
285
286 extern void GLAPIENTRY
287 _mesa_CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset,
288 GLint yoffset, GLsizei width, GLsizei height,
289 GLenum format, GLsizei imageSize,
290 const GLvoid *data);
291
292 extern void GLAPIENTRY
293 _mesa_CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset,
294 GLint yoffset, GLint zoffset, GLsizei width,
295 GLsizei height, GLsizei depth, GLenum format,
296 GLsizei imageSize, const GLvoid *data);
297
298
299 extern void GLAPIENTRY
300 _mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer);
301
302 extern void GLAPIENTRY
303 _mesa_TexBufferRange(GLenum target, GLenum internalFormat, GLuint buffer,
304 GLintptr offset, GLsizeiptr size);
305
306
307 extern void GLAPIENTRY
308 _mesa_TexImage2DMultisample(GLenum target, GLsizei samples,
309 GLenum internalformat, GLsizei width,
310 GLsizei height, GLboolean fixedsamplelocations);
311
312 extern void GLAPIENTRY
313 _mesa_TexImage3DMultisample(GLenum target, GLsizei samples,
314 GLenum internalformat, GLsizei width,
315 GLsizei height, GLsizei depth,
316 GLboolean fixedsamplelocations);
317
318 extern void GLAPIENTRY
319 _mesa_TexStorage2DMultisample(GLenum target, GLsizei samples,
320 GLenum internalformat, GLsizei width,
321 GLsizei height, GLboolean fixedsamplelocations);
322
323 extern void GLAPIENTRY
324 _mesa_TexStorage3DMultisample(GLenum target, GLsizei samples,
325 GLenum internalformat, GLsizei width,
326 GLsizei height, GLsizei depth,
327 GLboolean fixedsamplelocations);
328
329 /*@}*/
330
331 #ifdef __cplusplus
332 }
333 #endif
334
335 #endif