mesa/swrast: handle sRGB FBOs correctly (v2)
[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 * Version: 6.5
9 *
10 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
26 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR 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
39 extern void *
40 _mesa_alloc_texmemory(GLsizei bytes);
41
42 extern void
43 _mesa_free_texmemory(void *m);
44
45
46 /** \name Internal functions */
47 /*@{*/
48
49 extern GLint
50 _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat );
51
52
53 extern GLboolean
54 _mesa_is_proxy_texture(GLenum target);
55
56
57 extern struct gl_texture_image *
58 _mesa_new_texture_image( struct gl_context *ctx );
59
60
61 extern void
62 _mesa_delete_texture_image( struct gl_context *ctx, struct gl_texture_image *teximage );
63
64 extern void
65 _mesa_free_texture_image_data( struct gl_context *ctx,
66 struct gl_texture_image *texImage );
67
68
69 extern void
70 _mesa_init_teximage_fields(struct gl_context *ctx, GLenum target,
71 struct gl_texture_image *img,
72 GLsizei width, GLsizei height, GLsizei depth,
73 GLint border, GLenum internalFormat,
74 gl_format format);
75
76
77 extern gl_format
78 _mesa_choose_texture_format(struct gl_context *ctx,
79 struct gl_texture_object *texObj,
80 GLenum target, GLint level,
81 GLenum internalFormat, GLenum format, GLenum type);
82
83
84 extern void
85 _mesa_clear_texture_image(struct gl_context *ctx, struct gl_texture_image *texImage);
86
87
88 extern void
89 _mesa_set_tex_image(struct gl_texture_object *tObj,
90 GLenum target, GLint level,
91 struct gl_texture_image *texImage);
92
93
94 extern struct gl_texture_object *
95 _mesa_select_tex_object(struct gl_context *ctx, const struct gl_texture_unit *texUnit,
96 GLenum target);
97
98 extern struct gl_texture_object *
99 _mesa_get_current_tex_object(struct gl_context *ctx, GLenum target);
100
101
102 extern struct gl_texture_image *
103 _mesa_select_tex_image(struct gl_context *ctx, const struct gl_texture_object *texObj,
104 GLenum target, GLint level);
105
106
107 extern struct gl_texture_image *
108 _mesa_get_tex_image(struct gl_context *ctx, struct gl_texture_object *texObj,
109 GLenum target, GLint level);
110
111
112 extern struct gl_texture_image *
113 _mesa_get_proxy_tex_image(struct gl_context *ctx, GLenum target, GLint level);
114
115
116 extern GLint
117 _mesa_max_texture_levels(struct gl_context *ctx, GLenum target);
118
119
120 extern GLboolean
121 _mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level,
122 GLint internalFormat, GLenum format, GLenum type,
123 GLint width, GLint height, GLint depth, GLint border);
124
125
126 extern GLuint
127 _mesa_tex_target_to_face(GLenum target);
128
129 extern GLint
130 _mesa_get_texture_dimensions(GLenum target);
131
132 /**
133 * Lock a texture for updating. See also _mesa_lock_context_textures().
134 */
135 static INLINE void
136 _mesa_lock_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
137 {
138 _glthread_LOCK_MUTEX(ctx->Shared->TexMutex);
139 ctx->Shared->TextureStateStamp++;
140 (void) texObj;
141 }
142
143 static INLINE void
144 _mesa_unlock_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
145 {
146 _glthread_UNLOCK_MUTEX(ctx->Shared->TexMutex);
147 }
148
149 /*@}*/
150
151
152 /** \name API entry point functions */
153 /*@{*/
154
155 extern void GLAPIENTRY
156 _mesa_TexImage1D( GLenum target, GLint level, GLint internalformat,
157 GLsizei width, GLint border,
158 GLenum format, GLenum type, const GLvoid *pixels );
159
160
161 extern void GLAPIENTRY
162 _mesa_TexImage2D( GLenum target, GLint level, GLint internalformat,
163 GLsizei width, GLsizei height, GLint border,
164 GLenum format, GLenum type, const GLvoid *pixels );
165
166
167 extern void GLAPIENTRY
168 _mesa_TexImage3D( GLenum target, GLint level, GLint internalformat,
169 GLsizei width, GLsizei height, GLsizei depth, GLint border,
170 GLenum format, GLenum type, const GLvoid *pixels );
171
172
173 extern void GLAPIENTRY
174 _mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalformat,
175 GLsizei width, GLsizei height, GLsizei depth,
176 GLint border, GLenum format, GLenum type,
177 const GLvoid *pixels );
178
179 extern void GLAPIENTRY
180 _mesa_EGLImageTargetTexture2DOES( GLenum target, GLeglImageOES image );
181
182 extern void GLAPIENTRY
183 _mesa_TexSubImage1D( GLenum target, GLint level, GLint xoffset,
184 GLsizei width,
185 GLenum format, GLenum type,
186 const GLvoid *pixels );
187
188
189 extern void GLAPIENTRY
190 _mesa_TexSubImage2D( GLenum target, GLint level,
191 GLint xoffset, GLint yoffset,
192 GLsizei width, GLsizei height,
193 GLenum format, GLenum type,
194 const GLvoid *pixels );
195
196
197 extern void GLAPIENTRY
198 _mesa_TexSubImage3D( GLenum target, GLint level,
199 GLint xoffset, GLint yoffset, GLint zoffset,
200 GLsizei width, GLsizei height, GLsizei depth,
201 GLenum format, GLenum type,
202 const GLvoid *pixels );
203
204
205 extern void GLAPIENTRY
206 _mesa_CopyTexImage1D( GLenum target, GLint level, GLenum internalformat,
207 GLint x, GLint y, GLsizei width, GLint border );
208
209
210 extern void GLAPIENTRY
211 _mesa_CopyTexImage2D( GLenum target, GLint level,
212 GLenum internalformat, GLint x, GLint y,
213 GLsizei width, GLsizei height, GLint border );
214
215
216 extern void GLAPIENTRY
217 _mesa_CopyTexSubImage1D( GLenum target, GLint level, GLint xoffset,
218 GLint x, GLint y, GLsizei width );
219
220
221 extern void GLAPIENTRY
222 _mesa_CopyTexSubImage2D( GLenum target, GLint level,
223 GLint xoffset, GLint yoffset,
224 GLint x, GLint y, GLsizei width, GLsizei height );
225
226
227 extern void GLAPIENTRY
228 _mesa_CopyTexSubImage3D( GLenum target, GLint level,
229 GLint xoffset, GLint yoffset, GLint zoffset,
230 GLint x, GLint y, GLsizei width, GLsizei height );
231
232
233
234 extern void GLAPIENTRY
235 _mesa_CompressedTexImage1DARB(GLenum target, GLint level,
236 GLenum internalformat, GLsizei width,
237 GLint border, GLsizei imageSize,
238 const GLvoid *data);
239
240 extern void GLAPIENTRY
241 _mesa_CompressedTexImage2DARB(GLenum target, GLint level,
242 GLenum internalformat, GLsizei width,
243 GLsizei height, GLint border, GLsizei imageSize,
244 const GLvoid *data);
245
246 extern void GLAPIENTRY
247 _mesa_CompressedTexImage3DARB(GLenum target, GLint level,
248 GLenum internalformat, GLsizei width,
249 GLsizei height, GLsizei depth, GLint border,
250 GLsizei imageSize, const GLvoid *data);
251
252 #ifdef VMS
253 #define _mesa_CompressedTexSubImage1DARB _mesa_CompressedTexSubImage1DAR
254 #define _mesa_CompressedTexSubImage2DARB _mesa_CompressedTexSubImage2DAR
255 #define _mesa_CompressedTexSubImage3DARB _mesa_CompressedTexSubImage3DAR
256 #endif
257 extern void GLAPIENTRY
258 _mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
259 GLsizei width, GLenum format,
260 GLsizei imageSize, const GLvoid *data);
261
262 extern void GLAPIENTRY
263 _mesa_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
264 GLint yoffset, GLsizei width, GLsizei height,
265 GLenum format, GLsizei imageSize,
266 const GLvoid *data);
267
268 extern void GLAPIENTRY
269 _mesa_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
270 GLint yoffset, GLint zoffset, GLsizei width,
271 GLsizei height, GLsizei depth, GLenum format,
272 GLsizei imageSize, const GLvoid *data);
273
274 /*@}*/
275
276 #endif