mesa: add KHR_no_error support for glCopyTex{ture}SubImage*D()
[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 &&
47 target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z);
48 }
49
50
51 /**
52 * Return number of faces for a texture target. This will be 6 for
53 * cube maps and 1 otherwise.
54 * NOTE: this function is not used for cube map arrays which operate
55 * more like 2D arrays than cube maps.
56 */
57 static inline GLuint
58 _mesa_num_tex_faces(GLenum target)
59 {
60 switch (target) {
61 case GL_TEXTURE_CUBE_MAP:
62 case GL_PROXY_TEXTURE_CUBE_MAP:
63 return 6;
64 default:
65 return 1;
66 }
67 }
68
69
70 /**
71 * If the target is GL_TEXTURE_CUBE_MAP, return one of the
72 * GL_TEXTURE_CUBE_MAP_POSITIVE/NEGATIVE_X/Y/Z targets corresponding to
73 * the face parameter.
74 * Else, return target as-is.
75 */
76 static inline GLenum
77 _mesa_cube_face_target(GLenum target, unsigned face)
78 {
79 if (target == GL_TEXTURE_CUBE_MAP) {
80 assert(face < 6);
81 return GL_TEXTURE_CUBE_MAP_POSITIVE_X + face;
82 }
83 else {
84 return target;
85 }
86 }
87
88
89 /**
90 * For cube map faces, return a face index in [0,5].
91 * For other targets return 0;
92 */
93 static inline GLuint
94 _mesa_tex_target_to_face(GLenum target)
95 {
96 if (_mesa_is_cube_face(target))
97 return (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
98 else
99 return 0;
100 }
101
102
103 /** Are any of the dimensions of given texture equal to zero? */
104 static inline GLboolean
105 _mesa_is_zero_size_texture(const struct gl_texture_image *texImage)
106 {
107 return (texImage->Width == 0 ||
108 texImage->Height == 0 ||
109 texImage->Depth == 0);
110 }
111
112 /** \name Internal functions */
113 /*@{*/
114
115 extern GLboolean
116 _mesa_is_proxy_texture(GLenum target);
117
118 extern bool
119 _mesa_is_array_texture(GLenum target);
120
121
122 extern void
123 _mesa_delete_texture_image( struct gl_context *ctx,
124 struct gl_texture_image *teximage );
125
126
127 extern void
128 _mesa_init_teximage_fields(struct gl_context *ctx,
129 struct gl_texture_image *img,
130 GLsizei width, GLsizei height, GLsizei depth,
131 GLint border, GLenum internalFormat,
132 mesa_format format);
133
134
135 extern mesa_format
136 _mesa_choose_texture_format(struct gl_context *ctx,
137 struct gl_texture_object *texObj,
138 GLenum target, GLint level,
139 GLenum internalFormat, GLenum format, GLenum type);
140
141 extern void
142 _mesa_update_fbo_texture(struct gl_context *ctx,
143 struct gl_texture_object *texObj,
144 GLuint face, GLuint level);
145
146 extern void
147 _mesa_clear_texture_image(struct gl_context *ctx,
148 struct gl_texture_image *texImage);
149
150
151 extern struct gl_texture_image *
152 _mesa_select_tex_image(const struct gl_texture_object *texObj,
153 GLenum target, GLint level);
154
155
156 extern struct gl_texture_image *
157 _mesa_get_tex_image(struct gl_context *ctx, struct gl_texture_object *texObj,
158 GLenum target, GLint level);
159
160
161 /**
162 * Return the base-level texture image for the given texture object.
163 */
164 static inline const struct gl_texture_image *
165 _mesa_base_tex_image(const struct gl_texture_object *texObj)
166 {
167 return texObj->Image[0][texObj->BaseLevel];
168 }
169
170
171 extern GLint
172 _mesa_max_texture_levels(struct gl_context *ctx, GLenum target);
173
174
175 extern GLboolean
176 _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target,
177 GLuint numLevels, GLint level,
178 mesa_format format, GLuint numSamples,
179 GLint width, GLint height, GLint depth);
180
181 extern GLboolean
182 _mesa_target_can_be_compressed(const struct gl_context *ctx, GLenum target,
183 GLenum intFormat, GLenum *error);
184
185 extern GLint
186 _mesa_get_texture_dimensions(GLenum target);
187
188 extern GLboolean
189 _mesa_tex_target_is_layered(GLenum target);
190
191 extern GLuint
192 _mesa_get_texture_layers(const struct gl_texture_object *texObj, GLint level);
193
194 extern GLsizei
195 _mesa_get_tex_max_num_levels(GLenum target, GLsizei width, GLsizei height,
196 GLsizei depth);
197
198 extern GLboolean
199 _mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target,
200 GLint level, GLint width, GLint height,
201 GLint depth, GLint border);
202
203 extern mesa_format
204 _mesa_validate_texbuffer_format(const struct gl_context *ctx,
205 GLenum internalFormat);
206
207
208 bool
209 _mesa_legal_texture_base_format_for_target(struct gl_context *ctx,
210 GLenum target,
211 GLenum internalFormat);
212
213 bool
214 _mesa_format_no_online_compression(const struct gl_context *ctx, GLenum format);
215
216 GLboolean
217 _mesa_is_renderable_texture_format(struct gl_context *ctx, GLenum internalformat);
218
219 extern void
220 _mesa_texture_sub_image(struct gl_context *ctx, GLuint dims,
221 struct gl_texture_object *texObj,
222 struct gl_texture_image *texImage,
223 GLenum target, GLint level,
224 GLint xoffset, GLint yoffset, GLint zoffset,
225 GLsizei width, GLsizei height, GLsizei depth,
226 GLenum format, GLenum type, const GLvoid *pixels,
227 bool dsa);
228
229 bool
230 _mesa_is_cube_map_texture(GLenum target);
231
232 /*@}*/
233
234
235 /** \name API entry point functions */
236 /*@{*/
237
238 extern void GLAPIENTRY
239 _mesa_TexImage1D( GLenum target, GLint level, GLint internalformat,
240 GLsizei width, GLint border,
241 GLenum format, GLenum type, const GLvoid *pixels );
242
243
244 extern void GLAPIENTRY
245 _mesa_TexImage2D( GLenum target, GLint level, GLint internalformat,
246 GLsizei width, GLsizei height, GLint border,
247 GLenum format, GLenum type, const GLvoid *pixels );
248
249
250 extern void GLAPIENTRY
251 _mesa_TexImage3D( GLenum target, GLint level, GLint internalformat,
252 GLsizei width, GLsizei height, GLsizei depth, GLint border,
253 GLenum format, GLenum type, const GLvoid *pixels );
254
255
256 extern void GLAPIENTRY
257 _mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalformat,
258 GLsizei width, GLsizei height, GLsizei depth,
259 GLint border, GLenum format, GLenum type,
260 const GLvoid *pixels );
261
262 extern void GLAPIENTRY
263 _mesa_TexImage1D_no_error(GLenum target, GLint level, GLint internalformat,
264 GLsizei width, GLint border,
265 GLenum format, GLenum type, const GLvoid *pixels);
266
267 extern void GLAPIENTRY
268 _mesa_TexImage2D_no_error(GLenum target, GLint level, GLint internalformat,
269 GLsizei width, GLsizei height, GLint border,
270 GLenum format, GLenum type, const GLvoid *pixels);
271
272 extern void GLAPIENTRY
273 _mesa_TexImage3D_no_error(GLenum target, GLint level, GLint internalformat,
274 GLsizei width, GLsizei height, GLsizei depth,
275 GLint border, GLenum format, GLenum type,
276 const GLvoid *pixels);
277
278 extern void GLAPIENTRY
279 _mesa_EGLImageTargetTexture2DOES( GLenum target, GLeglImageOES image );
280
281 void GLAPIENTRY
282 _mesa_TexSubImage1D_no_error(GLenum target, GLint level, GLint xoffset,
283 GLsizei width,
284 GLenum format, GLenum type,
285 const GLvoid *pixels);
286
287 extern void GLAPIENTRY
288 _mesa_TexSubImage1D( GLenum target, GLint level, GLint xoffset,
289 GLsizei width,
290 GLenum format, GLenum type,
291 const GLvoid *pixels );
292
293 void GLAPIENTRY
294 _mesa_TexSubImage2D_no_error(GLenum target, GLint level,
295 GLint xoffset, GLint yoffset,
296 GLsizei width, GLsizei height,
297 GLenum format, GLenum type,
298 const GLvoid *pixels);
299
300 extern void GLAPIENTRY
301 _mesa_TexSubImage2D( GLenum target, GLint level,
302 GLint xoffset, GLint yoffset,
303 GLsizei width, GLsizei height,
304 GLenum format, GLenum type,
305 const GLvoid *pixels );
306
307 void GLAPIENTRY
308 _mesa_TexSubImage3D_no_error(GLenum target, GLint level,
309 GLint xoffset, GLint yoffset, GLint zoffset,
310 GLsizei width, GLsizei height, GLsizei depth,
311 GLenum format, GLenum type,
312 const GLvoid *pixels);
313
314 extern void GLAPIENTRY
315 _mesa_TexSubImage3D( GLenum target, GLint level,
316 GLint xoffset, GLint yoffset, GLint zoffset,
317 GLsizei width, GLsizei height, GLsizei depth,
318 GLenum format, GLenum type,
319 const GLvoid *pixels );
320
321 extern void GLAPIENTRY
322 _mesa_TextureSubImage1D(GLuint texture, GLint level, GLint xoffset,
323 GLsizei width,
324 GLenum format, GLenum type,
325 const GLvoid *pixels);
326
327
328 extern void GLAPIENTRY
329 _mesa_TextureSubImage2D(GLuint texture, GLint level,
330 GLint xoffset, GLint yoffset,
331 GLsizei width, GLsizei height,
332 GLenum format, GLenum type,
333 const GLvoid *pixels);
334
335 extern void GLAPIENTRY
336 _mesa_TextureSubImage3D(GLuint texture, GLint level,
337 GLint xoffset, GLint yoffset, GLint zoffset,
338 GLsizei width, GLsizei height, GLsizei depth,
339 GLenum format, GLenum type,
340 const GLvoid *pixels);
341
342
343 extern void GLAPIENTRY
344 _mesa_CopyTexImage1D(GLenum target, GLint level, GLenum internalformat,
345 GLint x, GLint y, GLsizei width, GLint border);
346
347
348 extern void GLAPIENTRY
349 _mesa_CopyTexImage2D( GLenum target, GLint level,
350 GLenum internalformat, GLint x, GLint y,
351 GLsizei width, GLsizei height, GLint border );
352
353
354 extern void GLAPIENTRY
355 _mesa_CopyTexSubImage1D( GLenum target, GLint level, GLint xoffset,
356 GLint x, GLint y, GLsizei width );
357
358
359 extern void GLAPIENTRY
360 _mesa_CopyTexSubImage2D( GLenum target, GLint level,
361 GLint xoffset, GLint yoffset,
362 GLint x, GLint y, GLsizei width, GLsizei height );
363
364
365 extern void GLAPIENTRY
366 _mesa_CopyTexSubImage3D( GLenum target, GLint level,
367 GLint xoffset, GLint yoffset, GLint zoffset,
368 GLint x, GLint y, GLsizei width, GLsizei height );
369
370 extern void GLAPIENTRY
371 _mesa_CopyTextureSubImage1D(GLuint texture, GLint level,
372 GLint xoffset, GLint x, GLint y, GLsizei width);
373
374 extern void GLAPIENTRY
375 _mesa_CopyTextureSubImage2D(GLuint texture, GLint level,
376 GLint xoffset, GLint yoffset,
377 GLint x, GLint y,
378 GLsizei width, GLsizei height);
379
380 extern void GLAPIENTRY
381 _mesa_CopyTextureSubImage3D(GLuint texture, GLint level,
382 GLint xoffset, GLint yoffset, GLint zoffset,
383 GLint x, GLint y,
384 GLsizei width, GLsizei height);
385
386 extern void GLAPIENTRY
387 _mesa_CopyTexSubImage1D_no_error(GLenum target, GLint level, GLint xoffset,
388 GLint x, GLint y, GLsizei width );
389
390 extern void GLAPIENTRY
391 _mesa_CopyTexSubImage2D_no_error(GLenum target, GLint level, GLint xoffset,
392 GLint yoffset, GLint x, GLint y, GLsizei width,
393 GLsizei height);
394
395 extern void GLAPIENTRY
396 _mesa_CopyTexSubImage3D_no_error(GLenum target, GLint level, GLint xoffset,
397 GLint yoffset, GLint zoffset, GLint x, GLint y,
398 GLsizei width, GLsizei height);
399
400 extern void GLAPIENTRY
401 _mesa_CopyTextureSubImage1D_no_error(GLuint texture, GLint level, GLint xoffset,
402 GLint x, GLint y, GLsizei width);
403
404 extern void GLAPIENTRY
405 _mesa_CopyTextureSubImage2D_no_error(GLuint texture, GLint level, GLint xoffset,
406 GLint yoffset, GLint x, GLint y,
407 GLsizei width, GLsizei height);
408
409 extern void GLAPIENTRY
410 _mesa_CopyTextureSubImage3D_no_error(GLuint texture, GLint level, GLint xoffset,
411 GLint yoffset, GLint zoffset, GLint x,
412 GLint y, GLsizei width, GLsizei height);
413
414 extern void GLAPIENTRY
415 _mesa_ClearTexSubImage( GLuint texture, GLint level,
416 GLint xoffset, GLint yoffset, GLint zoffset,
417 GLsizei width, GLsizei height, GLsizei depth,
418 GLenum format, GLenum type, const void *data );
419
420 extern void GLAPIENTRY
421 _mesa_ClearTexImage( GLuint texture, GLint level,
422 GLenum format, GLenum type, const void *data );
423
424 extern void GLAPIENTRY
425 _mesa_CompressedTexImage1D(GLenum target, GLint level,
426 GLenum internalformat, GLsizei width,
427 GLint border, GLsizei imageSize,
428 const GLvoid *data);
429
430 extern void GLAPIENTRY
431 _mesa_CompressedTexImage2D(GLenum target, GLint level,
432 GLenum internalformat, GLsizei width,
433 GLsizei height, GLint border, GLsizei imageSize,
434 const GLvoid *data);
435
436 extern void GLAPIENTRY
437 _mesa_CompressedTexImage3D(GLenum target, GLint level,
438 GLenum internalformat, GLsizei width,
439 GLsizei height, GLsizei depth, GLint border,
440 GLsizei imageSize, const GLvoid *data);
441
442 extern void GLAPIENTRY
443 _mesa_CompressedTexImage1D_no_error(GLenum target, GLint level,
444 GLenum internalformat, GLsizei width,
445 GLint border, GLsizei imageSize,
446 const GLvoid *data);
447
448 extern void GLAPIENTRY
449 _mesa_CompressedTexImage2D_no_error(GLenum target, GLint level,
450 GLenum internalformat, GLsizei width,
451 GLsizei height, GLint border,
452 GLsizei imageSize, const GLvoid *data);
453
454 extern void GLAPIENTRY
455 _mesa_CompressedTexImage3D_no_error(GLenum target, GLint level,
456 GLenum internalformat, GLsizei width,
457 GLsizei height, GLsizei depth, GLint border,
458 GLsizei imageSize, const GLvoid *data);
459
460
461 extern void GLAPIENTRY
462 _mesa_CompressedTexSubImage1D_no_error(GLenum target, GLint level,
463 GLint xoffset, GLsizei width,
464 GLenum format, GLsizei imageSize,
465 const GLvoid *data);
466 extern void GLAPIENTRY
467 _mesa_CompressedTexSubImage1D(GLenum target, GLint level, GLint xoffset,
468 GLsizei width, GLenum format,
469 GLsizei imageSize, const GLvoid *data);
470
471 extern void GLAPIENTRY
472 _mesa_CompressedTextureSubImage1D_no_error(GLuint texture, GLint level,
473 GLint xoffset, GLsizei width,
474 GLenum format, GLsizei imageSize,
475 const GLvoid *data);
476 extern void GLAPIENTRY
477 _mesa_CompressedTextureSubImage1D(GLuint texture, GLint level, GLint xoffset,
478 GLsizei width, GLenum format,
479 GLsizei imageSize, const GLvoid *data);
480
481 extern void GLAPIENTRY
482 _mesa_CompressedTexSubImage2D_no_error(GLenum target, GLint level,
483 GLint xoffset, GLint yoffset,
484 GLsizei width, GLsizei height,
485 GLenum format, GLsizei imageSize,
486 const GLvoid *data);
487 extern void GLAPIENTRY
488 _mesa_CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset,
489 GLint yoffset, GLsizei width, GLsizei height,
490 GLenum format, GLsizei imageSize,
491 const GLvoid *data);
492
493 extern void GLAPIENTRY
494 _mesa_CompressedTextureSubImage2D_no_error(GLuint texture, GLint level,
495 GLint xoffset, GLint yoffset,
496 GLsizei width, GLsizei height,
497 GLenum format, GLsizei imageSize,
498 const GLvoid *data);
499 extern void GLAPIENTRY
500 _mesa_CompressedTextureSubImage2D(GLuint texture, GLint level, GLint xoffset,
501 GLint yoffset,
502 GLsizei width, GLsizei height,
503 GLenum format, GLsizei imageSize,
504 const GLvoid *data);
505
506 extern void GLAPIENTRY
507 _mesa_CompressedTexSubImage3D_no_error(GLenum target, GLint level,
508 GLint xoffset, GLint yoffset,
509 GLint zoffset, GLsizei width,
510 GLsizei height, GLsizei depth,
511 GLenum format, GLsizei imageSize,
512 const GLvoid *data);
513 extern void GLAPIENTRY
514 _mesa_CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset,
515 GLint yoffset, GLint zoffset, GLsizei width,
516 GLsizei height, GLsizei depth, GLenum format,
517 GLsizei imageSize, const GLvoid *data);
518
519 extern void GLAPIENTRY
520 _mesa_CompressedTextureSubImage3D_no_error(GLuint texture, GLint level,
521 GLint xoffset, GLint yoffset,
522 GLint zoffset, GLsizei width,
523 GLsizei height, GLsizei depth,
524 GLenum format, GLsizei imageSize,
525 const GLvoid *data);
526 extern void GLAPIENTRY
527 _mesa_CompressedTextureSubImage3D(GLuint texture, GLint level, GLint xoffset,
528 GLint yoffset, GLint zoffset,
529 GLsizei width, GLsizei height,
530 GLsizei depth,
531 GLenum format, GLsizei imageSize,
532 const GLvoid *data);
533
534 extern void GLAPIENTRY
535 _mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer);
536
537 extern void GLAPIENTRY
538 _mesa_TexBufferRange(GLenum target, GLenum internalFormat, GLuint buffer,
539 GLintptr offset, GLsizeiptr size);
540
541 extern void GLAPIENTRY
542 _mesa_TextureBuffer(GLuint texture, GLenum internalFormat, GLuint buffer);
543
544 extern void GLAPIENTRY
545 _mesa_TextureBufferRange(GLuint texture, GLenum internalFormat, GLuint buffer,
546 GLintptr offset, GLsizeiptr size);
547
548
549 extern void GLAPIENTRY
550 _mesa_TexImage2DMultisample(GLenum target, GLsizei samples,
551 GLenum internalformat, GLsizei width,
552 GLsizei height, GLboolean fixedsamplelocations);
553
554 extern void GLAPIENTRY
555 _mesa_TexImage3DMultisample(GLenum target, GLsizei samples,
556 GLenum internalformat, GLsizei width,
557 GLsizei height, GLsizei depth,
558 GLboolean fixedsamplelocations);
559
560 extern void GLAPIENTRY
561 _mesa_TexStorage2DMultisample(GLenum target, GLsizei samples,
562 GLenum internalformat, GLsizei width,
563 GLsizei height, GLboolean fixedsamplelocations);
564
565 extern void GLAPIENTRY
566 _mesa_TexStorage3DMultisample(GLenum target, GLsizei samples,
567 GLenum internalformat, GLsizei width,
568 GLsizei height, GLsizei depth,
569 GLboolean fixedsamplelocations);
570
571 void GLAPIENTRY
572 _mesa_TextureStorage2DMultisample(GLuint texture, GLsizei samples,
573 GLenum internalformat, GLsizei width,
574 GLsizei height,
575 GLboolean fixedsamplelocations);
576
577 void GLAPIENTRY
578 _mesa_TextureStorage3DMultisample(GLuint texture, GLsizei samples,
579 GLenum internalformat, GLsizei width,
580 GLsizei height, GLsizei depth,
581 GLboolean fixedsamplelocations);
582 /*@}*/
583
584 #ifdef __cplusplus
585 }
586 #endif
587
588 #endif