broadcom/vc5: Fix CLIF dumping of lists that aren't capped by a HALT.
[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 /*@}*/
175
176 /**
177 * \name API functions
178 */
179 /*@{*/
180
181 void GLAPIENTRY
182 _mesa_GenTextures_no_error(GLsizei n, GLuint *textures);
183
184 extern void GLAPIENTRY
185 _mesa_GenTextures(GLsizei n, GLuint *textures);
186
187 void GLAPIENTRY
188 _mesa_CreateTextures_no_error(GLenum target, GLsizei n, GLuint *textures);
189
190 extern void GLAPIENTRY
191 _mesa_CreateTextures(GLenum target, GLsizei n, GLuint *textures);
192
193 void GLAPIENTRY
194 _mesa_DeleteTextures_no_error(GLsizei n, const GLuint *textures);
195
196 extern void GLAPIENTRY
197 _mesa_DeleteTextures( GLsizei n, const GLuint *textures );
198
199
200 void GLAPIENTRY
201 _mesa_BindTexture_no_error(GLenum target, GLuint texture);
202
203 extern void GLAPIENTRY
204 _mesa_BindTexture( GLenum target, GLuint texture );
205
206 void GLAPIENTRY
207 _mesa_BindTextureUnit_no_error(GLuint unit, GLuint texture);
208
209 extern void GLAPIENTRY
210 _mesa_BindTextureUnit(GLuint unit, GLuint texture);
211
212 void GLAPIENTRY
213 _mesa_BindTextures_no_error(GLuint first, GLsizei count,
214 const GLuint *textures);
215
216 extern void GLAPIENTRY
217 _mesa_BindTextures( GLuint first, GLsizei count, const GLuint *textures );
218
219
220 extern void GLAPIENTRY
221 _mesa_PrioritizeTextures( GLsizei n, const GLuint *textures,
222 const GLclampf *priorities );
223
224
225 extern GLboolean GLAPIENTRY
226 _mesa_AreTexturesResident( GLsizei n, const GLuint *textures,
227 GLboolean *residences );
228
229 extern GLboolean GLAPIENTRY
230 _mesa_IsTexture( GLuint texture );
231
232 void GLAPIENTRY
233 _mesa_InvalidateTexSubImage_no_error(GLuint texture, GLint level, GLint xoffset,
234 GLint yoffset, GLint zoffset,
235 GLsizei width, GLsizei height,
236 GLsizei depth);
237
238 extern void GLAPIENTRY
239 _mesa_InvalidateTexSubImage(GLuint texture, GLint level, GLint xoffset,
240 GLint yoffset, GLint zoffset, GLsizei width,
241 GLsizei height, GLsizei depth);
242 void GLAPIENTRY
243 _mesa_InvalidateTexImage_no_error(GLuint texture, GLint level);
244
245 extern void GLAPIENTRY
246 _mesa_InvalidateTexImage(GLuint texture, GLint level);
247
248 /*@}*/
249
250
251 #ifdef __cplusplus
252 }
253 #endif
254
255
256 #endif