ecdb7be244f3b779987527819b9dc4218c385596
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 * - maybe able to remove refcounting from intel_region?
41 * The fixed mipmap layout of intel hardware where one offset
42 * specifies the position of all images in a mipmap hierachy
43 * complicates the implementation of GL texture image commands,
44 * compared to hardware where each image is specified with an
47 * In an ideal world, each texture object would be associated with a
48 * single bufmgr buffer or 2d intel_region, and all the images within
49 * the texture object would slot into the tree as they arrive. The
50 * reality can be a little messier, as images can arrive from the user
51 * with sizes that don't fit in the existing tree, or in an order
52 * where the tree layout cannot be guessed immediately.
54 * This structure encodes an idealized mipmap tree. The GL image
55 * commands build these where possible, otherwise store the images in
56 * temporary system buffers.
61 * Describes the location of each texture image within a texture region.
63 struct intel_mipmap_level
71 /* Explicitly store the offset of each image for each cube face or
72 * depth value. Pretty much have to accept that hardware formats
73 * are going to be so diverse that there is no unified way to
74 * compute the offsets of depth/cube images within a mipmap level,
75 * so have to store them as a lookup table:
80 struct intel_mipmap_tree
82 /* Effectively the key:
85 GLenum internal_format
;
90 GLuint width0
, height0
, depth0
; /**< Level zero image dimensions */
94 /* Derived from the above:
97 GLuint depth_pitch
; /* per-image on i945? */
100 /* Includes image offset tables:
102 struct intel_mipmap_level level
[MAX_TEXTURE_LEVELS
];
104 /* The data is held here:
106 struct intel_region
*region
;
108 /* These are also refcounted:
115 struct intel_mipmap_tree
*intel_miptree_create(struct intel_context
*intel
,
117 GLenum internal_format
,
124 GLuint compress_byte
);
126 void intel_miptree_reference(struct intel_mipmap_tree
**dst
,
127 struct intel_mipmap_tree
*src
);
129 void intel_miptree_release(struct intel_context
*intel
,
130 struct intel_mipmap_tree
**mt
);
132 /* Check if an image fits an existing mipmap tree layout
134 GLboolean
intel_miptree_match_image(struct intel_mipmap_tree
*mt
,
135 struct gl_texture_image
*image
,
136 GLuint face
, GLuint level
);
138 /* Return a pointer to an image within a tree. Return image stride as
141 GLubyte
*intel_miptree_image_map(struct intel_context
*intel
,
142 struct intel_mipmap_tree
*mt
,
145 GLuint
* row_stride
, GLuint
* image_stride
);
147 void intel_miptree_image_unmap(struct intel_context
*intel
,
148 struct intel_mipmap_tree
*mt
);
151 /* Return the linear offset of an image relative to the start of the
154 GLuint
intel_miptree_image_offset(struct intel_mipmap_tree
*mt
,
155 GLuint face
, GLuint level
);
157 /* Return pointers to each 2d slice within an image. Indexed by depth
160 const GLuint
*intel_miptree_depth_offsets(struct intel_mipmap_tree
*mt
,
164 void intel_miptree_set_level_info(struct intel_mipmap_tree
*mt
,
168 GLuint w
, GLuint h
, GLuint d
);
170 void intel_miptree_set_image_offset(struct intel_mipmap_tree
*mt
,
172 GLuint img
, GLuint x
, GLuint y
);
175 /* Upload an image into a tree
177 void intel_miptree_image_data(struct intel_context
*intel
,
178 struct intel_mipmap_tree
*dst
,
182 GLuint src_row_pitch
, GLuint src_image_pitch
);
184 /* Copy an image between two trees
186 void intel_miptree_image_copy(struct intel_context
*intel
,
187 struct intel_mipmap_tree
*dst
,
188 GLuint face
, GLuint level
,
189 struct intel_mipmap_tree
*src
);
191 /* i915_mipmap_tree.c:
193 GLboolean
i915_miptree_layout(struct intel_mipmap_tree
*mt
);
194 GLboolean
i945_miptree_layout(struct intel_mipmap_tree
*mt
);