1 /**************************************************************************
3 * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
28 #ifndef INTEL_MIPMAP_TREE_H
29 #define INTEL_MIPMAP_TREE_H
31 #include "intel_regions.h"
33 /* A layer on top of the intel_regions code which adds:
35 * - Code to size and layout a region to hold a set of mipmaps.
36 * - Query to determine if a new image fits in an existing tree.
38 * The fixed mipmap layout of intel hardware where one offset
39 * specifies the position of all images in a mipmap hierachy
40 * complicates the implementation of GL texture image commands,
41 * compared to hardware where each image is specified with an
44 * In an ideal world, each texture object would be associated with a
45 * single bufmgr buffer or 2d intel_region, and all the images within
46 * the texture object would slot into the tree as they arrive. The
47 * reality can be a little messier, as images can arrive from the user
48 * with sizes that don't fit in the existing tree, or in an order
49 * where the tree layout cannot be guessed immediately.
51 * This structure encodes an idealized mipmap tree. The GL image
52 * commands build these where possible, otherwise store the images in
53 * temporary system buffers.
57 struct intel_mipmap_level
{
64 /* Explicitly store the offset of each image for each cube face or
65 * depth value. Pretty much have to accept that hardware formats
66 * are going to be so diverse that there is no unified way to
67 * compute the offsets of depth/cube images within a mipmap level,
68 * so have to store them as a lookup table:
73 struct intel_mipmap_tree
{
74 /* Effectively the key:
77 GLenum internal_format
;
82 GLuint width0
, height0
, depth0
;
86 /* Derived from the above:
89 GLuint depth_pitch
; /* per-image on i945? */
92 /* Includes image offset tables:
94 struct intel_mipmap_level level
[MAX_TEXTURE_LEVELS
];
96 /* The data is held here:
98 struct intel_region
*region
;
100 /* These are also refcounted:
107 struct intel_mipmap_tree
*intel_miptree_create( struct intel_context
*intel
,
109 GLenum internal_format
,
116 GLboolean compressed
);
118 void intel_miptree_destroy( struct intel_context
*intel
,
119 struct intel_mipmap_tree
*mt
);
122 /* Return the linear offset of an image relative to the start of the
125 GLuint
intel_miptree_image_offset( struct intel_mipmap_tree
*mt
,
129 /* Return pointers to each 2d slice within an image. Indexed by depth
132 const GLuint
*intel_miptree_depth_offsets(struct intel_mipmap_tree
*mt
,
136 void intel_miptree_set_level_info(struct intel_mipmap_tree
*mt
,
140 GLuint w
, GLuint h
, GLuint d
);
142 void intel_miptree_set_image_offset(struct intel_mipmap_tree
*mt
,
148 /* Upload an image into a tree
150 GLboolean
intel_miptree_image_data(struct intel_context
*intel
,
151 struct intel_mipmap_tree
*dst
,
155 GLuint src_row_pitch
,
156 GLuint src_image_pitch
);
158 /* i915_mipmap_tree.c:
160 GLboolean
i915_miptree_layout( struct intel_mipmap_tree
*mt
);
161 GLboolean
i945_miptree_layout( struct intel_mipmap_tree
*mt
);
162 GLboolean
brw_miptree_layout( struct intel_mipmap_tree
*mt
);