Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

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