mesa: handle GL_PROXY_TEXTURE_CUBE_MAP in _mesa_num_tex_faces()
[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 * Version: 6.5
9 *
10 * Copyright (C) 1999-2006 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 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 /**
42 * \name Internal functions
43 */
44 /*@{*/
45
46 extern struct gl_texture_object *
47 _mesa_lookup_texture(struct gl_context *ctx, GLuint id);
48
49 extern struct gl_texture_object *
50 _mesa_new_texture_object( struct gl_context *ctx, GLuint name, GLenum target );
51
52 extern void
53 _mesa_initialize_texture_object( struct gl_texture_object *obj,
54 GLuint name, GLenum target );
55
56 extern void
57 _mesa_delete_texture_object( struct gl_context *ctx,
58 struct gl_texture_object *obj );
59
60 extern void
61 _mesa_copy_texture_object( struct gl_texture_object *dest,
62 const struct gl_texture_object *src );
63
64 extern void
65 _mesa_clear_texture_object(struct gl_context *ctx,
66 struct gl_texture_object *obj);
67
68 extern void
69 _mesa_reference_texobj_(struct gl_texture_object **ptr,
70 struct gl_texture_object *tex);
71
72 static inline void
73 _mesa_reference_texobj(struct gl_texture_object **ptr,
74 struct gl_texture_object *tex)
75 {
76 if (*ptr != tex)
77 _mesa_reference_texobj_(ptr, tex);
78 }
79
80
81 /**
82 * Return number of faces for a texture target. This will be 6 for
83 * cube maps (and cube map arrays) and 1 otherwise.
84 */
85 static inline GLuint
86 _mesa_num_tex_faces(GLenum target)
87 {
88 switch (target) {
89 case GL_TEXTURE_CUBE_MAP:
90 case GL_PROXY_TEXTURE_CUBE_MAP:
91 return 6;
92 default:
93 return 1;
94 }
95 }
96
97
98 /** Is the texture "complete" with respect to the given sampler state? */
99 static inline GLboolean
100 _mesa_is_texture_complete(const struct gl_texture_object *texObj,
101 const struct gl_sampler_object *sampler)
102 {
103 if (texObj->_IsIntegerFormat &&
104 (sampler->MagFilter != GL_NEAREST ||
105 (sampler->MinFilter != GL_NEAREST &&
106 sampler->MinFilter != GL_NEAREST_MIPMAP_NEAREST))) {
107 /* If the format is integer, only nearest filtering is allowed */
108 return GL_FALSE;
109 }
110
111 if (_mesa_is_mipmap_filter(sampler))
112 return texObj->_MipmapComplete;
113 else
114 return texObj->_BaseComplete;
115 }
116
117
118 extern void
119 _mesa_test_texobj_completeness( const struct gl_context *ctx,
120 struct gl_texture_object *obj );
121
122 extern GLboolean
123 _mesa_cube_complete(const struct gl_texture_object *texObj);
124
125 extern void
126 _mesa_dirty_texobj(struct gl_context *ctx, struct gl_texture_object *texObj,
127 GLboolean invalidate_state);
128
129 extern struct gl_texture_object *
130 _mesa_get_fallback_texture(struct gl_context *ctx, gl_texture_index tex);
131
132 extern GLuint
133 _mesa_total_texture_memory(struct gl_context *ctx);
134
135 extern void
136 _mesa_unlock_context_textures( struct gl_context *ctx );
137
138 extern void
139 _mesa_lock_context_textures( struct gl_context *ctx );
140
141 /*@}*/
142
143 /**
144 * \name API functions
145 */
146 /*@{*/
147
148 extern void GLAPIENTRY
149 _mesa_GenTextures( GLsizei n, GLuint *textures );
150
151
152 extern void GLAPIENTRY
153 _mesa_DeleteTextures( GLsizei n, const GLuint *textures );
154
155
156 extern void GLAPIENTRY
157 _mesa_BindTexture( GLenum target, GLuint texture );
158
159
160 extern void GLAPIENTRY
161 _mesa_PrioritizeTextures( GLsizei n, const GLuint *textures,
162 const GLclampf *priorities );
163
164
165 extern GLboolean GLAPIENTRY
166 _mesa_AreTexturesResident( GLsizei n, const GLuint *textures,
167 GLboolean *residences );
168
169 extern GLboolean GLAPIENTRY
170 _mesa_IsTexture( GLuint texture );
171
172 extern void GLAPIENTRY
173 _mesa_InvalidateTexSubImage(GLuint texture, GLint level, GLint xoffset,
174 GLint yoffset, GLint zoffset, GLsizei width,
175 GLsizei height, GLsizei depth);
176
177 extern void GLAPIENTRY
178 _mesa_InvalidateTexImage(GLuint texture, GLint level);
179
180 /*@}*/
181
182
183 #endif