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