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