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