3 * Texture object management.
7 * Mesa 3-D graphics library
10 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
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:
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
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.
38 #include "samplerobj.h"
42 * \name Internal functions
46 extern struct gl_texture_object
*
47 _mesa_lookup_texture(struct gl_context
*ctx
, GLuint id
);
49 extern struct gl_texture_object
*
50 _mesa_new_texture_object( struct gl_context
*ctx
, GLuint name
, GLenum target
);
53 _mesa_initialize_texture_object( struct gl_texture_object
*obj
,
54 GLuint name
, GLenum target
);
57 _mesa_delete_texture_object( struct gl_context
*ctx
,
58 struct gl_texture_object
*obj
);
61 _mesa_copy_texture_object( struct gl_texture_object
*dest
,
62 const struct gl_texture_object
*src
);
65 _mesa_clear_texture_object(struct gl_context
*ctx
,
66 struct gl_texture_object
*obj
);
69 _mesa_reference_texobj_(struct gl_texture_object
**ptr
,
70 struct gl_texture_object
*tex
);
73 _mesa_reference_texobj(struct gl_texture_object
**ptr
,
74 struct gl_texture_object
*tex
)
77 _mesa_reference_texobj_(ptr
, tex
);
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 * NOTE: this function is not used for cube map arrays which operate
85 * more like 2D arrays than cube maps.
88 _mesa_num_tex_faces(GLenum target
)
91 case GL_TEXTURE_CUBE_MAP
:
92 case GL_PROXY_TEXTURE_CUBE_MAP
:
100 /** Is the texture "complete" with respect to the given sampler state? */
101 static inline GLboolean
102 _mesa_is_texture_complete(const struct gl_texture_object
*texObj
,
103 const struct gl_sampler_object
*sampler
)
105 if (texObj
->_IsIntegerFormat
&&
106 (sampler
->MagFilter
!= GL_NEAREST
||
107 (sampler
->MinFilter
!= GL_NEAREST
&&
108 sampler
->MinFilter
!= GL_NEAREST_MIPMAP_NEAREST
))) {
109 /* If the format is integer, only nearest filtering is allowed */
113 if (_mesa_is_mipmap_filter(sampler
))
114 return texObj
->_MipmapComplete
;
116 return texObj
->_BaseComplete
;
121 _mesa_test_texobj_completeness( const struct gl_context
*ctx
,
122 struct gl_texture_object
*obj
);
125 _mesa_cube_complete(const struct gl_texture_object
*texObj
);
128 _mesa_dirty_texobj(struct gl_context
*ctx
, struct gl_texture_object
*texObj
,
129 GLboolean invalidate_state
);
131 extern struct gl_texture_object
*
132 _mesa_get_fallback_texture(struct gl_context
*ctx
, gl_texture_index tex
);
135 _mesa_total_texture_memory(struct gl_context
*ctx
);
138 _mesa_unlock_context_textures( struct gl_context
*ctx
);
141 _mesa_lock_context_textures( struct gl_context
*ctx
);
146 * \name API functions
150 extern void GLAPIENTRY
151 _mesa_GenTextures( GLsizei n
, GLuint
*textures
);
154 extern void GLAPIENTRY
155 _mesa_DeleteTextures( GLsizei n
, const GLuint
*textures
);
158 extern void GLAPIENTRY
159 _mesa_BindTexture( GLenum target
, GLuint texture
);
162 extern void GLAPIENTRY
163 _mesa_PrioritizeTextures( GLsizei n
, const GLuint
*textures
,
164 const GLclampf
*priorities
);
167 extern GLboolean GLAPIENTRY
168 _mesa_AreTexturesResident( GLsizei n
, const GLuint
*textures
,
169 GLboolean
*residences
);
171 extern GLboolean GLAPIENTRY
172 _mesa_IsTexture( GLuint texture
);
174 extern void GLAPIENTRY
175 _mesa_InvalidateTexSubImage(GLuint texture
, GLint level
, GLint xoffset
,
176 GLint yoffset
, GLint zoffset
, GLsizei width
,
177 GLsizei height
, GLsizei depth
);
179 extern void GLAPIENTRY
180 _mesa_InvalidateTexImage(GLuint texture
, GLint level
);