b25e3f3f3bd90b60224c19d8d0f82553a5cda971
[mesa.git] / src / mesa / state_tracker / st_texture.h
1 /**************************************************************************
2 *
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
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:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
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.
25 *
26 **************************************************************************/
27
28 #ifndef ST_TEXTURE_H
29 #define ST_TEXTURE_H
30
31
32 #include "main/mtypes.h"
33
34 struct pipe_context;
35 struct pipe_texture;
36 struct pipe_region;
37
38
39 extern struct pipe_texture *
40 st_texture_create(struct st_context *st,
41 unsigned target,
42 unsigned format,
43 GLenum internal_format,
44 GLuint first_level,
45 GLuint last_level,
46 GLuint width0,
47 GLuint height0,
48 GLuint depth0,
49 GLuint compress_byte);
50
51
52 /* Check if an image fits an existing texture
53 */
54 extern GLboolean
55 st_texture_match_image(struct pipe_texture *pt,
56 struct gl_texture_image *image,
57 GLuint face, GLuint level);
58
59 /* Return a pointer to an image within a texture. Return image stride as
60 * well.
61 */
62 extern GLubyte *
63 st_texture_image_map(struct st_context *st,
64 struct st_texture_image *stImage,
65 GLuint zoffset);
66
67 extern void
68 st_texture_image_unmap(struct st_context *st,
69 struct st_texture_image *stImage);
70
71
72 /* Return pointers to each 2d slice within an image. Indexed by depth
73 * value.
74 */
75 extern const GLuint *
76 st_texture_depth_offsets(struct pipe_texture *pt, GLuint level);
77
78
79 /* Return the linear offset of an image relative to the start of its region:
80 */
81 extern GLuint
82 st_texture_image_offset(const struct pipe_texture *pt,
83 GLuint face, GLuint level);
84
85 extern GLuint
86 st_texture_texel_offset(const struct pipe_texture * pt,
87 GLuint face, GLuint level,
88 GLuint col, GLuint row, GLuint img);
89
90
91 /* Upload an image into a texture
92 */
93 extern void
94 st_texture_image_data(struct pipe_context *pipe,
95 struct pipe_texture *dst,
96 GLuint face, GLuint level, void *src,
97 GLuint src_row_pitch, GLuint src_image_pitch);
98
99
100 /* Copy an image between two textures
101 */
102 extern void
103 st_texture_image_copy(struct pipe_context *pipe,
104 struct pipe_texture *dst,
105 GLuint face, GLuint level,
106 struct pipe_texture *src);
107
108
109 #endif