1 /*
2  * Mesa 3-D graphics library
3  *
4  * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
5  * Copyright (c) 2008 VMware, Inc.
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation
10  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11  * and/or sell copies of the Software, and to permit persons to whom the
12  * Software is furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included
15  * in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23  * OTHER DEALINGS IN THE SOFTWARE.
24  */
25 
26 
27 /**
28  * \file texstore.h
29  * Texture image storage routines.
30  *
31  * \author Brian Paul
32  */
33 
34 
35 #ifndef TEXSTORE_H
36 #define TEXSTORE_H
37 
38 
39 #include "glheader.h"
40 #include "formats.h"
41 #include "util/macros.h"
42 
43 struct gl_context;
44 struct gl_pixelstore_attrib;
45 struct gl_texture_image;
46 
47 /**
48  * This macro defines the (many) parameters to the texstore functions.
49  * \param dims  either 1 or 2 or 3
50  * \param baseInternalFormat  user-specified base internal format
51  * \param dstFormat  destination Mesa texture format
52  * \param dstX/Y/Zoffset  destination x/y/z offset (ala TexSubImage), in texels
53  * \param dstRowStride  destination image row stride, in bytes
54  * \param dstSlices  array of addresses of image slices (for 3D, array texture)
55  * \param srcWidth/Height/Depth  source image size, in pixels
56  * \param srcFormat  incoming image format
57  * \param srcType  incoming image data type
58  * \param srcAddr  source image address
59  * \param srcPacking  source image packing parameters
60  */
61 #define TEXSTORE_PARAMS \
62 	struct gl_context *ctx, GLuint dims, \
63         UNUSED GLenum baseInternalFormat, \
64         UNUSED mesa_format dstFormat, \
65         GLint dstRowStride, \
66         GLubyte **dstSlices, \
67 	GLint srcWidth, GLint srcHeight, GLint srcDepth, \
68 	GLenum srcFormat, GLenum srcType, \
69 	const GLvoid *srcAddr, \
70 	const struct gl_pixelstore_attrib *srcPacking
71 
72 /* This macro must be kept in sync with TEXSTORE_PARAMS.  It is used in the
73  * few places where none of the parameters are used (i.e., the ETC texstore
74  * functions).
75  */
76 #define UNUSED_TEXSTORE_PARAMS                                          \
77         UNUSED struct gl_context *ctx, UNUSED GLuint dims,              \
78         UNUSED GLenum baseInternalFormat,                               \
79         UNUSED mesa_format dstFormat,                                   \
80         UNUSED GLint dstRowStride,                                      \
81         UNUSED GLubyte **dstSlices,                                     \
82         UNUSED GLint srcWidth, UNUSED GLint srcHeight, UNUSED GLint srcDepth, \
83         UNUSED GLenum srcFormat, UNUSED GLenum srcType,                 \
84         UNUSED const GLvoid *srcAddr,                                   \
85         UNUSED const struct gl_pixelstore_attrib *srcPacking
86 
87 extern GLboolean
88 _mesa_texstore(TEXSTORE_PARAMS);
89 
90 extern GLboolean
91 _mesa_texstore_needs_transfer_ops(struct gl_context *ctx,
92                                   GLenum baseInternalFormat,
93                                   mesa_format dstFormat);
94 
95 extern void
96 _mesa_memcpy_texture(struct gl_context *ctx,
97                      GLuint dimensions,
98                      mesa_format dstFormat,
99                      GLint dstRowStride,
100                      GLubyte **dstSlices,
101                      GLint srcWidth, GLint srcHeight, GLint srcDepth,
102                      GLenum srcFormat, GLenum srcType,
103                      const GLvoid *srcAddr,
104                      const struct gl_pixelstore_attrib *srcPacking);
105 
106 extern GLboolean
107 _mesa_texstore_can_use_memcpy(struct gl_context *ctx,
108                               GLenum baseInternalFormat, mesa_format dstFormat,
109                               GLenum srcFormat, GLenum srcType,
110                               const struct gl_pixelstore_attrib *srcPacking);
111 
112 
113 extern void
114 _mesa_store_teximage(struct gl_context *ctx,
115                      GLuint dims,
116                      struct gl_texture_image *texImage,
117                      GLenum format, GLenum type, const GLvoid *pixels,
118                      const struct gl_pixelstore_attrib *packing);
119 
120 
121 extern void
122 _mesa_store_texsubimage(struct gl_context *ctx, GLuint dims,
123                         struct gl_texture_image *texImage,
124                         GLint xoffset, GLint yoffset, GLint zoffset,
125                         GLint width, GLint height, GLint depth,
126                         GLenum format, GLenum type, const GLvoid *pixels,
127                         const struct gl_pixelstore_attrib *packing);
128 
129 
130 extern void
131 _mesa_store_cleartexsubimage(struct gl_context *ctx,
132                              struct gl_texture_image *texImage,
133                              GLint xoffset, GLint yoffset, GLint zoffset,
134                              GLsizei width, GLsizei height, GLsizei depth,
135                              const GLvoid *clearValue);
136 
137 extern void
138 _mesa_store_compressed_teximage(struct gl_context *ctx, GLuint dims,
139                                 struct gl_texture_image *texImage,
140                                 GLsizei imageSize, const GLvoid *data);
141 
142 
143 extern void
144 _mesa_store_compressed_texsubimage(struct gl_context *ctx, GLuint dims,
145                                    struct gl_texture_image *texImage,
146                                    GLint xoffset, GLint yoffset, GLint zoffset,
147                                    GLsizei width, GLsizei height, GLsizei depth,
148                                    GLenum format,
149                                    GLsizei imageSize, const GLvoid *data);
150 
151 
152 struct compressed_pixelstore {
153    int SkipBytes;
154    int CopyBytesPerRow;
155    int CopyRowsPerSlice;
156    int TotalBytesPerRow;
157    int TotalRowsPerSlice;
158    int CopySlices;
159 };
160 
161 
162 extern void
163 _mesa_compute_compressed_pixelstore(GLuint dims, mesa_format texFormat,
164                                     GLsizei width, GLsizei height,
165                                     GLsizei depth,
166                                     const struct gl_pixelstore_attrib *packing,
167                                     struct compressed_pixelstore *store);
168 
169 
170 #endif
171