st_texture.h

Go to the documentation of this file.
00001 /**************************************************************************
00002  * 
00003  * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
00004  * All Rights Reserved.
00005  * 
00006  * Permission is hereby granted, free of charge, to any person obtaining a
00007  * copy of this software and associated documentation files (the
00008  * "Software"), to deal in the Software without restriction, including
00009  * without limitation the rights to use, copy, modify, merge, publish,
00010  * distribute, sub license, and/or sell copies of the Software, and to
00011  * permit persons to whom the Software is furnished to do so, subject to
00012  * the following conditions:
00013  * 
00014  * The above copyright notice and this permission notice (including the
00015  * next paragraph) shall be included in all copies or substantial portions
00016  * of the Software.
00017  * 
00018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00019  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00020  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
00021  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
00022  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
00023  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
00024  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00025  * 
00026  **************************************************************************/
00027 
00028 #ifndef ST_TEXTURE_H
00029 #define ST_TEXTURE_H
00030 
00031 
00032 #include "main/mtypes.h"
00033 
00034 struct pipe_context;
00035 struct pipe_texture;
00036 
00037 
00038 struct st_texture_image
00039 {
00040    struct gl_texture_image base;
00041 
00042    /* These aren't stored in gl_texture_image 
00043     */
00044    GLuint level;
00045    GLuint face;
00046 
00047    /* If stImage->pt != NULL, image data is stored here.
00048     * Else if stImage->base.Data != NULL, image is stored there.
00049     * Else there is no image data.
00050     */
00051    struct pipe_texture *pt;
00052 
00053    struct pipe_surface *surface;
00054 };
00055 
00056 
00057 
00058 struct st_texture_object
00059 {
00060    struct gl_texture_object base;       /* The "parent" object */
00061 
00062    /* The texture must include at levels [0..lastLevel] once validated:
00063     */
00064    GLuint lastLevel;
00065 
00066    /* On validation any active images held in main memory or in other
00067     * textures will be copied to this texture and the old storage freed.
00068     */
00069    struct pipe_texture *pt;
00070 
00071    GLboolean teximage_realloc;
00072 };
00073 
00074 
00075 static INLINE struct st_texture_image *
00076 st_texture_image(struct gl_texture_image *img)
00077 {
00078    return (struct st_texture_image *) img;
00079 }
00080 
00081 static INLINE struct st_texture_object *
00082 st_texture_object(struct gl_texture_object *obj)
00083 {
00084    return (struct st_texture_object *) obj;
00085 }
00086 
00087 
00088 static INLINE struct pipe_texture *
00089 st_get_texobj_texture(struct gl_texture_object *texObj)
00090 {
00091    struct st_texture_object *stObj = st_texture_object(texObj);
00092    return stObj ? stObj->pt : NULL;
00093 }
00094 
00095 
00096 static INLINE struct pipe_texture *
00097 st_get_stobj_texture(struct st_texture_object *stObj)
00098 {
00099    return stObj ? stObj->pt : NULL;
00100 }
00101 
00102 static INLINE GLboolean pf_is_depth_stencil( enum pipe_format format )
00103 {
00104    return (pf_get_component_bits( format, PIPE_FORMAT_COMP_Z ) +
00105            pf_get_component_bits( format, PIPE_FORMAT_COMP_S )) != 0;
00106 }
00107 
00108 
00109 extern struct pipe_texture *
00110 st_texture_create(struct st_context *st,
00111                   enum pipe_texture_target target,
00112                   enum pipe_format format,
00113                   GLuint last_level,
00114                   GLuint width0,
00115                   GLuint height0,
00116                   GLuint depth0,
00117                   GLuint compress_byte,
00118                   GLuint tex_usage );
00119 
00120 
00121 /* Check if an image fits into an existing texture object.
00122  */
00123 extern GLboolean
00124 st_texture_match_image(const struct pipe_texture *pt,
00125                        const struct gl_texture_image *image,
00126                        GLuint face, GLuint level);
00127 
00128 /* Return a pointer to an image within a texture.  Return image stride as
00129  * well.
00130  */
00131 extern GLubyte *
00132 st_texture_image_map(struct st_context *st,
00133                      struct st_texture_image *stImage,
00134                      GLuint zoffset,
00135                      GLuint flags);
00136 
00137 extern void
00138 st_texture_image_unmap(struct st_context *st,
00139                        struct st_texture_image *stImage);
00140 
00141 
00142 /* Return pointers to each 2d slice within an image.  Indexed by depth
00143  * value.
00144  */
00145 extern const GLuint *
00146 st_texture_depth_offsets(struct pipe_texture *pt, GLuint level);
00147 
00148 
00149 /* Return the linear offset of an image relative to the start of its region.
00150  */
00151 extern GLuint
00152 st_texture_image_offset(const struct pipe_texture *pt,
00153                         GLuint face, GLuint level);
00154 
00155 extern GLuint
00156 st_texture_texel_offset(const struct pipe_texture * pt,
00157                         GLuint face, GLuint level,
00158                         GLuint col, GLuint row, GLuint img);
00159 
00160 
00161 /* Upload an image into a texture
00162  */
00163 extern void
00164 st_texture_image_data(struct pipe_context *pipe,
00165                       struct pipe_texture *dst,
00166                       GLuint face, GLuint level, void *src,
00167                       GLuint src_row_pitch, GLuint src_image_pitch);
00168 
00169 
00170 /* Copy an image between two textures
00171  */
00172 extern void
00173 st_texture_image_copy(struct pipe_context *pipe,
00174                       struct pipe_texture *dst, GLuint dstLevel,
00175                       struct pipe_texture *src,
00176                       GLuint face);
00177 
00178 
00179 #endif

Generated on Tue Sep 29 06:25:18 2009 for Gallium3D by  doxygen 1.5.4