2 * Copyright (C) 2008 Nicolai Haehnle.
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a 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, sublicense, 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
16 * portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 #ifndef __RADEON_MIPMAP_TREE_H_
29 #define __RADEON_MIPMAP_TREE_H_
31 #include "radeon_common.h"
33 typedef struct _radeon_mipmap_tree radeon_mipmap_tree;
34 typedef struct _radeon_mipmap_level radeon_mipmap_level;
35 typedef struct _radeon_mipmap_image radeon_mipmap_image;
37 struct _radeon_mipmap_image {
38 GLuint offset; /** Offset of this image from the start of mipmap tree buffer, in bytes */
41 struct _radeon_mipmap_level {
45 GLuint size; /** Size of each image, in bytes */
46 GLuint rowstride; /** in bytes */
48 radeon_mipmap_image faces[6];
51 /* store the max possible in the miptree */
52 #define RADEON_MIPTREE_MAX_TEXTURE_LEVELS 15
55 * A mipmap tree contains texture images in the layout that the hardware
58 * The meta-data of mipmap trees is immutable, i.e. you cannot change the
59 * layout on-the-fly; however, the texture contents (i.e. texels) can be
62 struct _radeon_mipmap_tree {
66 GLuint totalsize; /** total size of the miptree, in bytes */
68 GLenum target; /** GL_TEXTURE_xxx */
69 GLenum mesaFormat; /** MESA_FORMAT_xxx */
70 GLuint faces; /** # of faces: 6 for cubemaps, 1 otherwise */
71 GLuint baseLevel; /** gl_texture_object->baseLevel it was created for */
72 GLuint numLevels; /** Number of mip levels stored in this mipmap tree */
74 GLuint width0; /** Width of baseLevel image */
75 GLuint height0; /** Height of baseLevel image */
76 GLuint depth0; /** Depth of baseLevel image */
78 GLuint tilebits; /** RADEON_TXO_xxx_TILE */
80 radeon_mipmap_level levels[RADEON_MIPTREE_MAX_TEXTURE_LEVELS];
83 void radeon_miptree_reference(radeon_mipmap_tree *mt, radeon_mipmap_tree **ptr);
84 void radeon_miptree_unreference(radeon_mipmap_tree **ptr);
86 GLboolean radeon_miptree_matches_image(radeon_mipmap_tree *mt,
87 struct gl_texture_image *texImage, GLuint face, GLuint level);
88 void radeon_try_alloc_miptree(radeonContextPtr rmesa, radeonTexObj *t);
89 GLuint radeon_miptree_image_offset(radeon_mipmap_tree *mt,
90 GLuint face, GLuint level);
91 uint32_t get_base_teximage_offset(radeonTexObj *texObj);
93 unsigned get_texture_image_row_stride(radeonContextPtr rmesa, gl_format format, unsigned width, unsigned tiling);
95 unsigned get_texture_image_size(
101 #endif /* __RADEON_MIPMAP_TREE_H_ */