1eebaa8b6318fe2ccbae2534e5c99a7895cd563e
[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 /** Are 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 bool
70 _mesa_is_array_texture(GLenum target);
71
72 extern struct gl_texture_image *
73 _mesa_new_texture_image( struct gl_context *ctx );
74
75
76 extern void
77 _mesa_delete_texture_image( struct gl_context *ctx,
78 struct gl_texture_image *teximage );
79
80
81 extern void
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,
86 mesa_format format);
87
88
89 extern mesa_format
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);
94
95 extern void
96 _mesa_update_fbo_texture(struct gl_context *ctx,
97 struct gl_texture_object *texObj,
98 GLuint face, GLuint level);
99
100 extern void
101 _mesa_clear_texture_image(struct gl_context *ctx,
102 struct gl_texture_image *texImage);
103
104
105 extern struct gl_texture_image *
106 _mesa_select_tex_image(const struct gl_texture_object *texObj,
107 GLenum target, GLint level);
108
109
110 extern struct gl_texture_image *
111 _mesa_get_tex_image(struct gl_context *ctx, struct gl_texture_object *texObj,
112 GLenum target, GLint level);
113
114
115 /**
116 * Return the base-level texture image for the given texture object.
117 */
118 static inline const struct gl_texture_image *
119 _mesa_base_tex_image(const struct gl_texture_object *texObj)
120 {
121 return texObj->Image[0][texObj->BaseLevel];
122 }
123
124
125 extern GLint
126 _mesa_max_texture_levels(struct gl_context *ctx, GLenum target);
127
128
129 extern GLboolean
130 _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level,
131 mesa_format format,
132 GLint width, GLint height, GLint depth, GLint border);
133
134 extern GLboolean
135 _mesa_target_can_be_compressed(const struct gl_context *ctx, GLenum target,
136 GLenum intFormat);
137
138 extern GLuint
139 _mesa_tex_target_to_face(GLenum target);
140
141 extern GLint
142 _mesa_get_texture_dimensions(GLenum target);
143
144 extern GLboolean
145 _mesa_tex_target_is_layered(GLenum target);
146
147 extern GLuint
148 _mesa_get_texture_layers(const struct gl_texture_object *texObj, GLint level);
149
150 extern GLsizei
151 _mesa_get_tex_max_num_levels(GLenum target, GLsizei width, GLsizei height,
152 GLsizei depth);
153
154 extern GLboolean
155 _mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target,
156 GLint level, GLint width, GLint height,
157 GLint depth, GLint border);
158
159 extern mesa_format
160 _mesa_validate_texbuffer_format(const struct gl_context *ctx,
161 GLenum internalFormat);
162
163
164 bool
165 _mesa_legal_texture_base_format_for_target(struct gl_context *ctx,
166 GLenum target,
167 GLenum internalFormat,
168 unsigned dimensions,
169 const char *caller);
170
171 extern void
172 _mesa_texture_sub_image(struct gl_context *ctx, GLuint dims,
173 struct gl_texture_object *texObj,
174 struct gl_texture_image *texImage,
175 GLenum target, GLint level,
176 GLint xoffset, GLint yoffset, GLint zoffset,
177 GLsizei width, GLsizei height, GLsizei depth,
178 GLenum format, GLenum type, const GLvoid *pixels,
179 bool dsa);
180
181 extern void
182 _mesa_compressed_texture_sub_image(struct gl_context *ctx, GLuint dims,
183 struct gl_texture_object *texObj,
184 struct gl_texture_image *texImage,
185 GLenum target, GLint level,
186 GLint xoffset, GLint yoffset,
187 GLint zoffset,
188 GLsizei width, GLsizei height,
189 GLsizei depth,
190 GLenum format, GLsizei imageSize,
191 const GLvoid *data);
192
193 extern void
194 _mesa_copy_texture_sub_image(struct gl_context *ctx, GLuint dims,
195 struct gl_texture_object *texObj,
196 GLenum target, GLint level,
197 GLint xoffset, GLint yoffset, GLint zoffset,
198 GLint x, GLint y,
199 GLsizei width, GLsizei height,
200 const char *caller);
201
202 extern void
203 _mesa_texture_image_multisample(struct gl_context *ctx, GLuint dims,
204 struct gl_texture_object *texObj,
205 GLenum target, GLsizei samples,
206 GLint internalformat, GLsizei width,
207 GLsizei height, GLsizei depth,
208 GLboolean fixedsamplelocations,
209 GLboolean immutable, const char *func);
210
211 extern void
212 _mesa_texture_buffer_range(struct gl_context *ctx,
213 struct gl_texture_object *texObj,
214 GLenum internalFormat,
215 struct gl_buffer_object *bufObj,
216 GLintptr offset, GLsizeiptr size,
217 const char *caller);
218 /*@}*/
219
220
221 /** \name API entry point functions */
222 /*@{*/
223
224 extern void GLAPIENTRY
225 _mesa_TexImage1D( GLenum target, GLint level, GLint internalformat,
226 GLsizei width, GLint border,
227 GLenum format, GLenum type, const GLvoid *pixels );
228
229
230 extern void GLAPIENTRY
231 _mesa_TexImage2D( GLenum target, GLint level, GLint internalformat,
232 GLsizei width, GLsizei height, GLint border,
233 GLenum format, GLenum type, const GLvoid *pixels );
234
235
236 extern void GLAPIENTRY
237 _mesa_TexImage3D( GLenum target, GLint level, GLint internalformat,
238 GLsizei width, GLsizei height, GLsizei depth, GLint border,
239 GLenum format, GLenum type, const GLvoid *pixels );
240
241
242 extern void GLAPIENTRY
243 _mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalformat,
244 GLsizei width, GLsizei height, GLsizei depth,
245 GLint border, GLenum format, GLenum type,
246 const GLvoid *pixels );
247
248 extern void GLAPIENTRY
249 _mesa_EGLImageTargetTexture2DOES( GLenum target, GLeglImageOES image );
250
251 extern void GLAPIENTRY
252 _mesa_TexSubImage1D( GLenum target, GLint level, GLint xoffset,
253 GLsizei width,
254 GLenum format, GLenum type,
255 const GLvoid *pixels );
256
257
258 extern void GLAPIENTRY
259 _mesa_TexSubImage2D( GLenum target, GLint level,
260 GLint xoffset, GLint yoffset,
261 GLsizei width, GLsizei height,
262 GLenum format, GLenum type,
263 const GLvoid *pixels );
264
265
266 extern void GLAPIENTRY
267 _mesa_TexSubImage3D( GLenum target, GLint level,
268 GLint xoffset, GLint yoffset, GLint zoffset,
269 GLsizei width, GLsizei height, GLsizei depth,
270 GLenum format, GLenum type,
271 const GLvoid *pixels );
272
273 extern void GLAPIENTRY
274 _mesa_TextureSubImage1D(GLuint texture, GLint level, GLint xoffset,
275 GLsizei width,
276 GLenum format, GLenum type,
277 const GLvoid *pixels);
278
279
280 extern void GLAPIENTRY
281 _mesa_TextureSubImage2D(GLuint texture, GLint level,
282 GLint xoffset, GLint yoffset,
283 GLsizei width, GLsizei height,
284 GLenum format, GLenum type,
285 const GLvoid *pixels);
286
287 extern void GLAPIENTRY
288 _mesa_TextureSubImage3D(GLuint texture, GLint level,
289 GLint xoffset, GLint yoffset, GLint zoffset,
290 GLsizei width, GLsizei height, GLsizei depth,
291 GLenum format, GLenum type,
292 const GLvoid *pixels);
293
294
295 extern void GLAPIENTRY
296 _mesa_CopyTexImage1D(GLenum target, GLint level, GLenum internalformat,
297 GLint x, GLint y, GLsizei width, GLint border);
298
299
300 extern void GLAPIENTRY
301 _mesa_CopyTexImage2D( GLenum target, GLint level,
302 GLenum internalformat, GLint x, GLint y,
303 GLsizei width, GLsizei height, GLint border );
304
305
306 extern void GLAPIENTRY
307 _mesa_CopyTexSubImage1D( GLenum target, GLint level, GLint xoffset,
308 GLint x, GLint y, GLsizei width );
309
310
311 extern void GLAPIENTRY
312 _mesa_CopyTexSubImage2D( GLenum target, GLint level,
313 GLint xoffset, GLint yoffset,
314 GLint x, GLint y, GLsizei width, GLsizei height );
315
316
317 extern void GLAPIENTRY
318 _mesa_CopyTexSubImage3D( GLenum target, GLint level,
319 GLint xoffset, GLint yoffset, GLint zoffset,
320 GLint x, GLint y, GLsizei width, GLsizei height );
321
322 extern void GLAPIENTRY
323 _mesa_CopyTextureSubImage1D(GLuint texture, GLint level,
324 GLint xoffset, GLint x, GLint y, GLsizei width);
325
326 extern void GLAPIENTRY
327 _mesa_CopyTextureSubImage2D(GLuint texture, GLint level,
328 GLint xoffset, GLint yoffset,
329 GLint x, GLint y,
330 GLsizei width, GLsizei height);
331
332 extern void GLAPIENTRY
333 _mesa_CopyTextureSubImage3D(GLuint texture, GLint level,
334 GLint xoffset, GLint yoffset, GLint zoffset,
335 GLint x, GLint y,
336 GLsizei width, GLsizei height);
337
338 extern void GLAPIENTRY
339 _mesa_ClearTexSubImage( GLuint texture, GLint level,
340 GLint xoffset, GLint yoffset, GLint zoffset,
341 GLsizei width, GLsizei height, GLsizei depth,
342 GLenum format, GLenum type, const void *data );
343
344 extern void GLAPIENTRY
345 _mesa_ClearTexImage( GLuint texture, GLint level,
346 GLenum format, GLenum type, const void *data );
347
348 extern void GLAPIENTRY
349 _mesa_CompressedTexImage1D(GLenum target, GLint level,
350 GLenum internalformat, GLsizei width,
351 GLint border, GLsizei imageSize,
352 const GLvoid *data);
353
354 extern void GLAPIENTRY
355 _mesa_CompressedTexImage2D(GLenum target, GLint level,
356 GLenum internalformat, GLsizei width,
357 GLsizei height, GLint border, GLsizei imageSize,
358 const GLvoid *data);
359
360 extern void GLAPIENTRY
361 _mesa_CompressedTexImage3D(GLenum target, GLint level,
362 GLenum internalformat, GLsizei width,
363 GLsizei height, GLsizei depth, GLint border,
364 GLsizei imageSize, const GLvoid *data);
365
366 extern void GLAPIENTRY
367 _mesa_CompressedTexSubImage1D(GLenum target, GLint level, GLint xoffset,
368 GLsizei width, GLenum format,
369 GLsizei imageSize, const GLvoid *data);
370
371 extern void GLAPIENTRY
372 _mesa_CompressedTextureSubImage1D(GLuint texture, GLint level, GLint xoffset,
373 GLsizei width, GLenum format,
374 GLsizei imageSize, const GLvoid *data);
375
376 extern void GLAPIENTRY
377 _mesa_CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset,
378 GLint yoffset, GLsizei width, GLsizei height,
379 GLenum format, GLsizei imageSize,
380 const GLvoid *data);
381
382 extern void GLAPIENTRY
383 _mesa_CompressedTextureSubImage2D(GLuint texture, GLint level, GLint xoffset,
384 GLint yoffset,
385 GLsizei width, GLsizei height,
386 GLenum format, GLsizei imageSize,
387 const GLvoid *data);
388
389 extern void GLAPIENTRY
390 _mesa_CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset,
391 GLint yoffset, GLint zoffset, GLsizei width,
392 GLsizei height, GLsizei depth, GLenum format,
393 GLsizei imageSize, const GLvoid *data);
394
395 extern void GLAPIENTRY
396 _mesa_CompressedTextureSubImage3D(GLuint texture, GLint level, GLint xoffset,
397 GLint yoffset, GLint zoffset,
398 GLsizei width, GLsizei height,
399 GLsizei depth,
400 GLenum format, GLsizei imageSize,
401 const GLvoid *data);
402
403 extern void GLAPIENTRY
404 _mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer);
405
406 extern void GLAPIENTRY
407 _mesa_TexBufferRange(GLenum target, GLenum internalFormat, GLuint buffer,
408 GLintptr offset, GLsizeiptr size);
409
410 extern void GLAPIENTRY
411 _mesa_TextureBuffer(GLuint texture, GLenum internalFormat, GLuint buffer);
412
413 extern void GLAPIENTRY
414 _mesa_TextureBufferRange(GLuint texture, GLenum internalFormat, GLuint buffer,
415 GLintptr offset, GLsizeiptr size);
416
417
418 extern void GLAPIENTRY
419 _mesa_TexImage2DMultisample(GLenum target, GLsizei samples,
420 GLenum internalformat, GLsizei width,
421 GLsizei height, GLboolean fixedsamplelocations);
422
423 extern void GLAPIENTRY
424 _mesa_TexImage3DMultisample(GLenum target, GLsizei samples,
425 GLenum internalformat, GLsizei width,
426 GLsizei height, GLsizei depth,
427 GLboolean fixedsamplelocations);
428
429 extern void GLAPIENTRY
430 _mesa_TexStorage2DMultisample(GLenum target, GLsizei samples,
431 GLenum internalformat, GLsizei width,
432 GLsizei height, GLboolean fixedsamplelocations);
433
434 extern void GLAPIENTRY
435 _mesa_TexStorage3DMultisample(GLenum target, GLsizei samples,
436 GLenum internalformat, GLsizei width,
437 GLsizei height, GLsizei depth,
438 GLboolean fixedsamplelocations);
439
440 void GLAPIENTRY
441 _mesa_TextureStorage2DMultisample(GLuint texture, GLsizei samples,
442 GLenum internalformat, GLsizei width,
443 GLsizei height,
444 GLboolean fixedsamplelocations);
445
446 void GLAPIENTRY
447 _mesa_TextureStorage3DMultisample(GLuint texture, GLsizei samples,
448 GLenum internalformat, GLsizei width,
449 GLsizei height, GLsizei depth,
450 GLboolean fixedsamplelocations);
451 /*@}*/
452
453 #ifdef __cplusplus
454 }
455 #endif
456
457 #endif