mesa: remove unneeded semicolons
[mesa.git] / src / mesa / main / texobj.h
1 /**
2 * \file texobj.h
3 * Texture object management.
4 */
5
6 /*
7 * Mesa 3-D graphics library
8 *
9 * Copyright (C) 1999-2006 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 TEXTOBJ_H
32 #define TEXTOBJ_H
33
34
35 #include "compiler.h"
36 #include "glheader.h"
37 #include "mtypes.h"
38 #include "samplerobj.h"
39
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45
46 /**
47 * \name Internal functions
48 */
49 /*@{*/
50
51 extern struct gl_texture_object *
52 _mesa_lookup_texture(struct gl_context *ctx, GLuint id);
53
54 extern struct gl_texture_object *
55 _mesa_lookup_texture_err(struct gl_context *ctx, GLuint id, const char* func);
56
57 extern struct gl_texture_object *
58 _mesa_lookup_texture_locked(struct gl_context *ctx, GLuint id);
59
60 extern struct gl_texture_object *
61 _mesa_get_current_tex_object(struct gl_context *ctx, GLenum target);
62
63 extern struct gl_texture_object *
64 _mesa_new_texture_object( struct gl_context *ctx, GLuint name, GLenum target );
65
66 extern void
67 _mesa_initialize_texture_object( struct gl_context *ctx,
68 struct gl_texture_object *obj,
69 GLuint name, GLenum target );
70
71 extern int
72 _mesa_tex_target_to_index(const struct gl_context *ctx, GLenum target);
73
74 extern void
75 _mesa_delete_texture_object( struct gl_context *ctx,
76 struct gl_texture_object *obj );
77
78 extern void
79 _mesa_copy_texture_object( struct gl_texture_object *dest,
80 const struct gl_texture_object *src );
81
82 extern void
83 _mesa_clear_texture_object(struct gl_context *ctx,
84 struct gl_texture_object *obj,
85 struct gl_texture_image *retainTexImage);
86
87 extern void
88 _mesa_reference_texobj_(struct gl_texture_object **ptr,
89 struct gl_texture_object *tex);
90
91 static inline void
92 _mesa_reference_texobj(struct gl_texture_object **ptr,
93 struct gl_texture_object *tex)
94 {
95 if (*ptr != tex)
96 _mesa_reference_texobj_(ptr, tex);
97 }
98
99 /**
100 * Lock a texture for updating. See also _mesa_lock_context_textures().
101 */
102 static inline void
103 _mesa_lock_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
104 {
105 mtx_lock(&ctx->Shared->TexMutex);
106 ctx->Shared->TextureStateStamp++;
107 (void) texObj;
108 }
109
110 static inline void
111 _mesa_unlock_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
112 {
113 (void) texObj;
114 mtx_unlock(&ctx->Shared->TexMutex);
115 }
116
117
118 /** Is the texture "complete" with respect to the given sampler state? */
119 static inline GLboolean
120 _mesa_is_texture_complete(const struct gl_texture_object *texObj,
121 const struct gl_sampler_object *sampler)
122 {
123 /*
124 * According to ARB_stencil_texturing, NEAREST_MIPMAP_NEAREST would
125 * be forbidden, however it is allowed per GL 4.5 rules, allow it
126 * even without GL 4.5 since it was a spec mistake.
127 */
128 if ((texObj->_IsIntegerFormat ||
129 (texObj->StencilSampling &&
130 texObj->Image[0][texObj->BaseLevel]->_BaseFormat == GL_DEPTH_STENCIL)) &&
131 (sampler->MagFilter != GL_NEAREST ||
132 (sampler->MinFilter != GL_NEAREST &&
133 sampler->MinFilter != GL_NEAREST_MIPMAP_NEAREST))) {
134 /* If the format is integer, only nearest filtering is allowed */
135 return GL_FALSE;
136 }
137
138 if (_mesa_is_mipmap_filter(sampler))
139 return texObj->_MipmapComplete;
140 else
141 return texObj->_BaseComplete;
142 }
143
144
145 extern void
146 _mesa_test_texobj_completeness( const struct gl_context *ctx,
147 struct gl_texture_object *obj );
148
149 extern GLboolean
150 _mesa_cube_level_complete(const struct gl_texture_object *texObj,
151 const GLint level);
152
153 extern GLboolean
154 _mesa_cube_complete(const struct gl_texture_object *texObj);
155
156 extern void
157 _mesa_dirty_texobj(struct gl_context *ctx, struct gl_texture_object *texObj);
158
159 extern struct gl_texture_object *
160 _mesa_get_fallback_texture(struct gl_context *ctx, gl_texture_index tex);
161
162 extern GLuint
163 _mesa_total_texture_memory(struct gl_context *ctx);
164
165 extern GLenum
166 _mesa_texture_base_format(const struct gl_texture_object *texObj);
167
168 extern void
169 _mesa_unlock_context_textures( struct gl_context *ctx );
170
171 extern void
172 _mesa_lock_context_textures( struct gl_context *ctx );
173
174 extern void
175 _mesa_delete_nameless_texture(struct gl_context *ctx,
176 struct gl_texture_object *texObj);
177
178 extern void
179 _mesa_bind_texture(struct gl_context *ctx, GLenum target,
180 struct gl_texture_object *tex_obj);
181 /*@}*/
182
183 /**
184 * \name API functions
185 */
186 /*@{*/
187
188 void GLAPIENTRY
189 _mesa_GenTextures_no_error(GLsizei n, GLuint *textures);
190
191 extern void GLAPIENTRY
192 _mesa_GenTextures(GLsizei n, GLuint *textures);
193
194 void GLAPIENTRY
195 _mesa_CreateTextures_no_error(GLenum target, GLsizei n, GLuint *textures);
196
197 extern void GLAPIENTRY
198 _mesa_CreateTextures(GLenum target, GLsizei n, GLuint *textures);
199
200 void GLAPIENTRY
201 _mesa_DeleteTextures_no_error(GLsizei n, const GLuint *textures);
202
203 extern void GLAPIENTRY
204 _mesa_DeleteTextures( GLsizei n, const GLuint *textures );
205
206
207 void GLAPIENTRY
208 _mesa_BindTexture_no_error(GLenum target, GLuint texture);
209
210 extern void GLAPIENTRY
211 _mesa_BindTexture( GLenum target, GLuint texture );
212
213 void GLAPIENTRY
214 _mesa_BindTextureUnit_no_error(GLuint unit, GLuint texture);
215
216 extern void GLAPIENTRY
217 _mesa_BindTextureUnit(GLuint unit, GLuint texture);
218
219 void GLAPIENTRY
220 _mesa_BindTextures_no_error(GLuint first, GLsizei count,
221 const GLuint *textures);
222
223 extern void GLAPIENTRY
224 _mesa_BindTextures( GLuint first, GLsizei count, const GLuint *textures );
225
226
227 extern void GLAPIENTRY
228 _mesa_PrioritizeTextures( GLsizei n, const GLuint *textures,
229 const GLclampf *priorities );
230
231
232 extern GLboolean GLAPIENTRY
233 _mesa_AreTexturesResident( GLsizei n, const GLuint *textures,
234 GLboolean *residences );
235
236 extern GLboolean GLAPIENTRY
237 _mesa_IsTexture( GLuint texture );
238
239 void GLAPIENTRY
240 _mesa_InvalidateTexSubImage_no_error(GLuint texture, GLint level, GLint xoffset,
241 GLint yoffset, GLint zoffset,
242 GLsizei width, GLsizei height,
243 GLsizei depth);
244
245 extern void GLAPIENTRY
246 _mesa_InvalidateTexSubImage(GLuint texture, GLint level, GLint xoffset,
247 GLint yoffset, GLint zoffset, GLsizei width,
248 GLsizei height, GLsizei depth);
249 void GLAPIENTRY
250 _mesa_InvalidateTexImage_no_error(GLuint texture, GLint level);
251
252 extern void GLAPIENTRY
253 _mesa_InvalidateTexImage(GLuint texture, GLint level);
254
255 /*@}*/
256
257
258 #ifdef __cplusplus
259 }
260 #endif
261
262
263 #endif