b8281c51e2a9770d87d4dde92dbad09db6d3f8b1
[mesa.git] / src / mesa / main / texstore.h
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 "mtypes.h"
40 #include "formats.h"
41
42
43 /**
44 * This macro defines the (many) parameters to the texstore functions.
45 * \param dims either 1 or 2 or 3
46 * \param baseInternalFormat user-specified base internal format
47 * \param dstFormat destination Mesa texture format
48 * \param dstX/Y/Zoffset destination x/y/z offset (ala TexSubImage), in texels
49 * \param dstRowStride destination image row stride, in bytes
50 * \param dstSlices array of addresses of image slices (for 3D, array texture)
51 * \param srcWidth/Height/Depth source image size, in pixels
52 * \param srcFormat incoming image format
53 * \param srcType incoming image data type
54 * \param srcAddr source image address
55 * \param srcPacking source image packing parameters
56 */
57 #define TEXSTORE_PARAMS \
58 struct gl_context *ctx, GLuint dims, \
59 MAYBE_UNUSED GLenum baseInternalFormat, \
60 MAYBE_UNUSED mesa_format dstFormat, \
61 GLint dstRowStride, \
62 GLubyte **dstSlices, \
63 GLint srcWidth, GLint srcHeight, GLint srcDepth, \
64 GLenum srcFormat, GLenum srcType, \
65 const GLvoid *srcAddr, \
66 const struct gl_pixelstore_attrib *srcPacking
67
68 /* This macro must be kept in sync with TEXSTORE_PARAMS. It is used in the
69 * few places where none of the parameters are used (i.e., the ETC texstore
70 * functions).
71 */
72 #define UNUSED_TEXSTORE_PARAMS \
73 UNUSED struct gl_context *ctx, UNUSED GLuint dims, \
74 UNUSED GLenum baseInternalFormat, \
75 UNUSED mesa_format dstFormat, \
76 UNUSED GLint dstRowStride, \
77 UNUSED GLubyte **dstSlices, \
78 UNUSED GLint srcWidth, UNUSED GLint srcHeight, UNUSED GLint srcDepth, \
79 UNUSED GLenum srcFormat, UNUSED GLenum srcType, \
80 UNUSED const GLvoid *srcAddr, \
81 UNUSED const struct gl_pixelstore_attrib *srcPacking
82
83 extern GLboolean
84 _mesa_texstore(TEXSTORE_PARAMS);
85
86 extern GLboolean
87 _mesa_texstore_needs_transfer_ops(struct gl_context *ctx,
88 GLenum baseInternalFormat,
89 mesa_format dstFormat);
90
91 extern void
92 _mesa_memcpy_texture(struct gl_context *ctx,
93 GLuint dimensions,
94 mesa_format dstFormat,
95 GLint dstRowStride,
96 GLubyte **dstSlices,
97 GLint srcWidth, GLint srcHeight, GLint srcDepth,
98 GLenum srcFormat, GLenum srcType,
99 const GLvoid *srcAddr,
100 const struct gl_pixelstore_attrib *srcPacking);
101
102 extern GLboolean
103 _mesa_texstore_can_use_memcpy(struct gl_context *ctx,
104 GLenum baseInternalFormat, mesa_format dstFormat,
105 GLenum srcFormat, GLenum srcType,
106 const struct gl_pixelstore_attrib *srcPacking);
107
108
109 extern void
110 _mesa_store_teximage(struct gl_context *ctx,
111 GLuint dims,
112 struct gl_texture_image *texImage,
113 GLenum format, GLenum type, const GLvoid *pixels,
114 const struct gl_pixelstore_attrib *packing);
115
116
117 extern void
118 _mesa_store_texsubimage(struct gl_context *ctx, GLuint dims,
119 struct gl_texture_image *texImage,
120 GLint xoffset, GLint yoffset, GLint zoffset,
121 GLint width, GLint height, GLint depth,
122 GLenum format, GLenum type, const GLvoid *pixels,
123 const struct gl_pixelstore_attrib *packing);
124
125
126 extern void
127 _mesa_store_cleartexsubimage(struct gl_context *ctx,
128 struct gl_texture_image *texImage,
129 GLint xoffset, GLint yoffset, GLint zoffset,
130 GLsizei width, GLsizei height, GLsizei depth,
131 const GLvoid *clearValue);
132
133 extern void
134 _mesa_store_compressed_teximage(struct gl_context *ctx, GLuint dims,
135 struct gl_texture_image *texImage,
136 GLsizei imageSize, const GLvoid *data);
137
138
139 extern void
140 _mesa_store_compressed_texsubimage(struct gl_context *ctx, GLuint dims,
141 struct gl_texture_image *texImage,
142 GLint xoffset, GLint yoffset, GLint zoffset,
143 GLsizei width, GLsizei height, GLsizei depth,
144 GLenum format,
145 GLsizei imageSize, const GLvoid *data);
146
147
148 struct compressed_pixelstore {
149 int SkipBytes;
150 int CopyBytesPerRow;
151 int CopyRowsPerSlice;
152 int TotalBytesPerRow;
153 int TotalRowsPerSlice;
154 int CopySlices;
155 };
156
157
158 extern void
159 _mesa_compute_compressed_pixelstore(GLuint dims, mesa_format texFormat,
160 GLsizei width, GLsizei height,
161 GLsizei depth,
162 const struct gl_pixelstore_attrib *packing,
163 struct compressed_pixelstore *store);
164
165
166 #endif