mesa: remove unused ctx parameter for _mesa_select_tex_image()
[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(const struct gl_texture_object *texObj,
108 GLenum target, GLint level);
109
110
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);
114
115
116 /**
117 * Return the base-level texture image for the given texture object.
118 */
119 static inline const struct gl_texture_image *
120 _mesa_base_tex_image(const struct gl_texture_object *texObj)
121 {
122 return texObj->Image[0][texObj->BaseLevel];
123 }
124
125
126 extern GLint
127 _mesa_max_texture_levels(struct gl_context *ctx, GLenum target);
128
129
130 extern GLboolean
131 _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level,
132 mesa_format format,
133 GLint width, GLint height, GLint depth, GLint border);
134
135 extern GLboolean
136 _mesa_target_can_be_compressed(const struct gl_context *ctx, GLenum target,
137 GLenum intFormat);
138
139 extern GLuint
140 _mesa_tex_target_to_face(GLenum target);
141
142 extern GLint
143 _mesa_get_texture_dimensions(GLenum target);
144
145 extern GLboolean
146 _mesa_tex_target_is_layered(GLenum target);
147
148 extern GLuint
149 _mesa_get_texture_layers(const struct gl_texture_object *texObj, GLint level);
150
151 extern GLsizei
152 _mesa_get_tex_max_num_levels(GLenum target, GLsizei width, GLsizei height,
153 GLsizei depth);
154
155 extern GLboolean
156 _mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target,
157 GLint level, GLint width, GLint height,
158 GLint depth, GLint border);
159
160 extern mesa_format
161 _mesa_validate_texbuffer_format(const struct gl_context *ctx,
162 GLenum internalFormat);
163
164
165 bool
166 _mesa_legal_texture_base_format_for_target(struct gl_context *ctx,
167 GLenum target,
168 GLenum internalFormat,
169 unsigned dimensions,
170 const char *caller);
171
172 /**
173 * Lock a texture for updating. See also _mesa_lock_context_textures().
174 */
175 static inline void
176 _mesa_lock_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
177 {
178 mtx_lock(&ctx->Shared->TexMutex);
179 ctx->Shared->TextureStateStamp++;
180 (void) texObj;
181 }
182
183 static inline void
184 _mesa_unlock_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
185 {
186 (void) texObj;
187 mtx_unlock(&ctx->Shared->TexMutex);
188 }
189
190 /*@}*/
191
192
193 /** \name API entry point functions */
194 /*@{*/
195
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 );
200
201
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 );
206
207
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 );
212
213
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 );
219
220 extern void GLAPIENTRY
221 _mesa_EGLImageTargetTexture2DOES( GLenum target, GLeglImageOES image );
222
223 extern void GLAPIENTRY
224 _mesa_TexSubImage1D( GLenum target, GLint level, GLint xoffset,
225 GLsizei width,
226 GLenum format, GLenum type,
227 const GLvoid *pixels );
228
229
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 );
236
237
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 );
244
245
246 extern void GLAPIENTRY
247 _mesa_CopyTexImage1D( GLenum target, GLint level, GLenum internalformat,
248 GLint x, GLint y, GLsizei width, GLint border );
249
250
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 );
255
256
257 extern void GLAPIENTRY
258 _mesa_CopyTexSubImage1D( GLenum target, GLint level, GLint xoffset,
259 GLint x, GLint y, GLsizei width );
260
261
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 );
266
267
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 );
272
273
274
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 );
280
281 extern void GLAPIENTRY
282 _mesa_ClearTexImage( GLuint texture, GLint level,
283 GLenum format, GLenum type, const void *data );
284
285 extern void GLAPIENTRY
286 _mesa_CompressedTexImage1D(GLenum target, GLint level,
287 GLenum internalformat, GLsizei width,
288 GLint border, GLsizei imageSize,
289 const GLvoid *data);
290
291 extern void GLAPIENTRY
292 _mesa_CompressedTexImage2D(GLenum target, GLint level,
293 GLenum internalformat, GLsizei width,
294 GLsizei height, GLint border, GLsizei imageSize,
295 const GLvoid *data);
296
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);
302
303 extern void GLAPIENTRY
304 _mesa_CompressedTexSubImage1D(GLenum target, GLint level, GLint xoffset,
305 GLsizei width, GLenum format,
306 GLsizei imageSize, const GLvoid *data);
307
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,
312 const GLvoid *data);
313
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);
319
320
321 extern void GLAPIENTRY
322 _mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer);
323
324 extern void GLAPIENTRY
325 _mesa_TexBufferRange(GLenum target, GLenum internalFormat, GLuint buffer,
326 GLintptr offset, GLsizeiptr size);
327
328
329 extern void GLAPIENTRY
330 _mesa_TexImage2DMultisample(GLenum target, GLsizei samples,
331 GLenum internalformat, GLsizei width,
332 GLsizei height, GLboolean fixedsamplelocations);
333
334 extern void GLAPIENTRY
335 _mesa_TexImage3DMultisample(GLenum target, GLsizei samples,
336 GLenum internalformat, GLsizei width,
337 GLsizei height, GLsizei depth,
338 GLboolean fixedsamplelocations);
339
340 extern void GLAPIENTRY
341 _mesa_TexStorage2DMultisample(GLenum target, GLsizei samples,
342 GLenum internalformat, GLsizei width,
343 GLsizei height, GLboolean fixedsamplelocations);
344
345 extern void GLAPIENTRY
346 _mesa_TexStorage3DMultisample(GLenum target, GLsizei samples,
347 GLenum internalformat, GLsizei width,
348 GLsizei height, GLsizei depth,
349 GLboolean fixedsamplelocations);
350
351 /*@}*/
352
353 #ifdef __cplusplus
354 }
355 #endif
356
357 #endif