mesa: move _mesa_compressed_texture_pixel_storage_error_check()
[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(struct gl_context *ctx,
108 const struct gl_texture_object *texObj,
109 GLenum target, GLint level);
110
111
112 extern struct gl_texture_image *
113 _mesa_get_tex_image(struct gl_context *ctx, struct gl_texture_object *texObj,
114 GLenum target, GLint level);
115
116
117 extern GLint
118 _mesa_max_texture_levels(struct gl_context *ctx, GLenum target);
119
120
121 extern GLboolean
122 _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level,
123 mesa_format format,
124 GLint width, GLint height, GLint depth, GLint border);
125
126 extern GLboolean
127 _mesa_target_can_be_compressed(const struct gl_context *ctx, GLenum target,
128 GLenum intFormat);
129
130 extern GLuint
131 _mesa_tex_target_to_face(GLenum target);
132
133 extern GLint
134 _mesa_get_texture_dimensions(GLenum target);
135
136 extern GLboolean
137 _mesa_tex_target_is_layered(GLenum target);
138
139 extern GLuint
140 _mesa_get_texture_layers(const struct gl_texture_object *texObj, GLint level);
141
142 extern GLsizei
143 _mesa_get_tex_max_num_levels(GLenum target, GLsizei width, GLsizei height,
144 GLsizei depth);
145
146 extern GLboolean
147 _mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target,
148 GLint level, GLint width, GLint height,
149 GLint depth, GLint border);
150
151 extern mesa_format
152 _mesa_validate_texbuffer_format(const struct gl_context *ctx,
153 GLenum internalFormat);
154
155
156 bool
157 _mesa_legal_texture_base_format_for_target(struct gl_context *ctx,
158 GLenum target,
159 GLenum internalFormat,
160 unsigned dimensions,
161 const char *caller);
162
163 /**
164 * Lock a texture for updating. See also _mesa_lock_context_textures().
165 */
166 static inline void
167 _mesa_lock_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
168 {
169 mtx_lock(&ctx->Shared->TexMutex);
170 ctx->Shared->TextureStateStamp++;
171 (void) texObj;
172 }
173
174 static inline void
175 _mesa_unlock_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
176 {
177 (void) texObj;
178 mtx_unlock(&ctx->Shared->TexMutex);
179 }
180
181 /*@}*/
182
183
184 /** \name API entry point functions */
185 /*@{*/
186
187 extern void GLAPIENTRY
188 _mesa_TexImage1D( GLenum target, GLint level, GLint internalformat,
189 GLsizei width, GLint border,
190 GLenum format, GLenum type, const GLvoid *pixels );
191
192
193 extern void GLAPIENTRY
194 _mesa_TexImage2D( GLenum target, GLint level, GLint internalformat,
195 GLsizei width, GLsizei height, GLint border,
196 GLenum format, GLenum type, const GLvoid *pixels );
197
198
199 extern void GLAPIENTRY
200 _mesa_TexImage3D( GLenum target, GLint level, GLint internalformat,
201 GLsizei width, GLsizei height, GLsizei depth, GLint border,
202 GLenum format, GLenum type, const GLvoid *pixels );
203
204
205 extern void GLAPIENTRY
206 _mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalformat,
207 GLsizei width, GLsizei height, GLsizei depth,
208 GLint border, GLenum format, GLenum type,
209 const GLvoid *pixels );
210
211 extern void GLAPIENTRY
212 _mesa_EGLImageTargetTexture2DOES( GLenum target, GLeglImageOES image );
213
214 extern void GLAPIENTRY
215 _mesa_TexSubImage1D( GLenum target, GLint level, GLint xoffset,
216 GLsizei width,
217 GLenum format, GLenum type,
218 const GLvoid *pixels );
219
220
221 extern void GLAPIENTRY
222 _mesa_TexSubImage2D( GLenum target, GLint level,
223 GLint xoffset, GLint yoffset,
224 GLsizei width, GLsizei height,
225 GLenum format, GLenum type,
226 const GLvoid *pixels );
227
228
229 extern void GLAPIENTRY
230 _mesa_TexSubImage3D( GLenum target, GLint level,
231 GLint xoffset, GLint yoffset, GLint zoffset,
232 GLsizei width, GLsizei height, GLsizei depth,
233 GLenum format, GLenum type,
234 const GLvoid *pixels );
235
236
237 extern void GLAPIENTRY
238 _mesa_CopyTexImage1D( GLenum target, GLint level, GLenum internalformat,
239 GLint x, GLint y, GLsizei width, GLint border );
240
241
242 extern void GLAPIENTRY
243 _mesa_CopyTexImage2D( GLenum target, GLint level,
244 GLenum internalformat, GLint x, GLint y,
245 GLsizei width, GLsizei height, GLint border );
246
247
248 extern void GLAPIENTRY
249 _mesa_CopyTexSubImage1D( GLenum target, GLint level, GLint xoffset,
250 GLint x, GLint y, GLsizei width );
251
252
253 extern void GLAPIENTRY
254 _mesa_CopyTexSubImage2D( GLenum target, GLint level,
255 GLint xoffset, GLint yoffset,
256 GLint x, GLint y, GLsizei width, GLsizei height );
257
258
259 extern void GLAPIENTRY
260 _mesa_CopyTexSubImage3D( GLenum target, GLint level,
261 GLint xoffset, GLint yoffset, GLint zoffset,
262 GLint x, GLint y, GLsizei width, GLsizei height );
263
264
265
266 extern void GLAPIENTRY
267 _mesa_ClearTexSubImage( GLuint texture, GLint level,
268 GLint xoffset, GLint yoffset, GLint zoffset,
269 GLsizei width, GLsizei height, GLsizei depth,
270 GLenum format, GLenum type, const void *data );
271
272 extern void GLAPIENTRY
273 _mesa_ClearTexImage( GLuint texture, GLint level,
274 GLenum format, GLenum type, const void *data );
275
276 extern void GLAPIENTRY
277 _mesa_CompressedTexImage1D(GLenum target, GLint level,
278 GLenum internalformat, GLsizei width,
279 GLint border, GLsizei imageSize,
280 const GLvoid *data);
281
282 extern void GLAPIENTRY
283 _mesa_CompressedTexImage2D(GLenum target, GLint level,
284 GLenum internalformat, GLsizei width,
285 GLsizei height, GLint border, GLsizei imageSize,
286 const GLvoid *data);
287
288 extern void GLAPIENTRY
289 _mesa_CompressedTexImage3D(GLenum target, GLint level,
290 GLenum internalformat, GLsizei width,
291 GLsizei height, GLsizei depth, GLint border,
292 GLsizei imageSize, const GLvoid *data);
293
294 extern void GLAPIENTRY
295 _mesa_CompressedTexSubImage1D(GLenum target, GLint level, GLint xoffset,
296 GLsizei width, GLenum format,
297 GLsizei imageSize, const GLvoid *data);
298
299 extern void GLAPIENTRY
300 _mesa_CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset,
301 GLint yoffset, GLsizei width, GLsizei height,
302 GLenum format, GLsizei imageSize,
303 const GLvoid *data);
304
305 extern void GLAPIENTRY
306 _mesa_CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset,
307 GLint yoffset, GLint zoffset, GLsizei width,
308 GLsizei height, GLsizei depth, GLenum format,
309 GLsizei imageSize, const GLvoid *data);
310
311
312 extern void GLAPIENTRY
313 _mesa_TexBuffer(GLenum target, GLenum internalFormat, GLuint buffer);
314
315 extern void GLAPIENTRY
316 _mesa_TexBufferRange(GLenum target, GLenum internalFormat, GLuint buffer,
317 GLintptr offset, GLsizeiptr size);
318
319
320 extern void GLAPIENTRY
321 _mesa_TexImage2DMultisample(GLenum target, GLsizei samples,
322 GLenum internalformat, GLsizei width,
323 GLsizei height, GLboolean fixedsamplelocations);
324
325 extern void GLAPIENTRY
326 _mesa_TexImage3DMultisample(GLenum target, GLsizei samples,
327 GLenum internalformat, GLsizei width,
328 GLsizei height, GLsizei depth,
329 GLboolean fixedsamplelocations);
330
331 extern void GLAPIENTRY
332 _mesa_TexStorage2DMultisample(GLenum target, GLsizei samples,
333 GLenum internalformat, GLsizei width,
334 GLsizei height, GLboolean fixedsamplelocations);
335
336 extern void GLAPIENTRY
337 _mesa_TexStorage3DMultisample(GLenum target, GLsizei samples,
338 GLenum internalformat, GLsizei width,
339 GLsizei height, GLsizei depth,
340 GLboolean fixedsamplelocations);
341
342 /*@}*/
343
344 #ifdef __cplusplus
345 }
346 #endif
347
348 #endif