1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
32 #include "main/mtypes.h"
38 struct st_texture_image
40 struct gl_texture_image base
;
42 /* These aren't stored in gl_texture_image
47 /* If stImage->pt != NULL, image data is stored here.
48 * Else if stImage->base.Data != NULL, image is stored there.
49 * Else there is no image data.
51 struct pipe_texture
*pt
;
53 struct pipe_surface
*surface
;
58 struct st_texture_object
60 struct gl_texture_object base
; /* The "parent" object */
62 /* The texture must include at levels [0..lastLevel] once validated:
66 /* On validation any active images held in main memory or in other
67 * textures will be copied to this texture and the old storage freed.
69 struct pipe_texture
*pt
;
71 GLboolean imageOverride
;
79 static INLINE
struct st_texture_object
*
80 st_texture_object(struct gl_texture_object
*obj
)
82 return (struct st_texture_object
*) obj
;
86 static INLINE
struct pipe_texture
*
87 st_get_texobj_texture(struct gl_texture_object
*texObj
)
89 struct st_texture_object
*stObj
= st_texture_object(texObj
);
90 return stObj
? stObj
->pt
: NULL
;
94 static INLINE
struct pipe_texture
*
95 st_get_stobj_texture(struct st_texture_object
*stObj
)
97 return stObj
? stObj
->pt
: NULL
;
102 extern struct pipe_texture
*
103 st_texture_create(struct st_context
*st
,
104 enum pipe_texture_target target
,
105 enum pipe_format format
,
110 GLuint compress_byte
);
113 /* Check if an image fits into an existing texture object.
116 st_texture_match_image(const struct pipe_texture
*pt
,
117 const struct gl_texture_image
*image
,
118 GLuint face
, GLuint level
);
120 /* Return a pointer to an image within a texture. Return image stride as
124 st_texture_image_map(struct st_context
*st
,
125 struct st_texture_image
*stImage
,
129 st_texture_image_unmap(struct st_texture_image
*stImage
);
132 /* Return pointers to each 2d slice within an image. Indexed by depth
135 extern const GLuint
*
136 st_texture_depth_offsets(struct pipe_texture
*pt
, GLuint level
);
139 /* Return the linear offset of an image relative to the start of its region.
142 st_texture_image_offset(const struct pipe_texture
*pt
,
143 GLuint face
, GLuint level
);
146 st_texture_texel_offset(const struct pipe_texture
* pt
,
147 GLuint face
, GLuint level
,
148 GLuint col
, GLuint row
, GLuint img
);
151 /* Upload an image into a texture
154 st_texture_image_data(struct pipe_context
*pipe
,
155 struct pipe_texture
*dst
,
156 GLuint face
, GLuint level
, void *src
,
157 GLuint src_row_pitch
, GLuint src_image_pitch
);
160 /* Copy an image between two textures
163 st_texture_image_copy(struct pipe_context
*pipe
,
164 struct pipe_texture
*dst
, GLuint dstLevel
,
165 struct pipe_texture
*src
,