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